2017-09-19 14:47:10 +00:00
|
|
|
import Ember from 'ember';
|
|
|
|
import ApplicationSerializer from './application';
|
|
|
|
|
|
|
|
const { get } = Ember;
|
|
|
|
|
|
|
|
export default ApplicationSerializer.extend({
|
|
|
|
attrs: {
|
|
|
|
taskGroupName: 'TaskGroup',
|
|
|
|
states: 'TaskStates',
|
|
|
|
},
|
|
|
|
|
|
|
|
normalize(typeHash, hash) {
|
|
|
|
// Transform the map-based TaskStates object into an array-based
|
|
|
|
// TaskState fragment list
|
|
|
|
hash.TaskStates = Object.keys(get(hash, 'TaskStates') || {}).map(key => {
|
|
|
|
const state = get(hash, `TaskStates.${key}`);
|
|
|
|
const summary = { Name: key };
|
|
|
|
Object.keys(state).forEach(stateKey => (summary[stateKey] = state[stateKey]));
|
|
|
|
summary.Resources = hash.TaskResources && hash.TaskResources[key];
|
|
|
|
return summary;
|
|
|
|
});
|
|
|
|
|
2017-10-05 22:21:10 +00:00
|
|
|
// TEMPORARY: https://github.com/emberjs/data/issues/5209
|
|
|
|
hash.OriginalJobId = hash.JobID;
|
|
|
|
|
2017-09-19 14:47:10 +00:00
|
|
|
return this._super(typeHash, hash);
|
|
|
|
},
|
|
|
|
});
|