host_stack_version.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.HostStackVersion = DS.Model.extend({
  20. stack: DS.attr('string'),
  21. version: DS.attr('string'),
  22. repo: DS.belongsTo('App.Repository'),
  23. repoVersion: DS.attr('string'),
  24. displayName: DS.attr('string'),
  25. isVisible: DS.attr('boolean', {defaultValue: true}),
  26. /**
  27. * possible property value defined at App.HostStackVersion.statusDefinition
  28. * @type {string}
  29. */
  30. status: DS.attr('string'),
  31. host: DS.belongsTo('App.Host'),
  32. hostName: DS.attr('string'),
  33. /**
  34. * @type {boolean}
  35. */
  36. isCurrent: Em.computed.equal('status', 'CURRENT'),
  37. /**
  38. * @type {boolean}
  39. */
  40. isInstalling: Em.computed.equal('status', 'INSTALLING'),
  41. /**
  42. * @type {boolean}
  43. */
  44. isOutOfSync: Em.computed.equal('status', 'OUT_OF_SYNC'),
  45. /**
  46. * @type {string}
  47. */
  48. displayStatus: function() {
  49. return App.HostStackVersion.formatStatus(this.get('status'));
  50. }.property('status'),
  51. /**
  52. * @type {boolean}
  53. */
  54. installEnabled: Em.computed.existsIn('status', ['OUT_OF_SYNC', 'INSTALL_FAILED']),
  55. installDisabled: Em.computed.not('installEnabled')
  56. });
  57. App.HostStackVersion.FIXTURES = [];
  58. /**
  59. * definition of possible statuses of Stack Version
  60. * @type {Array}
  61. */
  62. App.HostStackVersion.statusDefinition = [
  63. "INSTALLED",
  64. "INSTALLING",
  65. "INSTALL_FAILED",
  66. "OUT_OF_SYNC",
  67. "CURRENT",
  68. "UPGRADING",
  69. "UPGRADE_FAILED"
  70. ];
  71. /**
  72. * translate status to label
  73. * @param status
  74. * @return {string}
  75. */
  76. App.HostStackVersion.formatStatus = function (status) {
  77. return App.HostStackVersion.statusDefinition.contains(status) ?
  78. Em.I18n.t('hosts.host.stackVersions.status.' + status.toLowerCase()) :
  79. status.toCapital();
  80. };