wizard.js 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356
  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. require('models/host');
  20. App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingMixin, {
  21. isStepDisabled: null,
  22. previousStep: 0,
  23. /**
  24. * map of actions which load data required by which step
  25. * used by <code>loadAllPriorSteps</code>
  26. */
  27. loadMap: {},
  28. /**
  29. * Wizard properties in local storage, which should be cleaned right after wizard has been finished
  30. */
  31. dbPropertiesToClean: [
  32. 'service',
  33. 'hosts',
  34. 'masterComponentHosts',
  35. 'slaveComponentHosts',
  36. 'cluster',
  37. 'allHostNames',
  38. 'installOptions',
  39. 'allHostNamesPattern',
  40. 'serviceComponents',
  41. 'fileNamesToUpdate'
  42. ],
  43. sensibleConfigs: [
  44. { name: 'admin_principal', filename: 'krb5-conf.xml'},
  45. { name: 'admin_password', filename: 'krb5-conf.xml' }
  46. ],
  47. init: function () {
  48. this.clusters = App.Cluster.find();
  49. this.setIsStepDisabled();
  50. },
  51. connectOutlet:function(name, context) {
  52. if (name !== 'loading') this.set('isStepDisabled.isLocked', false);
  53. return this._super.apply(this,arguments);
  54. },
  55. /**
  56. * Set <code>isStepDisabled</code> with list of available steps (basing on <code>totalSteps</code>)
  57. * @method setIsStepDisabled
  58. */
  59. setIsStepDisabled: function () {
  60. this.set('isStepDisabled', Ember.ArrayProxy.create({
  61. content:[],
  62. isLocked:true,
  63. objectAtContent: function(idx) {
  64. var obj = this.get('content').objectAt(idx);
  65. if (obj && !obj.hasOwnProperty('isLocked')) {
  66. obj.reopen({
  67. isLocked:true,
  68. get:function (key) {
  69. return (key === 'value' && this.get('isLocked')) || this._super.apply(this,arguments);
  70. },
  71. notifyValues:function () {
  72. this.notifyPropertyChange('value');
  73. }.observes('isLocked')
  74. });
  75. }
  76. return obj;
  77. },
  78. toggleLock:function () {
  79. this.setEach('isLocked',this.get('isLocked'));
  80. }.observes('isLocked')
  81. }));
  82. this.get('isStepDisabled').pushObject(Em.Object.create({
  83. step: 1,
  84. value: false
  85. }));
  86. for (var i = 2; i <= this.get('totalSteps'); i++) {
  87. this.get('isStepDisabled').pushObject(Em.Object.create({
  88. step: i,
  89. value: true
  90. }));
  91. }
  92. },
  93. slaveComponents: function () {
  94. return App.StackServiceComponent.find().filterProperty('isSlave', true);
  95. }.property('App.router.clusterController.isLoaded'),
  96. allHosts: function () {
  97. var dbHosts = this.get('content.hosts');
  98. var hosts = [];
  99. var hostComponents = [];
  100. for (var hostName in dbHosts) {
  101. hostComponents = [];
  102. var disksOverallCapacity = 0;
  103. var diskFree = 0;
  104. dbHosts[hostName].hostComponents.forEach(function (componentName) {
  105. hostComponents.push(Em.Object.create({
  106. componentName: componentName,
  107. displayName: App.format.role(componentName)
  108. }));
  109. });
  110. dbHosts[hostName].disk_info.forEach(function (disk) {
  111. disksOverallCapacity += parseFloat(disk.size);
  112. diskFree += parseFloat(disk.available);
  113. });
  114. hosts.push(Em.Object.create({
  115. id: hostName,
  116. hostName: hostName,
  117. publicHostName: hostName,
  118. diskInfo: dbHosts[hostName].disk_info,
  119. diskTotal: disksOverallCapacity / (1024 * 1024),
  120. diskFree: diskFree / (1024 * 1024),
  121. disksMounted: dbHosts[hostName].disk_info.length,
  122. cpu: dbHosts[hostName].cpu,
  123. memory: dbHosts[hostName].memory,
  124. osType: dbHosts[hostName].osType ? dbHosts[hostName].osType: 0,
  125. osArch: dbHosts[hostName].osArch ? dbHosts[hostName].osArch : 0,
  126. ip: dbHosts[hostName].ip ? dbHosts[hostName].ip: 0,
  127. hostComponents: hostComponents
  128. }))
  129. }
  130. return hosts;
  131. }.property('content.hosts'),
  132. setStepsEnable: function () {
  133. for (var i = 1; i <= this.totalSteps; i++) {
  134. var step = this.get('isStepDisabled').findProperty('step', i);
  135. if (i <= this.get('currentStep')) {
  136. step.set('value', false);
  137. } else {
  138. step.set('value', true);
  139. }
  140. }
  141. }.observes('currentStep'),
  142. /**
  143. * Enable step link in left nav menu
  144. * @param step - step number
  145. */
  146. enableStep: function (step) {
  147. this.get('isStepDisabled').findProperty('step', step).set('value', false);
  148. },
  149. setLowerStepsDisable: function (stepNo) {
  150. for (var i = 1; i < stepNo; i++) {
  151. var step = this.get('isStepDisabled').findProperty('step', i);
  152. step.set('value', true);
  153. }
  154. },
  155. /**
  156. * Set current step to new value.
  157. * Method moved from App.router.setInstallerCurrentStep
  158. * @param currentStep
  159. * @param completed
  160. */
  161. currentStep: function () {
  162. return App.get('router').getWizardCurrentStep(this.get('name').substr(0, this.get('name').length - 10));
  163. }.property(),
  164. /**
  165. * Set current step to new value.
  166. * Method moved from App.router.setInstallerCurrentStep
  167. * @param currentStep
  168. * @param completed
  169. */
  170. setCurrentStep: function (currentStep, completed) {
  171. this.set('previousStep', this.get('currentStep'));
  172. App.db.setWizardCurrentStep(this.get('name').substr(0, this.get('name').length - 10), currentStep, completed);
  173. this.set('currentStep', currentStep);
  174. },
  175. clusters: null,
  176. isStep0: function () {
  177. return this.get('currentStep') == 0;
  178. }.property('currentStep'),
  179. isStep1: function () {
  180. return this.get('currentStep') == 1;
  181. }.property('currentStep'),
  182. isStep2: function () {
  183. return this.get('currentStep') == 2;
  184. }.property('currentStep'),
  185. isStep3: function () {
  186. return this.get('currentStep') == 3;
  187. }.property('currentStep'),
  188. isStep4: function () {
  189. return this.get('currentStep') == 4;
  190. }.property('currentStep'),
  191. isStep5: function () {
  192. return this.get('currentStep') == 5;
  193. }.property('currentStep'),
  194. isStep6: function () {
  195. return this.get('currentStep') == 6;
  196. }.property('currentStep'),
  197. isStep7: function () {
  198. return this.get('currentStep') == 7;
  199. }.property('currentStep'),
  200. isStep8: function () {
  201. return this.get('currentStep') == 8;
  202. }.property('currentStep'),
  203. isStep9: function () {
  204. return this.get('currentStep') == 9;
  205. }.property('currentStep'),
  206. isStep10: function () {
  207. return this.get('currentStep') == 10;
  208. }.property('currentStep'),
  209. /**
  210. * Move user to the selected step
  211. *
  212. * @param {number} step number of the step, where user is moved
  213. * @param {boolean} disableNaviWarning true - don't show warning about moving more than 1 step back
  214. * @returns {boolean}
  215. */
  216. gotoStep: function (step, disableNaviWarning) {
  217. if (this.get('isStepDisabled').findProperty('step', step).get('value') !== false) {
  218. return false;
  219. }
  220. // if going back from Step 9 in Install Wizard, delete the checkpoint so that the user is not redirected
  221. // to Step 9
  222. if (this.get('content.controllerName') == 'installerController' && this.get('currentStep') === '9' && step < 9) {
  223. App.clusterStatus.setClusterStatus({
  224. clusterName: this.get('clusterName'),
  225. clusterState: 'CLUSTER_NOT_CREATED_1',
  226. wizardControllerName: 'installerController',
  227. localdb: {}
  228. });
  229. }
  230. if ((this.get('currentStep') - step) > 1 && !disableNaviWarning) {
  231. App.ModalPopup.show({
  232. header: Em.I18n.t('installer.navigation.warning.header'),
  233. onPrimary: function () {
  234. App.router.send('gotoStep' + step);
  235. this.hide();
  236. },
  237. body: "If you proceed to go back to Step " + step + ", you will lose any changes you have made beyond this step"
  238. });
  239. } else {
  240. App.router.send('gotoStep' + step);
  241. }
  242. return true;
  243. },
  244. gotoStep0: function () {
  245. this.gotoStep(0);
  246. },
  247. gotoStep1: function () {
  248. this.gotoStep(1);
  249. },
  250. gotoStep2: function () {
  251. this.gotoStep(2);
  252. },
  253. gotoStep3: function () {
  254. this.gotoStep(3);
  255. },
  256. gotoStep4: function () {
  257. this.gotoStep(4);
  258. },
  259. gotoStep5: function () {
  260. this.gotoStep(5);
  261. },
  262. gotoStep6: function () {
  263. this.gotoStep(6);
  264. },
  265. gotoStep7: function () {
  266. this.gotoStep(7);
  267. },
  268. gotoStep8: function () {
  269. this.gotoStep(8);
  270. },
  271. gotoStep9: function () {
  272. this.gotoStep(9);
  273. },
  274. gotoStep10: function () {
  275. this.gotoStep(10);
  276. },
  277. /**
  278. * Initialize host status info for step9
  279. */
  280. setInfoForStep9: function () {
  281. var hostInfo = this.getDBProperty('hosts');
  282. for (var index in hostInfo) {
  283. hostInfo[index].status = "pending";
  284. hostInfo[index].message = 'Waiting';
  285. hostInfo[index].logTasks = [];
  286. hostInfo[index].tasks = [];
  287. hostInfo[index].progress = '0';
  288. }
  289. this.setDBProperty('hosts', hostInfo);
  290. },
  291. /**
  292. * Remove all data for installOptions step
  293. */
  294. clearInstallOptions: function () {
  295. var installOptions = this.getInstallOptions();
  296. this.set('content.installOptions', installOptions);
  297. this.set('content.hosts', {});
  298. this.setDBProperties({
  299. installOptions: installOptions,
  300. hosts: {}
  301. });
  302. },
  303. toObject: function (object) {
  304. var result = {};
  305. for (var i in object) {
  306. if (object.hasOwnProperty(i)) {
  307. result[i] = object[i];
  308. }
  309. }
  310. return result;
  311. },
  312. /**
  313. * Convert any object or array to pure JS instance without inherit properties
  314. * It is used to convert Ember.Object to pure JS Object and Ember.Array to pure JS Array
  315. * @param originalInstance
  316. * @returns {*}
  317. */
  318. toJSInstance: function (originalInstance) {
  319. var convertedInstance = originalInstance;
  320. if (Em.isArray(originalInstance)) {
  321. convertedInstance = [];
  322. originalInstance.forEach(function (element) {
  323. convertedInstance.push(this.toJSInstance(element));
  324. }, this)
  325. } else if (originalInstance && typeof originalInstance === 'object') {
  326. convertedInstance = {};
  327. for (var property in originalInstance) {
  328. if (originalInstance.hasOwnProperty(property)) {
  329. convertedInstance[property] = this.toJSInstance(originalInstance[property]);
  330. }
  331. }
  332. }
  333. return convertedInstance
  334. },
  335. /**
  336. * save status of the cluster. This is called from step8 and step9 to persist install and start requestId
  337. * @param clusterStatus object with status, isCompleted, requestId, isInstallError and isStartError field.
  338. */
  339. saveClusterStatus: function (clusterStatus) {
  340. var oldStatus = this.toObject(this.get('content.cluster'));
  341. clusterStatus = jQuery.extend(oldStatus, clusterStatus);
  342. if (clusterStatus.requestId &&
  343. clusterStatus.oldRequestsId.indexOf(clusterStatus.requestId) === -1) {
  344. clusterStatus.oldRequestsId.push(clusterStatus.requestId);
  345. }
  346. this.set('content.cluster', clusterStatus);
  347. this.setDBProperty('cluster', clusterStatus);
  348. },
  349. /**
  350. * Invoke installation of selected services to the server and saves the request id returned by the server.
  351. * @param isRetry
  352. */
  353. installServices: function (isRetry, callback) {
  354. // clear requests since we are installing services
  355. // and we don't want to get tasks for previous install attempts
  356. this.set('content.cluster.oldRequestsId', []);
  357. var data;
  358. callback = callback || Em.K;
  359. if (isRetry) {
  360. data = {
  361. context: Em.I18n.t('requestInfo.installComponents'),
  362. HostRoles: {"state": "INSTALLED"},
  363. urlParams: "HostRoles/desired_state=INSTALLED"
  364. };
  365. } else {
  366. data = {
  367. context: Em.I18n.t('requestInfo.installServices'),
  368. ServiceInfo: {"state": "INSTALLED"},
  369. urlParams: "ServiceInfo/state=INIT"
  370. };
  371. }
  372. var clusterStatus = {
  373. status: 'PENDING'
  374. };
  375. this.saveClusterStatus(clusterStatus);
  376. App.ajax.send({
  377. name: isRetry ? 'common.host_components.update' : 'common.services.update',
  378. sender: this,
  379. data: data,
  380. success: 'installServicesSuccessCallback',
  381. error: 'installServicesErrorCallback'
  382. }).then(callback, callback);
  383. },
  384. installServicesSuccessCallback: function (jsonData) {
  385. var installStartTime = App.dateTime();
  386. if (jsonData) {
  387. var requestId = jsonData.Requests.id;
  388. var clusterStatus = {
  389. status: 'PENDING',
  390. requestId: requestId,
  391. isInstallError: false,
  392. isCompleted: false,
  393. installStartTime: installStartTime
  394. };
  395. this.saveClusterStatus(clusterStatus);
  396. }
  397. },
  398. installServicesErrorCallback: function (request, ajaxOptions, error) {
  399. var clusterStatus = {
  400. status: 'PENDING',
  401. requestId: this.get('content.cluster.requestId'),
  402. isInstallError: true,
  403. isCompleted: false
  404. };
  405. this.saveClusterStatus(clusterStatus);
  406. App.showAlertPopup(Em.I18n.t('common.errorPopup.header'), request.responseText);
  407. },
  408. /**
  409. * show popup, that display status of bootstrap launching
  410. * @param callback
  411. * @return {Object}
  412. */
  413. showLaunchBootstrapPopup: function (callback) {
  414. return App.ModalPopup.show({
  415. header: Em.I18n.t('installer.step2.bootStrap.header'),
  416. isError: false,
  417. serverError: null,
  418. bodyClass: Em.View.extend({
  419. templateName: require('templates/wizard/bootstrap_call_popup')
  420. }),
  421. showFooter: false,
  422. showCloseButton: false,
  423. secondary: null,
  424. /**
  425. * handle requestId when call is completed,
  426. * if it's correct call callback and hide popup
  427. * otherwise notify error and enable buttons to close popup
  428. * @param requestId
  429. * @param serverError
  430. * @param status
  431. * @param log
  432. */
  433. finishLoading: function (requestId, serverError, status, log) {
  434. if (Em.isNone(requestId) || status == 'ERROR') {
  435. var stepController = App.get('router.wizardStep3Controller');
  436. this.setProperties({
  437. isError: true,
  438. showFooter: true,
  439. showCloseButton: true,
  440. serverError: status == 'ERROR' ? log : serverError
  441. });
  442. stepController.setProperties({
  443. isRegistrationInProgress: false,
  444. isBootstrapFailed: true
  445. });
  446. stepController.get('hosts').setEach('bootStatus', 'FAILED');
  447. } else {
  448. callback(requestId);
  449. this.hide();
  450. }
  451. }
  452. });
  453. },
  454. /**
  455. * Bootstrap selected hosts.
  456. * @param bootStrapData
  457. * @param callback
  458. * @return {Object}
  459. */
  460. launchBootstrap: function (bootStrapData, callback) {
  461. var popup = this.showLaunchBootstrapPopup(callback);
  462. App.ajax.send({
  463. name: 'wizard.launch_bootstrap',
  464. sender: this,
  465. data: {
  466. bootStrapData: bootStrapData,
  467. popup: popup
  468. },
  469. success: 'launchBootstrapSuccessCallback',
  470. error: 'launchBootstrapErrorCallback'
  471. });
  472. return popup;
  473. },
  474. launchBootstrapSuccessCallback: function (data, opt, params) {
  475. params.popup.finishLoading(data.requestId, null, data.status, data.log);
  476. },
  477. launchBootstrapErrorCallback: function (request, ajaxOptions, error, opt, params) {
  478. params.popup.finishLoading(null, error);
  479. },
  480. /**
  481. * Load <code>content.<name></code> variable from localStorage, if wasn't loaded before.
  482. * If you specify <code>reload</code> to true - it will reload it.
  483. * @param name
  484. * @param reload
  485. * @return {Boolean}
  486. */
  487. load: function (name, reload) {
  488. if (this.get('content.' + name) && !reload) {
  489. return false;
  490. }
  491. var result = this.getDBProperty(name);
  492. if (!result) {
  493. if (this['get' + name.capitalize()]) {
  494. result = this['get' + name.capitalize()]();
  495. this.setDBProperty(name, result);
  496. }
  497. else {
  498. console.debug('get' + name.capitalize(), ' not defined in the ' + this.get('name'));
  499. }
  500. }
  501. this.set('content.' + name, result);
  502. },
  503. save: function (name) {
  504. var convertedValue = this.toJSInstance(this.get('content.' + name));
  505. this.setDBProperty(name, convertedValue);
  506. },
  507. clear: function () {
  508. this.set('content', Ember.Object.create({
  509. 'controllerName': this.get('content.controllerName')
  510. }));
  511. this.set('currentStep', 0);
  512. this.clearStorageData();
  513. },
  514. clusterStatusTemplate: {
  515. name: "",
  516. status: "PENDING",
  517. isCompleted: false,
  518. requestId: null,
  519. installStartTime: null,
  520. installTime: null,
  521. isInstallError: false,
  522. isStartError: false,
  523. oldRequestsId: []
  524. },
  525. clearStorageData: function () {
  526. var hash = {};
  527. this.get('dbPropertiesToClean').forEach(function (key) {
  528. hash[key] = undefined;
  529. }, this);
  530. this.setDBProperties(hash);
  531. },
  532. getInstallOptions: function() {
  533. return jQuery.extend({}, App.get('isHadoopWindowsStack') ? this.get('installWindowsOptionsTemplate') : this.get('installOptionsTemplate'));
  534. },
  535. installOptionsTemplate: {
  536. hostNames: "", //string
  537. manualInstall: false, //true, false
  538. useSsh: true, //bool
  539. javaHome: App.defaultJavaHome, //string
  540. localRepo: false, //true, false
  541. sshKey: "", //string
  542. bootRequestId: null, //string
  543. sshUser: "root", //string
  544. sshPort: "22",
  545. agentUser: "root" //string
  546. },
  547. installWindowsOptionsTemplate: {
  548. hostNames: "", //string
  549. manualInstall: false, //true, false
  550. useSsh: true, //bool
  551. javaHome: App.defaultJavaHome, //string
  552. localRepo: false, //true, false
  553. sshKey: "", //string
  554. bootRequestId: null, //string
  555. sshUser: "", //string
  556. sshPort: "22",
  557. agentUser: "" //string
  558. },
  559. loadedServiceComponents: null,
  560. /**
  561. * Generate serviceComponents as pr the stack definition and save it to localdata
  562. * called form stepController step4WizardController
  563. */
  564. loadServiceComponents: function () {
  565. return App.ajax.send({
  566. name: 'wizard.service_components',
  567. sender: this,
  568. data: {
  569. stackUrl: App.get('stackVersionURL'),
  570. stackVersion: App.get('currentStackVersionNumber')
  571. },
  572. success: 'loadServiceComponentsSuccessCallback',
  573. error: 'loadServiceComponentsErrorCallback'
  574. });
  575. },
  576. loadServiceComponentsSuccessCallback: function (jsonData) {
  577. var props = this.getDBProperties(['selectedServiceNames', 'installedServiceNames']);
  578. var savedSelectedServices = props.selectedServiceNames;
  579. var savedInstalledServices = props.installedServiceNames;
  580. this.set('content.selectedServiceNames', savedSelectedServices);
  581. this.set('content.installedServiceNames', savedInstalledServices);
  582. if (!savedSelectedServices) {
  583. jsonData.items.forEach(function (service) {
  584. service.StackServices.is_selected = true;
  585. }, this);
  586. } else {
  587. jsonData.items.forEach(function (service) {
  588. if (savedSelectedServices.contains(service.StackServices.service_name))
  589. service.StackServices.is_selected = true;
  590. else
  591. service.StackServices.is_selected = false;
  592. }, this);
  593. }
  594. if (!savedInstalledServices) {
  595. jsonData.items.forEach(function (service) {
  596. service.StackServices.is_installed = false;
  597. }, this);
  598. } else {
  599. jsonData.items.forEach(function (service) {
  600. if (savedInstalledServices.contains(service.StackServices.service_name))
  601. service.StackServices.is_installed = true;
  602. else
  603. service.StackServices.is_installed = false;
  604. }, this);
  605. }
  606. App.stackServiceMapper.mapStackServices(jsonData);
  607. },
  608. loadServiceComponentsErrorCallback: function (request, ajaxOptions, error) {
  609. },
  610. /**
  611. * Load config groups from local DB
  612. */
  613. loadServiceConfigGroups: function () {
  614. var props = this.getDBProperties(['serviceConfigGroups', 'hosts']);
  615. var serviceConfigGroups = props.serviceConfigGroups,
  616. hosts = props.hosts || {},
  617. host_names = Em.keys(hosts);
  618. if (Em.isNone(serviceConfigGroups)) {
  619. serviceConfigGroups = [];
  620. }
  621. else {
  622. serviceConfigGroups.forEach(function(group) {
  623. var hostNames = group.hosts.map(function(host_id) {
  624. for (var i = 0; i < host_names.length; i++) {
  625. if (hosts[host_names[i]].id === host_id) {
  626. return host_names[i];
  627. }
  628. }
  629. Em.assert('host is missing!!!!', false);
  630. });
  631. Em.set(group, 'hosts', hostNames);
  632. });
  633. }
  634. this.set('content.configGroups', serviceConfigGroups);
  635. },
  636. registerErrPopup: function (header, message) {
  637. App.ModalPopup.show({
  638. header: header,
  639. secondary: false,
  640. bodyClass: Ember.View.extend({
  641. template: Ember.Handlebars.compile('<p>{{view.message}}</p>'),
  642. message: message
  643. })
  644. });
  645. },
  646. /**
  647. * Save hosts that the user confirmed to proceed with from step 3
  648. * @param stepController App.WizardStep3Controller
  649. */
  650. saveConfirmedHosts: function (stepController) {
  651. var hosts = this.get('content.hosts'),
  652. indx = 1;
  653. //add previously installed hosts
  654. for (var hostName in hosts) {
  655. if (!hosts[hostName].isInstalled) {
  656. delete hosts[hostName];
  657. }
  658. }
  659. stepController.get('confirmedHosts').forEach(function (_host) {
  660. if (_host.bootStatus == 'REGISTERED') {
  661. hosts[_host.name] = {
  662. name: _host.name,
  663. cpu: _host.cpu,
  664. memory: _host.memory,
  665. disk_info: _host.disk_info,
  666. os_type: _host.os_type,
  667. os_arch: _host.os_arch,
  668. ip: _host.ip,
  669. bootStatus: _host.bootStatus,
  670. isInstalled: false,
  671. id: indx++
  672. };
  673. }
  674. });
  675. this.setDBProperty('hosts', hosts);
  676. this.set('content.hosts', hosts);
  677. },
  678. /**
  679. * Save data after installation to main controller
  680. * @param stepController App.WizardStep9Controller
  681. */
  682. saveInstalledHosts: function (stepController) {
  683. var hosts = stepController.get('hosts');
  684. var hostInfo = this.getDBProperty('hosts');
  685. for (var index in hostInfo) {
  686. hostInfo[index].status = "pending";
  687. var host = hosts.findProperty('name', hostInfo[index].name);
  688. if (host) {
  689. hostInfo[index].status = host.status;
  690. hostInfo[index].message = host.message;
  691. hostInfo[index].progress = host.progress;
  692. }
  693. }
  694. this.set('content.hosts', hostInfo);
  695. this.setDBProperty('hosts', hostInfo);
  696. },
  697. /**
  698. * Save slaveHostComponents to main controller
  699. * @param stepController
  700. */
  701. saveSlaveComponentHosts: function (stepController) {
  702. var hosts = stepController.get('hosts'),
  703. dbHosts = this.getDBProperty('hosts'),
  704. headers = stepController.get('headers');
  705. var formattedHosts = Ember.Object.create();
  706. headers.forEach(function (header) {
  707. formattedHosts.set(header.get('name'), []);
  708. });
  709. hosts.forEach(function (host) {
  710. var checkboxes = host.checkboxes;
  711. headers.forEach(function (header) {
  712. var cb = checkboxes.findProperty('title', header.get('label'));
  713. if (cb.checked) {
  714. formattedHosts.get(header.get('name')).push({
  715. group: 'Default',
  716. isInstalled: cb.isInstalled,
  717. host_id: dbHosts[host.hostName].id
  718. });
  719. }
  720. });
  721. });
  722. var slaveComponentHosts = [];
  723. headers.forEach(function (header) {
  724. slaveComponentHosts.push({
  725. componentName: header.get('name'),
  726. displayName: header.get('label').replace(/\s/g, ''),
  727. hosts: formattedHosts.get(header.get('name'))
  728. });
  729. });
  730. this.setDBProperty('slaveComponentHosts', slaveComponentHosts);
  731. this.set('content.slaveComponentHosts', slaveComponentHosts);
  732. },
  733. /**
  734. * Return true if cluster data is loaded and false otherwise.
  735. * This is used for all wizard controllers except for installer wizard.
  736. */
  737. dataLoading: function () {
  738. var dfd = $.Deferred();
  739. this.connectOutlet('loading');
  740. if (App.router.get('clusterController.isLoaded')) {
  741. dfd.resolve();
  742. } else {
  743. var interval = setInterval(function () {
  744. if (App.router.get('clusterController.isLoaded')) {
  745. dfd.resolve();
  746. clearInterval(interval);
  747. }
  748. }, 50);
  749. }
  750. return dfd.promise();
  751. },
  752. /**
  753. * Return true if user data is loaded via App.MainServiceInfoConfigsController
  754. * This function is used in reassign master wizard right now.
  755. */
  756. usersLoading: function () {
  757. var self = this;
  758. var dfd = $.Deferred();
  759. var miscController = App.MainAdminServiceAccountsController.create({content: self.get('content')});
  760. miscController.loadUsers();
  761. var interval = setInterval(function () {
  762. if (miscController.get('dataIsLoaded')) {
  763. if (self.get("content.hdfsUser")) {
  764. self.set('content.hdfsUser', miscController.get('content.hdfsUser'));
  765. }
  766. dfd.resolve();
  767. clearInterval(interval);
  768. }
  769. }, 10);
  770. return dfd.promise();
  771. },
  772. /**
  773. * Save cluster status before going to deploy step
  774. * @param name cluster state. Unique for every wizard
  775. */
  776. saveClusterState: function (name) {
  777. App.clusterStatus.setClusterStatus({
  778. clusterName: this.get('content.cluster.name'),
  779. clusterState: name,
  780. wizardControllerName: this.get('content.controllerName'),
  781. localdb: App.db.data
  782. });
  783. },
  784. /**
  785. * Load serviceConfigProperties to model
  786. */
  787. loadServiceConfigProperties: function () {
  788. var serviceConfigProperties = this.getDBProperty('serviceConfigProperties');
  789. this.set('content.serviceConfigProperties', serviceConfigProperties);
  790. },
  791. /**
  792. * Save config properties
  793. * @param stepController Step7WizardController
  794. */
  795. saveServiceConfigProperties: function (stepController) {
  796. var serviceConfigProperties = [];
  797. var fileNamesToUpdate = this.getDBProperty('fileNamesToUpdate') || [];
  798. var installedServiceNames = stepController.get('installedServiceNames') || [];
  799. var installedServiceNamesMap = installedServiceNames.toWickMap();
  800. stepController.get('stepConfigs').forEach(function (_content) {
  801. if (_content.serviceName === 'YARN') {
  802. _content.set('configs', App.config.textareaIntoFileConfigs(_content.get('configs'), 'capacity-scheduler.xml'));
  803. }
  804. _content.get('configs').forEach(function (_configProperties) {
  805. var configProperty = App.config.createDefaultConfig(
  806. _configProperties.get('name'),
  807. _configProperties.get('serviceName'),
  808. _configProperties.get('filename'),
  809. _configProperties.get('isUserProperty'),
  810. {value: _configProperties.get('value')}
  811. );
  812. configProperty = App.config.mergeStaticProperties(configProperty, _configProperties, ['name', 'filename']);
  813. if (this.isExcludedConfig(configProperty)) {
  814. configProperty.value = '';
  815. }
  816. serviceConfigProperties.push(configProperty);
  817. }, this);
  818. // check for configs that need to update for installed services
  819. if (installedServiceNamesMap[_content.get('serviceName')]) {
  820. // get only modified configs
  821. var configs = _content.get('configs').filter(function (config) {
  822. if (config.get('isNotDefaultValue') || (config.get('savedValue') === null)) {
  823. return config.isRequiredByAgent!== false;
  824. }
  825. return false;
  826. });
  827. // if modified configs detected push all service's configs for update
  828. if (configs.length) {
  829. fileNamesToUpdate = fileNamesToUpdate.concat(configs.mapProperty('filename').uniq());
  830. }
  831. }
  832. }, this);
  833. this.setDBProperties({
  834. fileNamesToUpdate: fileNamesToUpdate,
  835. serviceConfigProperties: serviceConfigProperties
  836. });
  837. this.set('content.serviceConfigProperties', serviceConfigProperties);
  838. },
  839. isExcludedConfig: function (configProperty) {
  840. return this.get('sensibleConfigs').mapProperty('name').indexOf(configProperty.name) > -1
  841. && this.get('sensibleConfigs').mapProperty('filename').indexOf(configProperty.filename) > -1;
  842. },
  843. /**
  844. * save Config groups
  845. * @param stepController
  846. * @param isAddService
  847. */
  848. saveServiceConfigGroups: function (stepController, isAddService) {
  849. var serviceConfigGroups = [],
  850. isForInstalledService = false,
  851. hosts = isAddService ? App.router.get('addServiceController').getDBProperty('hosts') : this.getDBProperty('hosts');
  852. stepController.get('stepConfigs').forEach(function (service) {
  853. // mark group of installed service
  854. if (service.get('selected') === false) isForInstalledService = true;
  855. service.get('configGroups').forEach(function (configGroup) {
  856. var properties = [];
  857. configGroup.get('properties').forEach(function (property) {
  858. properties.push({
  859. isRequiredByAgent: property.get('isRequiredByAgent'),
  860. name: property.get('name'),
  861. value: property.get('value'),
  862. isFinal: property.get('isFinal'),
  863. filename: property.get('filename')
  864. })
  865. });
  866. //configGroup copied into plain JS object to avoid Converting circular structure to JSON
  867. var hostNames = configGroup.get('hosts').map(function(host_name) {return hosts[host_name].id;});
  868. serviceConfigGroups.push({
  869. id: configGroup.get('id'),
  870. name: configGroup.get('name'),
  871. description: configGroup.get('description'),
  872. hosts: hostNames.slice(),
  873. properties: properties.slice(),
  874. is_default: configGroup.get('isDefault'),
  875. is_for_installed_service: isForInstalledService,
  876. is_for_update: configGroup.isForUpdate || configGroup.get('hash') != this.getConfigGroupHash(configGroup, hostNames),
  877. service_name: configGroup.get('serviceName'),
  878. service_id: configGroup.get('serviceName'),
  879. desired_configs: configGroup.get('desiredConfigs'),
  880. config_group_id: configGroup.get('configGroupId'),
  881. child_config_groups: configGroup.get('childConfigGroups') ? configGroup.get('childConfigGroups').mapProperty('id') : [],
  882. parent_config_group_id: configGroup.get('parentConfigGroup.id')
  883. });
  884. }, this)
  885. }, this);
  886. this.setDBProperty('serviceConfigGroups', serviceConfigGroups);
  887. this.set('content.configGroups', serviceConfigGroups);
  888. },
  889. /**
  890. * generate string hash for config group
  891. * @param {Object} configGroup
  892. * @param {Array|undefined} hosts
  893. * @returns {String|null}
  894. * @method getConfigGroupHash
  895. */
  896. getConfigGroupHash: function(configGroup, hosts) {
  897. if (!Em.get(configGroup, 'properties.length') && !Em.get(configGroup, 'hosts.length') && !hosts) {
  898. return null;
  899. }
  900. var hash = {};
  901. Em.get(configGroup, 'properties').forEach(function (config) {
  902. hash[Em.get(config, 'name')] = {value: Em.get(config, 'value'), isFinal: Em.get(config, 'isFinal')};
  903. });
  904. hash['hosts'] = hosts || Em.get(configGroup, 'hosts');
  905. return JSON.stringify(hash);
  906. },
  907. /**
  908. * return slaveComponents bound to hosts
  909. * @return {Array}
  910. */
  911. getSlaveComponentHosts: function () {
  912. var components = this.get('slaveComponents');
  913. var result = [];
  914. var installedServices = App.Service.find().mapProperty('serviceName');
  915. var selectedServices = App.StackService.find().filterProperty('isSelected', true).mapProperty('serviceName');
  916. var installedComponentsMap = {};
  917. var uninstalledComponents = [];
  918. components.forEach(function (component) {
  919. if (installedServices.contains(component.get('serviceName'))) {
  920. installedComponentsMap[component.get('componentName')] = [];
  921. } else if (selectedServices.contains(component.get('serviceName'))) {
  922. uninstalledComponents.push(component);
  923. }
  924. }, this);
  925. installedComponentsMap['HDFS_CLIENT'] = [];
  926. App.HostComponent.find().forEach(function (hostComponent) {
  927. if (installedComponentsMap[hostComponent.get('componentName')]) {
  928. installedComponentsMap[hostComponent.get('componentName')].push(hostComponent.get('hostName'));
  929. }
  930. }, this);
  931. for (var componentName in installedComponentsMap) {
  932. var name = (componentName === 'HDFS_CLIENT') ? 'CLIENT' : componentName;
  933. var component = {
  934. componentName: name,
  935. displayName: App.format.role(name),
  936. hosts: [],
  937. isInstalled: true
  938. };
  939. installedComponentsMap[componentName].forEach(function (hostName) {
  940. component.hosts.push({
  941. group: "Default",
  942. hostName: hostName,
  943. isInstalled: true
  944. });
  945. }, this);
  946. result.push(component);
  947. }
  948. uninstalledComponents.forEach(function (component) {
  949. var hosts = jQuery.extend(true, [], result.findProperty('componentName', 'DATANODE').hosts);
  950. hosts.setEach('isInstalled', false);
  951. result.push({
  952. componentName: component.get('componentName'),
  953. displayName: App.format.role(component.get('componentName')),
  954. hosts: hosts,
  955. isInstalled: false
  956. })
  957. });
  958. return result;
  959. },
  960. /**
  961. * Load master component hosts data for using in required step controllers
  962. */
  963. loadMasterComponentHosts: function () {
  964. var masterComponentHosts = this.getDBProperty('masterComponentHosts');
  965. var stackMasterComponents = App.get('components.masters').uniq();
  966. if (!masterComponentHosts) {
  967. masterComponentHosts = [];
  968. App.HostComponent.find().filter(function(component) {
  969. return stackMasterComponents.contains(component.get('componentName'));
  970. }).forEach(function (item) {
  971. masterComponentHosts.push({
  972. component: item.get('componentName'),
  973. hostName: item.get('hostName'),
  974. isInstalled: true,
  975. serviceId: item.get('service.id'),
  976. display_name: item.get('displayName')
  977. })
  978. });
  979. this.setDBProperty('masterComponentHosts', masterComponentHosts);
  980. }
  981. this.set("content.masterComponentHosts", masterComponentHosts);
  982. },
  983. /**
  984. * Save Master Component Hosts data to Main Controller
  985. * @param stepController App.WizardStep5Controller
  986. */
  987. saveMasterComponentHosts: function (stepController) {
  988. var obj = stepController.get('selectedServicesMasters');
  989. var masterComponentHosts = [];
  990. obj.forEach(function (_component) {
  991. masterComponentHosts.push({
  992. display_name: _component.get('display_name'),
  993. component: _component.get('component_name'),
  994. hostName: _component.get('selectedHost'),
  995. serviceId: _component.get('serviceId'),
  996. isInstalled: _component.get('isInstalled')
  997. });
  998. });
  999. this.setDBProperty('masterComponentHosts', masterComponentHosts);
  1000. this.set('content.masterComponentHosts', masterComponentHosts);
  1001. },
  1002. clearMasterComponentHosts: function() {
  1003. this.set('content.masterComponentHosts', null);
  1004. this.setDBProperty('masterComponentHosts', null);
  1005. },
  1006. /**
  1007. * Load information about hosts with clients components
  1008. */
  1009. loadClients: function () {
  1010. var clients = this.getDBProperty('clientInfo');
  1011. this.set('content.clients', clients);
  1012. },
  1013. /**
  1014. * load methods assigned to each step
  1015. * methods executed in exact order as they described in map
  1016. * @return {object}
  1017. */
  1018. loadAllPriorSteps: function () {
  1019. var currentStep = this.get('currentStep');
  1020. var loadMap = this.get('loadMap');
  1021. var operationStack = [];
  1022. var dfd = $.Deferred();
  1023. for (var s in loadMap) {
  1024. if (parseInt(s) <= parseInt(currentStep)) {
  1025. operationStack.pushObjects(loadMap[s]);
  1026. }
  1027. }
  1028. var sequence = App.actionSequence.create({context: this});
  1029. sequence.setSequence(operationStack).onFinish(function () {
  1030. dfd.resolve();
  1031. }).start();
  1032. return dfd.promise();
  1033. },
  1034. /**
  1035. * return new object extended from clusterStatusTemplate
  1036. * @return Object
  1037. */
  1038. getCluster: function () {
  1039. return jQuery.extend({}, this.get('clusterStatusTemplate'), {name: App.router.getClusterName()});
  1040. },
  1041. /**
  1042. * Load services data from server.
  1043. */
  1044. loadServicesFromServer: function () {
  1045. var services = this.getDBProperty('services');
  1046. if (!services) {
  1047. services = {
  1048. selectedServices: [],
  1049. installedServices: []
  1050. };
  1051. App.StackService.find().forEach(function(item){
  1052. var isInstalled = App.Service.find().someProperty('id', item.get('serviceName'));
  1053. item.set('isSelected', isInstalled);
  1054. item.set('isInstalled', isInstalled);
  1055. if (isInstalled) {
  1056. services.selectedServices.push(item.get('serviceName'));
  1057. services.installedServices.push(item.get('serviceName'));
  1058. }
  1059. },this);
  1060. this.setDBProperty('services',services);
  1061. } else {
  1062. App.StackService.find().forEach(function(item) {
  1063. var isSelected = services.selectedServices.contains(item.get('serviceName'));
  1064. var isInstalled = services.installedServices.contains(item.get('serviceName'));
  1065. item.set('isSelected', isSelected);
  1066. item.set('isInstalled', isInstalled);
  1067. },this);
  1068. }
  1069. this.set('content.services', App.StackService.find());
  1070. },
  1071. /**
  1072. * Load confirmed hosts.
  1073. * Will be used at <code>Assign Masters(step5)</code> step
  1074. */
  1075. loadConfirmedHosts: function () {
  1076. var hosts = App.db.getHosts();
  1077. if (hosts) {
  1078. this.set('content.hosts', hosts);
  1079. }
  1080. },
  1081. loadHosts: function () {
  1082. var dfd;
  1083. var hostsInDb = this.getDBProperty('hosts');
  1084. if (hostsInDb) {
  1085. this.set('content.hosts', hostsInDb);
  1086. dfd = $.Deferred();
  1087. dfd.resolve();
  1088. } else {
  1089. dfd = App.ajax.send({
  1090. name: 'hosts.confirmed',
  1091. sender: this,
  1092. data: {},
  1093. success: 'loadHostsSuccessCallback',
  1094. error: 'loadHostsErrorCallback'
  1095. });
  1096. }
  1097. return dfd.promise();
  1098. },
  1099. loadHostsSuccessCallback: function (response) {
  1100. var installedHosts = {};
  1101. response.items.forEach(function (item, indx) {
  1102. installedHosts[item.Hosts.host_name] = {
  1103. name: item.Hosts.host_name,
  1104. cpu: item.Hosts.cpu_count,
  1105. memory: item.Hosts.total_mem,
  1106. disk_info: item.Hosts.disk_info,
  1107. osType: item.Hosts.os_type,
  1108. osArch: item.Hosts.os_arch,
  1109. ip: item.Hosts.ip,
  1110. bootStatus: "REGISTERED",
  1111. isInstalled: true,
  1112. hostComponents: item.host_components,
  1113. id: indx++
  1114. };
  1115. });
  1116. this.setDBProperty('hosts', installedHosts);
  1117. this.set('content.hosts', installedHosts);
  1118. },
  1119. loadHostsErrorCallback: function (jqXHR, ajaxOptions, error, opt) {
  1120. App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
  1121. },
  1122. /**
  1123. * Determine if <code>Assign Slaves and Clients</code> step should be skipped
  1124. * @method setSkipSlavesStep
  1125. * @param services
  1126. * @param step
  1127. */
  1128. setSkipSlavesStep: function (services, step) {
  1129. var hasServicesWithSlave = services.someProperty('hasSlave');
  1130. var hasServicesWithClient = services.someProperty('hasClient');
  1131. var hasServicesWithCustomAssignedNonMasters = services.someProperty('hasNonMastersWithCustomAssignment');
  1132. this.set('content.skipSlavesStep', !hasServicesWithSlave && !hasServicesWithClient || !hasServicesWithCustomAssignedNonMasters);
  1133. if (this.get('content.skipSlavesStep')) {
  1134. this.get('isStepDisabled').findProperty('step', step).set('value', this.get('content.skipSlavesStep'));
  1135. }
  1136. },
  1137. /**
  1138. * Load config themes for enhanced config layout.
  1139. *
  1140. * @method loadConfigThemes
  1141. * @return {$.Deferred}
  1142. */
  1143. loadConfigThemes: function () {
  1144. var self = this;
  1145. var dfd = $.Deferred();
  1146. if (!this.get('stackConfigsLoaded')) {
  1147. var serviceNames = App.StackService.find().filter(function (s) {
  1148. return s.get('isSelected') || s.get('isInstalled');
  1149. }).mapProperty('serviceName');
  1150. // Load stack configs before loading themes
  1151. App.config.loadClusterConfigsFromStack().always(function() {
  1152. App.config.loadConfigsFromStack(serviceNames).done(function () {
  1153. if (App.get('isClusterSupportsEnhancedConfigs')) {
  1154. self.loadConfigThemeForServices(serviceNames).always(function () {
  1155. self.set('stackConfigsLoaded', true);
  1156. App.themesMapper.generateAdvancedTabs(serviceNames);
  1157. dfd.resolve();
  1158. });
  1159. } else {
  1160. self.set('stackConfigsLoaded', true);
  1161. dfd.resolve();
  1162. }
  1163. });
  1164. });
  1165. }
  1166. else {
  1167. dfd.resolve();
  1168. this.set('stackConfigsLoaded', true);
  1169. }
  1170. return dfd.promise();
  1171. },
  1172. /**
  1173. * Cache "stepConfigs" to local storage in name value pairs
  1174. * @param stepController
  1175. */
  1176. cacheStepConfigValues: function(stepController) {
  1177. var self = this;
  1178. var stepConfigs = [];
  1179. stepController.get("stepConfigs").forEach(function (category) {
  1180. var configs = category.configs.map(function(config) {
  1181. if (self.isExcludedConfig(config)) {
  1182. config.set('value', '');
  1183. }
  1184. return {
  1185. name: config.name,
  1186. filename: config.filename,
  1187. value: config.value
  1188. };
  1189. });
  1190. stepConfigs = stepConfigs.concat(configs);
  1191. });
  1192. if (stepConfigs.length > 0 ) {
  1193. this.setDBProperty(stepController.name + "-sc", stepConfigs);
  1194. }
  1195. },
  1196. loadCachedStepConfigValues: function(stepController) {
  1197. return this.getDBProperty(stepController.name + "-sc");
  1198. },
  1199. clearCachedStepConfigValues: function(stepController) {
  1200. this.setDBProperty(stepController.name + "-sc", null);
  1201. },
  1202. saveTasksStatuses: function (tasksStatuses) {
  1203. this.set('content.tasksStatuses', tasksStatuses);
  1204. this.setDBProperty('tasksStatuses', tasksStatuses);
  1205. },
  1206. loadTasksStatuses: function() {
  1207. var tasksStatuses = this.getDBProperty('tasksStatuses');
  1208. this.set('content.tasksStatuses', tasksStatuses);
  1209. },
  1210. saveTasksRequestIds: function (tasksRequestIds) {
  1211. this.set('content.tasksRequestIds', tasksRequestIds);
  1212. this.setDBProperty('tasksRequestIds', tasksRequestIds);
  1213. },
  1214. loadTasksRequestIds: function() {
  1215. var tasksRequestIds = this.getDBProperty('tasksRequestIds');
  1216. this.set('content.tasksRequestIds', tasksRequestIds);
  1217. },
  1218. saveRequestIds: function (requestIds) {
  1219. this.set('content.requestIds', requestIds);
  1220. this.setDBProperty('requestIds', requestIds);
  1221. },
  1222. loadRequestIds: function() {
  1223. var requestIds = this.getDBProperty('requestIds');
  1224. this.set('content.requestIds', requestIds);
  1225. },
  1226. loadRecommendations: function () {
  1227. this.set("content.recommendations", this.getDBProperty('recommendations'));
  1228. }
  1229. });