mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
29 lines
747 B
JavaScript
29 lines
747 B
JavaScript
|
import { appendTargetTypeToTargets } from 'redux/nodes/entities/targets/helpers';
|
||
|
import endpoints from 'kolide/endpoints';
|
||
|
|
||
|
const defaultSelected = {
|
||
|
hosts: [],
|
||
|
labels: [],
|
||
|
};
|
||
|
|
||
|
export default (client) => {
|
||
|
return {
|
||
|
loadAll: (query, selected = defaultSelected) => {
|
||
|
const { TARGETS } = endpoints;
|
||
|
|
||
|
return client.authenticatedPost(client._endpoint(TARGETS), JSON.stringify({ query, selected }))
|
||
|
.then((response) => {
|
||
|
const { targets } = response;
|
||
|
|
||
|
return {
|
||
|
...response,
|
||
|
targets: [
|
||
|
...appendTargetTypeToTargets(targets.hosts, 'hosts'),
|
||
|
...appendTargetTypeToTargets(targets.labels, 'labels'),
|
||
|
],
|
||
|
};
|
||
|
});
|
||
|
},
|
||
|
};
|
||
|
};
|