Support v4 for info widget

pull/3196/head
shamoon 2 months ago
parent 0af975b3d9
commit 3600f9d34f

@ -12,6 +12,7 @@ The Glances widget allows you to monitor the resources (CPU, memory, storage, te
url: http://host.or.ip:port
username: user # optional if auth enabled in Glances
password: pass # optional if auth enabled in Glances
version: 4 # required only if running glances v4 or higher, defaults to 3
cpu: true # optional, enabled by default, disable by setting to false
mem: true # optional, enabled by default, disable by setting to false
cputemp: true # disabled by default

@ -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");

Loading…
Cancel
Save