open-nomad/ui/app/serializers/node.js

38 lines
875 B
JavaScript
Raw Normal View History

import Ember from 'ember';
2017-09-19 14:47:10 +00:00
import ApplicationSerializer from './application';
const { inject } = Ember;
2017-09-19 14:47:10 +00:00
export default ApplicationSerializer.extend({
config: inject.service(),
2017-09-19 14:47:10 +00:00
attrs: {
httpAddr: 'HTTPAddr',
},
normalize(modelClass, hash) {
// Proxy local agent to the same proxy express server Ember is using
// to avoid CORS
if (this.get('config.isDev') && hash.HTTPAddr === '127.0.0.1:4646') {
hash.HTTPAddr = '127.0.0.1:4200';
}
return this._super(modelClass, hash);
},
2017-09-19 14:47:10 +00:00
extractRelationships(modelClass, hash) {
const { modelName } = modelClass;
const nodeURL = this.store
.adapterFor(modelName)
.buildURL(modelName, this.extractId(modelClass, hash), hash, 'findRecord');
return {
allocations: {
links: {
related: `${nodeURL}/allocations`,
},
},
};
},
});