mirror of
https://github.com/status-im/consul.git
synced 2025-01-09 21:35:52 +00:00
6589cbbd0d
* ui: Add the most basic workspace root in /ui * We already have a LICENSE file in the repository root * Change directory path in build scripts ui-v2 -> ui * Make yarn install flags configurable from elsewhere * Minimal workspace root makefile * Call the new docker specific target * Update yarn in the docker build image * Reconfigure the netlify target and move to the higher makefile * Move ui-v2 -> ui/packages/consul-ui * Change repo root to refleect new folder structure * Temporarily don't hoist consul-api-double * Fixup CI configuration * Fixup lint errors * Fixup Netlify target
50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
import Serializer from './application';
|
|
import { PRIMARY_KEY, SLUG_KEY } from 'consul-ui/models/node';
|
|
|
|
// TODO: Looks like ID just isn't used at all
|
|
// consider just using .Node for the SLUG_KEY
|
|
const fillSlug = function(item) {
|
|
if (item[SLUG_KEY] === '') {
|
|
item[SLUG_KEY] = item['Node'];
|
|
}
|
|
return item;
|
|
};
|
|
|
|
export default Serializer.extend({
|
|
primaryKey: PRIMARY_KEY,
|
|
slugKey: SLUG_KEY,
|
|
respondForQuery: function(respond, query) {
|
|
return this._super(cb => respond((headers, body) => cb(headers, body.map(fillSlug))), query);
|
|
},
|
|
respondForQueryRecord: function(respond, query) {
|
|
return this._super(
|
|
cb =>
|
|
respond((headers, body) => {
|
|
return cb(headers, fillSlug(body));
|
|
}),
|
|
query
|
|
);
|
|
},
|
|
respondForQueryLeader: function(respond, query) {
|
|
// don't call super here we don't care about
|
|
// ids/fingerprinting
|
|
return respond((headers, body) => {
|
|
// This response/body is just an ip:port like `"10.0.0.1:8500"`
|
|
// split it and make it look like a `C`onsul.`R`esponse
|
|
// popping off the end for ports should cover us for IPv6 addresses
|
|
// as we should always get a `address:port` or `[a:dd:re:ss]:port` combo
|
|
const temp = body.split(':');
|
|
const port = temp.pop();
|
|
const address = temp.join(':');
|
|
return this.attachHeaders(
|
|
headers,
|
|
{
|
|
Address: address,
|
|
Port: port,
|
|
},
|
|
query
|
|
);
|
|
});
|
|
},
|
|
});
|