github.com/zoomfoo/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/ui/app/models/node.js (about) 1 import { computed } from '@ember/object'; 2 import { equal } from '@ember/object/computed'; 3 import Model from 'ember-data/model'; 4 import attr from 'ember-data/attr'; 5 import { hasMany } from 'ember-data/relationships'; 6 import { fragment, fragmentArray } from 'ember-data-model-fragments/attributes'; 7 import shortUUIDProperty from '../utils/properties/short-uuid'; 8 import ipParts from '../utils/ip-parts'; 9 10 export default Model.extend({ 11 // Available from list response 12 name: attr('string'), 13 datacenter: attr('string'), 14 isDraining: attr('boolean'), 15 schedulingEligibility: attr('string'), 16 status: attr('string'), 17 statusDescription: attr('string'), 18 shortId: shortUUIDProperty('id'), 19 modifyIndex: attr('number'), 20 21 // Available from single response 22 httpAddr: attr('string'), 23 tlsEnabled: attr('boolean'), 24 attributes: fragment('node-attributes'), 25 meta: fragment('node-attributes'), 26 resources: fragment('resources'), 27 reserved: fragment('resources'), 28 drainStrategy: fragment('drain-strategy'), 29 30 isEligible: equal('schedulingEligibility', 'eligible'), 31 32 address: computed('httpAddr', function() { 33 return ipParts(this.get('httpAddr')).address; 34 }), 35 36 port: computed('httpAddr', function() { 37 return ipParts(this.get('httpAddr')).port; 38 }), 39 40 isPartial: computed('httpAddr', function() { 41 return this.get('httpAddr') == null; 42 }), 43 44 allocations: hasMany('allocations', { inverse: 'node' }), 45 46 drivers: fragmentArray('node-driver'), 47 events: fragmentArray('node-event'), 48 49 detectedDrivers: computed('drivers.@each.detected', function() { 50 return this.get('drivers').filterBy('detected'); 51 }), 52 53 unhealthyDrivers: computed('detectedDrivers.@each.healthy', function() { 54 return this.get('detectedDrivers').filterBy('healthy', false); 55 }), 56 57 unhealthyDriverNames: computed('unhealthyDrivers.@each.name', function() { 58 return this.get('unhealthyDrivers').mapBy('name'); 59 }), 60 61 // A status attribute that includes states not included in node status. 62 // Useful for coloring and sorting nodes 63 compositeStatus: computed('status', 'isEligible', function() { 64 return this.get('isEligible') ? this.get('status') : 'ineligible'; 65 }), 66 });