progress_controller.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. var installedComponents = [];
  20. App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardController.extend(App.wizardProgressPageControllerMixin, {
  21. name: 'highAvailabilityProgressPageController',
  22. clusterDeployState: 'HIGH_AVAILABILITY_DEPLOY',
  23. tasksMessagesPrefix: 'admin.highAvailability.wizard.step',
  24. isRollback: false,
  25. manualRollback: function () {
  26. App.ModalPopup.show({
  27. header: Em.I18n.t('admin.highAvailability.confirmRollbackHeader'),
  28. primary: Em.I18n.t('yes'),
  29. showCloseButton: false,
  30. onPrimary: function () {
  31. var self = this;
  32. var controller = App.router.get('highAvailabilityWizardController');
  33. controller.clearTasksData();
  34. controller.clearStorageData();
  35. controller.finish();
  36. App.router.get('updateController').set('isWorking', true);
  37. App.clusterStatus.setClusterStatus({
  38. clusterName: App.router.get('content.cluster.name'),
  39. clusterState: 'DEFAULT',
  40. localdb: App.db.data
  41. },{alwaysCallback: function() {self.hide();App.router.transitionTo('main.index');location.reload();}});
  42. },
  43. secondary: Em.I18n.t('no'),
  44. onSecondary: function () {
  45. this.hide();
  46. },
  47. bodyClass: Ember.View.extend({
  48. template: Ember.Handlebars.compile(Em.I18n.t('admin.highAvailability.confirmManualRollbackBody'))
  49. })
  50. });
  51. },
  52. rollback: function () {
  53. var task = this.get('tasks').findProperty('status', 'FAILED');
  54. App.router.get(this.get('content.controllerName')).saveFailedTask(task);
  55. App.ModalPopup.show({
  56. header: Em.I18n.t('admin.highAvailability.confirmRollbackHeader'),
  57. primary: Em.I18n.t('common.confirm'),
  58. showCloseButton: false,
  59. onPrimary: function () {
  60. App.router.get('highAvailabilityWizardController').clearTasksData();
  61. App.router.transitionTo('main.admin.highAvailabilityRollback');
  62. this.hide();
  63. },
  64. secondary: Em.I18n.t('common.cancel'),
  65. body: Em.I18n.t('admin.highAvailability.confirmRollbackBody')
  66. });
  67. },
  68. /**
  69. *
  70. * @param siteNames Array
  71. */
  72. reconfigureSites: function(siteNames, data) {
  73. var tagName = App.get('testMode') ? 'version1' : 'version' + (new Date).getTime();
  74. var componentName;
  75. switch (this.get('content.controllerName')) {
  76. case 'rMHighAvailabilityWizardController':
  77. componentName = 'RESOURCEMANAGER';
  78. break;
  79. default:
  80. componentName = 'NAMENODE';
  81. }
  82. return siteNames.map(function(_siteName) {
  83. var config = data.items.findProperty('type', _siteName);
  84. var configToSave = {
  85. type: _siteName,
  86. tag: tagName,
  87. properties: config && config.properties,
  88. service_config_version_note: Em.I18n.t('admin.highAvailability.step4.save.configuration.note').format(App.format.role(componentName))
  89. }
  90. if (config && config.properties_attributes) {
  91. configToSave.properties_attributes = config.properties_attributes;
  92. }
  93. return configToSave;
  94. });
  95. }
  96. });