Minor status refactoring

pull/2708/head
shamoon 9 months ago
parent 5892d7407c
commit 70f0eb3af6

@ -36,7 +36,6 @@ export default function Item({ service, group, useEqualHeights }) {
<div <div
className={classNames( className={classNames(
settings.cardBlur !== undefined && `backdrop-blur${settings.cardBlur.length ? "-" : ""}${settings.cardBlur}`, settings.cardBlur !== undefined && `backdrop-blur${settings.cardBlur.length ? "-" : ""}${settings.cardBlur}`,
hasLink && "cursor-pointer",
useEqualHeights && "h-[calc(100%-0.5rem)]", useEqualHeights && "h-[calc(100%-0.5rem)]",
"transition-all mb-2 p-1 rounded-md font-medium text-theme-700 dark:text-theme-200 dark:hover:text-theme-300 shadow-md shadow-theme-900/10 dark:shadow-theme-900/20 bg-theme-100/20 hover:bg-theme-300/20 dark:bg-white/5 dark:hover:bg-white/10 relative overflow-clip service-card", "transition-all mb-2 p-1 rounded-md font-medium text-theme-700 dark:text-theme-200 dark:hover:text-theme-300 shadow-md shadow-theme-900/10 dark:shadow-theme-900/20 bg-theme-100/20 hover:bg-theme-300/20 dark:bg-white/5 dark:hover:bg-white/10 relative overflow-clip service-card",
)} )}

@ -7,12 +7,11 @@ export default function Status({ service, style }) {
const { data, error } = useSWR(`/api/docker/status/${service.container}/${service.server || ""}`); const { data, error } = useSWR(`/api/docker/status/${service.container}/${service.server || ""}`);
let statusLabel = t("docker.unknown"); 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 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 "; let colorClass = "text-black/20 dark:text-white/40 ";
if (error) { if (error) {
statusTitle = t("docker.error"); statusLabel = t("docker.error");
colorClass = "text-rose-500/80"; colorClass = "text-rose-500/80";
} else if (data) { } else if (data) {
if (data.status?.includes("running")) { if (data.status?.includes("running")) {
@ -33,8 +32,6 @@ export default function Status({ service, style }) {
colorClass = "text-orange-400/50 dark:text-orange-400/80"; colorClass = "text-orange-400/50 dark:text-orange-400/80";
} }
} }
statusTitle = statusLabel;
} }
if (data.status === "not found" || data.status === "exited" || data.status?.startsWith("partial")) { if (data.status === "not found" || data.status === "exited" || data.status?.startsWith("partial")) {
@ -42,14 +39,12 @@ export default function Status({ service, style }) {
else if (data.status === "exited") statusLabel = t("docker.exited"); else if (data.status === "exited") statusLabel = t("docker.exited");
else statusLabel = data.status.replace("partial", t("docker.partial")); else statusLabel = data.status.replace("partial", t("docker.partial"));
colorClass = "text-orange-400/50 dark:text-orange-400/80"; colorClass = "text-orange-400/50 dark:text-orange-400/80";
statusTitle = statusLabel;
} }
} }
if (style === "dot") { if (style === "dot") {
colorClass = colorClass.replace(/text-/g, "bg-").replace(/\/\d\d/g, ""); colorClass = colorClass.replace(/text-/g, "bg-").replace(/\/\d\d/g, "");
backgroundClass = "p-4 hover:bg-theme-500/10 dark:hover:bg-theme-900/20"; backgroundClass = "p-4 hover:bg-theme-500/10 dark:hover:bg-theme-900/20";
statusTitle = statusLabel;
} }
return ( return (
@ -57,7 +52,7 @@ export default function Status({ service, style }) {
className={`w-auto text-center overflow-hidden ${backgroundClass} rounded-b-[3px] docker-status docker-status-${statusLabel className={`w-auto text-center overflow-hidden ${backgroundClass} rounded-b-[3px] docker-status docker-status-${statusLabel
.toLowerCase() .toLowerCase()
.replace(" ", "-")}`} .replace(" ", "-")}`}
title={statusTitle} title={statusLabel}
> >
{style !== "dot" ? ( {style !== "dot" ? (
<div className={`text-[8px] font-bold ${colorClass} uppercase`}>{statusLabel}</div> <div className={`text-[8px] font-bold ${colorClass} uppercase`}>{statusLabel}</div>

Loading…
Cancel
Save