mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Include truenas in uptime refactor
This commit is contained in:
parent
e768b1c83a
commit
30e4a2ae3a
@ -519,8 +519,7 @@
|
|||||||
"truenas": {
|
"truenas": {
|
||||||
"load": "System Load",
|
"load": "System Load",
|
||||||
"uptime": "Uptime",
|
"uptime": "Uptime",
|
||||||
"alerts": "Alerts",
|
"alerts": "Alerts"
|
||||||
"time": "{{value, number(style: unit; unitDisplay: long;)}}"
|
|
||||||
},
|
},
|
||||||
"pyload": {
|
"pyload": {
|
||||||
"speed": "Speed",
|
"speed": "Speed",
|
||||||
|
@ -4,34 +4,6 @@ import Container from "components/services/widget/container";
|
|||||||
import Block from "components/services/widget/block";
|
import Block from "components/services/widget/block";
|
||||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
|
|
||||||
const processUptime = (uptime) => {
|
|
||||||
const seconds = uptime.toFixed(0);
|
|
||||||
|
|
||||||
const levels = [
|
|
||||||
[Math.floor(seconds / 31536000), "year"],
|
|
||||||
[Math.floor((seconds % 31536000) / 2592000), "month"],
|
|
||||||
[Math.floor(((seconds % 31536000) % 2592000) / 86400), "day"],
|
|
||||||
[Math.floor(((seconds % 31536000) % 86400) / 3600), "hour"],
|
|
||||||
[Math.floor((((seconds % 31536000) % 86400) % 3600) / 60), "minute"],
|
|
||||||
[(((seconds % 31536000) % 86400) % 3600) % 60, "second"],
|
|
||||||
];
|
|
||||||
|
|
||||||
for (let i = 0; i < levels.length; i += 1) {
|
|
||||||
const level = levels[i];
|
|
||||||
if (level[0] > 0) {
|
|
||||||
return {
|
|
||||||
value: level[0],
|
|
||||||
unit: level[1],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
value: 0,
|
|
||||||
unit: "second",
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function Component({ service }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@ -58,7 +30,7 @@ export default function Component({ service }) {
|
|||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="truenas.load" value={t("common.number", { value: statusData.loadavg[0] })} />
|
<Block label="truenas.load" value={t("common.number", { value: statusData.loadavg[0] })} />
|
||||||
<Block label="truenas.uptime" value={t("truenas.time", processUptime(statusData.uptime_seconds))} />
|
<Block label="truenas.uptime" value={t("common.uptime", { value: statusData.uptime_seconds })} />
|
||||||
<Block label="truenas.alerts" value={t("common.number", { value: alertData.pending })} />
|
<Block label="truenas.alerts" value={t("common.number", { value: alertData.pending })} />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user