progress_controller.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.finish();
  35. App.router.get('updateController').set('isWorking', true);
  36. App.clusterStatus.setClusterStatus({
  37. clusterName: App.router.get('content.cluster.name'),
  38. clusterState: 'DEFAULT',
  39. localdb: App.db.data
  40. }, {
  41. alwaysCallback: function () {
  42. self.hide();
  43. App.router.transitionTo('main.index');
  44. Em.run.next(function () {
  45. location.reload();
  46. });
  47. }
  48. });
  49. },
  50. secondary: Em.I18n.t('no'),
  51. onSecondary: function () {
  52. this.hide();
  53. },
  54. bodyClass: Ember.View.extend({
  55. template: Ember.Handlebars.compile(Em.I18n.t('admin.highAvailability.confirmManualRollbackBody'))
  56. })
  57. });
  58. },
  59. rollback: function () {
  60. var task = this.get('tasks').findProperty('status', 'FAILED');
  61. App.router.get(this.get('content.controllerName')).saveFailedTask(task);
  62. App.ModalPopup.show({
  63. header: Em.I18n.t('admin.highAvailability.confirmRollbackHeader'),
  64. primary: Em.I18n.t('common.confirm'),
  65. showCloseButton: false,
  66. onPrimary: function () {
  67. App.router.get('highAvailabilityWizardController').clearTasksData();
  68. App.router.transitionTo('main.admin.highAvailabilityRollback');
  69. this.hide();
  70. },
  71. secondary: Em.I18n.t('common.cancel'),
  72. body: Em.I18n.t('admin.highAvailability.confirmRollbackBody')
  73. });
  74. },
  75. /**
  76. * Prepare object to send to the server to save configs
  77. * Split all configs by site names and tag and note
  78. * @param siteNames Array
  79. * @param data Object
  80. * @param note String
  81. */
  82. reconfigureSites: function(siteNames, data, note) {
  83. var tagName = App.get('testMode') ? 'version1' : 'version' + (new Date).getTime();
  84. return siteNames.map(function(_siteName) {
  85. var config = data.items.findProperty('type', _siteName);
  86. var configToSave = {
  87. type: _siteName,
  88. tag: tagName,
  89. properties: config && config.properties,
  90. service_config_version_note: note || ''
  91. };
  92. if (config && config.properties_attributes) {
  93. configToSave.properties_attributes = config.properties_attributes;
  94. }
  95. return configToSave;
  96. });
  97. }
  98. });