You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hostedit.controller.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * Created by robin on 11/4/15.
  3. */
  4. angular.module('camotionAdmin')
  5. .controller('HostEditController', ['$scope', 'HostsService', 'data', 'dialogs', '$q', 'luticateAuthCache',
  6. function($scope, HostsService, data, dialogs, $q, luticateAuthCache) {
  7. if (data != null) {
  8. $scope.host = data;
  9. $scope.host.host_id = $scope.host.Id;
  10. $scope.permission = "CAMOTION_HOST_EDIT";
  11. }
  12. else {
  13. $scope.host = {
  14. Name: "",
  15. Url: "",
  16. Token: ""
  17. };
  18. $scope.permission = "CAMOTION_HOST_ADD";
  19. }
  20. $scope.submitForm = function()
  21. {
  22. if (luticateAuthCache.hasEffectivePermission($scope.permission)) {
  23. if ($scope.host.Id != null) {
  24. var promiseEditHost = {
  25. id: "promiseEditHost",
  26. loaderGroups: ["modal"]
  27. };
  28. return HostsService.edit($scope.host, promiseEditHost);
  29. }
  30. else {
  31. var promiseAddHost = {
  32. id: "promiseAddHost",
  33. loaderGroups: ["modal"]
  34. };
  35. return HostsService.add($scope.host, promiseAddHost);
  36. }
  37. }
  38. else {
  39. var defer = $q.defer();
  40. defer.resolve();
  41. return defer.promise;
  42. }
  43. };
  44. }]);