mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-29 16:14:43 +00:00
Monitoring Settings
This commit is contained in:
62
hooks/useMonitoring.ts
Normal file
62
hooks/useMonitoring.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { useState, useEffect, useCallback } from "react";
|
||||
import axios from "axios";
|
||||
|
||||
interface MonitoringSettings {
|
||||
frequency: number;
|
||||
checksUntilOffline: number;
|
||||
}
|
||||
|
||||
|
||||
const useMonitoring = () => {
|
||||
const getGeneralApplicationMonitoringSettings = (): Promise<any> | string => {
|
||||
return axios.get('/api/monitoring/applications/get_general')
|
||||
.then((response) => {
|
||||
if(response.data) {
|
||||
return response.data
|
||||
} else {
|
||||
return
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
return error.response.data.error
|
||||
});
|
||||
}
|
||||
|
||||
const getGeneralServerMonitoringSettings = (): Promise<any> | string => {
|
||||
return axios.get('/api/monitoring/servers/get_general')
|
||||
.then((response) => {
|
||||
if(response.data) {
|
||||
return response.data
|
||||
} else {
|
||||
return
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
return error.response.data.error
|
||||
});
|
||||
}
|
||||
|
||||
const editGeneralApplicationMonitoringSettings = (settings: MonitoringSettings): Promise<any> | string => {
|
||||
return axios.post('/api/monitoring/applications/edit_general', settings)
|
||||
.then((response) => {
|
||||
return response.data
|
||||
})
|
||||
.catch((error) => {
|
||||
return error.response.data.error
|
||||
});
|
||||
}
|
||||
|
||||
const editGeneralServerMonitoringSettings = (settings: MonitoringSettings): Promise<any> | string => {
|
||||
return axios.post('/api/monitoring/servers/edit_general', settings)
|
||||
.then((response) => {
|
||||
return response.data
|
||||
})
|
||||
.catch((error) => {
|
||||
return error.response.data.error
|
||||
});
|
||||
}
|
||||
|
||||
return { getGeneralApplicationMonitoringSettings, getGeneralServerMonitoringSettings, editGeneralApplicationMonitoringSettings, editGeneralServerMonitoringSettings };
|
||||
};
|
||||
|
||||
export default useMonitoring;
|
||||
Reference in New Issue
Block a user