b6f6f4db37
* Bones of a new flyout section * Basic sidebar behaviour and style edits * Concept of a refID for service fragments to disambiguate task and group * A11y audit etc * Moves health check aggregation to serviceFragment model and retains history * Has to be a getter * flyout populated * Sidebar styling * Sidebar table and details added * Mirage fixture * Active status and table styles * Unit test mock updated * Acceptance tests for alloc services table and flyout * Chart styles closer to mock * Without a paused test * Consul and Nomad icons in services table * Alloc services test updates in light of new column changes * without using an inherited scenario
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
import { attr } from '@ember-data/model';
|
|
import Fragment from 'ember-data-model-fragments/fragment';
|
|
import { fragment } from 'ember-data-model-fragments/attributes';
|
|
import { computed } from '@ember/object';
|
|
import classic from 'ember-classic-decorator';
|
|
|
|
@classic
|
|
export default class Service extends Fragment {
|
|
@attr('string') name;
|
|
@attr('string') portLabel;
|
|
@attr() tags;
|
|
@attr('string') onUpdate;
|
|
@attr('string') provider;
|
|
@fragment('consul-connect') connect;
|
|
@attr() groupName;
|
|
@attr() taskName;
|
|
get refID() {
|
|
return `${this.groupName || this.taskName}-${this.name}`;
|
|
}
|
|
@attr({ defaultValue: () => [] }) healthChecks;
|
|
|
|
@computed('healthChecks.[]')
|
|
get mostRecentChecks() {
|
|
// Get unique check names, then get the most recent one
|
|
return this.get('healthChecks')
|
|
.mapBy('Check')
|
|
.uniq()
|
|
.map((name) => {
|
|
return this.get('healthChecks')
|
|
.sortBy('Timestamp')
|
|
.reverse()
|
|
.find((x) => x.Check === name);
|
|
})
|
|
.sortBy('Check');
|
|
}
|
|
|
|
@computed('mostRecentChecks.[]')
|
|
get mostRecentCheckStatus() {
|
|
// Get unique check names, then get the most recent one
|
|
return this.get('mostRecentChecks')
|
|
.mapBy('Status')
|
|
.reduce((acc, curr) => {
|
|
acc[curr] = (acc[curr] || 0) + 1;
|
|
return acc;
|
|
}, {});
|
|
}
|
|
}
|