Commit 8d8a9563 authored by Kushal Pandya's avatar Kushal Pandya

Add helpers for Toggle, Repair and Remove node actions

parent da3886c5
...@@ -3,8 +3,7 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -3,8 +3,7 @@ import axios from '~/lib/utils/axios_utils';
import Api from '~/api'; import Api from '~/api';
export default class GeoNodesService { export default class GeoNodesService {
constructor(nodeDetailsBasePath) { constructor() {
this.geoNodeDetailsBasePath = nodeDetailsBasePath;
this.geoNodesPath = Api.buildUrl(Api.geoNodesPath); this.geoNodesPath = Api.buildUrl(Api.geoNodesPath);
} }
...@@ -12,8 +11,29 @@ export default class GeoNodesService { ...@@ -12,8 +11,29 @@ export default class GeoNodesService {
return axios.get(this.geoNodesPath); return axios.get(this.geoNodesPath);
} }
getGeoNodeDetails(nodeId) { // eslint-disable-next-line class-methods-use-this
const geoNodeDetailsPath = `${this.geoNodeDetailsBasePath}/${nodeId}/status.json`; getGeoNodeDetails(node) {
return axios.get(geoNodeDetailsPath); return axios.get(node.statusPath, {
params: {
refresh: true,
},
});
}
// eslint-disable-next-line class-methods-use-this
toggleNode(node) {
return axios.put(node.basePath, {
enabled: !node.enabled, // toggle from existing status
});
}
// eslint-disable-next-line class-methods-use-this
repairNode(node) {
return axios.post(node.repairPath);
}
// eslint-disable-next-line class-methods-use-this
removeNode(node) {
return axios.delete(node.basePath);
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment