f9710c2c92
* ui: Reconciliate ember-data store when records are deleted via blocking Currently we are barely using the ember-data store/cache, but it will still cache records in the store even though technically we aren't using it. This adds a SyncTime to every record that uses blocking queries so we can delete older records from the ember-data cache to prevent them building up * ui: Add basic timestamp method we can access from tests, fixup tests Adds a timestamp method that we can access from within tests so we can test that the SyncTime is being set. There is probably a better way to do this, but this is also probably the simplest approach - we are also likely to revisit this at a later date
36 lines
998 B
JavaScript
36 lines
998 B
JavaScript
import Model from 'ember-data/model';
|
|
import attr from 'ember-data/attr';
|
|
import { computed, get } from '@ember/object';
|
|
import sumOfUnhealthy from 'consul-ui/utils/sumOfUnhealthy';
|
|
import hasStatus from 'consul-ui/utils/hasStatus';
|
|
|
|
export const PRIMARY_KEY = 'uid';
|
|
export const SLUG_KEY = 'ID';
|
|
|
|
export default Model.extend({
|
|
[PRIMARY_KEY]: attr('string'),
|
|
[SLUG_KEY]: attr('string'),
|
|
Address: attr('string'),
|
|
Node: attr('string'),
|
|
Meta: attr(),
|
|
Services: attr(),
|
|
Checks: attr(),
|
|
CreateIndex: attr('number'),
|
|
ModifyIndex: attr('number'),
|
|
TaggedAddresses: attr(),
|
|
Datacenter: attr('string'),
|
|
Segment: attr(),
|
|
Coord: attr(),
|
|
SyncTime: attr('number'),
|
|
meta: attr(),
|
|
hasStatus: function(status) {
|
|
return hasStatus(get(this, 'Checks'), status);
|
|
},
|
|
isHealthy: computed('Checks', function() {
|
|
return sumOfUnhealthy(get(this, 'Checks')) === 0;
|
|
}),
|
|
isUnhealthy: computed('Checks', function() {
|
|
return sumOfUnhealthy(get(this, 'Checks')) > 0;
|
|
}),
|
|
});
|