progress_view.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. App.HighAvailabilityProgressPageView = Em.View.extend({
  20. didInsertElement: function () {
  21. this.get('controller').loadStep();
  22. },
  23. headerTitle: function () {
  24. var currentStep = App.router.get('highAvailabilityWizardController.currentStep');
  25. if(currentStep == 1) {
  26. return Em.I18n.t('admin.highAvailability.wizard.rollback.header.title');
  27. }else {
  28. return Em.I18n.t('admin.highAvailability.wizard.step' + currentStep + '.header.title');
  29. }
  30. }.property(),
  31. submitButtonText: Em.I18n.t('common.next'),
  32. noticeCompleted: Em.I18n.t('admin.highAvailability.wizard.progressPage.notice.completed'),
  33. noticeFailed: Em.I18n.t('admin.highAvailability.wizard.progressPage.notice.failed'),
  34. noticeInProgress: function () {
  35. var currentStep = App.router.get('highAvailabilityWizardController.currentStep');
  36. if(currentStep == 1) {
  37. return Em.I18n.t('admin.highAvailability.rollback.notice.inProgress');
  38. }else {
  39. return Em.I18n.t('admin.highAvailability.wizard.step' + currentStep + '.notice.inProgress');
  40. }
  41. }.property(),
  42. notice: Em.I18n.t('admin.highAvailability.wizard.progressPage.notice.inProgress'),
  43. noticeClass: 'alert alert-info',
  44. onStatusChange: function () {
  45. var status = this.get('controller.status');
  46. if (status === 'COMPLETED') {
  47. this.set('notice', this.get('noticeCompleted'));
  48. this.set('noticeClass', 'alert alert-success');
  49. } else if (status === 'FAILED') {
  50. this.set('notice', this.get('noticeFailed'));
  51. this.set('noticeClass', 'alert alert-error');
  52. } else {
  53. this.set('notice', this.get('noticeInProgress'));
  54. this.set('noticeClass', 'alert alert-info');
  55. }
  56. }.observes('controller.status'),
  57. taskView: Em.View.extend({
  58. icon: '',
  59. iconColor: '',
  60. linkClass: '',
  61. didInsertElement: function () {
  62. this.onStatus();
  63. },
  64. barWidth: function () {
  65. return 'width: ' + this.get('content.progress') + '%;';
  66. }.property('content.progress'),
  67. onStatus: function () {
  68. this.set('linkClass', 'active-link');
  69. if (this.get('content.status') === 'IN_PROGRESS') {
  70. this.set('icon', 'icon-cog');
  71. this.set('iconColor', 'text-info');
  72. } else if (this.get('content.status') === 'FAILED') {
  73. this.set('icon', 'icon-exclamation-sign');
  74. this.set('iconColor', 'text-error');
  75. } else if (this.get('content.status') === 'COMPLETED') {
  76. this.set('icon', 'icon-ok');
  77. this.set('iconColor', 'text-success');
  78. } else {
  79. this.set('icon', 'icon-cog');
  80. this.set('iconColor', '');
  81. this.set('linkClass', 'not-active-link');
  82. }
  83. }.observes('content.status'),
  84. showProgressBar: function () {
  85. return this.get('content.status') === "IN_PROGRESS";
  86. }.property('content.status'),
  87. /**
  88. * open popup with list of hosts, that associated to service
  89. * @param event
  90. */
  91. hostsLogPopup: function(event){
  92. if(event.contexts[0].linkClass != "not-active-link"){
  93. var serviceName = event.contexts[0].title;
  94. var controller = this.get("controller");
  95. App.HostPopup.initPopup(serviceName, controller);
  96. }
  97. }
  98. })
  99. });