4b885c080c
* add ember-cli-content-security-policy * only enable client side CSP when not in production - the go side handles this otherwise * add service that handles and stores CSP violations via the securitypolicyviolation event * update auth form component to show a specialized message when there's a CSP error * move to computed prop for showing the CSP error message * fix typos
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
import Ember from 'ember';
|
|
import DS from 'ember-data';
|
|
|
|
const { decamelize } = Ember.String;
|
|
|
|
export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
|
|
keyForAttribute: function(attr) {
|
|
return decamelize(attr);
|
|
},
|
|
|
|
pushPayload(store, payload) {
|
|
const transformedPayload = this.normalizeResponse(
|
|
store,
|
|
store.modelFor('node'),
|
|
payload,
|
|
null,
|
|
'findAll'
|
|
);
|
|
return store.push(transformedPayload);
|
|
},
|
|
|
|
nodeFromObject(name, payload) {
|
|
const nodeObj = payload.nodes[name];
|
|
return Ember.assign(nodeObj, {
|
|
name,
|
|
id: name,
|
|
});
|
|
},
|
|
|
|
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
|
|
const nodes = payload.nodes
|
|
? Object.keys(payload.nodes).map(name => this.nodeFromObject(name, payload))
|
|
: [Ember.assign(payload, { id: '1' })];
|
|
|
|
const transformedPayload = { nodes: nodes };
|
|
|
|
return this._super(store, primaryModelClass, transformedPayload, id, requestType);
|
|
},
|
|
|
|
normalize(model, hash, prop) {
|
|
hash.id = '1';
|
|
return this._super(model, hash, prop);
|
|
},
|
|
});
|