upgrade_task_view.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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.upgradeTaskView = Em.View.extend({
  20. templateName: require('templates/main/admin/stack_upgrade/upgrade_task'),
  21. /**
  22. * relation map between status and icon class
  23. * @type {Object}
  24. */
  25. statusIconMap: {
  26. 'COMPLETED': 'icon-ok',
  27. 'WARNING': 'icon-warning-sign',
  28. 'FAILED': 'icon-warning-sign',
  29. 'PENDING': 'icon-cog',
  30. 'IN_PROGRESS': 'icon-cogs'
  31. },
  32. /**
  33. * @type {Boolean}
  34. */
  35. isManualDone: false,
  36. /**
  37. * @type {Boolean}
  38. */
  39. isManualProceedDisabled: function () {
  40. return !this.get('isManualDone');
  41. }.property('isManualDone'),
  42. /**
  43. * @type {string}
  44. */
  45. iconClass: function () {
  46. return this.get('statusIconMap')[this.get('content.UpgradeGroup.status')] || 'icon-question-sign';
  47. }.property('content.UpgradeGroup.status'),
  48. /**
  49. * @type {Boolean}
  50. */
  51. isFailed: function () {
  52. return this.get('content.UpgradeGroup.status') === 'FAILED';
  53. }.property('content.UpgradeGroup.status'),
  54. /**
  55. * @type {Boolean}
  56. */
  57. showProgressBar: function () {
  58. return ['IN_PROGRESS', 'FAILED'].contains(this.get('content.UpgradeGroup.status')) && this.get('content.UpgradeGroup.type') !== 'manual';
  59. }.property('content.UpgradeGroup.status'),
  60. /**
  61. * @type {Boolean}
  62. */
  63. isInProgress: function () {
  64. return this.get('content.UpgradeGroup.status') === 'IN_PROGRESS' && this.get('content.UpgradeGroup.type') !== 'manual';
  65. }.property('content.UpgradeGroup.status'),
  66. /**
  67. * width style of progress bar
  68. * @type {String}
  69. */
  70. progressWidth: function () {
  71. return "width:" + Math.floor(this.get('progress')) + '%;';
  72. }.property('content.UpgradeGroup.progress_percent'),
  73. /**
  74. * @type {number}
  75. */
  76. progress: function () {
  77. return Math.floor(this.get('content.UpgradeGroup.progress_percent'))
  78. }.property('content.UpgradeGroup.progress_percent'),
  79. /**
  80. * if upgrade group is in progress it should have currently running item
  81. * @type {Object|null}
  82. */
  83. runningItem: function () {
  84. return this.get('content.upgrade_items').findProperty('UpgradeItem.status', 'IN_PROGRESS');
  85. }.property('content.upgrade_items.@each.UpgradeItem.status'),
  86. /**
  87. * if upgrade group is failed it should have failed item
  88. * @type {Object|null}
  89. */
  90. failedItem: function () {
  91. return this.get('content.upgrade_items').findProperty('UpgradeItem.status', 'FAILED');
  92. }.property('content.upgrade_items.@each.UpgradeItem.status'),
  93. /**
  94. * @type {Boolean}
  95. */
  96. isManualOpened: function () {
  97. //TODO modify logic according to actual API
  98. return this.get('content.UpgradeGroup.status') === 'IN_PROGRESS' && this.get('content.UpgradeGroup.type') === 'manual'
  99. }.property('content.UpgradeGroup.status', 'content.UpgradeGroup.type')
  100. });