wizardProgressPageView.js 3.8 KB

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