stack_upgrade_routes.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. module.exports = App.WizardRoute.extend({
  20. route: 'stack/upgrade',
  21. enter: function (router) {
  22. console.log('in /admin/stack/upgrade:enter');
  23. Ember.run.next(function () {
  24. App.router.get('updateController').set('isWorking', false);
  25. return App.ModalPopup.show({
  26. classNames: ['full-width-modal'],
  27. header: function () {
  28. return Em.I18n.t('admin.stackUpgrade.dialog.header').format(App.router.get('mainAdminStackAndUpgradeController').get('upgradeVersion'));
  29. }.property('App.router.mainAdminStackAndUpgradeController.upgradeVersion'),
  30. bodyClass: App.upgradeWizardView,
  31. primary: null,
  32. secondary: null,
  33. didInsertElement: function () {
  34. this.fitHeight();
  35. this.fitInnerHeight();
  36. },
  37. /**
  38. * fir height of scrollable block inside of modal body
  39. */
  40. fitInnerHeight: function () {
  41. var block = this.$().find('#modal > .modal-body');
  42. var scrollable = this.$().find('#modal .scrollable-block');
  43. scrollable.css('max-height', Number(block.css('max-height').slice(0, -2)) - block.height());
  44. block.css('max-height', 'none');
  45. },
  46. onClose: function() {
  47. var self = this, header, body;
  48. if (['IN_PROGRESS', 'PENDING', 'FAILED'].contains(App.get('upgradeState'))) {
  49. header = Em.I18n.t('admin.stackUpgrade.state.inProgress');
  50. body = Em.I18n.t('admin.stackUpgrade.dialog.closeProgress');
  51. } else if (App.get('upgradeState') === 'HOLDING') {
  52. header = Em.I18n.t('admin.stackUpgrade.state.paused');
  53. body = Em.I18n.t('admin.stackUpgrade.dialog.closePause');
  54. } else {
  55. this.closeWizard();
  56. return;
  57. }
  58. App.ModalPopup.show({
  59. header: header,
  60. body: body,
  61. showCloseButton: false,
  62. onPrimary: function() {
  63. self.closeWizard();
  64. this._super();
  65. }
  66. })
  67. },
  68. closeWizard: function () {
  69. App.router.get('updateController').set('isWorking', true);
  70. App.router.transitionTo('main.admin.stackAndUpgrade');
  71. this.hide();
  72. }
  73. });
  74. });
  75. }
  76. });