edit-ttl-ctrl.js 787 B

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