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

22 lines
549 B
JavaScript
Raw Normal View History

2020-07-25 04:36:43 +00:00
import ApplicationSerializer from './application';
import { arrToObj } from '../utils';
2020-07-25 04:36:43 +00:00
export default ApplicationSerializer.extend({
embed: true,
include: ['taskGroupScales'],
serialize() {
var json = ApplicationSerializer.prototype.serialize.apply(this, arguments);
if (json instanceof Array) {
json.forEach(serializeJobScale);
} else {
serializeJobScale(json);
}
return json;
},
2020-07-25 04:36:43 +00:00
});
function serializeJobScale(jobScale) {
jobScale.TaskGroups = jobScale.TaskGroupScales.reduce(arrToObj('Name'), {});
}