Diskstation widget : code cleanup
This commit is contained in:
parent
879079a0cd
commit
b114339866
@ -413,22 +413,12 @@
|
||||
"wanUpload": "WAN Upload",
|
||||
"wanDownload": "WAN Download"
|
||||
},
|
||||
"synology": {
|
||||
"diskstation": {
|
||||
"uptime": "Uptime",
|
||||
"volumeUsage": "Volume Usage",
|
||||
"cpuLoad": "CPU Load",
|
||||
"memoryUsage": "Memory Usage",
|
||||
"status": "Status",
|
||||
"volumeTotal": "Total space"
|
||||
},
|
||||
"opnsense": {
|
||||
"cpu": "CPU Load",
|
||||
"memory": "Memory Used",
|
||||
"uptime": "Uptime",
|
||||
"wanUpload": "WAN Upload",
|
||||
"wanDownload": "WAN Download",
|
||||
"wanUploadRate": "WAN Upload Rate",
|
||||
"wanDownloadRate": "WAN Download Rate"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,11 +18,11 @@ export default function Component({ service }) {
|
||||
if (!dsData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="synology.uptime" />
|
||||
<Block label="synology.volumeUsage" />
|
||||
<Block label="synology.volumeTotal" />
|
||||
<Block label="synology.cpuLoad" />
|
||||
<Block label="synology.memoryUsage" />
|
||||
<Block label="diskstation.uptime" />
|
||||
<Block label="diskstation.volumeUsage" />
|
||||
<Block label="diskstation.volumeTotal" />
|
||||
<Block label="diskstation.cpuLoad" />
|
||||
<Block label="diskstation.memoryUsage" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
@ -30,11 +30,11 @@ export default function Component({ service }) {
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="synology.uptime" value={ dsData.uptime } />
|
||||
<Block label="synology.volumeUsage" value={t("common.percent", { value: dsData.usedVolume })} />
|
||||
<Block label="synology.volumeTotal" value={t("common.bytes", { value: dsData.totalSize })} />
|
||||
<Block label="synology.cpuLoad" value={t("common.percent", { value: dsData.cpuLoad })} />
|
||||
<Block label="synology.memoryUsage" value={t("common.percent", { value: dsData.memoryUsage })} />
|
||||
<Block label="diskstation.uptime" value={ dsData.uptime } />
|
||||
<Block label="diskstation.volumeUsage" value={t("common.percent", { value: dsData.usedVolume })} />
|
||||
<Block label="diskstation.volumeTotal" value={t("common.bytes", { value: dsData.totalSize })} />
|
||||
<Block label="diskstation.cpuLoad" value={t("common.percent", { value: dsData.cpuLoad })} />
|
||||
<Block label="diskstation.memoryUsage" value={t("common.percent", { value: dsData.memoryUsage })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
@ -106,13 +106,12 @@ export default async function synologyProxyHandler(req, res) {
|
||||
const memoryUsage = 100 - (100 * (parseFloat(JSON.parse(data.toString()).data.memory.avail_real) + parseFloat(JSON.parse(data.toString()).data.memory.cached)) / parseFloat(JSON.parse(data.toString()).data.memory.total_real));
|
||||
const cpuLoad = parseFloat(JSON.parse(data.toString()).data.cpu.user_load) + parseFloat(JSON.parse(data.toString()).data.cpu.system_load);
|
||||
|
||||
const resdata = {
|
||||
if (contentType) res.setHeader("Content-Type", contentType);
|
||||
return res.status(status).send(JSON.stringify({
|
||||
uptime,
|
||||
usedVolume,
|
||||
totalSize,
|
||||
memoryUsage,
|
||||
cpuLoad,
|
||||
}
|
||||
if (contentType) res.setHeader("Content-Type", contentType);
|
||||
return res.status(status).send(JSON.stringify(resdata));
|
||||
}));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user