ffffng/app/scripts/controllers/updateNodeCtrl.js

41 lines
1 KiB
JavaScript
Raw Normal View History

2014-05-12 20:08:19 +02:00
'use strict';
angular.module('ffffng')
2014-05-31 19:19:36 +02:00
.controller('UpdateNodeCtrl', function ($scope, Navigator, NodeService, config) {
$scope.config = config;
2014-05-12 20:08:19 +02:00
$scope.node = undefined;
$scope.token = undefined;
$scope.saved = false;
$scope.hasData = function () {
return $scope.node !== undefined;
};
$scope.onSubmitToken = function (token) {
$scope.token = token;
return NodeService.getNode(token)
2019-04-28 22:55:10 +02:00
.then(function (response) {
$scope.node = response.data;
2014-05-12 20:08:19 +02:00
});
};
$scope.save = function (node) {
return NodeService.updateNode(node, $scope.token)
.then(function (response) {
$scope.node = response.data.node;
$scope.token = response.data.token;
2014-05-12 20:08:19 +02:00
$scope.saved = true;
});
};
$scope.cancel = function () {
Navigator.home();
};
2016-06-07 14:08:04 +02:00
if (window.__nodeToken) {
var token = window.__nodeToken;
window.__nodeToken = undefined;
$scope.onSubmitToken(token);
}
2014-05-12 20:08:19 +02:00
});