progress_controller.js 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. * Prepare object to send to the server to save configs
  70. * Split all configs by site names and tag and note
  71. * @param siteNames Array
  72. * @param data Object
  73. * @param note String
  74. */
  75. reconfigureSites: function(siteNames, data, note) {
  76. var tagName = App.get('testMode') ? 'version1' : 'version' + (new Date).getTime();
  77. return siteNames.map(function(_siteName) {
  78. var config = data.items.findProperty('type', _siteName);
  79. var configToSave = {
  80. type: _siteName,
  81. tag: tagName,
  82. properties: config && config.properties,
  83. service_config_version_note: note || ''
  84. };
  85. if (config && config.properties_attributes) {
  86. configToSave.properties_attributes = config.properties_attributes;
  87. }
  88. return configToSave;
  89. });
  90. }
  91. });