step3_view.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.WizardStep3View = Em.View.extend({
  20. templateName: require('templates/wizard/step3'),
  21. category: '',
  22. didInsertElement: function () {
  23. this.get('controller').loadStep();
  24. },
  25. message:'',
  26. linkText: '',
  27. status: '',
  28. registeredHostsMessage: '',
  29. setRegisteredHosts: function(){
  30. this.set('registeredHostsMessage',Em.I18n.t('installer.step3.warning.registeredHosts').format(this.get('controller.registeredHosts').length));
  31. }.observes('controller.registeredHosts'),
  32. monitorStatuses: function() {
  33. var failedHosts = 0;
  34. var hosts = this.get('controller.bootHosts');
  35. hosts.forEach(function(host) {
  36. if (host.get('bootStatus') == 'FAILED') {
  37. failedHosts++;
  38. }
  39. });
  40. if (hosts.length==0) {
  41. this.set('status', 'alert-warn');
  42. this.set('linkText', '');
  43. this.set('message', Em.I18n.t('installer.step3.warnings.missingHosts'));
  44. } else if (this.get('controller.isHostHaveWarnings') || this.get('controller.repoCategoryWarnings.length') || this.get('controller.diskCategoryWarnings.length')) {
  45. this.set('status', 'alert-warn');
  46. this.set('linkText', Em.I18n.t('installer.step3.warnings.linkText'));
  47. this.set('message', Em.I18n.t('installer.step3.warnings.fails').format(hosts.length - failedHosts));
  48. } else {
  49. this.set('status', 'alert-success');
  50. this.set('linkText', Em.I18n.t('installer.step3.noWarnings.linkText'));
  51. if (failedHosts == 0) {
  52. // all are ok
  53. this.set('message', Em.I18n.t('installer.step3.warnings.noWarnings').format(hosts.length));
  54. } else if (failedHosts == hosts.length) {
  55. // all failed
  56. this.set('status', 'alert-warn');
  57. this.set('linkText', '');
  58. this.set('message', Em.I18n.t('installer.step3.warnings.allFailed').format(failedHosts));
  59. } else {
  60. // some failed
  61. this.set('message', Em.I18n.t('installer.step3.warnings.someWarnings').format((hosts.length-failedHosts), failedHosts));
  62. }
  63. }
  64. }.observes('controller.isHostHaveWarnings', 'controller.bootHosts.@each.bootStatus', 'controller.repoCategoryWarnings', 'controller.diskCategoryWarnings')
  65. });
  66. //todo: move it inside WizardStep3View
  67. App.WizardHostView = Em.View.extend({
  68. tagName: 'tr',
  69. classNameBindings: ['hostInfo.bootStatus', 'hostInfo.isVisible::hidden'],
  70. hostInfo: null,
  71. remove: function () {
  72. this.get('controller').removeHost(this.get('hostInfo'));
  73. },
  74. retry: function() {
  75. this.get('controller').retryHost(this.get('hostInfo'));
  76. },
  77. isRemovable: function () {
  78. return true;
  79. }.property(),
  80. isRetryable: function() {
  81. // return ['FAILED'].contains(this.get('hostInfo.bootStatus'));
  82. return false;
  83. }.property('hostInfo.bootStatus')
  84. });