diff --git a/docs/configs/settings.md b/docs/configs/settings.md index 50066db8..1e313724 100644 --- a/docs/configs/settings.md +++ b/docs/configs/settings.md @@ -382,9 +382,9 @@ If you have both set the per-service settings take precedence. ## Status Style -You can choose from the following styles for status / ping: `dot` or `basic` +You can choose from the following styles for docker or k8s status and ping: `dot` or `basic` -The default is no value, and displays the ping response time in ms. `dot` shows a green dot for a successful ping, and `basic` shows either ONLINE or OFFLINE to match the status style of Docker containers. For example: +The default is no value, and displays the ping response time in ms. `dot` shows a green dot for a successful ping or healthy status, and `basic` shows either ONLINE or OFFLINE to match the status style of Docker containers. For example: ```yaml - Sonarr: diff --git a/src/components/services/item.jsx b/src/components/services/item.jsx index 3d661382..d3dfedcb 100644 --- a/src/components/services/item.jsx +++ b/src/components/services/item.jsx @@ -77,7 +77,7 @@ export default function Item({ service, group }) { )} -
+
{service.ping && (
@@ -91,7 +91,7 @@ export default function Item({ service, group }) { onClick={() => (statsOpen ? closeStats() : setStatsOpen(true))} className="flex-shrink-0 flex items-center justify-center cursor-pointer service-tag service-container-stats" > - + View container stats )} @@ -101,7 +101,7 @@ export default function Item({ service, group }) { onClick={() => (statsOpen ? closeStats() : setStatsOpen(true))} className="flex-shrink-0 flex items-center justify-center cursor-pointer service-tag service-app" > - + View container stats )} diff --git a/src/components/services/kubernetes-status.jsx b/src/components/services/kubernetes-status.jsx index 41302994..81509dde 100644 --- a/src/components/services/kubernetes-status.jsx +++ b/src/components/services/kubernetes-status.jsx @@ -5,31 +5,35 @@ export default function KubernetesStatus({ service }) { const podSelectorString = service.podSelector !== undefined ? `podSelector=${service.podSelector}` : ""; const { data, error } = useSWR(`/api/kubernetes/status/${service.namespace}/${service.app}?${podSelectorString}`); + let statusLabel = t("docker.unknown"); + let statusTitle = ""; + let backgroundClass = "px-1.5 py-0.5 bg-theme-500/10 dark:bg-theme-900/50"; + let colorClass = "text-black/20 dark:text-white/40 "; + if (error) { -
-
{t("docker.error")}
-
+ statusLabel = statusTitle = t("docker.error"); + colorClass = "text-rose-500/80"; + } else if (data) { + if (data.status === "running") { + statusLabel = statusTitle = data.health ?? data.status; + colorClass = "text-emerald-500/80"; + } + + if (data.status === "not found" || data.status === "down" || data.status === "partial") { + statusLabel = statusTitle = data.status; + colorClass = "text-orange-400/50 dark:text-orange-400/80"; + } } - if (data && data.status === "running") { - return ( -
-
{data.health ?? data.status}
-
- ); - } - - if (data && (data.status === "not found" || data.status === "down" || data.status === "partial")) { - return ( -
-
{data.status}
-
- ); + if (style === 'dot') { + colorClass = colorClass.replace('text-', 'bg-').replace(/\/\d\d$/, ''); + backgroundClass = "p-3 hover:bg-theme-500/10 dark:hover:bg-theme-900/50"; } return ( -
-
{t("docker.unknown")}
+
+ {style !== 'dot' &&
{statusLabel}
} + {style == 'dot' &&
}
); } diff --git a/src/components/services/ping.jsx b/src/components/services/ping.jsx index 29c7c375..5c131516 100644 --- a/src/components/services/ping.jsx +++ b/src/components/services/ping.jsx @@ -8,7 +8,7 @@ export default function Ping({ group, service, style }) { }); let colorClass = "" - let backgroundClass = "bg-theme-500/10 dark:bg-theme-900/50"; + let backgroundClass = "bg-theme-500/10 dark:bg-theme-900/50 px-1.5 py-0.5"; let statusTitle = "HTTP status"; let statusText; @@ -42,17 +42,14 @@ export default function Ping({ group, service, style }) { } if (style === "dot") { - backgroundClass = colorClass.replace('text-', 'bg-').replace(/\/\d\d$/, '') + backgroundClass = 'p-3'; + colorClass = colorClass.replace('text-', 'bg-').replace(/\/\d\d$/, ''); } return ( - <> - {style !== 'dot' && -
-
{statusText}
-
- } - {style == 'dot' &&
} - +
+ {style !== 'dot' &&
{statusText}
} + {style == 'dot' &&
} +
); } diff --git a/src/components/services/status.jsx b/src/components/services/status.jsx index 18b871b8..800480c8 100644 --- a/src/components/services/status.jsx +++ b/src/components/services/status.jsx @@ -1,65 +1,58 @@ import { useTranslation } from "react-i18next"; import useSWR from "swr"; -export default function Status({ service }) { +export default function Status({ service, style }) { const { t } = useTranslation(); const { data, error } = useSWR(`/api/docker/status/${service.container}/${service.server || ""}`); + let statusLabel = t("docker.unknown"); + let statusTitle = ""; + let backgroundClass = "px-1.5 py-0.5 bg-theme-500/10 dark:bg-theme-900/50"; + let colorClass = "text-black/20 dark:text-white/40 "; + if (error) { -
-
{t("docker.error")}
-
- } - - if (data) { - let statusLabel = ""; - + statusTitle = t("docker.error"); + colorClass = "text-rose-500/80"; + } else if (data) { if (data.status?.includes("running")) { if (data.health === "starting") { - return ( -
-
{t("docker.starting")}
-
- ); + statusTitle = t("docker.starting"); + colorClass = "text-blue-500/80"; } if (data.health === "unhealthy") { - return ( -
-
{t("docker.unhealthy")}
-
- ); + statusTitle = t("docker.unhealthy"); + colorClass = "text-orange-400/50 dark:text-orange-400/80"; } if (!data.health) { - statusLabel = data.status.replace("running", t("docker.running")) + statusLabel = data.status.replace("running", t("docker.running")); } else { - statusLabel = data.health === "healthy" ? t("docker.healthy") : data.health + statusLabel = data.health === "healthy" ? t("docker.healthy") : data.health; } - return ( -
-
{statusLabel}
-
- ); + statusTitle = statusLabel; + colorClass = "text-emerald-500/80"; } if (data.status === "not found" || data.status === "exited" || data.status?.startsWith("partial")) { if (data.status === "not found") statusLabel = t("docker.not_found") else if (data.status === "exited") statusLabel = t("docker.exited") else statusLabel = data.status.replace("partial", t("docker.partial")) - return ( -
-
{statusLabel}
-
- ); + colorClass = "text-orange-400/50 dark:text-orange-400/80"; } } + if (style === 'dot') { + colorClass = colorClass.replace('text-', 'bg-').replace(/\/\d\d$/, ''); + backgroundClass = "p-3 hover:bg-theme-500/10 dark:hover:bg-theme-900/50"; + } + return ( -
-
{t("docker.unknown")}
+
+ {style !== 'dot' &&
{statusLabel}
} + {style == 'dot' &&
}
); }