mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-16 09:49:49 +00:00
starting of widget refactoring
This commit is contained in:
parent
d6f6ea9dba
commit
562235f828
42 changed files with 337 additions and 301 deletions
|
@ -4,14 +4,14 @@ import { useTranslation } from "next-i18next";
|
|||
import Widget from "../widget";
|
||||
import Block from "../block";
|
||||
|
||||
import { formatApiUrl } from "utils/api-helpers";
|
||||
import { formatProxyUrl } from "utils/api-helpers";
|
||||
|
||||
export default function StRelaySrv({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const config = service.widget;
|
||||
|
||||
const { data: statsData, error: statsError } = useSWR(formatApiUrl(config, `status`));
|
||||
const { data: statsData, error: statsError } = useSWR(formatProxyUrl(config, `status`));
|
||||
|
||||
if (statsError) {
|
||||
return <Widget error={t("widget.api_error")} />;
|
||||
|
@ -29,10 +29,16 @@ export default function StRelaySrv({ service }) {
|
|||
|
||||
return (
|
||||
<Widget>
|
||||
<Block label={t("strelaysrv.numActiveSessions")} value={t("common.number", { value: statsData.numActiveSessions })} />
|
||||
<Block label={t("strelaysrv.numConnections")} value={t("common.number", { value: statsData.numConnections })} />
|
||||
<Block label={t("strelaysrv.dataRelayed")} value={t("common.bytes", { value: statsData.bytesProxied })} />
|
||||
<Block label={t("strelaysrv.transferRate")} value={t("common.bitrate",{ value: statsData.kbps10s1m5m15m30m60m[5] })} />
|
||||
<Block
|
||||
label={t("strelaysrv.numActiveSessions")}
|
||||
value={t("common.number", { value: statsData.numActiveSessions })}
|
||||
/>
|
||||
<Block label={t("strelaysrv.numConnections")} value={t("common.number", { value: statsData.numConnections })} />
|
||||
<Block label={t("strelaysrv.dataRelayed")} value={t("common.bytes", { value: statsData.bytesProxied })} />
|
||||
<Block
|
||||
label={t("strelaysrv.transferRate")}
|
||||
value={t("common.bitrate", { value: statsData.kbps10s1m5m15m30m60m[5] })}
|
||||
/>
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue