addSecurity_controller.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. App.AddSecurityController = App.WizardController.extend({
  20. name: 'addSecurityController',
  21. securityEnabled: false,
  22. totalSteps: 3,
  23. content: Em.Object.create({
  24. services: [],
  25. serviceConfigProperties: null,
  26. controllerName: 'addSecurityController',
  27. saveCurrentStage: function (stage) {
  28. App.db.setSecurityStage(stage);
  29. },
  30. loadCurrentStage: function () {
  31. return App.db.getSecurityStage();
  32. }
  33. }),
  34. /**
  35. * Loads all prior steps on refresh
  36. */
  37. loadAllPriorSteps: function () {
  38. var step = this.get('currentStep');
  39. switch (step) {
  40. case '3':
  41. this.loadStages();
  42. case '2':
  43. this.loadServiceConfigs();
  44. case '1':
  45. this.loadServices();
  46. }
  47. },
  48. clearServices: function () {
  49. if (this.get('content.services')) {
  50. this.get('content.services').clear();
  51. }
  52. },
  53. /**
  54. * loads the status of stages of step3 from localDb
  55. */
  56. loadStages: function () {
  57. },
  58. /**
  59. * Loads all installed services
  60. */
  61. loadServices: function () {
  62. this.clearServices();
  63. var secureServices = require('data/secure_configs');
  64. var installedServices = App.Service.find().mapProperty('serviceName');
  65. //General (only non service tab) tab is always displayed
  66. this.get('content.services').push(secureServices.findProperty('serviceName', 'GENERAL'));
  67. installedServices.forEach(function (_service) {
  68. var secureService = secureServices.findProperty('serviceName', _service);
  69. if (secureService) {
  70. this.get('content.services').push(secureService);
  71. }
  72. }, this);
  73. },
  74. /**
  75. * Loads all service config properties
  76. */
  77. loadServiceConfigs: function () {
  78. var serviceConfigProperties = App.db.getServiceConfigProperties();
  79. this.set('content.serviceConfigProperties', serviceConfigProperties);
  80. }
  81. });