github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/ui/app/serializers/node.js (about) 1 import { assign } from '@ember/polyfills'; 2 import { inject as service } from '@ember/service'; 3 import ApplicationSerializer from './application'; 4 5 export default ApplicationSerializer.extend({ 6 config: service(), 7 8 attrs: { 9 isDraining: 'Drain', 10 httpAddr: 'HTTPAddr', 11 }, 12 13 normalize(modelClass, hash) { 14 // Transform map-based objects into array-based fragment lists 15 const drivers = hash.Drivers || {}; 16 hash.Drivers = Object.keys(drivers).map(key => { 17 return assign({}, drivers[key], { Name: key }); 18 }); 19 20 const hostVolumes = hash.HostVolumes || {}; 21 hash.HostVolumes = Object.keys(hostVolumes).map(key => hostVolumes[key]); 22 23 return this._super(modelClass, hash); 24 }, 25 26 extractRelationships(modelClass, hash) { 27 const { modelName } = modelClass; 28 const nodeURL = this.store 29 .adapterFor(modelName) 30 .buildURL(modelName, this.extractId(modelClass, hash), hash, 'findRecord'); 31 32 return { 33 allocations: { 34 links: { 35 related: `${nodeURL}/allocations`, 36 }, 37 }, 38 }; 39 }, 40 });