2019-03-22 17:24:40 +00:00
|
|
|
import { get } from '@ember/object';
|
2018-10-26 16:36:15 +00:00
|
|
|
import RepositoryService from 'consul-ui/services/repository';
|
|
|
|
|
2019-03-22 17:24:40 +00:00
|
|
|
import tomographyFactory from 'consul-ui/utils/tomography';
|
|
|
|
import distance from 'consul-ui/utils/distance';
|
|
|
|
const tomography = tomographyFactory(distance);
|
|
|
|
|
2018-10-26 16:36:15 +00:00
|
|
|
const modelName = 'coordinate';
|
|
|
|
export default RepositoryService.extend({
|
|
|
|
getModelName: function() {
|
|
|
|
return modelName;
|
|
|
|
},
|
2019-12-17 18:47:37 +00:00
|
|
|
findAllByNode: function(node, dc, nspace, configuration) {
|
|
|
|
return this.findAllByDatacenter(dc, nspace, configuration).then(function(coordinates) {
|
2019-03-22 17:24:40 +00:00
|
|
|
let results = {};
|
|
|
|
if (get(coordinates, 'length') > 1) {
|
|
|
|
results = tomography(node, coordinates.map(item => get(item, 'data')));
|
|
|
|
}
|
|
|
|
results.meta = get(coordinates, 'meta');
|
|
|
|
return results;
|
|
|
|
});
|
|
|
|
},
|
2018-10-26 16:36:15 +00:00
|
|
|
});
|