host_component.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.HostComponent = DS.Model.extend({
  20. workStatus: DS.attr('string'),
  21. componentName: DS.attr('string'),
  22. host: DS.belongsTo('App.Host'),
  23. service: DS.belongsTo('App.Service'),
  24. isClient:function () {
  25. return Boolean(this.get('componentName').match(/_client/gi));
  26. }.property('componentName'),
  27. isRunning: function(){
  28. return (this.get('workStatus') == 'STARTED' || this.get('workStatus') == 'STARTING');
  29. }.property('workStatus'),
  30. displayName: function () {
  31. return App.format.role(this.get('componentName'));
  32. }.property('componentName')
  33. })
  34. App.HostComponent.Status = {
  35. started: "STARTED",
  36. starting: "STARTING",
  37. stopped: "INSTALLED",
  38. stopping: "STOPPING",
  39. getKeyName:function(value){
  40. switch(value){
  41. case this.started:
  42. return 'started';
  43. case this.starting:
  44. return 'starting';
  45. case this.stopped:
  46. return 'installed';
  47. case this.stopping:
  48. return 'stopping';
  49. }
  50. return 'none';
  51. }
  52. }
  53. App.HostComponent.FIXTURES = [];