github.com/sym3tri/etcd@v0.2.1-0.20140422215517-a563d82f95d6/mod/dashboard/app/page/browser/edit-node-ctrl.js (about) 1 'use strict'; 2 3 angular.module('etcd.page') 4 .controller('EditNodeCtrl', function($scope, $rootScope, $modalInstance, _, 5 ETCD_EVENT, etcdApiSvc, pathSvc, node) { 6 7 $scope.node = node; 8 9 $scope.displayKey = pathSvc.truncate(node.key, 50) + '/' 10 11 $scope.save = function(node) { 12 $scope.requestPromise = etcdApiSvc.save(node) 13 .then(function() { 14 $rootScope.$broadcast(ETCD_EVENT.NODE_CHANGED, node); 15 $modalInstance.close(node); 16 }); 17 }; 18 19 $scope.cancel = function() { 20 $modalInstance.dismiss('cancel'); 21 }; 22 23 }); 24 25 26 /** 27 * Controller for the form. Must be different than the modal controller. 28 */ 29 angular.module('etcd.page').controller('EditNodeFormCtrl', function($scope, pathSvc) { 30 31 $scope.fields = { 32 value: $scope.node.value || '', 33 ttl: $scope.node.ttl || '' 34 }; 35 36 $scope.submit = function() { 37 var editNode = { 38 key: $scope.node.key, 39 value: $scope.fields.value, 40 ttl: $scope.fields.ttl ? parseInt($scope.fields.ttl, 10) : null 41 }; 42 $scope.save(editNode); 43 }; 44 45 });