From e4a6013248b017748990df31d61100d7bac04eeb Mon Sep 17 00:00:00 2001 From: Jerald-Golden-B Date: Mon, 22 Dec 2025 18:03:18 +0530 Subject: [PATCH] feat: Implement AnalyzerManager for dynamic simulation analysis data binding to dashboard label-value and graph elements, including custom predictive insight UI. --- .../SimulationDashboard/AnalyzerManager.tsx | 22 ++++++++++--------- .../components/element/ElementData.tsx | 6 ++++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/src/components/SimulationDashboard/AnalyzerManager.tsx b/app/src/components/SimulationDashboard/AnalyzerManager.tsx index d5def2d..f34e7e0 100644 --- a/app/src/components/SimulationDashboard/AnalyzerManager.tsx +++ b/app/src/components/SimulationDashboard/AnalyzerManager.tsx @@ -144,8 +144,14 @@ const AnalyzerManager: React.FC = () => { const rawDataValue = element.dataBinding.dataValue; const dataKeys = Array.isArray(rawDataValue) ? rawDataValue : [rawDataValue as string]; - const assetAnalysis = getAssetAnalysis(assetId); - if (assetAnalysis) { + let dataObject: any = null; + if (assetId === "global") { + dataObject = getSystemMetrics(); + } else { + dataObject = getAssetAnalysis(assetId); + } + + if (dataObject) { let newGraphData: GraphDataPoint[] = []; if (element.graphType === "line") { @@ -155,16 +161,11 @@ const AnalyzerManager: React.FC = () => { const dataPoint: GraphDataPoint = { name: timeStr, value: 0 }; dataKeys.forEach((key) => { - const val = resolvePath(assetAnalysis, key); + const path = assetId === "global" && key.startsWith("global.") ? key.replace("global.", "") : key; + const val = resolvePath(dataObject, path); dataPoint[key] = typeof val === "number" ? val : 0; }); - // Add slight variations if values are static to make it "live" as requested (optional, but requested "up and down") - // If the user feels the values are strictly from store, I should stick to store. - // "makeing the lines go up dna down as times goes on" - // If I just use store values, they might be flat. - // I will stick to store values. The user's system likely updates `analysis`. - history.push(dataPoint); if (history.length > 20) history.shift(); @@ -172,7 +173,8 @@ const AnalyzerManager: React.FC = () => { lineChartHistory.current.set(element.elementUuid, history); } else { newGraphData = dataKeys.map((key) => { - const val = resolvePath(assetAnalysis, key); + const path = assetId === "global" && key.startsWith("global.") ? key.replace("global.", "") : key; + const val = resolvePath(dataObject, path); return { // Make the key readable or just use it as name name: key.split(".").pop() || key, diff --git a/app/src/components/SimulationDashboard/components/element/ElementData.tsx b/app/src/components/SimulationDashboard/components/element/ElementData.tsx index 43f5520..75d50ef 100644 --- a/app/src/components/SimulationDashboard/components/element/ElementData.tsx +++ b/app/src/components/SimulationDashboard/components/element/ElementData.tsx @@ -183,7 +183,11 @@ const ElementData: React.FC = ({ key={field.id} label={field.label} options={field.options} - selected={getEventByModelUuid(selectedProduct.productUuid, element.dataBinding?.dataSource as string)?.modelName ?? ""} + selected={ + element.dataBinding?.dataSource === "global" + ? "Global" + : getEventByModelUuid(selectedProduct.productUuid, element.dataBinding?.dataSource as string)?.modelName ?? "" + } onSelect={(value) => { updateDataSource(selectedBlock, selectedElement, value.id); }}