"agent/git@git.gitsec.cn:baidan/Mizu.git" did not exist on "bb3ae1ef70818abe5a980fe3e58c6d078d3c5f12"
Commit bc6467c6 authored by Michael Lange's avatar Michael Lange
Browse files

Data modeling for node events and node drivers

parent a7eca168
Showing with 45 additions and 1 deletion
+45 -1
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'),
});
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'),
});
import ApplicationSerializer from './application';
export default ApplicationSerializer.extend({
attrs: {
time: 'Timestamp',
},
});
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);
},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment