From b1143398668f07ed2cbcb243ef0dc968079709f8 Mon Sep 17 00:00:00 2001 From: Benoit Date: Fri, 13 Jan 2023 17:03:29 +0100 Subject: [PATCH] Diskstation widget : code cleanup --- public/locales/en/common.json | 12 +----------- src/widgets/diskstation/component.jsx | 20 ++++++++++---------- src/widgets/diskstation/proxy.js | 7 +++---- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index ad77cbb2..9b4a30de 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -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" - } } diff --git a/src/widgets/diskstation/component.jsx b/src/widgets/diskstation/component.jsx index 95405e84..aaf69d31 100644 --- a/src/widgets/diskstation/component.jsx +++ b/src/widgets/diskstation/component.jsx @@ -18,11 +18,11 @@ export default function Component({ service }) { if (!dsData) { return ( - - - - - + + + + + ); } @@ -30,11 +30,11 @@ export default function Component({ service }) { return ( - - - - - + + + + + ); } diff --git a/src/widgets/diskstation/proxy.js b/src/widgets/diskstation/proxy.js index aa1023bc..55d22e31 100644 --- a/src/widgets/diskstation/proxy.js +++ b/src/widgets/diskstation/proxy.js @@ -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)); + })); }