wizardProgressPageView.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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.wizardProgressPageViewMixin = Em.Mixin.create({
  25. /**
  26. * Following computed property needs to be overridden by the view implementing this mixin
  27. */
  28. currentStep: '',
  29. /**
  30. * Following computed property needs to be overridden by the view implementing this mixin
  31. */
  32. headerTitle: function () {
  33. }.property(),
  34. submitButtonText: Em.I18n.t('common.next'),
  35. noticeCompleted: Em.I18n.t('wizard.progressPage.notice.completed'),
  36. noticeFailed: Em.I18n.t('wizard.progressPage.notice.failed'),
  37. /**
  38. * @noticeInProgress: Following computed property needs to be overridden to show the label text while the commands
  39. * on the page are progressing
  40. */
  41. noticeInProgress: function () {
  42. }.property(),
  43. /**
  44. * @showBackButton: Override this property to show back button on the wizard progress page
  45. */
  46. showBackButton: false,
  47. /**
  48. * Following computed property needs to be overridden by the view implementing this mixin
  49. */
  50. notice: '',
  51. noticeClass: 'alert alert-info',
  52. onStatusChange: function () {
  53. var status = this.get('controller.status');
  54. if (status === 'COMPLETED') {
  55. this.set('notice', this.get('noticeCompleted'));
  56. this.set('noticeClass', 'alert alert-success');
  57. } else if (status === 'FAILED') {
  58. this.set('notice', this.get('noticeFailed'));
  59. this.set('noticeClass', 'alert alert-error');
  60. } else {
  61. this.set('notice', this.get('noticeInProgress'));
  62. this.set('noticeClass', 'alert alert-info');
  63. }
  64. }.observes('controller.status'),
  65. taskView: Em.View.extend({
  66. icon: '',
  67. iconColor: '',
  68. linkClass: '',
  69. didInsertElement: function () {
  70. this.onStatus();
  71. },
  72. barWidth: function () {
  73. return 'width: ' + this.get('content.progress') + '%;';
  74. }.property('content.progress'),
  75. onStatus: function () {
  76. var linkClass = !!this.get('content.requestIds.length') ? 'active-link' : 'active-text';
  77. this.set('linkClass', linkClass);
  78. if (this.get('content.status') === 'IN_PROGRESS') {
  79. this.set('icon', 'icon-cog');
  80. this.set('iconColor', 'text-info');
  81. } else if (this.get('content.status') === 'FAILED') {
  82. this.set('icon', 'icon-exclamation-sign');
  83. this.set('iconColor', 'text-error');
  84. } else if (this.get('content.status') === 'COMPLETED') {
  85. this.set('icon', 'icon-ok');
  86. this.set('iconColor', 'text-success');
  87. } else {
  88. this.set('icon', 'icon-cog');
  89. this.set('iconColor', '');
  90. this.set('linkClass', 'not-active-link');
  91. }
  92. }.observes('content.status', 'content.hosts.length'),
  93. showProgressBar: function () {
  94. return this.get('content.status') === "IN_PROGRESS";
  95. }.property('content.status')
  96. })
  97. });