open-nomad/ui/mirage/serializers/job.js

25 lines
540 B
JavaScript
Raw Normal View History

2017-09-19 14:47:10 +00:00
import ApplicationSerializer from './application';
export default ApplicationSerializer.extend({
embed: true,
include: ['task_groups', 'job_summary'],
serialize() {
var json = ApplicationSerializer.prototype.serialize.apply(this, arguments);
if (json instanceof Array) {
json.forEach(serializeJob);
} else {
serializeJob(json);
}
return json;
},
2017-09-19 14:47:10 +00:00
});
function serializeJob(job) {
job.TaskGroups.forEach(group => {
if (group.Services.length === 0) {
group.Services = null;
}
});
}