progress_controller.js 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardController.extend(App.wizardProgressPageControllerMixin, {
  20. name: 'highAvailabilityProgressPageController',
  21. clusterDeployState: 'HIGH_AVAILABILITY_DEPLOY',
  22. tasksMessagesPrefix: 'admin.highAvailability.wizard.step',
  23. isRollback: false,
  24. manualRollback: function () {
  25. App.ModalPopup.show({
  26. header: Em.I18n.t('admin.highAvailability.confirmRollbackHeader'),
  27. primary: Em.I18n.t('yes'),
  28. showCloseButton: false,
  29. onPrimary: function () {
  30. var self = this;
  31. var controller = App.router.get('highAvailabilityWizardController');
  32. controller.clearTasksData();
  33. controller.clearStorageData();
  34. controller.resetOnClose(controller, 'main.services.index');
  35. this.hide();
  36. },
  37. secondary: Em.I18n.t('no'),
  38. onSecondary: function () {
  39. this.hide();
  40. },
  41. bodyClass: Ember.View.extend({
  42. template: Ember.Handlebars.compile(Em.I18n.t('admin.highAvailability.confirmManualRollbackBody'))
  43. })
  44. });
  45. },
  46. rollback: function () {
  47. var task = this.get('tasks').findProperty('status', 'FAILED');
  48. App.router.get(this.get('content.controllerName')).saveFailedTask(task);
  49. App.ModalPopup.show({
  50. header: Em.I18n.t('admin.highAvailability.confirmRollbackHeader'),
  51. primary: Em.I18n.t('common.confirm'),
  52. showCloseButton: false,
  53. onPrimary: function () {
  54. App.router.get('highAvailabilityWizardController').clearTasksData();
  55. App.router.transitionTo('main.admin.highAvailabilityRollback');
  56. this.hide();
  57. },
  58. secondary: Em.I18n.t('common.cancel'),
  59. body: Em.I18n.t('admin.highAvailability.confirmRollbackBody')
  60. });
  61. },
  62. /**
  63. * Prepare object to send to the server to save configs
  64. * Split all configs by site names and tag and note
  65. * @param siteNames Array
  66. * @param data Object
  67. * @param note String
  68. */
  69. reconfigureSites: function(siteNames, data, note) {
  70. var tagName = App.get('testMode') ? 'version1' : 'version' + (new Date).getTime();
  71. return siteNames.map(function(_siteName) {
  72. var config = data.items.findProperty('type', _siteName);
  73. var configToSave = {
  74. type: _siteName,
  75. tag: tagName,
  76. properties: config && config.properties,
  77. service_config_version_note: note || ''
  78. };
  79. if (config && config.properties_attributes) {
  80. configToSave.properties_attributes = config.properties_attributes;
  81. }
  82. return configToSave;
  83. });
  84. }
  85. });