diff --git a/src/components/services/item.jsx b/src/components/services/item.jsx index 6528a7b5c..aaee81cd1 100644 --- a/src/components/services/item.jsx +++ b/src/components/services/item.jsx @@ -29,8 +29,6 @@ export default function Item({ service, group }) { } }; - - return (
  • {service.ping && (
    - + Ping status
    )} diff --git a/src/components/services/ping.jsx b/src/components/services/ping.jsx index 27ea92eff..a14fa6602 100644 --- a/src/components/services/ping.jsx +++ b/src/components/services/ping.jsx @@ -1,7 +1,7 @@ import { useTranslation } from "react-i18next"; import useSWR from "swr"; -export default function Ping({ group, service }) { +export default function Ping({ group, service, style }) { const { t } = useTranslation(); const { data, error } = useSWR(`/api/ping?${new URLSearchParams({ group, service }).toString()}`, { refreshInterval: 30000 @@ -23,20 +23,41 @@ export default function Ping({ group, service }) { ); } - const statusText = `${service}: HTTP status ${data.status}`; - + var statusText = `HTTP status ${data.status}`; + var status; + if (data.status > 403) { + if (style === "basic") { + status = t("docker.offline") + } else if (style === "dot") { + status = "◉" + } else { + status = data.status + } + return (
    -
    {data.status}
    +
    {status}
    ); } - + + // Sucessful ping + var ping = t("common.ms", { value: data.latency, style: "unit", unit: "millisecond", maximumFractionDigits: 0 }) + + statusText += ` (${ping})`; + + if (style === "basic") { + status = t("docker.running") + } else if (style === "dot") { + status = "◉" + } else { + status = ping + } + return (
    -
    {t("common.ms", { value: data.latency, style: "unit", unit: "millisecond", maximumFractionDigits: 0 })}
    +
    {status}
    ); - }