open-vault/ui/app/serializers/cluster.js
Matthew Irish d509588cd2
Ember update (#5386)
Ember update - update ember-cli, ember-data, and ember to 3.4 series
2018-09-25 11:28:26 -05:00

34 lines
854 B
JavaScript

import { assign } from '@ember/polyfills';
import { decamelize } from '@ember/string';
import DS from 'ember-data';
export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
keyForAttribute: function(attr) {
return decamelize(attr);
},
attrs: {
nodes: { embedded: 'always' },
},
pushPayload(store, payload) {
const transformedPayload = this.normalizeResponse(
store,
store.modelFor('cluster'),
payload,
null,
'findAll'
);
return store.push(transformedPayload);
},
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
// FIXME when multiple clusters lands
const transformedPayload = {
clusters: assign({ id: '1' }, payload.data || payload),
};
return this._super(store, primaryModelClass, transformedPayload, id, requestType);
},
});