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