repository_version.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.RepositoryVersion = DS.Model.extend({
  20. displayName: DS.attr('string'),
  21. type: DS.attr('string'), // "PATCH" /* STANDARD, (future: SERVICE) */
  22. repositoryVersion: DS.attr('string'),
  23. upgradePack: DS.attr('string'),
  24. stackVersionType: DS.attr('string'),
  25. stackVersionNumber: DS.attr('string'),
  26. operatingSystems: DS.hasMany('App.OS'),
  27. services: DS.hasMany('App.ServiceSimple'),
  28. stackVersion: DS.belongsTo('App.StackVersion'),
  29. stack: Em.computed.concat(' ', 'stackVersionType', 'stackVersionNumber'),
  30. displayNameSimple: function() {
  31. return this.get('stackVersionType') + '-' + this.get('repositoryVersion').split('-')[0];
  32. }.property('stackVersionType', 'repositoryVersion'),
  33. /**
  34. * status used until corresponding stack version get created
  35. * @type {string}
  36. */
  37. defaultStatus: 'INIT',
  38. /**
  39. * @type {string}
  40. */
  41. status: Em.computed.firstNotBlank('stackVersion.state', 'defaultStatus'),
  42. /**
  43. * @type {Array}
  44. */
  45. notInstalledHosts: function () {
  46. return Array.isArray(this.get('stackVersion.notInstalledHosts'))
  47. ? this.get('stackVersion.notInstalledHosts')
  48. : App.get('allHostNames');
  49. }.property('stackVersion.notInstalledHosts'),
  50. /**
  51. * @type {Array}
  52. */
  53. installedHosts: function () {
  54. return this.get('stackVersion.installedHosts') || [];
  55. }.property('stackVersion.installedHosts'),
  56. /**
  57. * @type {Array}
  58. */
  59. currentHosts: function () {
  60. return this.get('stackVersion.currentHosts') || [];
  61. }.property('stackVersion.currentHosts'),
  62. /**
  63. * @type {boolean}
  64. */
  65. noInstalledHosts: function () {
  66. return (this.get('stackVersion')) ? this.get('stackVersion.noInstalledHosts') : true;
  67. }.property('stackVersion.noInstalledHosts'),
  68. /**
  69. * @type {boolean}
  70. */
  71. noCurrentHosts: function () {
  72. return (this.get('stackVersion')) ? this.get('stackVersion.noCurrentHosts') : true;
  73. }.property('stackVersion.noCurrentHosts'),
  74. /**
  75. * @type {boolean}
  76. */
  77. noInitHosts: function () {
  78. return (this.get('stackVersion')) ? this.get('stackVersion.noInitHosts') : false;
  79. }.property('stackVersion.noInitHosts'),
  80. /**
  81. * @type {string}
  82. */
  83. noInitHostsTooltip: Em.computed.ifThenElse('noInitHosts', Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip'), Em.I18n.t('admin.stackVersions.version.hostsTooltip')),
  84. /**
  85. * @type {string}
  86. */
  87. noCurrentHostsTooltip: Em.computed.ifThenElse('noCurrentHosts', Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip'), Em.I18n.t('admin.stackVersions.version.hostsTooltip')),
  88. /**
  89. * @type {string}
  90. */
  91. noInstalledHostsTooltip: Em.computed.ifThenElse('noInstalledHosts', Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip'), Em.I18n.t('admin.stackVersions.version.hostsTooltip')),
  92. /**
  93. * @type {boolean}
  94. */
  95. isVisible: true
  96. });
  97. App.RepositoryVersion.FIXTURES = [];