add_security.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. module.exports = Em.Route.extend({
  20. route: '/addSecurity',
  21. enter: function (router) {
  22. console.log('in /security/add:enter');
  23. Ember.run.next(function () {
  24. //after refresh check if the wizard is open then restore it
  25. if (router.get('mainAdminSecurityController').getAddSecurityWizardStatus() === 'RUNNING') {
  26. var mainAdminSecurityController = router.get('mainAdminSecurityController');
  27. var addSecurityController = router.get('addSecurityController');
  28. var currentStep = router.get('addSecurityController').get('currentStep');
  29. App.router.get('updateController').set('isWorking', false);
  30. App.ModalPopup.show({
  31. classNames: ['full-width-modal'],
  32. header: Em.I18n.t('admin.addSecurity.header'),
  33. bodyClass: App.MainAdminSecurityAddMenuView.extend({
  34. controllerBinding: 'App.router.addSecurityController'
  35. }),
  36. primary: Em.I18n.t('form.cancel'),
  37. secondary: null,
  38. showFooter: false,
  39. onClose: function () {
  40. var self = this;
  41. if (router.get('addSecurityController.currentStep') == 3) {
  42. var controller = router.get('mainAdminSecurityAddStep3Controller');
  43. if (!controller.get('isSubmitDisabled')) {
  44. self.proceedOnClose();
  45. return;
  46. }
  47. var applyingConfigStage = router.get('mainAdminSecurityAddStep3Controller.stages').findProperty('stage', 'stage3');
  48. if (applyingConfigStage) {
  49. if (!applyingConfigStage.get('isCompleted')) {
  50. if (applyingConfigStage.get('isStarted')) {
  51. App.showAlertPopup(Em.I18n.t('admin.security.applying.config.header'), Em.I18n.t('admin.security.applying.config.body'));
  52. } else {
  53. App.showConfirmationPopup(function () {
  54. self.proceedOnClose();
  55. }, Em.I18n.t('admin.addSecurity.enable.onClose'));
  56. }
  57. } else {
  58. App.showConfirmationPopup(function () {},
  59. Em.I18n.t('admin.addSecurity.enable.after.stage2.onClose'),
  60. function () {
  61. self.proceedOnClose();
  62. });
  63. }
  64. return;
  65. }
  66. }
  67. router.get('mainAdminSecurityAddStep3Controller').clearStep();
  68. App.db.setSecurityDeployStages(undefined);
  69. self.proceedOnClose();
  70. },
  71. proceedOnClose: function () {
  72. this.hide();
  73. router.get('mainAdminSecurityAddStep3Controller').clearStep();
  74. router.get('addSecurityController.content.services').clear();
  75. router.set('addSecurityController.content.serviceConfigProperties', null);
  76. App.router.get('updateController').set('isWorking', true);
  77. mainAdminSecurityController.setAddSecurityWizardStatus(null);
  78. App.db.setSecurityDeployStages(undefined);
  79. router.get('addSecurityController').setCurrentStep(1);
  80. App.clusterStatus.setClusterStatus({
  81. clusterName: router.get('content.cluster.name'),
  82. clusterState: 'SECURITY_COMPLETED',
  83. wizardControllerName: router.get('addSecurityController.name'),
  84. localdb: App.db.data
  85. });
  86. router.transitionTo('adminSecurity.index');
  87. },
  88. didInsertElement: function () {
  89. this.fitHeight();
  90. }
  91. }
  92. );
  93. App.router.transitionTo('step' + currentStep);
  94. } else {
  95. router.transitionTo('adminSecurity.index');
  96. }
  97. });
  98. },
  99. step1: Em.Route.extend({
  100. route: '/start',
  101. enter: function (router) {
  102. if(!App.testMode){
  103. App.clusterStatus.setClusterStatus({
  104. clusterName: this.get('clusterName'),
  105. clusterState: 'ADD_SECURITY_STEP_1',
  106. wizardControllerName: router.get('addSecurityController.name'),
  107. localdb: App.db.data
  108. });
  109. }
  110. },
  111. connectOutlets: function (router) {
  112. console.log('in addSecurity.step1:connectOutlets');
  113. var controller = router.get('addSecurityController');
  114. controller.dataLoading().done(function () {
  115. controller.setCurrentStep('1');
  116. controller.loadAllPriorSteps();
  117. controller.connectOutlet('mainAdminSecurityAddStep1', controller.get('content'));
  118. })
  119. },
  120. next: function (router) {
  121. var addSecurityController = router.get('addSecurityController');
  122. addSecurityController.get('content').set('serviceConfigProperties', null);
  123. router.transitionTo('step2');
  124. }
  125. }),
  126. step2: Em.Route.extend({
  127. route: '/configure',
  128. enter: function (router) {
  129. if(!App.testMode){
  130. App.clusterStatus.setClusterStatus({
  131. clusterName: this.get('clusterName'),
  132. clusterState: 'ADD_SECURITY_STEP_2',
  133. wizardControllerName: router.get('addSecurityController.name'),
  134. localdb: App.db.data
  135. });
  136. }
  137. },
  138. connectOutlets: function (router) {
  139. console.log('in addSecurity.step2:connectOutlets');
  140. var controller = router.get('addSecurityController');
  141. controller.dataLoading().done(function () {
  142. controller.setCurrentStep('2');
  143. controller.loadAllPriorSteps();
  144. controller.connectOutlet('mainAdminSecurityAddStep2', controller.get('content'));
  145. })
  146. },
  147. back: Em.Router.transitionTo('step1'),
  148. next: function (router) {
  149. var addSecurityController = router.get('addSecurityController');
  150. var addSecurityStep2Controller = router.get('mainAdminSecurityAddStep2Controller');
  151. addSecurityController.saveServiceConfigProperties(addSecurityStep2Controller);
  152. App.db.setSecurityDeployStages(undefined);
  153. router.transitionTo('step3');
  154. }
  155. }),
  156. step3: Em.Route.extend({
  157. route: '/apply',
  158. enter: function (router) {
  159. App.clusterStatus.setClusterStatus({
  160. clusterName: this.get('clusterName'),
  161. clusterState: 'ADD_SECURITY_STEP_3',
  162. wizardControllerName: router.get('addSecurityController.name'),
  163. localdb: App.db.data
  164. });
  165. },
  166. connectOutlets: function (router) {
  167. console.log('in addSecurity.step3:connectOutlets');
  168. var controller = router.get('addSecurityController');
  169. controller.dataLoading().done(function () {
  170. controller.setCurrentStep('3');
  171. controller.loadAllPriorSteps();
  172. controller.setLowerStepsDisable(3);
  173. controller.connectOutlet('mainAdminSecurityAddStep3', controller.get('content'));
  174. })
  175. },
  176. unroutePath: function () {
  177. return false;
  178. },
  179. back: function (router, context) {
  180. var controller = router.get('mainAdminSecurityAddStep3Controller');
  181. if (!controller.get('isBackBtnDisabled')) {
  182. router.transitionTo('step2');
  183. }
  184. },
  185. done: function (router, context) {
  186. var controller = router.get('mainAdminSecurityAddStep3Controller');
  187. if (!controller.get('isSubmitDisabled')) {
  188. $(context.currentTarget).parents("#modal").find(".close").trigger('click');
  189. }
  190. }
  191. }),
  192. gotoStep1: Em.Router.transitionTo('step1'),
  193. gotoStep2: Em.Router.transitionTo('step2'),
  194. gotoStep3: Em.Router.transitionTo('step3')
  195. });