github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/models/agent.js (about)

     1  import { inject as service } from '@ember/service';
     2  import { computed } from '@ember/object';
     3  import Model from '@ember-data/model';
     4  import { attr } from '@ember-data/model';
     5  import classic from 'ember-classic-decorator';
     6  import formatHost from 'nomad-ui/utils/format-host';
     7  
     8  @classic
     9  export default class Agent extends Model {
    10    @service system;
    11  
    12    @attr('string') name;
    13    @attr('string') address;
    14    @attr('string') serfPort;
    15    @attr('string') rpcPort;
    16    @attr({ defaultValue: () => ({}) }) tags;
    17    @attr('string') status;
    18    @attr('string') datacenter;
    19    @attr('string') region;
    20  
    21    @computed('address', 'port')
    22    get rpcAddr() {
    23      const { address, rpcPort } = this;
    24      return formatHost(address, rpcPort);
    25    }
    26  
    27    @computed('rpcAddr', 'system.leader.rpcAddr')
    28    get isLeader() {
    29      return this.get('system.leader.rpcAddr') === this.rpcAddr;
    30    }
    31  
    32    @computed('tags.build')
    33    get version() {
    34      return this.tags?.build || '';
    35    }
    36  }