Data modeling for node events and node drivers
This commit is contained in:
parent
4d9859103f
commit
d6ebf77b08
15
ui/app/models/node-driver.js
Normal file
15
ui/app/models/node-driver.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
import Fragment from 'ember-data-model-fragments/fragment';
|
||||
import attr from 'ember-data/attr';
|
||||
import { fragmentOwner } from 'ember-data-model-fragments/attributes';
|
||||
import { fragment } from 'ember-data-model-fragments/attributes';
|
||||
|
||||
export default Fragment.extend({
|
||||
node: fragmentOwner(),
|
||||
|
||||
attributes: fragment('node-attributes'),
|
||||
name: attr('string'),
|
||||
detected: attr('boolean', { defaultValue: false }),
|
||||
healthy: attr('boolean', { defaultValue: false }),
|
||||
healthDescription: attr('string'),
|
||||
updateTime: attr('date'),
|
||||
});
|
12
ui/app/models/node-event.js
Normal file
12
ui/app/models/node-event.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import Fragment from 'ember-data-model-fragments/fragment';
|
||||
import attr from 'ember-data/attr';
|
||||
import { fragmentOwner } from 'ember-data-model-fragments/attributes';
|
||||
|
||||
export default Fragment.extend({
|
||||
node: fragmentOwner(),
|
||||
|
||||
message: attr('string'),
|
||||
subsystem: attr('string'),
|
||||
details: attr(),
|
||||
time: attr('date'),
|
||||
});
|
|
@ -2,7 +2,7 @@ import { computed } from '@ember/object';
|
|||
import Model from 'ember-data/model';
|
||||
import attr from 'ember-data/attr';
|
||||
import { hasMany } from 'ember-data/relationships';
|
||||
import { fragment } from 'ember-data-model-fragments/attributes';
|
||||
import { fragment, fragmentArray } from 'ember-data-model-fragments/attributes';
|
||||
import shortUUIDProperty from '../utils/properties/short-uuid';
|
||||
import ipParts from '../utils/ip-parts';
|
||||
|
||||
|
@ -37,4 +37,7 @@ export default Model.extend({
|
|||
}),
|
||||
|
||||
allocations: hasMany('allocations', { inverse: 'node' }),
|
||||
|
||||
drivers: fragmentArray('node-driver'),
|
||||
events: fragmentArray('node-event'),
|
||||
});
|
||||
|
|
7
ui/app/serializers/node-event.js
Normal file
7
ui/app/serializers/node-event.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
import ApplicationSerializer from './application';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
attrs: {
|
||||
time: 'Timestamp',
|
||||
},
|
||||
});
|
|
@ -1,3 +1,5 @@
|
|||
import { get } from '@ember/object';
|
||||
import { assign } from '@ember/polyfills';
|
||||
import { inject as service } from '@ember/service';
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
|
@ -9,6 +11,11 @@ export default ApplicationSerializer.extend({
|
|||
},
|
||||
|
||||
normalize(modelClass, hash) {
|
||||
// Transform the map-based Drivers object into an array-based NodeDriver fragment list
|
||||
hash.Drivers = Object.keys(get(hash, 'Drivers') || {}).map(key => {
|
||||
return assign({}, get(hash, `Drivers.${key}`), { Name: key });
|
||||
});
|
||||
|
||||
return this._super(modelClass, hash);
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue