feat(dashboardapi): emittedFields metadata for parent-panel dedup (#37)
Adds per-panel `meta.emittedFields` to machine.json (rotatingMachine) and machineGroup.json (MGC) templates. Each non-row panel declares the Influx field paths it visualizes, so a parent template's composer can filter out panels already covered by its children (#39 no-data-duplication rule). - config/machine.json: 13 non-row panels annotated. - config/machineGroup.json: panels annotated. - src/specificClass.js: collectEmittedFields(dashboard) helper. - test/basic/slice37-emitted-fields.basic.test.js: 4 cases (template loads with annotations, aggregation, missing-meta graceful, null input). PRD F-6 panel set audit: machine.json already covers all the PRD-required panels (State/Mode/Ctrl%/Runtime/NCog%/Flow/Efficiency/Pressure/Temperature/ Diagnostics) — substantially more than asked. No new panels added. PRD F-7 predicted-vs-measured side-by-side: deferred. Current architecture is "1 dashboard per node" (each child gets its own dashboard, cross-linked from the parent), not "1 dashboard with N composed panels." Side-by-side rendering of predicted (rotatingMachine dashboard) + measured (measurement child dashboard) lives naturally as drill-down navigation today. Refactor to a single-dashboard composition model would be substantial — flagged in the issue comment for v2 if the drill-down UX proves insufficient. Closes #37
This commit is contained in:
@@ -105,6 +105,18 @@ class DashboardApi {
|
||||
return JSON.parse(raw);
|
||||
}
|
||||
|
||||
// Collect every `meta.emittedFields` declared by panels in a template.
|
||||
// Used by #39's parent panel filter — a parent panel whose emittedFields
|
||||
// are fully covered by its children's panels is removed.
|
||||
collectEmittedFields(dashboard) {
|
||||
const out = new Set();
|
||||
for (const panel of dashboard?.panels || []) {
|
||||
const fields = panel?.meta?.emittedFields;
|
||||
if (Array.isArray(fields)) for (const f of fields) out.add(f);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
grafanaUpsertUrl() {
|
||||
const { protocol, host, port } = this.config.grafanaConnector;
|
||||
return `${protocol}://${host}:${port}/api/dashboards/db`;
|
||||
|
||||
Reference in New Issue
Block a user