Enhancement: support for glances v4 (#3196)

This commit is contained in:
shamoon 2024-03-28 11:16:00 -05:00 committed by GitHub
parent 4fe4ae9622
commit def9b27006
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 38 additions and 18 deletions

View file

@ -13,7 +13,7 @@ async function retrieveFromGlancesAPI(privateWidgetOptions, endpoint) {
throw new Error(errorMessage);
}
const apiUrl = `${url}/api/3/${endpoint}`;
const apiUrl = `${url}/api/${privateWidgetOptions.version}/${endpoint}`;
const headers = {
"Accept-Encoding": "application/json",
};
@ -42,9 +42,10 @@ async function retrieveFromGlancesAPI(privateWidgetOptions, endpoint) {
}
export default async function handler(req, res) {
const { index, cputemp: includeCpuTemp, uptime: includeUptime, disk: includeDisks } = req.query;
const { index, cputemp: includeCpuTemp, uptime: includeUptime, disk: includeDisks, version } = req.query;
const privateWidgetOptions = await getPrivateWidgetOptions("glances", index);
privateWidgetOptions.version = version ?? 3;
try {
const cpuData = await retrieveFromGlancesAPI(privateWidgetOptions, "cpu");