feat: Add AnalyzerManager component to dynamically bind and display simulation analysis data on the dashboard.
This commit is contained in:
@@ -70,6 +70,43 @@ const AnalyzerManager: React.FC = () => {
|
||||
const path = dataValueStr.startsWith("global.") ? dataValueStr.replace("global.", "") : dataValueStr;
|
||||
|
||||
value = resolvePath(metrics, path);
|
||||
|
||||
if (path.includes("predictiveInsights") && Array.isArray(value)) {
|
||||
// 1. Format text
|
||||
value = value
|
||||
.map((item: any) => {
|
||||
if (typeof item === "string") return `• ${item}`;
|
||||
return item.description ? `• ${item.description}` : item.recommendation ? `• ${item.recommendation}` : item.metric ? `• ${item.metric}: ${item.trend}` : "";
|
||||
})
|
||||
.filter((s: string) => s)
|
||||
.join("\n");
|
||||
|
||||
// 2. Apply Custom UI Styles for Insights
|
||||
setTimeout(() => {
|
||||
const container = document.querySelector(`[data-element-id="${element.elementUuid}"]`) as HTMLElement;
|
||||
const textElem = container?.querySelector(".value-text") as HTMLElement;
|
||||
|
||||
if (container && textElem) {
|
||||
// Container Styles
|
||||
container.style.width = "auto";
|
||||
container.style.height = "auto";
|
||||
container.style.minWidth = "280px";
|
||||
container.style.maxWidth = "500px";
|
||||
container.style.zIndex = "10"; // Bring to front
|
||||
|
||||
// Text Styles
|
||||
textElem.style.whiteSpace = "pre-wrap"; // Handle newlines
|
||||
textElem.style.textAlign = "left";
|
||||
textElem.style.fontSize = "12px";
|
||||
textElem.style.lineHeight = "1.5";
|
||||
textElem.style.maxHeight = "300px";
|
||||
textElem.style.overflowY = "auto";
|
||||
|
||||
// Optional: Add some padding if needed, assuming class controls it usually
|
||||
// container.style.padding = "8px";
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Handle Asset Specific
|
||||
|
||||
@@ -26,7 +26,7 @@ function Simulation() {
|
||||
const { analysis } = analysisStore();
|
||||
|
||||
useEffect(() => {
|
||||
console.log("analysis: ", analysis);
|
||||
// console.log("analysis: ", analysis);
|
||||
}, [analysis]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user