github.com/blixtra/nomad@v0.7.2-0.20171221000451-da9a1d7bb050/ui/app/serializers/node.js (about)

     1  import Ember from 'ember';
     2  import ApplicationSerializer from './application';
     3  
     4  const { inject } = Ember;
     5  
     6  export default ApplicationSerializer.extend({
     7    config: inject.service(),
     8  
     9    attrs: {
    10      httpAddr: 'HTTPAddr',
    11    },
    12  
    13    normalize(modelClass, hash) {
    14      // Proxy local agent to the same proxy express server Ember is using
    15      // to avoid CORS
    16      if (this.get('config.isDev') && hash.HTTPAddr === '127.0.0.1:4646') {
    17        hash.HTTPAddr = '127.0.0.1:4200';
    18      }
    19  
    20      return this._super(modelClass, hash);
    21    },
    22  
    23    extractRelationships(modelClass, hash) {
    24      const { modelName } = modelClass;
    25      const nodeURL = this.store
    26        .adapterFor(modelName)
    27        .buildURL(modelName, this.extractId(modelClass, hash), hash, 'findRecord');
    28  
    29      return {
    30        allocations: {
    31          links: {
    32            related: `${nodeURL}/allocations`,
    33          },
    34        },
    35      };
    36    },
    37  });