mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-17 18:29:48 +00:00
Run pre-commit hooks over existing codebase
Co-Authored-By: Ben Phelps <ben@phelps.io>
This commit is contained in:
parent
fa50bbad9c
commit
19c25713c4
387 changed files with 4785 additions and 4109 deletions
|
@ -12,7 +12,7 @@ export default function Component({ service }) {
|
|||
const { data: utilizationData, error: utilizationError } = useWidgetAPI(widget, "utilization");
|
||||
|
||||
if (storageError || infoError || utilizationError) {
|
||||
return <Container service={service} error={ storageError ?? infoError ?? utilizationError } />;
|
||||
return <Container service={service} error={storageError ?? infoError ?? utilizationError} />;
|
||||
}
|
||||
|
||||
if (!storageData || !infoData || !utilizationData) {
|
||||
|
@ -30,10 +30,12 @@ export default function Component({ service }) {
|
|||
// eslint-disable-next-line no-unused-vars
|
||||
const [hour, minutes, seconds] = infoData.data.up_time.split(":");
|
||||
const days = Math.floor(hour / 24);
|
||||
const uptime = `${ t("common.number", { value: days }) } ${ t("diskstation.days") }`;
|
||||
const uptime = `${t("common.number", { value: days })} ${t("diskstation.days")}`;
|
||||
|
||||
// storage info
|
||||
const volume = widget.volume ? storageData.data.vol_info?.find(vol => vol.name === widget.volume) : storageData.data.vol_info?.[0];
|
||||
const volume = widget.volume
|
||||
? storageData.data.vol_info?.find((vol) => vol.name === widget.volume)
|
||||
: storageData.data.vol_info?.[0];
|
||||
const usedBytes = parseFloat(volume?.used_size);
|
||||
const totalBytes = parseFloat(volume?.total_size);
|
||||
const freeBytes = totalBytes - usedBytes;
|
||||
|
@ -41,14 +43,18 @@ export default function Component({ service }) {
|
|||
// utilization info
|
||||
const { cpu, memory } = utilizationData.data;
|
||||
const cpuLoad = parseFloat(cpu.user_load) + parseFloat(cpu.system_load);
|
||||
const memoryUsage = 100 - ((100 * (parseFloat(memory.avail_real) + parseFloat(memory.cached))) / parseFloat(memory.total_real));
|
||||
const memoryUsage =
|
||||
100 - (100 * (parseFloat(memory.avail_real) + parseFloat(memory.cached))) / parseFloat(memory.total_real);
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="diskstation.uptime" value={ uptime } />
|
||||
<Block label="diskstation.volumeAvailable" value={ t("common.bbytes", { value: freeBytes, maximumFractionDigits: 1 }) } />
|
||||
<Block label="resources.cpu" value={ t("common.percent", { value: cpuLoad }) } />
|
||||
<Block label="resources.mem" value={ t("common.percent", { value: memoryUsage }) } />
|
||||
<Block label="diskstation.uptime" value={uptime} />
|
||||
<Block
|
||||
label="diskstation.volumeAvailable"
|
||||
value={t("common.bbytes", { value: freeBytes, maximumFractionDigits: 1 })}
|
||||
/>
|
||||
<Block label="resources.cpu" value={t("common.percent", { value: cpuLoad })} />
|
||||
<Block label="resources.mem" value={t("common.percent", { value: memoryUsage })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import synologyProxyHandler from '../../utils/proxy/handlers/synology'
|
||||
import synologyProxyHandler from "../../utils/proxy/handlers/synology";
|
||||
|
||||
const widget = {
|
||||
// cgiPath and maxVersion are discovered at runtime, don't supply
|
||||
|
@ -6,21 +6,21 @@ const widget = {
|
|||
proxyHandler: synologyProxyHandler,
|
||||
|
||||
mappings: {
|
||||
"system_storage": {
|
||||
system_storage: {
|
||||
apiName: "SYNO.Core.System",
|
||||
apiMethod: "info&type=\"storage\"",
|
||||
endpoint: "system_storage"
|
||||
apiMethod: 'info&type="storage"',
|
||||
endpoint: "system_storage",
|
||||
},
|
||||
"system_info": {
|
||||
system_info: {
|
||||
apiName: "SYNO.Core.System",
|
||||
apiMethod: "info",
|
||||
endpoint: "system_info"
|
||||
endpoint: "system_info",
|
||||
},
|
||||
"utilization": {
|
||||
utilization: {
|
||||
apiName: "SYNO.Core.System.Utilization",
|
||||
apiMethod: "get",
|
||||
endpoint: "utilization"
|
||||
}
|
||||
endpoint: "utilization",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue