github.com/emate/nomad@v0.8.2-wo-binpacking/ui/app/serializers/deployment.js (about) 1 import { get } from '@ember/object'; 2 import { assign } from '@ember/polyfills'; 3 import ApplicationSerializer from './application'; 4 5 export default ApplicationSerializer.extend({ 6 attrs: { 7 versionNumber: 'JobVersion', 8 }, 9 10 normalize(typeHash, hash) { 11 hash.TaskGroupSummaries = Object.keys(get(hash, 'TaskGroups') || {}).map(key => { 12 const deploymentStats = get(hash, `TaskGroups.${key}`); 13 return assign({ Name: key }, deploymentStats); 14 }); 15 16 hash.PlainJobId = hash.JobID; 17 hash.Namespace = 18 hash.Namespace || 19 get(hash, 'Job.Namespace') || 20 this.get('system.activeNamespace.id') || 21 'default'; 22 hash.JobID = JSON.stringify([hash.JobID, hash.Namespace]); 23 24 return this._super(typeHash, hash); 25 }, 26 27 extractRelationships(modelClass, hash) { 28 const namespace = this.store.adapterFor(modelClass.modelName).get('namespace'); 29 const id = this.extractId(modelClass, hash); 30 31 return assign( 32 { 33 allocations: { 34 links: { 35 related: `/${namespace}/deployment/allocations/${id}`, 36 }, 37 }, 38 }, 39 this._super(modelClass, hash) 40 ); 41 }, 42 });