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: Em.computed.ifThenElse('controller.isSingleRequestPage', Em.I18n.t('wizard.singleRequest.progressPage.notice.failed'), 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. /**
  53. * Class to define task label width
  54. * @type {String}
  55. */
  56. labelWidth: 'span4',
  57. onStatusChange: function () {
  58. var status = this.get('controller.status');
  59. if (status === 'COMPLETED') {
  60. this.set('notice', this.get('noticeCompleted'));
  61. this.set('noticeClass', 'alert alert-success');
  62. } else if (status === 'FAILED') {
  63. this.set('notice', this.get('noticeFailed'));
  64. this.set('noticeClass', 'alert alert-error');
  65. } else {
  66. this.set('notice', this.get('noticeInProgress'));
  67. this.set('noticeClass', 'alert alert-info');
  68. }
  69. }.observes('controller.status'),
  70. taskView: Em.View.extend({
  71. icon: '',
  72. iconColor: '',
  73. linkClass: '',
  74. didInsertElement: function () {
  75. this.onStatus();
  76. },
  77. barWidth: Em.computed.format('width: {0}%;', 'content.progress'),
  78. onStatus: function () {
  79. var linkClass = !!this.get('content.requestIds.length') ? 'active-link' : 'active-text';
  80. this.set('linkClass', linkClass);
  81. if (this.get('content.status') === 'IN_PROGRESS') {
  82. this.set('icon', 'icon-cog');
  83. this.set('iconColor', 'text-info');
  84. } else if (this.get('content.status') === 'FAILED') {
  85. this.set('icon', 'icon-exclamation-sign');
  86. this.set('iconColor', 'text-error');
  87. } else if (this.get('content.status') === 'COMPLETED') {
  88. this.set('icon', 'icon-ok');
  89. this.set('iconColor', 'text-success');
  90. } else {
  91. this.set('icon', 'icon-cog');
  92. this.set('iconColor', '');
  93. this.set('linkClass', 'not-active-link');
  94. }
  95. }.observes('content.status', 'content.hosts.length','content.requestIds'),
  96. showProgressBar: Em.computed.equal('content.status', 'IN_PROGRESS')
  97. })
  98. });