mirror of
https://github.com/status-im/consul.git
synced 2025-01-27 14:05:45 +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
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
import { get } from '@ember/object';
|
|
import RepositoryService from 'consul-ui/services/repository';
|
|
|
|
import tomographyFactory from 'consul-ui/utils/tomography';
|
|
import distance from 'consul-ui/utils/distance';
|
|
const tomography = tomographyFactory(distance);
|
|
|
|
const modelName = 'coordinate';
|
|
export default RepositoryService.extend({
|
|
getModelName: function() {
|
|
return modelName;
|
|
},
|
|
// Coordinates don't need nspaces so we have a custom method here
|
|
// that doesn't accept nspaces
|
|
findAllByDatacenter: function(dc, configuration = {}) {
|
|
const query = {
|
|
dc: dc,
|
|
};
|
|
if (typeof configuration.cursor !== 'undefined') {
|
|
query.index = configuration.cursor;
|
|
query.uri = configuration.uri;
|
|
}
|
|
return this.store.query(this.getModelName(), query);
|
|
},
|
|
findAllByNode: function(node, dc, configuration) {
|
|
return this.findAllByDatacenter(dc, configuration).then(function(coordinates) {
|
|
let results = {};
|
|
if (get(coordinates, 'length') > 1) {
|
|
results = tomography(
|
|
node,
|
|
coordinates.map(item => get(item, 'data'))
|
|
);
|
|
}
|
|
results.meta = get(coordinates, 'meta');
|
|
return results;
|
|
});
|
|
},
|
|
});
|