2014-05-12 20:08:19 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular.module('ffffng')
|
2014-05-31 19:19:36 +02:00
|
|
|
.controller('NewNodeCtrl', function ($scope, Navigator, NodeService, $routeParams, _, config) {
|
|
|
|
$scope.config = config;
|
|
|
|
|
2014-05-12 20:08:19 +02:00
|
|
|
$scope.node = {};
|
|
|
|
$scope.saved = false;
|
|
|
|
|
|
|
|
_.each(['hostname', 'key', 'mac'], function (field) {
|
|
|
|
var value = $routeParams[field];
|
|
|
|
if (value) {
|
|
|
|
$scope.node[field] = value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.save = function (node) {
|
|
|
|
return NodeService.createNode(node)
|
2016-06-07 14:40:05 +02:00
|
|
|
.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();
|
|
|
|
};
|
|
|
|
});
|