add_security.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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 = App.WizardRoute.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') == 4) {
  42. var controller = router.get('mainAdminSecurityAddStep4Controller');
  43. if (!controller.get('isSubmitDisabled')) {
  44. router.get('mainAdminSecurityAddStep4Controller').clearStep();
  45. self.proceedOnClose();
  46. return;
  47. }
  48. var applyingConfigCommand = router.get('mainAdminSecurityAddStep4Controller.commands').findProperty('name', 'APPLY_CONFIGURATIONS');
  49. if (applyingConfigCommand) {
  50. if (!applyingConfigCommand.get('isCompleted')) {
  51. if (applyingConfigCommand.get('isStarted')) {
  52. App.showAlertPopup(Em.I18n.t('admin.security.applying.config.header'), Em.I18n.t('admin.security.applying.config.body'));
  53. } else {
  54. App.showConfirmationPopup(function () {
  55. self.proceedOnClose();
  56. }, Em.I18n.t('admin.addSecurity.enable.onClose'));
  57. }
  58. } else {
  59. App.showConfirmationPopup(function () {
  60. self.proceedOnClose();
  61. },
  62. Em.I18n.t('admin.addSecurity.enable.after.stage2.onClose')
  63. );
  64. }
  65. return;
  66. }
  67. }
  68. router.get('mainAdminSecurityAddStep4Controller').clearStep();
  69. App.db.setSecurityDeployCommands(undefined);
  70. self.proceedOnClose();
  71. },
  72. proceedOnClose: function () {
  73. this.hide();
  74. router.get('mainAdminSecurityAddStep4Controller').clearStep();
  75. router.get('addSecurityController.content.services').clear();
  76. router.set('addSecurityController.content.serviceConfigProperties', null);
  77. App.router.get('updateController').set('isWorking', true);
  78. mainAdminSecurityController.setAddSecurityWizardStatus(null);
  79. App.db.setSecurityDeployCommands(undefined);
  80. router.get('addSecurityController').setCurrentStep(1);
  81. App.clusterStatus.setClusterStatus({
  82. clusterName: router.get('content.cluster.name'),
  83. clusterState: 'DEFAULT'
  84. });
  85. router.transitionTo('adminSecurity.index');
  86. },
  87. didInsertElement: function () {
  88. this.fitHeight();
  89. }
  90. }
  91. );
  92. App.router.transitionTo('step' + currentStep);
  93. } else {
  94. router.transitionTo('adminSecurity.index');
  95. }
  96. });
  97. },
  98. step1: Em.Route.extend({
  99. route: '/start',
  100. enter: function (router) {
  101. router.get('addSecurityController').setCurrentStep('1');
  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.loadAllPriorSteps();
  116. controller.connectOutlet('mainAdminSecurityAddStep1', controller.get('content'));
  117. })
  118. },
  119. unroutePath: function () {
  120. return false;
  121. },
  122. next: function (router) {
  123. var addSecurityController = router.get('addSecurityController');
  124. addSecurityController.get('content').set('serviceConfigProperties', null);
  125. App.db.setSecureConfigProperties(null);
  126. router.transitionTo('step2');
  127. }
  128. }),
  129. step2: Em.Route.extend({
  130. route: '/configure',
  131. enter: function (router) {
  132. router.get('addSecurityController').setCurrentStep('2');
  133. if(!App.testMode){
  134. App.clusterStatus.setClusterStatus({
  135. clusterName: this.get('clusterName'),
  136. clusterState: 'ADD_SECURITY_STEP_2',
  137. wizardControllerName: router.get('addSecurityController.name'),
  138. localdb: App.db.data
  139. });
  140. }
  141. },
  142. connectOutlets: function (router) {
  143. console.log('in addSecurity.step2:connectOutlets');
  144. var controller = router.get('addSecurityController');
  145. controller.dataLoading().done(function () {
  146. controller.loadAllPriorSteps();
  147. controller.connectOutlet('mainAdminSecurityAddStep2', controller.get('content'));
  148. })
  149. },
  150. unroutePath: function () {
  151. return false;
  152. },
  153. back: Em.Router.transitionTo('step1'),
  154. next: function (router) {
  155. var addSecurityController = router.get('addSecurityController');
  156. var addSecurityStep2Controller = router.get('mainAdminSecurityAddStep2Controller');
  157. addSecurityController.saveServiceConfigProperties(addSecurityStep2Controller);
  158. router.transitionTo('step3');
  159. }
  160. }),
  161. step3: Em.Route.extend({
  162. route: '/principal_keytab',
  163. enter: function (router) {
  164. router.get('addSecurityController').setCurrentStep('3');
  165. if(!App.testMode){
  166. App.clusterStatus.setClusterStatus({
  167. clusterName: this.get('clusterName'),
  168. clusterState: 'ADD_SECURITY_STEP_3',
  169. wizardControllerName: router.get('addSecurityController.name'),
  170. localdb: App.db.data
  171. });
  172. }
  173. },
  174. connectOutlets: function (router) {
  175. console.log('in addSecurity.step3:connectOutlets');
  176. var controller = router.get('addSecurityController');
  177. controller.dataLoading().done(function () {
  178. controller.loadAllPriorSteps();
  179. controller.connectOutlet('mainAdminSecurityAddStep3', controller.get('content'));
  180. })
  181. },
  182. unroutePath: function () {
  183. return false;
  184. },
  185. back: Em.Router.transitionTo('step2'),
  186. next: function (router) {
  187. App.db.setSecurityDeployCommands(undefined);
  188. router.transitionTo('step4');
  189. }
  190. }),
  191. step4: Em.Route.extend({
  192. route: '/apply',
  193. enter: function (router) {
  194. router.get('addSecurityController').setCurrentStep('4');
  195. },
  196. connectOutlets: function (router) {
  197. console.log('in addSecurity.step4:connectOutlets');
  198. var controller = router.get('addSecurityController');
  199. controller.dataLoading().done(function () {
  200. controller.loadAllPriorSteps();
  201. controller.setLowerStepsDisable(4);
  202. controller.connectOutlet('mainAdminSecurityAddStep4', controller.get('content'));
  203. })
  204. },
  205. unroutePath: function () {
  206. return false;
  207. },
  208. back: function (router, context) {
  209. var controller = router.get('mainAdminSecurityAddStep4Controller');
  210. if (!controller.get('isBackBtnDisabled')) {
  211. router.transitionTo('step3');
  212. }
  213. },
  214. done: function (router, context) {
  215. var controller = router.get('mainAdminSecurityAddStep4Controller');
  216. if (!controller.get('isSubmitDisabled')) {
  217. $(context.currentTarget).parents("#modal").find(".close").trigger('click');
  218. location.reload();
  219. }
  220. }
  221. }),
  222. gotoStep1: Em.Router.transitionTo('step1'),
  223. gotoStep2: Em.Router.transitionTo('step2'),
  224. gotoStep3: Em.Router.transitionTo('step3'),
  225. gotoStep4: Em.Router.transitionTo('step4')
  226. });