open-nomad/ui/mirage/serializers/deployment.js
Alex Dadgar e5ec915ac3 sync
2017-09-19 10:08:23 -05:00

22 lines
587 B
JavaScript

import ApplicationSerializer from './application';
import { arrToObj } from '../utils';
export default ApplicationSerializer.extend({
embed: true,
include: ['deploymentTaskGroupSummaries'],
serialize() {
var json = ApplicationSerializer.prototype.serialize.apply(this, arguments);
if (json instanceof Array) {
json.forEach(serializeDeployment);
} else {
serializeDeployment(json);
}
return json;
},
});
function serializeDeployment(deployment) {
deployment.TaskGroups = deployment.DeploymentTaskGroupSummaries.reduce(arrToObj('Name'), {});
}