wizardDeployProgressView.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. /**
  20. * Mixin for wizard view for showing command progress on wizard pages
  21. * This should
  22. * @type {Ember.Mixin}
  23. */
  24. App.wizardDeployProgressViewMixin = Em.Mixin.create({
  25. /**
  26. * Should ajax-queue progress bar be displayed
  27. * @method showLoadingIndicator
  28. */
  29. showLoadingIndicator: function () {
  30. if (!this.get('controller.isSubmitDisabled') || App.get('testMode')) {
  31. if (this.get('modalPopup')) {
  32. this.get('modalPopup').hide();
  33. this.set('modalPopup', null);
  34. }
  35. return;
  36. }
  37. // don't create popup if it already exists
  38. if (this.get('modalPopup')) {
  39. return;
  40. }
  41. this.set('modalPopup', App.ModalPopup.show({
  42. header: '',
  43. showFooter: false,
  44. showCloseButton: false,
  45. bodyClass: Em.View.extend({
  46. templateName: require('templates/wizard/step8/step8_log_popup'),
  47. controllerBinding: 'App.router.wizardStep8Controller',
  48. /**
  49. * Css-property for progress-bar
  50. * @type {string}
  51. */
  52. barWidth: '',
  53. /**
  54. * Popup-message
  55. * @type {string}
  56. */
  57. message: '',
  58. /**
  59. * Set progress bar width and popup message when ajax-queue requests are proccessed
  60. * @method ajaxQueueChangeObs
  61. */
  62. ajaxQueueChangeObs: function () {
  63. var length = this.get('controller.ajaxQueueLength');
  64. var left = this.get('controller.ajaxRequestsQueue.queue.length');
  65. this.set('barWidth', 'width: ' + ((length - left) / length * 100) + '%;');
  66. this.set('message', Em.I18n.t('installer.step8.deployPopup.message').format((length - left), length));
  67. }.observes('controller.ajaxQueueLength', 'controller.ajaxRequestsQueue.queue.length'),
  68. /**
  69. * Hide popup when ajax-queue is finished
  70. * @method autoHide
  71. */
  72. autoHide: function () {
  73. if (this.get('controller.servicesInstalled')) {
  74. this.get('parentView').hide();
  75. }
  76. }.observes('controller.servicesInstalled')
  77. })
  78. }));
  79. }.observes('controller.isDeployStarted')
  80. });