progress_view.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. notice: Em.I18n.t('admin.highAvailability.wizard.progressPage.notice.inProgress'),
  24. noticeClass: 'alert alert-info',
  25. onStatusChange: function () {
  26. var status = this.get('controller.status');
  27. if (status === 'COMPLETED') {
  28. this.set('notice', Em.I18n.t('admin.highAvailability.wizard.progressPage.notice.completed'));
  29. this.set('noticeClass', 'alert alert-success');
  30. } else if (status === 'FAILED') {
  31. this.set('notice', Em.I18n.t('admin.highAvailability.wizard.progressPage.notice.failed'));
  32. this.set('noticeClass', 'alert alert-error');
  33. } else {
  34. this.set('notice', Em.I18n.t('admin.highAvailability.wizard.progressPage.notice.inProgress'));
  35. this.set('noticeClass', 'alert alert-info');
  36. }
  37. }.observes('controller.status'),
  38. taskView: Em.View.extend({
  39. icon: '',
  40. iconColor: '',
  41. linkClass: '',
  42. didInsertElement: function () {
  43. this.onStatus();
  44. },
  45. barWidth: function () {
  46. return 'width: ' + this.get('content.progress') + '%;';
  47. }.property('content.progress'),
  48. onStatus: function () {
  49. this.set('linkClass', 'active-link');
  50. if (this.get('content.status') === 'IN_PROGRESS') {
  51. this.set('icon', 'icon-cog');
  52. this.set('iconColor', 'text-info');
  53. } else if (this.get('content.status') === 'FAILED') {
  54. this.set('icon', 'icon-exclamation-sign');
  55. this.set('iconColor', 'text-error');
  56. } else if (this.get('content.status') === 'COMPLETED') {
  57. this.set('icon', 'icon-ok');
  58. this.set('iconColor', 'text-success');
  59. } else {
  60. this.set('icon', 'icon-cog');
  61. this.set('iconColor', '');
  62. this.set('linkClass', 'not-active-link');
  63. }
  64. }.observes('content.status'),
  65. showProgressBar: function () {
  66. return this.get('content.status') === "IN_PROGRESS";
  67. }.property('content.status'),
  68. /**
  69. * open popup with list of hosts, that associated to service
  70. * @param event
  71. */
  72. hostsLogPopup: function(event){
  73. if(event.contexts[0].linkClass != "not-active-link"){
  74. var serviceName = event.contexts[0].title;
  75. var controller = this.get("controller");
  76. App.HostPopup.initPopup(serviceName, controller);
  77. }
  78. }
  79. })
  80. });