v9.47: fix graph modal (overlay, _getInstances, localStorage auth)

This commit is contained in:
Naeel
2026-04-17 09:50:45 +03:00
parent 99f39247e2
commit 5f14a8725f
3 changed files with 21 additions and 19 deletions
+1 -1
View File
@@ -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
+16 -18
View File
@@ -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; })
+4
View File
@@ -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() }; };
})();
</script>