mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-21 03:59:50 +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
|
@ -4,34 +4,33 @@ import Container from "components/services/widget/container";
|
|||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
const processUptime = uptime => {
|
||||
|
||||
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'],
|
||||
[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) {
|
||||
|
||||
for (let i = 0; i < levels.length; i += 1) {
|
||||
const level = levels[i];
|
||||
if (level[0] > 0){
|
||||
if (level[0] > 0) {
|
||||
return {
|
||||
value: level[0],
|
||||
unit: level[1]
|
||||
}
|
||||
}
|
||||
value: level[0],
|
||||
unit: level[1],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
value: 0,
|
||||
unit: 'second'
|
||||
unit: "second",
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
@ -55,11 +54,11 @@ export default function Component({ service }) {
|
|||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<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("truenas.time", processUptime(statusData.uptime_seconds))} />
|
||||
<Block label="truenas.alerts" value={t("common.number", { value: alertData.pending })} />
|
||||
</Container>
|
||||
);
|
||||
|
|
|
@ -5,9 +5,10 @@ import getServiceWidget from "utils/config/service-helpers";
|
|||
|
||||
const widget = {
|
||||
api: "{url}/api/v2.0/{endpoint}",
|
||||
proxyHandler: async (req, res, map) => { // choose proxy handler based on widget settings
|
||||
proxyHandler: async (req, res, map) => {
|
||||
// choose proxy handler based on widget settings
|
||||
const { group, service } = req.query;
|
||||
|
||||
|
||||
if (group && service) {
|
||||
const widgetOpts = await getServiceWidget(group, service);
|
||||
let handler;
|
||||
|
@ -19,11 +20,11 @@ const widget = {
|
|||
|
||||
if (handler) {
|
||||
return handler(req, res, map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return res.status(500).json({ error: "Username / password or API key required" });
|
||||
}
|
||||
|
||||
|
||||
return res.status(500).json({ error: "Error parsing widget request" });
|
||||
},
|
||||
|
||||
|
@ -36,10 +37,7 @@ const widget = {
|
|||
},
|
||||
status: {
|
||||
endpoint: "system/info",
|
||||
validate: [
|
||||
"loadavg",
|
||||
"uptime_seconds"
|
||||
]
|
||||
validate: ["loadavg", "uptime_seconds"],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue