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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
627 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
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'), {});
}