open-consul/ui/packages/consul-ui/app/serializers/dc.js
John Cowen a1b3f00a69
ui: Show local datacenter by default on first visit (#9377)
* Add `Local` property to Datacenters

* If you have not previous datacenter, redirect the user to the local dc

* Add an `is-local` class to the local datacenter in the DC picker
2020-12-14 15:29:40 +00:00

28 lines
622 B
JavaScript

import { inject as service } from '@ember/service';
import Serializer from './application';
export default class DcSerializer extends Serializer {
@service('env') env;
primaryKey = 'Name';
respondForQuery(respond, query) {
return respond(function(headers, body) {
return body;
});
}
normalizePayload(payload, id, requestType) {
switch (requestType) {
case 'query':
return payload.map(item => {
return {
Local: this.env.var('CONSUL_DATACENTER_LOCAL') === item,
[this.primaryKey]: item,
};
});
}
return payload;
}
}