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