stack_upgrade_routes.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. router.get('mainController').dataLoading().done(function () {
  23. Ember.run.next(function () {
  24. //if upgrade id is absent then upgrade is completed
  25. if (Em.isNone(App.db.get('MainAdminStackAndUpgrade', 'upgradeId'))) {
  26. router.transitionTo('main.admin.stackAndUpgrade.versions');
  27. return null;
  28. }
  29. App.router.get('updateController').set('isWorking', false);
  30. return App.ModalPopup.show({
  31. classNames: ['full-width-modal'],
  32. header: function () {
  33. var controller = App.router.get('mainAdminStackAndUpgradeController');
  34. if (controller.get('isDowngrade')) {
  35. return Em.I18n.t('admin.stackUpgrade.dialog.downgrade.header').format(controller.get('upgradeVersion'));
  36. } else {
  37. return Em.I18n.t('admin.stackUpgrade.dialog.header').format(controller.get('upgradeTypeDisplayName'), controller.get('upgradeVersion'));
  38. }
  39. }.property('App.router.mainAdminStackAndUpgradeController.upgradeVersion', 'App.router.mainAdminStackAndUpgradeController.isDowngrade'),
  40. bodyClass: App.upgradeWizardView,
  41. primary: Em.I18n.t('common.dismiss'),
  42. secondary: null,
  43. didInsertElement: function () {
  44. this.fitHeight();
  45. this.fitInnerHeight();
  46. },
  47. /**
  48. * fir height of scrollable block inside of modal body
  49. */
  50. fitInnerHeight: function () {
  51. var block = this.$().find('#modal > .modal-body');
  52. var scrollable = this.$().find('#modal .scrollable-block');
  53. scrollable.css('max-height', Number(block.css('max-height').slice(0, -2)) - block.height());
  54. block.css('max-height', 'none');
  55. },
  56. onPrimary: function () {
  57. this.closeWizard();
  58. },
  59. onClose: function () {
  60. this.closeWizard();
  61. },
  62. closeWizard: function () {
  63. App.router.get('updateController').set('isWorking', true);
  64. App.router.transitionTo('main.admin.stackAndUpgrade.versions');
  65. this.hide();
  66. location.reload();
  67. }
  68. });
  69. });
  70. });
  71. }
  72. });