Synology diskstation widget: code cleanup
This commit is contained in:
parent
46b98dbe67
commit
2401312869
@ -77,28 +77,23 @@ export default async function synologyProxyHandler(req, res) {
|
||||
let usedVolume = 0;
|
||||
if (status !== 200) {
|
||||
return res.status(status).set("Content-Type", contentType).send(data);
|
||||
} else {
|
||||
const json=JSON.parse(data.toString());
|
||||
if (json?.success !== true) {
|
||||
return res.status(401).json({ error: "Error getting volume stats" });
|
||||
} else {
|
||||
usedVolume = 100 * parseFloat(json.data.vol_info[0].used_size) / parseFloat(json.data.vol_info[0].total_size);
|
||||
}
|
||||
}
|
||||
let uptime = "Unknown";
|
||||
let json=JSON.parse(data.toString());
|
||||
if (json?.success !== true) {
|
||||
return res.status(401).json({ error: "Error getting volume stats" });
|
||||
}
|
||||
usedVolume = 100 * parseFloat(json.data.vol_info[0].used_size) / parseFloat(json.data.vol_info[0].total_size);
|
||||
|
||||
const healthUrl = `${widget.url}/webapi/${path}?api=${api}&version=${maxVersion}&method=info&_sid=${sid}`;
|
||||
[status, contentType, data] = await httpProxy(healthUrl);
|
||||
if (status !== 200) {
|
||||
return res.status(status).set("Content-Type", contentType).send(data);
|
||||
} else {
|
||||
const json=JSON.parse(data.toString());
|
||||
if (json?.success !== true) {
|
||||
return res.status(401).json({ error: "Error getting uptime" });
|
||||
} else {
|
||||
uptime = formatUptime(json.data.up_time);
|
||||
}
|
||||
}
|
||||
json=JSON.parse(data.toString());
|
||||
if (json?.success !== true) {
|
||||
return res.status(401).json({ error: "Error getting uptime" });
|
||||
}
|
||||
const uptime = formatUptime(json.data.up_time);
|
||||
|
||||
const resdata = {
|
||||
uptime,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user