installer.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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: '/installer',
  21. App: require('app'),
  22. enter: function (router) {
  23. console.log('in /installer:enter');
  24. if (router.getAuthenticated()) {
  25. console.log('In installer with successful authenticated');
  26. // router.loadAllPriorSteps(router.getInstallerCurrentStep());
  27. Ember.run.next(function () {
  28. router.transitionTo('step' + router.getInstallerCurrentStep());
  29. });
  30. } else {
  31. console.log('In installer but its not authenticated');
  32. console.log('value of authenticated is: ' + router.getAuthenticated());
  33. Ember.run.next(function () {
  34. router.transitionTo('login');
  35. });
  36. }
  37. },
  38. routePath: function (router, event) {
  39. console.log("INFO: value of router is: " + router);
  40. console.log("INFO: value of event is: " + event);
  41. router.setNavigationFlow(event);
  42. if (!router.isFwdNavigation) {
  43. this._super(router, event);
  44. } else {
  45. router.set('backBtnForHigherStep', true);
  46. router.transitionTo('step' + router.getInstallerCurrentStep());
  47. }
  48. },
  49. connectOutlets: function (router, context) {
  50. console.log('in /installer:connectOutlets');
  51. router.get('applicationController').connectOutlet('installer');
  52. },
  53. step1: Em.Route.extend({
  54. route: '/step1',
  55. enter: function (router) {
  56. },
  57. connectOutlets: function (router, context) {
  58. console.log('in installer.step1:connectOutlets');
  59. router.setNavigationFlow('step1');
  60. router.setInstallerCurrentStep('1', false);
  61. router.get('installerController').connectOutlet('installerStep1');
  62. },
  63. next: Em.Router.transitionTo('step2')
  64. }),
  65. step2: Em.Route.extend({
  66. route: '/step2',
  67. connectOutlets: function (router, context) {
  68. router.setNavigationFlow('step2');
  69. router.setInstallerCurrentStep('2', false);
  70. router.get('installerController').connectOutlet('installerStep2');
  71. },
  72. back: Em.Router.transitionTo('step1'),
  73. next: function (router, context) {
  74. App.db.setBootStatus(false);
  75. var hosts = App.db.getHosts();
  76. var hostInfo = {};
  77. for (var index in hosts) {
  78. hostInfo[index] = {
  79. name: hosts[index].name,
  80. bootStatus: 'pending'
  81. };
  82. }
  83. App.db.setHosts(hostInfo);
  84. router.transitionTo('step3');
  85. }
  86. }),
  87. step3: Em.Route.extend({
  88. route: '/step3',
  89. connectOutlets: function (router, context) {
  90. router.setNavigationFlow('step3');
  91. router.setInstallerCurrentStep('3', false);
  92. router.get('installerController').connectOutlet('installerStep3');
  93. },
  94. back: Em.Router.transitionTo('step2'),
  95. next: function (router, context) {
  96. App.db.setBootStatus(true);
  97. App.db.setService(router.get('installerStep4Controller.rawContent'));
  98. router.transitionTo('step4');
  99. }
  100. }),
  101. step4: Em.Route.extend({
  102. route: '/step4',
  103. connectOutlets: function (router, context) {
  104. router.setNavigationFlow('step4');
  105. router.setInstallerCurrentStep('4', false);
  106. router.get('installerController').connectOutlet('installerStep4');
  107. },
  108. back: Em.Router.transitionTo('step3'),
  109. next: function (router, context) {
  110. App.db.setMasterComponentHosts(undefined);
  111. router.transitionTo('step5');
  112. }
  113. }),
  114. step5: Em.Route.extend({
  115. route: '/step5',
  116. connectOutlets: function (router, context) {
  117. router.setNavigationFlow('step5');
  118. router.setInstallerCurrentStep('5', false);
  119. router.get('installerController').connectOutlet('installerStep5');
  120. },
  121. back: Em.Router.transitionTo('step4'),
  122. next: function (router, context) {
  123. App.db.setSlaveComponentHosts(undefined);
  124. router.transitionTo('step6');
  125. }
  126. }),
  127. step6: Em.Route.extend({
  128. route: '/step6',
  129. connectOutlets: function (router, context) {
  130. router.setNavigationFlow('step6');
  131. router.setInstallerCurrentStep('6', false);
  132. router.get('installerController').connectOutlet('installerStep6');
  133. },
  134. back: Em.Router.transitionTo('step5'),
  135. next: function (router, context) {
  136. App.db.setServiceConfigProperties(undefined);
  137. router.transitionTo('step7');
  138. }
  139. }),
  140. step7: Em.Route.extend({
  141. route: '/step7',
  142. connectOutlets: function (router, context) {
  143. router.setNavigationFlow('step7');
  144. router.setInstallerCurrentStep('7', false);
  145. router.get('installerController').connectOutlet('installerStep7');
  146. },
  147. back: Em.Router.transitionTo('step6'),
  148. next: Em.Router.transitionTo('step8')
  149. }),
  150. step8: Em.Route.extend({
  151. route: '/step8',
  152. connectOutlets: function (router, context) {
  153. router.setNavigationFlow('step8');
  154. router.setInstallerCurrentStep('8', false);
  155. router.get('installerController').connectOutlet('installerStep8');
  156. },
  157. back: Em.Router.transitionTo('step7'),
  158. next: function (router, context) {
  159. App.db.setClusterStatus({status: 'pending', isCompleted: false});
  160. var hostInfo = App.db.getHosts();
  161. for (var index in hostInfo) {
  162. hostInfo[index].status = "pending";
  163. hostInfo[index].message = 'Information';
  164. hostInfo[index].progress = '0';
  165. }
  166. App.db.setHosts(hostInfo);
  167. console.log("TRACE: host name is: " + hostInfo[index].name);
  168. router.transitionTo('step9');
  169. }
  170. }),
  171. step9: Em.Route.extend({
  172. route: '/step9',
  173. connectOutlets: function (router, context) {
  174. router.setNavigationFlow('step9');
  175. router.setInstallerCurrentStep('9', false);
  176. router.get('installerController').connectOutlet('installerStep9');
  177. },
  178. back: Em.Router.transitionTo('step8'),
  179. next: Em.Router.transitionTo('step10')
  180. }),
  181. step10: Em.Route.extend({
  182. route: '/step10',
  183. connectOutlets: function (router, context) {
  184. router.setNavigationFlow('step10');
  185. router.setInstallerCurrentStep('10', false);
  186. router.get('installerController').connectOutlet('installerStep10');
  187. },
  188. back: Em.Router.transitionTo('step9'),
  189. complete: function (router, context) {
  190. if (true) { // this function will be moved to installerController where it will validate
  191. router.setInstallerCurrentStep('1', true);
  192. router.setSection('main');
  193. router.transitionTo('main');
  194. } else {
  195. console.log('cluster installation failure');
  196. }
  197. }
  198. }),
  199. gotoStep1: Em.Router.transitionTo('step1'),
  200. gotoStep2: Em.Router.transitionTo('step2'),
  201. gotoStep3: Em.Router.transitionTo('step3'),
  202. gotoStep4: Em.Router.transitionTo('step4'),
  203. gotoStep5: Em.Router.transitionTo('step5'),
  204. gotoStep6: Em.Router.transitionTo('step6'),
  205. gotoStep7: Em.Router.transitionTo('step7'),
  206. gotoStep8: Em.Router.transitionTo('step8'),
  207. gotoStep9: Em.Router.transitionTo('step9'),
  208. gotoStep10: Em.Router.transitionTo('step10')
  209. });