host_stack_version.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. /**
  25. * possible property value defined at App.HostStackVersion.statusDefinition
  26. */
  27. status: DS.attr('string'),
  28. host: DS.belongsTo('App.Host'),
  29. hostName: DS.attr('string'),
  30. isCurrent: function () {
  31. return this.get('status') === 'CURRENT'
  32. }.property('status'),
  33. displayStatus: function() {
  34. return App.HostStackVersion.formatStatus(this.get('status'));
  35. }.property('status'),
  36. installEnabled: function () {
  37. return (this.get('status') === 'INIT' || this.get('status') === 'INSTALL_FAILED');
  38. }.property('status'),
  39. installDisabled: Ember.computed.not('installEnabled')
  40. });
  41. App.HostStackVersion.FIXTURES = [];
  42. /**
  43. * definition of possible statuses of Stack Version
  44. * @type {Array}
  45. */
  46. App.HostStackVersion.statusDefinition = [
  47. "INSTALLED",
  48. "INSTALLING",
  49. "INSTALL_FAILED",
  50. "INIT",
  51. "CURRENT"
  52. ];
  53. /**
  54. * translate status to label
  55. * @param status
  56. * @return {string}
  57. */
  58. App.HostStackVersion.formatStatus = function (status) {
  59. return status ?
  60. Em.I18n.t('hosts.host.stackVersions.status.' + status.toLowerCase()) :
  61. Em.I18n.t('common.unknown');
  62. };