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

31 lines
797 B
JavaScript
Raw Normal View History

import { inject as service } from '@ember/service';
import { computed } from '@ember/object';
2017-09-19 14:47:10 +00:00
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import classic from 'ember-classic-decorator';
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;
2017-09-19 14:47:10 +00:00
return address && rpcPort && `${address}:${rpcPort}`;
}
2017-09-19 14:47:10 +00:00
@computed('system.leader.rpcAddr')
get isLeader() {
2019-03-26 07:46:44 +00:00
return this.get('system.leader.rpcAddr') === this.rpcAddr;
}
}