step3_view.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.StackUpgradeStep3View = Em.View.extend({
  20. templateName: require('templates/wizard/stack_upgrade/step3'),
  21. didInsertElement: function(){
  22. this.get('controller').navigateStep();
  23. this.onStatus();
  24. },
  25. statusMessage: null,
  26. statusClass: 'alert-info',
  27. barColor: '',
  28. servicesStopWidth: function(){
  29. return 'width: ' + this.get('controller.servicesStopProgress') + '%;';
  30. }.property('controller.servicesStopProgress'),
  31. /**
  32. * change message of Upgrade status depending on the Upgrade status
  33. */
  34. onStatus: function(){
  35. switch (this.get('controller.status')){
  36. case 'SUCCESS':
  37. this.set('statusMessage', Em.I18n.t('installer.stackUpgrade.step3.status.success').format(this.get('controller.content.upgradeVersion')));
  38. this.set('statusClass', 'alert-success');
  39. break;
  40. case 'FAILED':
  41. this.set('statusMessage', Em.I18n.t('installer.stackUpgrade.step3.status.failed'));
  42. this.set('statusClass', 'alert-error');
  43. break;
  44. case 'WARNING':
  45. this.set('statusMessage', Em.I18n.t('installer.stackUpgrade.step3.status.warning').format(this.get('controller.content.upgradeVersion')));
  46. this.set('statusClass', 'alert-block');
  47. break;
  48. case 'IN_PROGRESS':
  49. default:
  50. this.set('statusMessage', Em.I18n.t('installer.stackUpgrade.step3.status.info'));
  51. this.set('statusClass', 'alert-info');
  52. }
  53. }.observes('controller.status'),
  54. serviceView: Em.View.extend({
  55. barColor: '',
  56. icon:'',
  57. iconColor:'',
  58. didInsertElement: function(){
  59. this.onStatus();
  60. },
  61. isServiceCompleted: function(){
  62. return this.get('content.status') === 'SUCCESS';
  63. }.property('content.status'),
  64. barWidth: function(){
  65. return 'width: ' + this.get('content.progress') + '%;';
  66. }.property('content.progress'),
  67. /**
  68. * change service appearance(icon, progress-bar color,) depending on the service status
  69. */
  70. onStatus:function () {
  71. if (this.get('content.status') === 'IN_PROGRESS') {
  72. this.set('barColor', 'progress-info');
  73. this.set('icon', 'icon-cog');
  74. this.set('iconColor', 'text-info');
  75. } else if (this.get('content.status') === 'WARNING') {
  76. this.set('barColor', 'progress-warning');
  77. this.set('icon', 'icon-warning-sign');
  78. this.set('iconColor', 'text-warning');
  79. } else if (this.get('content.status') === 'FAILED') {
  80. this.set('barColor', 'progress-danger');
  81. this.set('icon', 'icon-exclamation-sign');
  82. this.set('iconColor', 'text-error');
  83. } else if (this.get('content.status') === 'SUCCESS') {
  84. this.set('barColor', 'progress-success');
  85. this.set('icon', 'icon-ok');
  86. this.set('iconColor', 'text-success');
  87. } else {
  88. this.set('barColor', 'progress-info');
  89. this.set('icon', 'icon-cog');
  90. this.set('iconColor', '');
  91. }
  92. }.observes('content.status'),
  93. inProgress: function(){
  94. return this.get('content.status') === "IN_PROGRESS";
  95. }.property('content.status'),
  96. /**
  97. * open popup with list of hosts, that associated to service
  98. * @param event
  99. */
  100. hostsLogPopup: function(event){
  101. //TODO show popup with hosts
  102. var serviceName = event.contexts[0];
  103. }
  104. })
  105. });