This commit is contained in:
shamoon 2023-10-04 20:48:53 -07:00
parent cb716120d0
commit e9c00511d9
3 changed files with 10 additions and 7 deletions

View File

@ -1,7 +1,7 @@
import useSWR from "swr";
import { t } from "i18next";
export default function KubernetesStatus({ service }) {
export default function KubernetesStatus({ service, style }) {
const podSelectorString = service.podSelector !== undefined ? `podSelector=${service.podSelector}` : "";
const { data, error } = useSWR(`/api/kubernetes/status/${service.namespace}/${service.app}?${podSelectorString}`);
@ -11,16 +11,19 @@ export default function KubernetesStatus({ service }) {
let colorClass = "text-black/20 dark:text-white/40 ";
if (error) {
statusLabel = statusTitle = t("docker.error");
statusTitle = t("docker.error");
statusLabel = statusTitle;
colorClass = "text-rose-500/80";
} else if (data) {
if (data.status === "running") {
statusLabel = statusTitle = data.health ?? data.status;
statusTitle = data.health ?? data.status;
statusLabel = statusTitle;
colorClass = "text-emerald-500/80";
}
if (data.status === "not found" || data.status === "down" || data.status === "partial") {
statusLabel = statusTitle = data.status;
statusTitle = data.status;
statusLabel = statusTitle;
colorClass = "text-orange-400/50 dark:text-orange-400/80";
}
}
@ -33,7 +36,7 @@ export default function KubernetesStatus({ service }) {
return (
<div className={`w-auto text-center overflow-hidden ${backgroundClass} rounded-b-[3px] k8s-status-${statusLabel.toLowerCase().replace(' ', '')}`} title={statusTitle}>
{style !== 'dot' && <div className={`text-[8px] font-bold ${colorClass} uppercase`}>{statusLabel}</div>}
{style == 'dot' && <div className={`rounded-full h-3 w-3 ${colorClass}`}></div>}
{style === 'dot' && <div className={`rounded-full h-3 w-3 ${colorClass}`}/>}
</div>
);
}

View File

@ -49,7 +49,7 @@ export default function Ping({ group, service, style }) {
return (
<div className={`w-auto text-center rounded-b-[3px] overflow-hidden ping-status ${backgroundClass}`} title={statusTitle}>
{style !== 'dot' && <div className={`font-bold uppercase text-[8px] ${colorClass}`}>{statusText}</div>}
{style == 'dot' && <div className={`rounded-full h-3 w-3 ${colorClass}`}></div>}
{style === 'dot' && <div className={`rounded-full h-3 w-3 ${colorClass}`}/>}
</div>
);
}

View File

@ -52,7 +52,7 @@ export default function Status({ service, style }) {
return (
<div className={`w-auto text-center overflow-hidden ${backgroundClass} rounded-b-[3px] docker-status-${statusLabel.toLowerCase().replace(' ', '')}`} title={statusTitle}>
{style !== 'dot' && <div className={`text-[8px] font-bold ${colorClass} uppercase`}>{statusLabel}</div>}
{style == 'dot' && <div className={`rounded-full h-3 w-3 ${colorClass}`}></div>}
{style === 'dot' && <div className={`rounded-full h-3 w-3 ${colorClass}`}/>}
</div>
);
}