diff --git a/src/components/services/kubernetes-status.jsx b/src/components/services/kubernetes-status.jsx index 06dde6fa..4739980b 100644 --- a/src/components/services/kubernetes-status.jsx +++ b/src/components/services/kubernetes-status.jsx @@ -6,7 +6,7 @@ export default function KubernetesStatus({ service }) { const { data, error } = useSWR(`/api/kubernetes/status/${service.namespace}/${service.app}?${podSelectorString}`); if (error) { - <div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={data.status}> + <div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={t("docker.error")}> <div className="text-[8px] font-bold text-rose-500/80 uppercase">{t("docker.error")}</div> </div> } diff --git a/src/components/services/status.jsx b/src/components/services/status.jsx index 70cad6b2..7ef6a079 100644 --- a/src/components/services/status.jsx +++ b/src/components/services/status.jsx @@ -7,52 +7,54 @@ export default function Status({ service }) { const { data, error } = useSWR(`/api/docker/status/${service.container}/${service.server || ""}`); if (error) { - <div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={data.status}> + <div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={t("docker.error")}> <div className="text-[8px] font-bold text-rose-500/80 uppercase">{t("docker.error")}</div> </div> } - let statusLabel = ""; + if (data) { + let statusLabel = ""; + + if (data.status?.includes("running")) { + if (data.health === "starting") { + return ( + <div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={t("docker.starting")}> + <div className="text-[8px] font-bold text-blue-500/80 uppercase">{t("docker.starting")}</div> + </div> + ); + } + + if (data.health === "unhealthy") { + return ( + <div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={t("docker.unhealthy")}> + <div className="text-[8px] font-bold text-orange-400/50 dark:text-orange-400/80 uppercase">{t("docker.unhealthy")}</div> + </div> + ); + } + + if (!data.health) { + statusLabel = data.status.replace("running", t("docker.running")) + } else { + statusLabel = data.health === "healthy" ? t("docker.healthy") : data.health + } - if (data && data.status?.includes("running")) { - if (data.health === "starting") { return ( - <div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={t("docker.starting")}> - <div className="text-[8px] font-bold text-blue-500/80 uppercase">{t("docker.starting")}</div> + <div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={statusLabel}> + <div className="text-[8px] font-bold text-emerald-500/80 uppercase">{statusLabel}</div> </div> ); } - - if (data.health === "unhealthy") { + + 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 ( - <div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={t("docker.unhealthy")}> - <div className="text-[8px] font-bold text-orange-400/50 dark:text-orange-400/80 uppercase">{t("docker.unhealthy")}</div> + <div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={statusLabel}> + <div className="text-[8px] font-bold text-orange-400/50 dark:text-orange-400/80 uppercase">{statusLabel}</div> </div> ); } - - if (!data.health) { - statusLabel = data.status.replace("running", t("docker.running")) - } else { - statusLabel = data.health === "healthy" ? t("docker.healthy") : data.health - } - - return ( - <div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={statusLabel}> - <div className="text-[8px] font-bold text-emerald-500/80 uppercase">{statusLabel}</div> - </div> - ); - } - - if (data && (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 ( - <div className="w-auto px-1.5 py-0.5 text-center bg-theme-500/10 dark:bg-theme-900/50 rounded-b-[3px] overflow-hidden" title={statusLabel}> - <div className="text-[8px] font-bold text-orange-400/50 dark:text-orange-400/80 uppercase">{statusLabel}</div> - </div> - ); } return (