From 2a08ad6989c30845bb9c32c3ff3431e3ee265bdc Mon Sep 17 00:00:00 2001 From: kodi Date: Wed, 18 Feb 2026 11:41:48 +0100 Subject: [PATCH] feat(containers-dashboard): voeg host_ip toe aan gepubliceerde poorten en corrigeer portweergave --- control/Dockerfile | 2 +- control/app.py | 26 ++++++++++++++++++++++++++ webui/html/index.html | 5 ++--- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/control/Dockerfile b/control/Dockerfile index af16247..6384756 100644 --- a/control/Dockerfile +++ b/control/Dockerfile @@ -3,5 +3,5 @@ WORKDIR /app RUN apt-get update && apt-get install -y curl systemd && rm -rf /var/lib/apt/lists/* RUN pip install fastapi uvicorn requests-unixsocket pyyaml pytest httpx COPY app.py . -COPY tests/ ./tests/ +#COPY tests/ ./tests/ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/control/app.py b/control/app.py index ad4f8a8..6922b76 100644 --- a/control/app.py +++ b/control/app.py @@ -439,6 +439,31 @@ def find_defined_containers(): defined[name] = rel return defined +def _extract_published_ports(container: dict) -> list[str]: + """ + Normalize Podman API Ports into a stable display list: + - "127.0.0.1:8080:8000/tcp" + - "8080:8000/tcp" (if no host ip) + """ + out: list[str] = [] + for p in (container.get("Ports") or []): + host_ip = p.get("host_ip") or p.get("HostIp") or "" + host_port = p.get("host_port") or p.get("HostPort") + cont_port = p.get("container_port") or p.get("ContainerPort") + proto = p.get("protocol") or p.get("Protocol") or "" + + if host_port is None or cont_port is None: + continue + + s = "" + if host_ip: + s += f"{host_ip}:" + s += f"{host_port}:{cont_port}" + if proto: + s += f"/{proto}" + out.append(s) + + return out @app.get("/containers-dashboard") def containers_dashboard(): @@ -449,6 +474,7 @@ def containers_dashboard(): for c in real: _ensure_container_status_field(c) c["_dashboard_source"] = "podman" + c["_dashboard_published_ports"] = _extract_published_ports(c) dashboard.append(c) # B) Dedup set (HOTFIX 3.3) — exact extraction, no sorting diff --git a/webui/html/index.html b/webui/html/index.html index c0276b4..ab2efb5 100644 --- a/webui/html/index.html +++ b/webui/html/index.html @@ -635,9 +635,8 @@ const podName = c.PodName || '-'; const image = c.Image || c.image || ''; const managed = c._dashboard_source || 'podman'; - const ports = (c.Ports || []).map(p => - `${p.host_port}:${p.container_port}` - ).join(", "); + const ports = (c._dashboard_published_ports || []).join(", ") + || (c.Ports || []).map(p => `${p.host_port}:${p.container_port}`).join(", "); return ` ${esc(name)}