You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.3 KiB
45 lines
1.3 KiB
import useSWR from "swr";
|
|
import { useTranslation } from "next-i18next";
|
|
|
|
import Widget from "../widget";
|
|
import Block from "../block";
|
|
|
|
import { formatProxyUrl } from "utils/api-helpers";
|
|
|
|
export default function StRelaySrv({ service }) {
|
|
const { t } = useTranslation();
|
|
|
|
const config = service.widget;
|
|
|
|
const { data: statsData, error: statsError } = useSWR(formatProxyUrl(config, `status`));
|
|
|
|
if (statsError) {
|
|
return <Widget error={t("widget.api_error")} />;
|
|
}
|
|
|
|
if (!statsData) {
|
|
return (
|
|
<Widget>
|
|
<Block label={t("strelaysrv.numActiveSessions")} />
|
|
<Block label={t("strelaysrv.numConnections")} />
|
|
<Block label={t("strelaysrv.bytesProxied")} />
|
|
</Widget>
|
|
);
|
|
}
|
|
|
|
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] })}
|
|
/>
|
|
</Widget>
|
|
);
|
|
}
|