(function(SS) { 'use strict'; let uiContent function loadSVG(url) { fetch(url) .then(response => response.text()) .then(svgContent => { const container = document.getElementById('svg-container'); container.src = url; uiContent = svgContent; }) .catch(err => console.error('Failed to load SVG:', err)); } window.onload = function() { loadSVG('/ui'); }; document.getElementById('send-request').addEventListener('click', function() { const input = document.getElementById('payload'); const payloadData = JSON.parse(input.value); const data = { payload: payloadData }; fetch('/request', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(data), }) .then(response => { const contentType = response.headers.get('Content-Type'); if (contentType && contentType.includes("text/html")) { return response.text().then(html => ({ html })); } else { return response.json(); } }) .then(data => { if (data.html) { const el = document.getElementById("response"); el.innerHTML = data.html; } else { console.log("Success", data); } }) .catch(error => console.error('Error:', error)); }); const tasks = {}; function attachSVGNodeEvents() { const svgNodes = document.querySelectorAll('g.node'); // Adjust selector as per your SVG structure svgNodes.forEach(node => { node.classList.add("cursor-pointer") node.addEventListener('click', handleSVGNodeClick); }); } // Function to handle the click on an SVG node and show the popover function handleSVGNodeClick(event) { const nodeId = event.currentTarget.id; // Get the node ID (e.g., 'node_store:data') const nodeData = findNodeDataById(nodeId); // Fetch data related to the node (status, result, etc.) if (nodeData) { showSVGPopover(event, nodeData); } } // Function to show the popover next to the clicked SVG node function showSVGPopover(event, nodeData) { const popover = document.getElementById('svg-popover'); document.getElementById('task-id').innerHTML = nodeData.task_id popover.classList.add('visible'); popover.innerHTML = `
${JSON.stringify(nodeData.payload, null, 2)}Error: ${nodeData.error || 'N/A'} Created At: ${nodeData.created_at} Processed At: ${nodeData.processed_at} Latency: ${nodeData.latency}