John Cowen c8e40ee0de
ui: Move ember-data classes to use native JS classes/decorators (#9136)
* ui: Upgrade ember-data models to use native classes/decorators

* ui: Update remaining ember-data imports

* ui: Move ember-data Adapters to use native classes

* ui: Upgrade serializers to native classes/decorators

* ui: remove meta from roles, they never had it to start with
2020-11-09 17:29:12 +00:00

52 lines
1.3 KiB
JavaScript

import Model, { attr } from '@ember-data/model';
import { computed } from '@ember/object';
export const PRIMARY_KEY = 'uid';
export const SLUG_KEY = 'ID';
export default class Node extends Model {
@attr('string') uid;
@attr('string') ID;
@attr('string') Datacenter;
@attr('string') Address;
@attr('string') Node;
@attr('number') SyncTime;
@attr('number') CreateIndex;
@attr('number') ModifyIndex;
@attr() meta; // {}
@attr() Meta; // {}
@attr() TaggedAddresses; // {lan, wan}
@attr() Services; // ServiceInstances[]
@attr() Checks; // Checks[]
@computed('Checks.[]', 'ChecksCritical', 'ChecksPassing', 'ChecksWarning')
get Status() {
switch (true) {
case this.ChecksCritical !== 0:
return 'critical';
case this.ChecksWarning !== 0:
return 'warning';
case this.ChecksPassing !== 0:
return 'passing';
default:
return 'empty';
}
}
@computed('Checks.[]')
get ChecksCritical() {
return this.Checks.filter(item => item.Status === 'critical').length;
}
@computed('Checks.[]')
get ChecksPassing() {
return this.Checks.filter(item => item.Status === 'passing').length;
}
@computed('Checks.[]')
get ChecksWarning() {
return this.Checks.filter(item => item.Status === 'warning').length;
}
}