open-nomad/ui/app/models/agent.js

37 lines
935 B
JavaScript
Raw Normal View History

import { inject as service } from '@ember/service';
import { computed } from '@ember/object';
import Model from '@ember-data/model';
import { attr } from '@ember-data/model';
import classic from 'ember-classic-decorator';
import formatHost from 'nomad-ui/utils/format-host';
2017-09-19 14:47:10 +00:00
@classic
export default class Agent extends Model {
@service system;
2017-09-19 14:47:10 +00:00
@attr('string') name;
@attr('string') address;
@attr('string') serfPort;
@attr('string') rpcPort;
@attr({ defaultValue: () => ({}) }) tags;
@attr('string') status;
@attr('string') datacenter;
@attr('string') region;
2017-09-19 14:47:10 +00:00
@computed('address', 'port')
get rpcAddr() {
2019-03-26 07:46:44 +00:00
const { address, rpcPort } = this;
return formatHost(address, rpcPort);
}
2017-09-19 14:47:10 +00:00
@computed('rpcAddr', 'system.leader.rpcAddr')
get isLeader() {
2019-03-26 07:46:44 +00:00
return this.get('system.leader.rpcAddr') === this.rpcAddr;
}
@computed('tags.build')
get version() {
return this.tags?.build || '';
}
}