Diskstation widget : code cleanup
This commit is contained in:
parent
879079a0cd
commit
b114339866
@ -413,22 +413,12 @@
|
|||||||
"wanUpload": "WAN Upload",
|
"wanUpload": "WAN Upload",
|
||||||
"wanDownload": "WAN Download"
|
"wanDownload": "WAN Download"
|
||||||
},
|
},
|
||||||
"synology": {
|
"diskstation": {
|
||||||
"uptime": "Uptime",
|
"uptime": "Uptime",
|
||||||
"volumeUsage": "Volume Usage",
|
"volumeUsage": "Volume Usage",
|
||||||
"cpuLoad": "CPU Load",
|
"cpuLoad": "CPU Load",
|
||||||
"memoryUsage": "Memory Usage",
|
"memoryUsage": "Memory Usage",
|
||||||
"status": "Status",
|
"status": "Status",
|
||||||
"volumeTotal": "Total space"
|
"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) {
|
if (!dsData) {
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="synology.uptime" />
|
<Block label="diskstation.uptime" />
|
||||||
<Block label="synology.volumeUsage" />
|
<Block label="diskstation.volumeUsage" />
|
||||||
<Block label="synology.volumeTotal" />
|
<Block label="diskstation.volumeTotal" />
|
||||||
<Block label="synology.cpuLoad" />
|
<Block label="diskstation.cpuLoad" />
|
||||||
<Block label="synology.memoryUsage" />
|
<Block label="diskstation.memoryUsage" />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -30,11 +30,11 @@ export default function Component({ service }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="synology.uptime" value={ dsData.uptime } />
|
<Block label="diskstation.uptime" value={ dsData.uptime } />
|
||||||
<Block label="synology.volumeUsage" value={t("common.percent", { value: dsData.usedVolume })} />
|
<Block label="diskstation.volumeUsage" value={t("common.percent", { value: dsData.usedVolume })} />
|
||||||
<Block label="synology.volumeTotal" value={t("common.bytes", { value: dsData.totalSize })} />
|
<Block label="diskstation.volumeTotal" value={t("common.bytes", { value: dsData.totalSize })} />
|
||||||
<Block label="synology.cpuLoad" value={t("common.percent", { value: dsData.cpuLoad })} />
|
<Block label="diskstation.cpuLoad" value={t("common.percent", { value: dsData.cpuLoad })} />
|
||||||
<Block label="synology.memoryUsage" value={t("common.percent", { value: dsData.memoryUsage })} />
|
<Block label="diskstation.memoryUsage" value={t("common.percent", { value: dsData.memoryUsage })} />
|
||||||
</Container>
|
</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 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 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,
|
uptime,
|
||||||
usedVolume,
|
usedVolume,
|
||||||
totalSize,
|
totalSize,
|
||||||
memoryUsage,
|
memoryUsage,
|
||||||
cpuLoad,
|
cpuLoad,
|
||||||
}
|
}));
|
||||||
if (contentType) res.setHeader("Content-Type", contentType);
|
|
||||||
return res.status(status).send(JSON.stringify(resdata));
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user