feat: Implement AnalyzerManager for dynamic simulation analysis data binding to dashboard label-value and graph elements, including custom predictive insight UI.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -183,7 +183,11 @@ const ElementData: React.FC<ElementDataProps> = ({
|
||||
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);
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user