diff --git a/public/locales/en/common.json b/public/locales/en/common.json index d53d480c..c1b35aa7 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -47,7 +47,13 @@ "tx": "TX", "mem": "MEM", "cpu": "CPU", - "offline": "Offline" + "offline": "Offline", + "error": "Error", + "unknown": "Unknown" + }, + "ping": { + "error": "Error", + "ping": "Ping" }, "emby": { "playing": "Playing", diff --git a/src/components/services/item.jsx b/src/components/services/item.jsx index 25e94266..a4b54ad3 100644 --- a/src/components/services/item.jsx +++ b/src/components/services/item.jsx @@ -65,7 +65,7 @@ export default function Item({ service }) {
{service.icon && @@ -103,23 +103,25 @@ export default function Item({ service }) {
)} - {service.ping && ( -
- - Ping status -
- )} - - {service.container && ( - - )} +
+ {service.container && ( + + )} + + {service.ping && ( +
+ + Ping status +
+ )} +
{service.container && service.server && ( diff --git a/src/components/services/ping.jsx b/src/components/services/ping.jsx index 951a624d..18ad8696 100644 --- a/src/components/services/ping.jsx +++ b/src/components/services/ping.jsx @@ -1,33 +1,42 @@ -import { BsArrowDownCircle, BsArrowUpCircle } from "react-icons/bs"; +import { useTranslation } from "react-i18next"; import useSWR from "swr"; export default function Ping({ service }) { + const { t } = useTranslation(); const { data, error } = useSWR(`/api/ping?${new URLSearchParams({ping: service.ping}).toString()}`, { refreshInterval: 5000 }); if (error) { - return
; + return ( +
+
{t("ping.error")}
+
+ ); } if (!data) { - return
PING
; + return ( +
+
{t("ping.ping")}
+
+ ); } const statusText = `${service.ping}: HTTP status ${data.status}`; if (data && data.status !== 200) { return ( -
- +
+
{data.status}
); } if (data && data.status === 200) { return ( -
- +
+
{data.status}
); } diff --git a/src/components/services/status.jsx b/src/components/services/status.jsx index dc903408..2d07e49e 100644 --- a/src/components/services/status.jsx +++ b/src/components/services/status.jsx @@ -1,19 +1,36 @@ +import { useTranslation } from "react-i18next"; import useSWR from "swr"; export default function Status({ service }) { + const { t } = useTranslation(); + const { data, error } = useSWR(`/api/docker/status/${service.container}/${service.server || ""}`); if (error) { - return
; +
+
{t("docker.error")}
+
} if (data && data.status === "running") { - return
; + return ( +
+
{data.status}
+
+ ); } - if (data && data.status === "not found") { - return
; + if (data && (data.status === "not found" || data.status === "exited")) { + return ( +
+
{data.status}
+
+ ); } - return
; + return ( +
+
{t("docker.unknown")}
+
+ ); } diff --git a/src/pages/api/ping.js b/src/pages/api/ping.js index 548f1d9b..46ffda65 100644 --- a/src/pages/api/ping.js +++ b/src/pages/api/ping.js @@ -1,4 +1,3 @@ -import { servicesFromConfig } from "utils/config/service-helpers"; import createLogger from "utils/logger"; import { httpProxy } from "utils/proxy/http"; @@ -17,6 +16,6 @@ export default async function handler(req, res) { const [status] = await httpProxy(pingURL); return res.status(200).json({ - status: status, + status, }); }