From 5f14a8725fb13583263e778250c24c4c097ec742 Mon Sep 17 00:00:00 2001 From: Naeel Date: Fri, 17 Apr 2026 09:50:45 +0300 Subject: [PATCH] v9.47: fix graph modal (overlay, _getInstances, localStorage auth) --- k8s/deployment.yaml | 2 +- static/graph.js | 34 ++++++++++++++++------------------ static/index.html | 4 ++++ 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index 361d304..9f98a57 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: cloud-dashboard - image: naeel/cloud-dashboard:v9.46 + image: naeel/cloud-dashboard:v9.47 imagePullPolicy: Always ports: - containerPort: 8080 diff --git a/static/graph.js b/static/graph.js index dc26c27..09dab4a 100644 --- a/static/graph.js +++ b/static/graph.js @@ -75,16 +75,16 @@ var graphCache = null; // built SVG string, null = not built yet var building = false; // loading in progress flag - // ── Modal DOM ──────────────────────────────────────────────────────────── - function getModal() { return document.getElementById("graph-modal"); } - function getCanvas() { return document.getElementById("graph-canvas"); } - function getStatus() { return document.getElementById("graph-status"); } + // ── DOM helpers ────────────────────────────────────────────────────────── + function getOverlay() { return document.getElementById("graph-overlay"); } + function getCanvas() { return document.getElementById("graph-canvas"); } + function getStatus() { return document.getElementById("graph-status"); } // ── Open / Close ───────────────────────────────────────────────────────── function openGraph() { - var modal = getModal(); - if (!modal) return; - modal.style.display = "flex"; + var overlay = getOverlay(); + if (!overlay) { console.error("[graph] #graph-overlay not found"); return; } + overlay.style.display = "flex"; if (graphCache) { showCached(); } else if (!building) { @@ -93,8 +93,8 @@ } function closeGraph() { - var modal = getModal(); - if (modal) modal.style.display = "none"; + var overlay = getOverlay(); + if (overlay) overlay.style.display = "none"; } function refreshGraph() { @@ -130,7 +130,7 @@ g.setNode(n.id, { width: n.w || NODE_W, height: n.h || NODE_H, label: n.id }); }); edges.forEach(function (e) { - g.setEdge(e.from, e.to); + if (g.hasNode(e.from) && g.hasNode(e.to)) g.setEdge(e.from, e.to); }); dagre.layout(g); @@ -297,10 +297,10 @@ canvas.innerHTML = ""; setStatus("Строю схему: загрузка инстансов…"); - // Step 1: Use allInstances already loaded in memory - var instances = (typeof allInstances !== "undefined") ? allInstances : []; - if (!instances.length) { - setStatus("Нет данных. Обновите таблицу сначала."); + // Step 1: Use allInstances exposed from IIFE via window._getInstances() + var instances = (typeof window._getInstances === "function") ? window._getInstances() : []; + if (!instances || !instances.length) { + setStatus("Нет данных. Нажмите «Обновить» в таблице, затем откройте схему снова."); building = false; return; } @@ -373,13 +373,11 @@ } var uid = uidList[idx]; - var token = (typeof getToken === "function") ? getToken() : (window.getToken ? window.getToken() : ""); - var env = (typeof getDeckEnv === "function") ? getDeckEnv() : (window.getDeckEnv ? window.getDeckEnv() : "test"); fetch("/dashboard/api/instances/" + uid, { headers: { - "X-Deck-Token": token, - "X-Deck-Env": env + "X-Deck-Token": localStorage.getItem("deck_token") || "", + "X-Deck-Env": localStorage.getItem("deck_env") || "test" } }) .then(function (r) { return r.ok ? r.json() : null; }) diff --git a/static/index.html b/static/index.html index ab9393c..b4f3803 100644 --- a/static/index.html +++ b/static/index.html @@ -1094,6 +1094,10 @@ window.navigateToDep = navigateToDep; window.navBack = navBack; window.copyParamValue = copyParamValue; +// Expose live accessors for graph.js +window._getInstances = function(){ return allInstances; }; +window._apiHeaders = function(){ return { "X-Deck-Token": getToken(), "X-Deck-Env": getDeckEnv() }; }; + })();