repository_version.js 3.2 KB

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