github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/models/volume.js (about) 1 import { computed } from '@ember/object'; 2 import Model from '@ember-data/model'; 3 import { attr, belongsTo, hasMany } from '@ember-data/model'; 4 5 export default class Volume extends Model { 6 @attr('string') plainId; 7 @attr('string') name; 8 9 @belongsTo('namespace') namespace; 10 @belongsTo('plugin') plugin; 11 12 @hasMany('allocation') writeAllocations; 13 @hasMany('allocation') readAllocations; 14 15 @computed('writeAllocations.[]', 'readAllocations.[]') 16 get allocations() { 17 return [ 18 ...this.writeAllocations.toArray(), 19 ...this.readAllocations.toArray(), 20 ]; 21 } 22 23 @attr('number') currentWriters; 24 @attr('number') currentReaders; 25 26 @computed('currentWriters', 'currentReaders') 27 get allocationCount() { 28 return this.currentWriters + this.currentReaders; 29 } 30 31 @attr('string') externalId; 32 @attr() topologies; 33 @attr('string') accessMode; 34 @attr('string') attachmentMode; 35 @attr('boolean') schedulable; 36 @attr('string') provider; 37 @attr('string') version; 38 39 @attr('boolean') controllerRequired; 40 @attr('number') controllersHealthy; 41 @attr('number') controllersExpected; 42 43 @computed('plainId') 44 get idWithNamespace() { 45 return `${this.plainId}@${this.belongsTo('namespace').id()}`; 46 } 47 48 @computed('controllersHealthy', 'controllersExpected') 49 get controllersHealthyProportion() { 50 return this.controllersHealthy / this.controllersExpected; 51 } 52 53 @attr('number') nodesHealthy; 54 @attr('number') nodesExpected; 55 56 @computed('nodesHealthy', 'nodesExpected') 57 get nodesHealthyProportion() { 58 return this.nodesHealthy / this.nodesExpected; 59 } 60 61 @attr('number') resourceExhausted; 62 @attr('number') createIndex; 63 @attr('number') modifyIndex; 64 }