diff --git a/cockpit/fester-module/targets.js b/cockpit/fester-module/targets.js index cf3381a..ed49d7e 100644 --- a/cockpit/fester-module/targets.js +++ b/cockpit/fester-module/targets.js @@ -1,30 +1,84 @@ -async function loadTargets() { +// cockpit/fester-module/targets.js - const res = await fetch("/api/targets"); - const data = await res.json(); +/** + * Fester Targets Module + * Handles nodes, edges, metrics, heatmaps, and live updates for cockpit UI. + */ - const sys = document.getElementById("system"); - const arch = document.getElementById("arch"); - const runtime = document.getElementById("runtime"); +(function(global) { - data.systems.forEach(s => { - let o = document.createElement("option"); - o.value = s; - o.text = s; - sys.appendChild(o); + const targetsModule = { + nodes: {}, + edges: [], + metrics: {}, + heatmaps: {}, + callbacks: [], + + /** + * Register a callback to receive updated DAG data + */ + onUpdate(callback) { + if (typeof callback === 'function') { + this.callbacks.push(callback); + } + }, + + /** + * Update the internal state from WS or iframe message + */ + update(data) { + if (!data) return; + + if (data.nodes) { + data.nodes.forEach(node => this.nodes[node.id] = node); + } + if (data.edges) { + this.edges = data.edges; + } + if (data.metrics) { + Object.assign(this.metrics, data.metrics); + } + if (data.heatmaps) { + Object.assign(this.heatmaps, data.heatmaps); + } + + this.dispatch(); + }, + + /** + * Notify all registered callbacks with the updated data + */ + dispatch() { + const snapshot = { + nodes: Object.values(this.nodes), + edges: this.edges, + metrics: this.metrics, + heatmaps: this.heatmaps + }; + this.callbacks.forEach(cb => cb(snapshot)); + }, + + /** + * Clear all stored DAG state + */ + clear() { + this.nodes = {}; + this.edges = []; + this.metrics = {}; + this.heatmaps = {}; + this.dispatch(); + } + }; + + // Listen for iframe messages from cockpit.html + window.addEventListener('message', (event) => { + const data = event.data; + if (data && typeof data === 'object') { + targetsModule.update(data); + } }); - data.arches.forEach(a => { - let o = document.createElement("option"); - o.value = a; - o.text = a; - arch.appendChild(o); - }); + // Expose module globally + global.FesterTargets = targetsModule; - data.runtimes.forEach(r => { - let o = document.createElement("option"); - o.value = r; - o.text = r; - runtime.appendChild(o); - }); -} +})(window); diff --git a/cockpit/fester-module/ui.html b/cockpit/fester-module/ui.html index 1b2c0a6..2fbb02a 100644 --- a/cockpit/fester-module/ui.html +++ b/cockpit/fester-module/ui.html @@ -1,243 +1,57 @@ - -Fester Debug Cockpit - - + + Fester Cockpit + + - -
- - -
- -

Build Control

- - - - - - - - +
+

Fester Cockpit

+
+
+
Live DAG
+
Replay / Debugger
- -
- - -
-

Node Debugger

-
Select a node
-
- -
+ + diff --git a/ui/live_dag.html b/ui/live_dag.html index 3b1cfaa..520ba21 100644 --- a/ui/live_dag.html +++ b/ui/live_dag.html @@ -1,169 +1,123 @@ - + - Fester Live DAG + Cause Graph - - + +Fester Live DAG + + - -
-
+ + -