github.com/sym3tri/etcd@v0.2.1-0.20140422215517-a563d82f95d6/mod/dashboard/app/page/browser/edit-ttl-ctrl.js (about)

     1  'use strict';
     2  
     3  angular.module('etcd.page')
     4  .controller('EditTtlCtrl', function($scope, $rootScope, $modalInstance, _,
     5        ETCD_EVENT, etcdApiSvc, node) {
     6  
     7    $scope.node = node;
     8  
     9    $scope.save = function(ttl) {
    10      node.ttl = ttl;
    11      $scope.requestPromise = etcdApiSvc.save(node)
    12      .then(function() {
    13        $rootScope.$broadcast(ETCD_EVENT.NODE_CHANGED, node);
    14        $modalInstance.close(node);
    15      });
    16    };
    17  
    18    $scope.cancel = function() {
    19      $modalInstance.dismiss('cancel');
    20    };
    21  
    22  });
    23  
    24  
    25  /**
    26   * Controller for the form. Must be different than the modal controller.
    27   */
    28  angular.module('etcd.page').controller('EditTtlFormCtrl', function($scope) {
    29  
    30    $scope.fields = {
    31      ttl: $scope.node.ttl || ''
    32    };
    33  
    34    $scope.submit = function() {
    35      $scope.save($scope.fields.ttl);
    36    };
    37  
    38  });