parent
d25148c8ae
commit
c08d4b7b9c
@ -0,0 +1,98 @@
|
|||||||
|
{
|
||||||
|
"common": {
|
||||||
|
"bytes": "{{value, bytes}}",
|
||||||
|
"bits": "{{value, bytes(bits: true)}}",
|
||||||
|
"bbytes": "{{value, bytes(binary: true)}}",
|
||||||
|
"bbits": "{{value, bytes(bits: true, binary: true)}}",
|
||||||
|
"byterate": "{{value, bytes}}",
|
||||||
|
"bitrate": "{{value, bytes(bits: true)}}",
|
||||||
|
"percent": "{{value, percent}}",
|
||||||
|
"number": "{{value, number}}",
|
||||||
|
"ms": "{{value, number}}"
|
||||||
|
},
|
||||||
|
"widget": {
|
||||||
|
"missing_type": "Missing Widget Type: {{type}}",
|
||||||
|
"api_error": "API Error",
|
||||||
|
"status": "Status"
|
||||||
|
},
|
||||||
|
"search": {
|
||||||
|
"placeholder": "Search..."
|
||||||
|
},
|
||||||
|
"resources": {
|
||||||
|
"total": "Total",
|
||||||
|
"free": "Free",
|
||||||
|
"used": "Used"
|
||||||
|
},
|
||||||
|
"docker": {
|
||||||
|
"rx": "RX",
|
||||||
|
"tx": "TX",
|
||||||
|
"mem": "MEM",
|
||||||
|
"cpu": "CPU",
|
||||||
|
"offline": "Offline"
|
||||||
|
},
|
||||||
|
"emby": {
|
||||||
|
"playing": "Playing",
|
||||||
|
"transcoding": "Transcoding",
|
||||||
|
"bitrate": "Bitrate"
|
||||||
|
},
|
||||||
|
"tautulli": {
|
||||||
|
"playing": "Playing",
|
||||||
|
"transcoding": "Transcoding",
|
||||||
|
"bitrate": "Bitrate"
|
||||||
|
},
|
||||||
|
"nzbget": {
|
||||||
|
"rate": "Rate",
|
||||||
|
"remaining": "Remaining",
|
||||||
|
"downloaded": "Downloaded"
|
||||||
|
},
|
||||||
|
"rutorrent": {
|
||||||
|
"active": "Active",
|
||||||
|
"upload": "Upload",
|
||||||
|
"download": "Download"
|
||||||
|
},
|
||||||
|
"sonarr": {
|
||||||
|
"wanted": "Wanted",
|
||||||
|
"queued": "Queued",
|
||||||
|
"series": "Series"
|
||||||
|
},
|
||||||
|
"radarr": {
|
||||||
|
"wanted": "Wanted",
|
||||||
|
"queued": "Queued",
|
||||||
|
"movies": "Movies"
|
||||||
|
},
|
||||||
|
"ombi": {
|
||||||
|
"pending": "Pending",
|
||||||
|
"approved": "Approved",
|
||||||
|
"available": "Available"
|
||||||
|
},
|
||||||
|
"jellyseerr": {
|
||||||
|
"pending": "Pending",
|
||||||
|
"approved": "Approved",
|
||||||
|
"available": "Available"
|
||||||
|
},
|
||||||
|
"pihole": {
|
||||||
|
"queries": "Queries",
|
||||||
|
"blocked": "Blocked",
|
||||||
|
"gravity": "Gravity"
|
||||||
|
},
|
||||||
|
"speedtest": {
|
||||||
|
"upload": "Upload",
|
||||||
|
"download": "Download",
|
||||||
|
"ping": "Ping"
|
||||||
|
},
|
||||||
|
"portainer": {
|
||||||
|
"running": "Running",
|
||||||
|
"stopped": "Stopped",
|
||||||
|
"total": "Total"
|
||||||
|
},
|
||||||
|
"traefik": {
|
||||||
|
"routers": "Routers",
|
||||||
|
"services": "Services",
|
||||||
|
"middleware": "Middleware"
|
||||||
|
},
|
||||||
|
"npm": {
|
||||||
|
"enabled": "Enabled",
|
||||||
|
"disabled": "Disabled",
|
||||||
|
"total": "Total"
|
||||||
|
}
|
||||||
|
}
|
@ -1,35 +1,43 @@
|
|||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import Widget from "../widget";
|
import Widget from "../widget";
|
||||||
import Block from "../block";
|
import Block from "../block";
|
||||||
|
|
||||||
import { formatApiUrl } from "utils/api-helpers";
|
import { formatApiUrl } from "utils/api-helpers";
|
||||||
import { formatBytes } from "utils/stats-helpers";
|
|
||||||
|
|
||||||
export default function Nzbget({ service }) {
|
export default function Nzbget({ service }) {
|
||||||
|
const { t } = useTranslation("common");
|
||||||
|
|
||||||
const config = service.widget;
|
const config = service.widget;
|
||||||
|
|
||||||
const { data: statusData, error: statusError } = useSWR(formatApiUrl(config, "status"));
|
const { data: statusData, error: statusError } = useSWR(formatApiUrl(config, "status"));
|
||||||
|
|
||||||
if (statusError) {
|
if (statusError) {
|
||||||
return <Widget error="Nzbget API Error" />;
|
return <Widget error={t("widget.api_error")} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!statusData) {
|
if (!statusData) {
|
||||||
return (
|
return (
|
||||||
<Widget>
|
<Widget>
|
||||||
<Block label="Rate" />
|
<Block label={t("nzbget.rate")} />
|
||||||
<Block label="Remaining" />
|
<Block label={t("nzbget.remaining")} />
|
||||||
<Block label="Downloaded" />
|
<Block label={t("nzbget.downloaded")} />
|
||||||
</Widget>
|
</Widget>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Widget>
|
<Widget>
|
||||||
<Block label="Rate" value={`${formatBytes(statusData.DownloadRate)}/s`} />
|
<Block label={t("nzbget.rate")} value={t("common.bitrate", { value: statusData.DownloadRate })} />
|
||||||
<Block label="Remaining" value={`${Math.round((statusData.RemainingSizeMB / 1024) * 100) / 100} GB`} />
|
<Block
|
||||||
<Block label="Downloaded" value={`${Math.round((statusData.DownloadedSizeMB / 1024) * 100) / 100} GB`} />
|
label={t("nzbget.remaining")}
|
||||||
|
value={t("common.bytes", { value: statusData.RemainingSizeMB * 1024 * 1024 })}
|
||||||
|
/>
|
||||||
|
<Block
|
||||||
|
label={t("nzbget.downloaded")}
|
||||||
|
value={t("common.bytes", { value: statusData.DownloadedSizeMB * 1024 * 1024 })}
|
||||||
|
/>
|
||||||
</Widget>
|
</Widget>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,46 @@
|
|||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import Widget from "../widget";
|
import Widget from "../widget";
|
||||||
import Block from "../block";
|
import Block from "../block";
|
||||||
|
|
||||||
import { formatBits } from "utils/stats-helpers";
|
|
||||||
import { formatApiUrl } from "utils/api-helpers";
|
import { formatApiUrl } from "utils/api-helpers";
|
||||||
|
|
||||||
export default function Speedtest({ service }) {
|
export default function Speedtest({ service }) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const config = service.widget;
|
const config = service.widget;
|
||||||
|
|
||||||
const { data: speedtestData, error: speedtestError } = useSWR(formatApiUrl(config, "speedtest/latest"));
|
const { data: speedtestData, error: speedtestError } = useSWR(formatApiUrl(config, "speedtest/latest"));
|
||||||
|
|
||||||
if (speedtestError) {
|
if (speedtestError) {
|
||||||
return <Widget error="Speedtest API Error" />;
|
return <Widget error={t("widget.api_error")} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!speedtestData) {
|
if (!speedtestData) {
|
||||||
return (
|
return (
|
||||||
<Widget>
|
<Widget>
|
||||||
<Block label="Download" />
|
<Block label={t("speedtest.download")} />
|
||||||
<Block label="Upload" />
|
<Block label={t("speedtest.upload")} />
|
||||||
<Block label="Ping" />
|
<Block label={t("speedtest.ping")} />
|
||||||
</Widget>
|
</Widget>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Widget>
|
<Widget>
|
||||||
<Block label="Download" value={`${formatBits(speedtestData.data.download * 1024 * 1024, 0)}ps`} />
|
<Block
|
||||||
<Block label="Upload" value={`${formatBits(speedtestData.data.upload * 1024 * 1024, 0)}ps`} />
|
label={t("speedtest.download")}
|
||||||
<Block label="Ping" value={`${speedtestData.data.ping} ms`} />
|
value={t("common.bitrate", { value: speedtestData.data.download * 1024 * 1024 })}
|
||||||
|
/>
|
||||||
|
<Block
|
||||||
|
label={t("speedtest.upload")}
|
||||||
|
value={t("common.bitrate", { value: speedtestData.data.upload * 1024 * 1024 })}
|
||||||
|
/>
|
||||||
|
<Block
|
||||||
|
label={t("speedtest.ping")}
|
||||||
|
value={t("common.ms", { value: speedtestData.data.ping, style: "unit", unit: "millisecond" })}
|
||||||
|
/>
|
||||||
</Widget>
|
</Widget>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
import i18n from "i18next";
|
||||||
|
import { initReactI18next } from "react-i18next";
|
||||||
|
import Backend from "i18next-http-backend";
|
||||||
|
import LanguageDetector from "i18next-browser-languagedetector";
|
||||||
|
import prettyBytes from "pretty-bytes";
|
||||||
|
|
||||||
|
i18n
|
||||||
|
.use(Backend)
|
||||||
|
.use(LanguageDetector)
|
||||||
|
.use(initReactI18next)
|
||||||
|
.init({
|
||||||
|
fallbackLng: "en",
|
||||||
|
ns: ["common"],
|
||||||
|
debug: process.env.NODE_ENV === "development",
|
||||||
|
defaultNS: "common",
|
||||||
|
nonExplicitSupportedLngs: true,
|
||||||
|
interpolation: {
|
||||||
|
escapeValue: false,
|
||||||
|
},
|
||||||
|
backend: {
|
||||||
|
loadPath: "/locales/{{lng}}/{{ns}}.json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
i18n.services.formatter.add("bytes", (value, lng, options) =>
|
||||||
|
prettyBytes(parseFloat(value), { locale: lng, ...options })
|
||||||
|
);
|
||||||
|
i18n.services.formatter.add("percent", (value, lng, options) =>
|
||||||
|
new Intl.NumberFormat(lng, { style: "percent", ...options }).format(parseFloat(value) / 100.0)
|
||||||
|
);
|
||||||
|
|
||||||
|
export default i18n;
|
Loading…
Reference in new issue