diff --git a/src/components/services/ping.jsx b/src/components/services/ping.jsx index d6fc61a4d..7a5026a92 100644 --- a/src/components/services/ping.jsx +++ b/src/components/services/ping.jsx @@ -7,57 +7,52 @@ export default function Ping({ group, service, style }) { refreshInterval: 30000 }); - if (error) { - return ( -
-
{t("ping.error")}
-
- ); - } - - if (!data) { - return ( -
-
{t("ping.ping")}
-
- ); - } - - let statusText = `HTTP status ${data.status}`; - let status; + let textSize = "text-[8px]"; + let colorClass = "" + let backgroundClass = "bg-theme-500/10 dark:bg-theme-900/50"; + let statusTitle = "HTTP status"; + let statusText; - if (data.status > 403) { + if (error) { + colorClass = "text-rose-500" + statusText = t("ping.error") + statusTitle += " error" + } else if (!data) { + colorClass = "text-black/20 dark:text-white/40" + statusText = t("ping.ping") + statusTitle += " not available" + } else if (data.status > 403) { + colorClass = "text-rose-500/80" + statusTitle += ` ${data.status}` + if (style === "basic") { - status = t("docker.offline") + statusText = t("docker.offline") } else if (style === "dot") { - status = "◉" + statusText = "◉" + textSize += "text-[10px]" + backgroundClass = "" } else { - status = data.status + statusText = data.status } - - return ( -
-
{status}
-
- ); - } - - // Sucessful ping - const 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 + const ping = t("common.ms", { value: data.latency, style: "unit", unit: "millisecond", maximumFractionDigits: 0 }) + statusTitle += ` ${data.status} (${ping})`; + colorClass = "text-emerald-500/80" + + if (style === "basic") { + statusText = t("docker.running") + } else if (style === "dot") { + statusText = "◉" + textSize += "text-[10px]" + backgroundClass = "" + } else { + statusText = ping + } } return ( -
-
{status}
+
+
{statusText}
); }