mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-26 22:11:20 -07:00
Performance: fetch all docker container statuses in one request (#7092)
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
@@ -4,13 +4,16 @@ import useSWR from "swr";
|
||||
export default function Status({ service, style }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { data, error } = useSWR(`/api/docker/status/${service.container}/${service.server || ""}`);
|
||||
const { data: response, error } = useSWR(`/api/docker/statuses?server=${encodeURIComponent(service.server || "")}`);
|
||||
const statusError = error ?? response?.error;
|
||||
const { statuses } = response ?? {};
|
||||
const data = statuses ? (statuses[service.container] ?? { status: "not found" }) : undefined;
|
||||
|
||||
let statusLabel = t("docker.unknown");
|
||||
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) {
|
||||
if (statusError) {
|
||||
statusLabel = t("docker.error");
|
||||
colorClass = "text-rose-500/80";
|
||||
} else if (data) {
|
||||
|
||||
Reference in New Issue
Block a user