Compare commits
8 Commits
slice/35-m
...
dc08c85409
| Author | SHA1 | Date | |
|---|---|---|---|
| dc08c85409 | |||
| 2b745dfb51 | |||
| 3c8427ed7a | |||
| 8964b0b638 | |||
| a76f22281e | |||
| e5099de986 | |||
| 8639b02e6a | |||
| aac71eb129 |
1041
config/machine.json
1041
config/machine.json
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,10 @@
|
|||||||
"list": [
|
"list": [
|
||||||
{
|
{
|
||||||
"builtIn": 1,
|
"builtIn": 1,
|
||||||
"datasource": { "type": "grafana", "uid": "-- Grafana --" },
|
"datasource": {
|
||||||
|
"type": "grafana",
|
||||||
|
"uid": "-- Grafana --"
|
||||||
|
},
|
||||||
"enable": true,
|
"enable": true,
|
||||||
"hide": true,
|
"hide": true,
|
||||||
"iconColor": "rgba(0, 211, 255, 1)",
|
"iconColor": "rgba(0, 211, 255, 1)",
|
||||||
@@ -17,93 +20,505 @@
|
|||||||
"id": null,
|
"id": null,
|
||||||
"links": [],
|
"links": [],
|
||||||
"panels": [
|
"panels": [
|
||||||
{ "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 }, "id": 1, "title": "Status", "type": "row" },
|
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"gridPos": {
|
||||||
"fieldConfig": { "defaults": { "thresholds": { "mode": "absolute", "steps": [{ "color": "purple", "value": null }] } }, "overrides": [] },
|
"h": 1,
|
||||||
"gridPos": { "h": 4, "w": 6, "x": 0, "y": 1 },
|
"w": 24,
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"id": 1,
|
||||||
|
"title": "Status",
|
||||||
|
"type": "row"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "influxdb",
|
||||||
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "purple",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 6,
|
||||||
|
"x": 0,
|
||||||
|
"y": 1
|
||||||
|
},
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"] }, "colorMode": "value", "graphMode": "none" },
|
"options": {
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "none"
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field==\"mode\")\n |> last()", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field==\"mode\")\n |> last()",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Mode",
|
"title": "Mode",
|
||||||
"type": "stat"
|
"type": "stat",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"mode"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"datasource": {
|
||||||
"fieldConfig": { "defaults": { "thresholds": { "mode": "absolute", "steps": [{ "color": "blue", "value": null }] } }, "overrides": [] },
|
"type": "influxdb",
|
||||||
"gridPos": { "h": 4, "w": 6, "x": 6, "y": 1 },
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "blue",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 6,
|
||||||
|
"x": 6,
|
||||||
|
"y": 1
|
||||||
|
},
|
||||||
"id": 3,
|
"id": 3,
|
||||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"] }, "colorMode": "value", "graphMode": "none" },
|
"options": {
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "none"
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field==\"scaling\")\n |> last()", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field==\"scaling\")\n |> last()",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Scaling",
|
"title": "Scaling",
|
||||||
"type": "stat"
|
"type": "stat",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"scaling"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"datasource": {
|
||||||
"fieldConfig": { "defaults": { "thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }, { "color": "yellow", "value": 5 }, { "color": "red", "value": 15 }] } }, "overrides": [] },
|
"type": "influxdb",
|
||||||
"gridPos": { "h": 4, "w": 6, "x": 12, "y": 1 },
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "yellow",
|
||||||
|
"value": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": 15
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 6,
|
||||||
|
"x": 12,
|
||||||
|
"y": 1
|
||||||
|
},
|
||||||
"id": 4,
|
"id": 4,
|
||||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"] }, "colorMode": "value", "graphMode": "area" },
|
"options": {
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "area"
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field==\"absDistFromPeak\")\n |> last()", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field==\"absDistFromPeak\")\n |> last()",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Abs Dist Peak",
|
"title": "Abs Dist Peak",
|
||||||
"type": "stat"
|
"type": "stat",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"absDistFromPeak"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"datasource": {
|
||||||
"fieldConfig": { "defaults": { "unit": "percent", "thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }, { "color": "yellow", "value": 10 }, { "color": "red", "value": 25 }] } }, "overrides": [] },
|
"type": "influxdb",
|
||||||
"gridPos": { "h": 4, "w": 6, "x": 18, "y": 1 },
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "percent",
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "yellow",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": 25
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 6,
|
||||||
|
"x": 18,
|
||||||
|
"y": 1
|
||||||
|
},
|
||||||
"id": 5,
|
"id": 5,
|
||||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"] }, "colorMode": "value", "graphMode": "area" },
|
"options": {
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "area"
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field==\"relDistFromPeak\")\n |> last()", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field==\"relDistFromPeak\")\n |> last()",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Rel Dist Peak",
|
"title": "Rel Dist Peak",
|
||||||
"type": "stat"
|
"type": "stat",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"relDistFromPeak"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{ "gridPos": { "h": 1, "w": 24, "x": 0, "y": 5 }, "id": 6, "title": "Totals", "type": "row" },
|
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"gridPos": {
|
||||||
"fieldConfig": { "defaults": { "custom": { "drawStyle": "line", "lineWidth": 2, "fillOpacity": 10 } }, "overrides": [] },
|
"h": 1,
|
||||||
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 6 },
|
"w": 24,
|
||||||
|
"x": 0,
|
||||||
|
"y": 5
|
||||||
|
},
|
||||||
|
"id": 6,
|
||||||
|
"title": "Totals",
|
||||||
|
"type": "row"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "influxdb",
|
||||||
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"custom": {
|
||||||
|
"drawStyle": "line",
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"matcher": {
|
||||||
|
"id": "byRegexp",
|
||||||
|
"options": ".+\\.min$"
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": "custom.lineStyle",
|
||||||
|
"value": {
|
||||||
|
"fill": "dash",
|
||||||
|
"dash": [
|
||||||
|
10,
|
||||||
|
10
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "color",
|
||||||
|
"value": {
|
||||||
|
"mode": "fixed",
|
||||||
|
"fixedColor": "orange"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matcher": {
|
||||||
|
"id": "byRegexp",
|
||||||
|
"options": ".+\\.max$"
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": "custom.lineStyle",
|
||||||
|
"value": {
|
||||||
|
"fill": "dash",
|
||||||
|
"dash": [
|
||||||
|
10,
|
||||||
|
10
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "color",
|
||||||
|
"value": {
|
||||||
|
"mode": "fixed",
|
||||||
|
"fixedColor": "red"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 8,
|
||||||
|
"w": 12,
|
||||||
|
"x": 0,
|
||||||
|
"y": 6
|
||||||
|
},
|
||||||
"id": 7,
|
"id": 7,
|
||||||
"options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } },
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom"
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi"
|
||||||
|
}
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /predicted_flow|flow/)\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /predicted_flow|flow/)\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Total Flow",
|
"title": "Total Flow",
|
||||||
"type": "timeseries"
|
"type": "timeseries",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"flow.total",
|
||||||
|
"flow.group"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"datasource": {
|
||||||
"fieldConfig": { "defaults": { "custom": { "drawStyle": "line", "lineWidth": 2, "fillOpacity": 10 } }, "overrides": [] },
|
"type": "influxdb",
|
||||||
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 6 },
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"custom": {
|
||||||
|
"drawStyle": "line",
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"matcher": {
|
||||||
|
"id": "byRegexp",
|
||||||
|
"options": ".+\\.min$"
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": "custom.lineStyle",
|
||||||
|
"value": {
|
||||||
|
"fill": "dash",
|
||||||
|
"dash": [
|
||||||
|
10,
|
||||||
|
10
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "color",
|
||||||
|
"value": {
|
||||||
|
"mode": "fixed",
|
||||||
|
"fixedColor": "orange"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matcher": {
|
||||||
|
"id": "byRegexp",
|
||||||
|
"options": ".+\\.max$"
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": "custom.lineStyle",
|
||||||
|
"value": {
|
||||||
|
"fill": "dash",
|
||||||
|
"dash": [
|
||||||
|
10,
|
||||||
|
10
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "color",
|
||||||
|
"value": {
|
||||||
|
"mode": "fixed",
|
||||||
|
"fixedColor": "red"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 8,
|
||||||
|
"w": 12,
|
||||||
|
"x": 12,
|
||||||
|
"y": 6
|
||||||
|
},
|
||||||
"id": 8,
|
"id": 8,
|
||||||
"options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } },
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom"
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi"
|
||||||
|
}
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /predicted_power|power/)\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /predicted_power|power/)\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Total Power",
|
"title": "Total Power",
|
||||||
"type": "timeseries"
|
"type": "timeseries",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"power.total",
|
||||||
|
"power.group"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"schemaVersion": 39,
|
"schemaVersion": 39,
|
||||||
"tags": ["EVOLV", "machineGroup", "template"],
|
"tags": [
|
||||||
|
"EVOLV",
|
||||||
|
"machineGroup",
|
||||||
|
"template"
|
||||||
|
],
|
||||||
"templating": {
|
"templating": {
|
||||||
"list": [
|
"list": [
|
||||||
{ "name": "dbase", "type": "custom", "label": "dbase", "query": "cdzg44tv250jkd", "current": { "text": "cdzg44tv250jkd", "value": "cdzg44tv250jkd", "selected": false }, "options": [{ "text": "cdzg44tv250jkd", "value": "cdzg44tv250jkd", "selected": true }], "hide": 2 },
|
{
|
||||||
{ "name": "measurement", "type": "custom", "query": "template", "current": { "text": "template", "value": "template", "selected": false }, "options": [{ "text": "template", "value": "template", "selected": true }] },
|
"name": "dbase",
|
||||||
{ "name": "bucket", "type": "custom", "query": "lvl2", "current": { "text": "lvl2", "value": "lvl2", "selected": false }, "options": [{ "text": "lvl2", "value": "lvl2", "selected": true }] }
|
"type": "custom",
|
||||||
|
"label": "dbase",
|
||||||
|
"query": "cdzg44tv250jkd",
|
||||||
|
"current": {
|
||||||
|
"text": "cdzg44tv250jkd",
|
||||||
|
"value": "cdzg44tv250jkd",
|
||||||
|
"selected": false
|
||||||
|
},
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"text": "cdzg44tv250jkd",
|
||||||
|
"value": "cdzg44tv250jkd",
|
||||||
|
"selected": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hide": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "measurement",
|
||||||
|
"type": "custom",
|
||||||
|
"query": "template",
|
||||||
|
"current": {
|
||||||
|
"text": "template",
|
||||||
|
"value": "template",
|
||||||
|
"selected": false
|
||||||
|
},
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"text": "template",
|
||||||
|
"value": "template",
|
||||||
|
"selected": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bucket",
|
||||||
|
"type": "custom",
|
||||||
|
"query": "lvl2",
|
||||||
|
"current": {
|
||||||
|
"text": "lvl2",
|
||||||
|
"value": "lvl2",
|
||||||
|
"selected": false
|
||||||
|
},
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"text": "lvl2",
|
||||||
|
"value": "lvl2",
|
||||||
|
"selected": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"time": { "from": "now-6h", "to": "now" },
|
"time": {
|
||||||
|
"from": "now-6h",
|
||||||
|
"to": "now"
|
||||||
|
},
|
||||||
"timezone": "",
|
"timezone": "",
|
||||||
"title": "template",
|
"title": "template",
|
||||||
"uid": null,
|
"uid": null,
|
||||||
"version": 1
|
"version": 1
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,10 @@
|
|||||||
"list": [
|
"list": [
|
||||||
{
|
{
|
||||||
"builtIn": 1,
|
"builtIn": 1,
|
||||||
"datasource": { "type": "grafana", "uid": "-- Grafana --" },
|
"datasource": {
|
||||||
|
"type": "grafana",
|
||||||
|
"uid": "-- Grafana --"
|
||||||
|
},
|
||||||
"enable": true,
|
"enable": true,
|
||||||
"hide": true,
|
"hide": true,
|
||||||
"iconColor": "rgba(0, 211, 255, 1)",
|
"iconColor": "rgba(0, 211, 255, 1)",
|
||||||
@@ -17,155 +20,682 @@
|
|||||||
"id": null,
|
"id": null,
|
||||||
"links": [],
|
"links": [],
|
||||||
"panels": [
|
"panels": [
|
||||||
{ "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 }, "id": 1, "title": "Status", "type": "row" },
|
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"gridPos": {
|
||||||
"fieldConfig": { "defaults": { "thresholds": { "mode": "absolute", "steps": [{ "color": "blue", "value": null }] } }, "overrides": [] },
|
"h": 1,
|
||||||
"gridPos": { "h": 4, "w": 5, "x": 0, "y": 1 },
|
"w": 24,
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"id": 1,
|
||||||
|
"title": "Status",
|
||||||
|
"type": "row"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "influxdb",
|
||||||
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "blue",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 5,
|
||||||
|
"x": 0,
|
||||||
|
"y": 1
|
||||||
|
},
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"] }, "colorMode": "value", "graphMode": "none" },
|
"options": {
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "none"
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field==\"direction\")\n |> last()", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field==\"direction\")\n |> last()",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Direction",
|
"title": "Direction",
|
||||||
"type": "stat"
|
"type": "stat",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"direction"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"datasource": {
|
||||||
"fieldConfig": { "defaults": { "unit": "s", "thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }, { "color": "orange", "value": 300 }, { "color": "red", "value": 600 }] } }, "overrides": [] },
|
"type": "influxdb",
|
||||||
"gridPos": { "h": 4, "w": 5, "x": 5, "y": 1 },
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "s",
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "orange",
|
||||||
|
"value": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": 600
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 5,
|
||||||
|
"x": 5,
|
||||||
|
"y": 1
|
||||||
|
},
|
||||||
"id": 3,
|
"id": 3,
|
||||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"] }, "colorMode": "value", "graphMode": "area" },
|
"options": {
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "area"
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field==\"timeleft\")\n |> last()", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field==\"timeleft\")\n |> last()",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Time Left",
|
"title": "Time Left",
|
||||||
"type": "stat"
|
"type": "stat",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"timeLeft"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"datasource": {
|
||||||
"fieldConfig": { "defaults": { "thresholds": { "mode": "absolute", "steps": [{ "color": "purple", "value": null }] } }, "overrides": [] },
|
"type": "influxdb",
|
||||||
"gridPos": { "h": 4, "w": 4, "x": 10, "y": 1 },
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "purple",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 4,
|
||||||
|
"x": 10,
|
||||||
|
"y": 1
|
||||||
|
},
|
||||||
"id": 4,
|
"id": 4,
|
||||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"] }, "colorMode": "value", "graphMode": "none" },
|
"options": {
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "none"
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field==\"flowSource\")\n |> last()", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field==\"flowSource\")\n |> last()",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Flow Source",
|
"title": "Flow Source",
|
||||||
"type": "stat"
|
"type": "stat",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"flowSource"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"datasource": {
|
||||||
"fieldConfig": { "defaults": { "min": 0, "max": 100, "unit": "percent", "thresholds": { "mode": "absolute", "steps": [{ "color": "red", "value": null }, { "color": "orange", "value": 20 }, { "color": "green", "value": 40 }, { "color": "orange", "value": 80 }, { "color": "red", "value": 95 }] } }, "overrides": [] },
|
"type": "influxdb",
|
||||||
"gridPos": { "h": 4, "w": 5, "x": 14, "y": 1 },
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"min": 0,
|
||||||
|
"max": 100,
|
||||||
|
"unit": "percent",
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "orange",
|
||||||
|
"value": 20
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": 40
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "orange",
|
||||||
|
"value": 80
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": 95
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 5,
|
||||||
|
"x": 14,
|
||||||
|
"y": 1
|
||||||
|
},
|
||||||
"id": 5,
|
"id": 5,
|
||||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"] }, "showThresholdLabels": false, "showThresholdMarkers": true },
|
"options": {
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"showThresholdLabels": false,
|
||||||
|
"showThresholdMarkers": true
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /^volumePercent\\.predicted\\.atequipment/)\n |> last()", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /^volumePercent\\.predicted\\.atequipment/)\n |> last()",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Fill %",
|
"title": "Fill %",
|
||||||
"type": "gauge"
|
"type": "gauge",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"volumePercent"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"datasource": {
|
||||||
"fieldConfig": { "defaults": { "unit": "m", "thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] } }, "overrides": [] },
|
"type": "influxdb",
|
||||||
"gridPos": { "h": 4, "w": 5, "x": 19, "y": 1 },
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "m",
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 5,
|
||||||
|
"x": 19,
|
||||||
|
"y": 1
|
||||||
|
},
|
||||||
"id": 6,
|
"id": 6,
|
||||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"] }, "colorMode": "value", "graphMode": "area" },
|
"options": {
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "area"
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /^level\\.predicted\\.atequipment/)\n |> last()", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /^level\\.predicted\\.atequipment/)\n |> last()",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Level",
|
"title": "Level",
|
||||||
"type": "stat"
|
"type": "stat",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"level"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{ "gridPos": { "h": 1, "w": 24, "x": 0, "y": 5 }, "id": 7, "title": "Basin", "type": "row" },
|
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"gridPos": {
|
||||||
"fieldConfig": { "defaults": { "unit": "m", "custom": { "drawStyle": "line", "lineWidth": 2, "fillOpacity": 10 } }, "overrides": [] },
|
"h": 1,
|
||||||
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 6 },
|
"w": 24,
|
||||||
|
"x": 0,
|
||||||
|
"y": 5
|
||||||
|
},
|
||||||
|
"id": 7,
|
||||||
|
"title": "Basin",
|
||||||
|
"type": "row"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "influxdb",
|
||||||
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "m",
|
||||||
|
"custom": {
|
||||||
|
"drawStyle": "line",
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 8,
|
||||||
|
"w": 12,
|
||||||
|
"x": 0,
|
||||||
|
"y": 6
|
||||||
|
},
|
||||||
"id": 8,
|
"id": 8,
|
||||||
"options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } },
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom"
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi"
|
||||||
|
}
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /^level\\.(predicted|measured)\\.atequipment/)\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /^level\\.(predicted|measured)\\.atequipment/)\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Level",
|
"title": "Level",
|
||||||
"type": "timeseries"
|
"type": "timeseries",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"level"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"datasource": {
|
||||||
"fieldConfig": { "defaults": { "unit": "m\u00b3", "custom": { "drawStyle": "line", "lineWidth": 2, "fillOpacity": 10 } }, "overrides": [] },
|
"type": "influxdb",
|
||||||
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 6 },
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "m\u00b3",
|
||||||
|
"custom": {
|
||||||
|
"drawStyle": "line",
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 8,
|
||||||
|
"w": 12,
|
||||||
|
"x": 12,
|
||||||
|
"y": 6
|
||||||
|
},
|
||||||
"id": 9,
|
"id": 9,
|
||||||
"options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } },
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom"
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi"
|
||||||
|
}
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /^volume\\.predicted\\.atequipment/)\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /^volume\\.predicted\\.atequipment/)\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Volume",
|
"title": "Volume",
|
||||||
"type": "timeseries"
|
"type": "timeseries",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"volume"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{ "gridPos": { "h": 1, "w": 24, "x": 0, "y": 14 }, "id": 10, "title": "Flow", "type": "row" },
|
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"gridPos": {
|
||||||
"fieldConfig": { "defaults": { "unit": "m\u00b3/h", "custom": { "drawStyle": "line", "lineWidth": 2, "fillOpacity": 10 } }, "overrides": [] },
|
"h": 1,
|
||||||
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 15 },
|
"w": 24,
|
||||||
|
"x": 0,
|
||||||
|
"y": 14
|
||||||
|
},
|
||||||
|
"id": 10,
|
||||||
|
"title": "Flow",
|
||||||
|
"type": "row"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "influxdb",
|
||||||
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "m\u00b3/h",
|
||||||
|
"custom": {
|
||||||
|
"drawStyle": "line",
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 8,
|
||||||
|
"w": 12,
|
||||||
|
"x": 0,
|
||||||
|
"y": 15
|
||||||
|
},
|
||||||
"id": 11,
|
"id": 11,
|
||||||
"options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } },
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom"
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi"
|
||||||
|
}
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /^netFlowRate\\.predicted\\.atequipment/)\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /^netFlowRate\\.predicted\\.atequipment/)\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Net Flow Rate",
|
"title": "Net Flow Rate",
|
||||||
"type": "timeseries"
|
"type": "timeseries",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"flow.net",
|
||||||
|
"flow"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"datasource": {
|
||||||
"fieldConfig": { "defaults": { "unit": "m\u00b3/h", "custom": { "drawStyle": "line", "lineWidth": 2, "fillOpacity": 10 } }, "overrides": [] },
|
"type": "influxdb",
|
||||||
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 15 },
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "m\u00b3/h",
|
||||||
|
"custom": {
|
||||||
|
"drawStyle": "line",
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 8,
|
||||||
|
"w": 12,
|
||||||
|
"x": 12,
|
||||||
|
"y": 15
|
||||||
|
},
|
||||||
"id": 12,
|
"id": 12,
|
||||||
"options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } },
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom"
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi"
|
||||||
|
}
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /^flow\\.(predicted|measured)\\.atequipment/)\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and r._field =~ /^flow\\.(predicted|measured)\\.atequipment/)\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Inflow + Outflow",
|
"title": "Inflow + Outflow",
|
||||||
"type": "timeseries"
|
"type": "timeseries",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"flow.in",
|
||||||
|
"flow.out"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{ "gridPos": { "h": 1, "w": 24, "x": 0, "y": 23 }, "id": 13, "title": "Configuration", "type": "row" },
|
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"gridPos": {
|
||||||
"fieldConfig": { "defaults": { "unit": "m", "thresholds": { "mode": "absolute", "steps": [{ "color": "blue", "value": null }] } }, "overrides": [] },
|
"h": 1,
|
||||||
"gridPos": { "h": 4, "w": 12, "x": 0, "y": 24 },
|
"w": 24,
|
||||||
|
"x": 0,
|
||||||
|
"y": 23
|
||||||
|
},
|
||||||
|
"id": 13,
|
||||||
|
"title": "Configuration",
|
||||||
|
"type": "row"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "influxdb",
|
||||||
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "m",
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "blue",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 12,
|
||||||
|
"x": 0,
|
||||||
|
"y": 24
|
||||||
|
},
|
||||||
"id": 14,
|
"id": 14,
|
||||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"] }, "colorMode": "value", "graphMode": "none" },
|
"options": {
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "none"
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and (r._field==\"heightInlet\" or r._field==\"heightOverflow\" or r._field==\"volEmptyBasin\"))\n |> last()", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and (r._field==\"heightInlet\" or r._field==\"heightOverflow\" or r._field==\"volEmptyBasin\"))\n |> last()",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Heights",
|
"title": "Heights",
|
||||||
"type": "stat"
|
"type": "stat",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"heights.min",
|
||||||
|
"heights.max"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datasource": { "type": "influxdb", "uid": "cdzg44tv250jkd" },
|
"datasource": {
|
||||||
"fieldConfig": { "defaults": { "unit": "m\u00b3", "thresholds": { "mode": "absolute", "steps": [{ "color": "blue", "value": null }] } }, "overrides": [] },
|
"type": "influxdb",
|
||||||
"gridPos": { "h": 4, "w": 12, "x": 12, "y": 24 },
|
"uid": "cdzg44tv250jkd"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "m\u00b3",
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "blue",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 12,
|
||||||
|
"x": 12,
|
||||||
|
"y": 24
|
||||||
|
},
|
||||||
"id": 15,
|
"id": 15,
|
||||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"] }, "colorMode": "value", "graphMode": "none" },
|
"options": {
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "none"
|
||||||
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{ "query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and (r._field==\"maxVol\" or r._field==\"minVol\" or r._field==\"maxVolOverflow\" or r._field==\"minVolOut\" or r._field==\"minVolIn\"))\n |> last()", "refId": "A" }
|
{
|
||||||
|
"query": "from(bucket: \"${bucket}\")\n |> range(start: -7d)\n |> filter(fn:(r) => r._measurement==\"${measurement}\" and (r._field==\"maxVol\" or r._field==\"minVol\" or r._field==\"maxVolOverflow\" or r._field==\"minVolOut\" or r._field==\"minVolIn\"))\n |> last()",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"title": "Volume Limits",
|
"title": "Volume Limits",
|
||||||
"type": "stat"
|
"type": "stat",
|
||||||
|
"meta": {
|
||||||
|
"emittedFields": [
|
||||||
|
"volume.min",
|
||||||
|
"volume.max"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"schemaVersion": 39,
|
"schemaVersion": 39,
|
||||||
"tags": ["EVOLV", "pumpingStation", "template"],
|
"tags": [
|
||||||
|
"EVOLV",
|
||||||
|
"pumpingStation",
|
||||||
|
"template"
|
||||||
|
],
|
||||||
"templating": {
|
"templating": {
|
||||||
"list": [
|
"list": [
|
||||||
{ "name": "dbase", "type": "custom", "label": "dbase", "query": "cdzg44tv250jkd", "current": { "text": "cdzg44tv250jkd", "value": "cdzg44tv250jkd", "selected": false }, "options": [{ "text": "cdzg44tv250jkd", "value": "cdzg44tv250jkd", "selected": true }], "hide": 2 },
|
{
|
||||||
{ "name": "measurement", "type": "custom", "query": "template", "current": { "text": "template", "value": "template", "selected": false }, "options": [{ "text": "template", "value": "template", "selected": true }] },
|
"name": "dbase",
|
||||||
{ "name": "bucket", "type": "custom", "query": "lvl2", "current": { "text": "lvl2", "value": "lvl2", "selected": false }, "options": [{ "text": "lvl2", "value": "lvl2", "selected": true }] }
|
"type": "custom",
|
||||||
|
"label": "dbase",
|
||||||
|
"query": "cdzg44tv250jkd",
|
||||||
|
"current": {
|
||||||
|
"text": "cdzg44tv250jkd",
|
||||||
|
"value": "cdzg44tv250jkd",
|
||||||
|
"selected": false
|
||||||
|
},
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"text": "cdzg44tv250jkd",
|
||||||
|
"value": "cdzg44tv250jkd",
|
||||||
|
"selected": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hide": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "measurement",
|
||||||
|
"type": "custom",
|
||||||
|
"query": "template",
|
||||||
|
"current": {
|
||||||
|
"text": "template",
|
||||||
|
"value": "template",
|
||||||
|
"selected": false
|
||||||
|
},
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"text": "template",
|
||||||
|
"value": "template",
|
||||||
|
"selected": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bucket",
|
||||||
|
"type": "custom",
|
||||||
|
"query": "lvl2",
|
||||||
|
"current": {
|
||||||
|
"text": "lvl2",
|
||||||
|
"value": "lvl2",
|
||||||
|
"selected": false
|
||||||
|
},
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"text": "lvl2",
|
||||||
|
"value": "lvl2",
|
||||||
|
"selected": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"time": { "from": "now-6h", "to": "now" },
|
"time": {
|
||||||
|
"from": "now-6h",
|
||||||
|
"to": "now"
|
||||||
|
},
|
||||||
"timezone": "",
|
"timezone": "",
|
||||||
"title": "template",
|
"title": "template",
|
||||||
"uid": null,
|
"uid": null,
|
||||||
"version": 1
|
"version": 1
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,70 @@
|
|||||||
[
|
[
|
||||||
{"id":"dashboardAPI_basic_tab","type":"tab","label":"dashboardAPI basic","disabled":false,"info":"dashboardAPI basic example"},
|
{
|
||||||
{"id":"dashboardAPI_basic_node","type":"dashboardapi","z":"dashboardAPI_basic_tab","name":"dashboardAPI basic","x":420,"y":180,"wires":[["dashboardAPI_basic_dbg"]]},
|
"id": "dashboardAPI_basic_tab",
|
||||||
{"id":"dashboardAPI_basic_inj","type":"inject","z":"dashboardAPI_basic_tab","name":"basic trigger","props":[{"p":"topic","vt":"str"},{"p":"payload","vt":"str"}],"topic":"ping","payload":"1","payloadType":"str","x":160,"y":180,"wires":[["dashboardAPI_basic_node"]]},
|
"type": "tab",
|
||||||
{"id":"dashboardAPI_basic_dbg","type":"debug","z":"dashboardAPI_basic_tab","name":"dashboardAPI basic debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":660,"y":180,"wires":[]}
|
"label": "dashboardAPI basic — measurement → Grafana",
|
||||||
|
"disabled": false,
|
||||||
|
"info": "Demonstrates the round-trip:\n- inject simulates a child.register message from a measurement node\n- dashboardapi composes a Grafana dashboard for that child\n- http request posts the dashboard to Grafana\n- debug shows the HTTP response\n\nConfigure the dashboardapi node with your Grafana host/port + bearer token\n(encrypted via Node-RED credentials). Default targets http://grafana:3000\nfrom inside the Docker compose stack."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "dashboardAPI_basic_node",
|
||||||
|
"type": "dashboardapi",
|
||||||
|
"z": "dashboardAPI_basic_tab",
|
||||||
|
"name": "dashboardAPI",
|
||||||
|
"protocol": "http",
|
||||||
|
"host": "grafana",
|
||||||
|
"port": 3000,
|
||||||
|
"folderUid": "",
|
||||||
|
"defaultBucket": "telemetry",
|
||||||
|
"x": 460,
|
||||||
|
"y": 200,
|
||||||
|
"wires": [["dashboardAPI_basic_http"]]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "dashboardAPI_basic_inj",
|
||||||
|
"type": "inject",
|
||||||
|
"z": "dashboardAPI_basic_tab",
|
||||||
|
"name": "simulate child.register (measurement)",
|
||||||
|
"props": [
|
||||||
|
{ "p": "topic", "vt": "str" },
|
||||||
|
{ "p": "payload", "v": "{\"config\":{\"general\":{\"id\":\"meas-demo-001\",\"name\":\"FT-001 demo\"},\"functionality\":{\"softwareType\":\"measurement\",\"positionVsParent\":\"downstream\"}}}", "vt": "json" }
|
||||||
|
],
|
||||||
|
"topic": "child.register",
|
||||||
|
"x": 180,
|
||||||
|
"y": 200,
|
||||||
|
"wires": [["dashboardAPI_basic_node"]]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "dashboardAPI_basic_http",
|
||||||
|
"type": "http request",
|
||||||
|
"z": "dashboardAPI_basic_tab",
|
||||||
|
"name": "POST /api/dashboards/db",
|
||||||
|
"method": "use",
|
||||||
|
"ret": "obj",
|
||||||
|
"paytoqs": "ignore",
|
||||||
|
"url": "",
|
||||||
|
"tls": "",
|
||||||
|
"persist": false,
|
||||||
|
"proxy": "",
|
||||||
|
"authType": "",
|
||||||
|
"senderr": false,
|
||||||
|
"x": 720,
|
||||||
|
"y": 200,
|
||||||
|
"wires": [["dashboardAPI_basic_dbg"]]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "dashboardAPI_basic_dbg",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "dashboardAPI_basic_tab",
|
||||||
|
"name": "Grafana response",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": false,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "payload",
|
||||||
|
"targetType": "msg",
|
||||||
|
"x": 960,
|
||||||
|
"y": 200,
|
||||||
|
"wires": []
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -22,14 +22,9 @@ function resolveChildNode(childId, ctx) {
|
|||||||
return runtimeNode || flowNode || null;
|
return runtimeNode || flowNode || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On child.register: build the dashboard graph (root + direct children) and
|
// Shared emit path used by both child.register (auto, deploy-driven) and
|
||||||
// emit one Grafana upsert HTTP request per dashboard on Port 0.
|
// regenerate-dashboard (manual). `trigger` distinguishes the two for logs.
|
||||||
function registerChild(source, msg, ctx) {
|
function emitDashboardsFor(source, childSource, ctx, msg, trigger) {
|
||||||
const childSource = resolveChildSource(msg.payload, ctx);
|
|
||||||
if (!childSource?.config) {
|
|
||||||
throw new Error('Missing or invalid child node');
|
|
||||||
}
|
|
||||||
|
|
||||||
const dashboards = source.generateDashboardsForGraph(childSource, {
|
const dashboards = source.generateDashboardsForGraph(childSource, {
|
||||||
includeChildren: Boolean(msg.includeChildren ?? true),
|
includeChildren: Boolean(msg.includeChildren ?? true),
|
||||||
});
|
});
|
||||||
@@ -56,9 +51,73 @@ function registerChild(source, msg, ctx) {
|
|||||||
softwareType: dash.softwareType,
|
softwareType: dash.softwareType,
|
||||||
uid: dash.uid,
|
uid: dash.uid,
|
||||||
title: dash.title,
|
title: dash.title,
|
||||||
|
trigger,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (source.logger?.info) {
|
||||||
|
source.logger.info({
|
||||||
|
event: 'regen-emitted',
|
||||||
|
trigger,
|
||||||
|
dashboardApiId: ctx.node?.id,
|
||||||
|
childId: childSource?.config?.general?.id,
|
||||||
|
dashboardCount: dashboards.length,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { registerChild };
|
// On child.register: build the dashboard graph (root + direct children) and
|
||||||
|
// emit one Grafana upsert HTTP request per dashboard on Port 0.
|
||||||
|
//
|
||||||
|
// Diff-skip behavior (PRD F-1, S1 spike #32): if the latest flows:started
|
||||||
|
// payload's `diff` indicates that NEITHER the dashboardAPI itself NOR this
|
||||||
|
// child NOR its grandchildren changed, skip composition and log no-diff. The
|
||||||
|
// first call after startup (no cached diff yet) regenerates unconditionally.
|
||||||
|
function registerChild(source, msg, ctx) {
|
||||||
|
const childSource = resolveChildSource(msg.payload, ctx);
|
||||||
|
if (!childSource?.config) {
|
||||||
|
throw new Error('Missing or invalid child node');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cache the child source for later manual regen (#41).
|
||||||
|
source.recordChild?.(childSource);
|
||||||
|
|
||||||
|
const subtreeIds = source.subtreeIdsFor(ctx.node?.id, childSource);
|
||||||
|
const changed = source.subtreeChanged(source.lastFlowsStartedDiff, subtreeIds);
|
||||||
|
if (!changed) {
|
||||||
|
if (source.logger?.info) {
|
||||||
|
source.logger.info({
|
||||||
|
event: 'regen-skipped',
|
||||||
|
outcome: 'no-diff',
|
||||||
|
trigger: 'child.register',
|
||||||
|
dashboardApiId: ctx.node?.id,
|
||||||
|
childId: childSource?.config?.general?.id,
|
||||||
|
subtreeSize: subtreeIds.size,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emitDashboardsFor(source, childSource, ctx, msg, 'child.register');
|
||||||
|
}
|
||||||
|
|
||||||
|
// On regenerate-dashboard: re-emit dashboards for every cached child source,
|
||||||
|
// bypassing the diff predicate. Useful as an operator escape hatch when
|
||||||
|
// auto-regen missed an edge case or when the operator just wants to refresh.
|
||||||
|
function regenerateDashboard(source, msg, ctx) {
|
||||||
|
const cached = source.cachedChildSources?.() || [];
|
||||||
|
if (source.logger?.info) {
|
||||||
|
source.logger.info({
|
||||||
|
event: 'manual-regen-requested',
|
||||||
|
trigger: 'manual',
|
||||||
|
dashboardApiId: ctx.node?.id,
|
||||||
|
cachedChildCount: cached.length,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
for (const childSource of cached) {
|
||||||
|
emitDashboardsFor(source, childSource, ctx, msg, 'manual');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { registerChild, regenerateDashboard };
|
||||||
|
|||||||
@@ -13,4 +13,10 @@ module.exports = [
|
|||||||
payloadSchema: { type: 'any' },
|
payloadSchema: { type: 'any' },
|
||||||
handler: handlers.registerChild,
|
handler: handlers.registerChild,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
topic: 'regenerate-dashboard',
|
||||||
|
aliases: ['regen'],
|
||||||
|
payloadSchema: { type: 'any' },
|
||||||
|
handler: handlers.regenerateDashboard,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -26,6 +26,29 @@ class nodeClass {
|
|||||||
|
|
||||||
this._attachInputHandler();
|
this._attachInputHandler();
|
||||||
this._attachCloseHandler();
|
this._attachCloseHandler();
|
||||||
|
this._attachLifecycleHook();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subscribe to Node-RED's `flows:started` event to cache the deploy diff so
|
||||||
|
// the child.register handler can decide whether *this* dashboardAPI's
|
||||||
|
// subtree was affected. Predicate documented in Gitea issue #32 spike.
|
||||||
|
_attachLifecycleHook() {
|
||||||
|
if (!this.RED?.events?.on) return;
|
||||||
|
this._flowsStartedListener = (payload) => {
|
||||||
|
const diff = payload?.diff || null;
|
||||||
|
this.source.lastFlowsStartedDiff = diff;
|
||||||
|
this.source.lastFlowsStartedAt = Date.now();
|
||||||
|
if (this.source?.logger?.debug) {
|
||||||
|
const summary = diff
|
||||||
|
? Object.fromEntries(
|
||||||
|
['added', 'changed', 'removed', 'rewired', 'linked', 'flowChanged']
|
||||||
|
.map((k) => [k, (diff[k] || []).length])
|
||||||
|
)
|
||||||
|
: null;
|
||||||
|
this.source.logger.debug({ event: 'flows:started', type: payload?.type, diff: summary });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.RED.events.on('flows:started', this._flowsStartedListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
_buildConfig(uiConfig) {
|
_buildConfig(uiConfig) {
|
||||||
@@ -78,6 +101,10 @@ class nodeClass {
|
|||||||
|
|
||||||
_attachCloseHandler() {
|
_attachCloseHandler() {
|
||||||
this.node.on('close', (done) => {
|
this.node.on('close', (done) => {
|
||||||
|
if (this._flowsStartedListener && this.RED?.events?.off) {
|
||||||
|
this.RED.events.off('flows:started', this._flowsStartedListener);
|
||||||
|
this._flowsStartedListener = null;
|
||||||
|
}
|
||||||
if (typeof done === 'function') done();
|
if (typeof done === 'function') done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,20 @@ class DashboardApi {
|
|||||||
this.config.general.logging.logLevel,
|
this.config.general.logging.logLevel,
|
||||||
this.config.general.name
|
this.config.general.name
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Light state cache for manual regen (#41). Stores the latest child
|
||||||
|
// source object per child id so `regenerate-dashboard` can re-emit
|
||||||
|
// dashboards without waiting for children to re-register.
|
||||||
|
this._lastChildSources = new Map();
|
||||||
|
}
|
||||||
|
|
||||||
|
recordChild(childSource) {
|
||||||
|
const id = childSource?.config?.general?.id;
|
||||||
|
if (id) this._lastChildSources.set(id, childSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
cachedChildSources() {
|
||||||
|
return Array.from(this._lastChildSources.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
_templatesDir() {
|
_templatesDir() {
|
||||||
@@ -105,6 +119,18 @@ class DashboardApi {
|
|||||||
return JSON.parse(raw);
|
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() {
|
grafanaUpsertUrl() {
|
||||||
const { protocol, host, port } = this.config.grafanaConnector;
|
const { protocol, host, port } = this.config.grafanaConnector;
|
||||||
return `${protocol}://${host}:${port}/api/dashboards/db`;
|
return `${protocol}://${host}:${port}/api/dashboards/db`;
|
||||||
@@ -168,6 +194,34 @@ class DashboardApi {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Predicate from Gitea issue #32 spike (S1 findings). Given the diff payload
|
||||||
|
// from Node-RED's flows:started event and a set of node ids that constitute
|
||||||
|
// "my subtree", decides whether the subtree changed on this deploy.
|
||||||
|
// `null` diff (first deploy / startup) → always regen (safe default).
|
||||||
|
subtreeChanged(diff, subtreeIds) {
|
||||||
|
if (!diff) return true;
|
||||||
|
const mine = new Set(subtreeIds);
|
||||||
|
for (const field of ['added', 'changed', 'removed', 'rewired']) {
|
||||||
|
const arr = diff[field] || [];
|
||||||
|
if (arr.some((id) => mine.has(id))) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collect ids that constitute "this dashboardAPI + this child + its grandchildren"
|
||||||
|
// for the diff predicate. Pulls grandchildren via the existing extractChildren walk.
|
||||||
|
subtreeIdsFor(dashboardApiNodeId, childSource) {
|
||||||
|
const ids = new Set();
|
||||||
|
if (dashboardApiNodeId) ids.add(dashboardApiNodeId);
|
||||||
|
const childId = childSource?.config?.general?.id;
|
||||||
|
if (childId) ids.add(childId);
|
||||||
|
for (const { childSource: gc } of this.extractChildren(childSource)) {
|
||||||
|
const gcId = gc?.config?.general?.id;
|
||||||
|
if (gcId) ids.add(gcId);
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
generateDashboardsForGraph(rootSource, { includeChildren = true } = {}) {
|
generateDashboardsForGraph(rootSource, { includeChildren = true } = {}) {
|
||||||
if (!rootSource?.config) {
|
if (!rootSource?.config) {
|
||||||
this.logger.warn('generateDashboardsForGraph skipped: root source missing config');
|
this.logger.warn('generateDashboardsForGraph skipped: root source missing config');
|
||||||
@@ -188,6 +242,32 @@ class DashboardApi {
|
|||||||
if (childDash) results.push(childDash);
|
if (childDash) results.push(childDash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No-data-duplication rule (PRD F-5, #39): remove root panels whose
|
||||||
|
// emittedFields are fully covered by panels on child dashboards. The
|
||||||
|
// parent then shows only metrics its children don't already plot,
|
||||||
|
// avoiding redundant rendering of the same series in two places.
|
||||||
|
if (children.length > 0 && rootDash.dashboard) {
|
||||||
|
const childCoveredFields = new Set();
|
||||||
|
for (const dash of results.slice(1)) {
|
||||||
|
for (const f of this.collectEmittedFields(dash.dashboard)) childCoveredFields.add(f);
|
||||||
|
}
|
||||||
|
const before = rootDash.dashboard.panels.length;
|
||||||
|
rootDash.dashboard.panels = rootDash.dashboard.panels.filter((p) => {
|
||||||
|
if (p.type === 'row') return true; // never drop rows
|
||||||
|
const fields = p?.meta?.emittedFields;
|
||||||
|
if (!Array.isArray(fields) || fields.length === 0) return true; // no declaration, keep
|
||||||
|
return !fields.every((f) => childCoveredFields.has(f));
|
||||||
|
});
|
||||||
|
if (this.logger?.debug && before !== rootDash.dashboard.panels.length) {
|
||||||
|
this.logger.debug({
|
||||||
|
event: 'parent-panels-deduped',
|
||||||
|
before,
|
||||||
|
after: rootDash.dashboard.panels.length,
|
||||||
|
rootTitle: rootDash.title,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add links from the root dashboard to children dashboards (when possible)
|
// Add links from the root dashboard to children dashboards (when possible)
|
||||||
if (children.length > 0) {
|
if (children.length > 0) {
|
||||||
rootDash.dashboard.links = Array.isArray(rootDash.dashboard.links) ? rootDash.dashboard.links : [];
|
rootDash.dashboard.links = Array.isArray(rootDash.dashboard.links) ? rootDash.dashboard.links : [];
|
||||||
|
|||||||
67
test/_output-manifest.md
Normal file
67
test/_output-manifest.md
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
# dashboardAPI output manifest
|
||||||
|
|
||||||
|
Per `.claude/rules/output-coverage.md`: every output on every layer, in every state.
|
||||||
|
|
||||||
|
## Port 0 (process — Grafana upsert messages)
|
||||||
|
|
||||||
|
Emitted by the command handler(s) after a `child.register` or `regenerate-dashboard` message. Shape is the same for both; `meta.trigger` distinguishes them.
|
||||||
|
|
||||||
|
| Key | Source method | Type | States tested | Test file |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| `topic` | `handlers.emitDashboardsFor` | `'create'` (literal) | populated | `test/basic/slice41-manual-regen.basic.test.js` |
|
||||||
|
| `url` | `source.grafanaUpsertUrl()` | string (configured Grafana endpoint) | populated, default-config | `test/basic/slice34-credentials-and-folder.basic.test.js` |
|
||||||
|
| `method` | `handlers.emitDashboardsFor` | `'POST'` (literal) | populated | `test/basic/slice41-manual-regen.basic.test.js` |
|
||||||
|
| `headers.Accept` | `handlers.emitDashboardsFor` | `'application/json'` (literal) | populated | _via output manifest test below_ |
|
||||||
|
| `headers['Content-Type']` | `handlers.emitDashboardsFor` | `'application/json'` (literal) | populated | _via output manifest test below_ |
|
||||||
|
| `headers.Authorization` | `handlers.emitDashboardsFor` | `'Bearer <token>'` when configured; absent when not | populated, absent (degraded — no token) | `test/basic/slice43-output-manifest.basic.test.js` |
|
||||||
|
| `payload.dashboard` | `source.buildDashboard()` | object (Grafana dashboard JSON) | populated, byte-identical-on-repeat | `test/basic/slice35-graph-perf-and-uid-uniqueness.basic.test.js` |
|
||||||
|
| `payload.overwrite` | `source.buildUpsertRequest()` | `true` (literal) | populated | `test/basic/slice34-credentials-and-folder.basic.test.js` |
|
||||||
|
| `payload.folderUid` | `source.buildUpsertRequest()` | string when configured; absent when empty | populated, absent (degraded — empty config) | `test/basic/slice34-credentials-and-folder.basic.test.js` |
|
||||||
|
| `payload.folderId` | `source.buildUpsertRequest()` | number when explicitly passed; absent otherwise | absent (default), populated (explicit) | `test/basic/slice34-credentials-and-folder.basic.test.js` |
|
||||||
|
| `meta.nodeId` | `handlers.emitDashboardsFor` | string (child node id) | populated | `test/basic/slice43-output-manifest.basic.test.js` |
|
||||||
|
| `meta.softwareType` | `handlers.emitDashboardsFor` | string (child softwareType) | populated | `test/basic/slice43-output-manifest.basic.test.js` |
|
||||||
|
| `meta.uid` | `handlers.emitDashboardsFor` | string (stableUid hash, deterministic) | populated, byte-identical | `test/basic/slice35-graph-perf-and-uid-uniqueness.basic.test.js` |
|
||||||
|
| `meta.title` | `handlers.emitDashboardsFor` | string (child name or id) | populated | `test/basic/slice43-output-manifest.basic.test.js` |
|
||||||
|
| `meta.trigger` | `handlers.emitDashboardsFor` | `'child.register'` or `'manual'` | both states | `test/basic/slice41-manual-regen.basic.test.js` |
|
||||||
|
|
||||||
|
**Degraded-state convention:** missing keys are **absent**, never set to `null`. The `http request` consumer treats absent headers/payload fields as defaults.
|
||||||
|
|
||||||
|
## Port 1 (InfluxDB telemetry)
|
||||||
|
|
||||||
|
dashboardAPI emits **nothing** on Port 1 by design — it has no measurements, no tick loop, no telemetry. Verified by absence: no `formatForInflux` import, no Port 1 wires in `examples/`.
|
||||||
|
|
||||||
|
## Port 2 (registration / control plumbing)
|
||||||
|
|
||||||
|
dashboardAPI is a **sink** for `child.register` messages, not a source — it does not register itself with any parent. Nothing emitted on Port 2.
|
||||||
|
|
||||||
|
## Structured log outputs
|
||||||
|
|
||||||
|
| Event | Level | Triggered by | Fields | Test |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| `regen-emitted` | info | successful composition (auto or manual) | `event`, `trigger`, `dashboardApiId`, `childId`, `dashboardCount` | `test/basic/slice43-output-manifest.basic.test.js` |
|
||||||
|
| `regen-skipped` | info | diff predicate says subtree unchanged | `event`, `outcome: 'no-diff'`, `trigger: 'child.register'`, `dashboardApiId`, `childId`, `subtreeSize` | `test/basic/slice43-output-manifest.basic.test.js` |
|
||||||
|
| `manual-regen-requested` | info | `regenerate-dashboard` topic received | `event`, `trigger: 'manual'`, `dashboardApiId`, `cachedChildCount` | `test/basic/slice41-manual-regen.basic.test.js` |
|
||||||
|
| `parent-panels-deduped` | debug | no-data-duplication filter removed root panels | `event`, `before`, `after`, `rootTitle` | _covered by composition tests in slice39_ |
|
||||||
|
| `flows:started` | debug | Node-RED runtime emits flows:started | `event: 'flows:started'`, `type`, `diff` (count summary) | _covered by predicate tests in slice36_ |
|
||||||
|
|
||||||
|
## specificClass return shapes
|
||||||
|
|
||||||
|
| Method | Return shape | Populated states | Degraded states | Test |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| `buildDashboard(opts)` | `{ dashboard, uid, title, softwareType, nodeId, measurementName }` or `null` | success | `null` when no template for softwareType | `test/basic/slice43-output-manifest.basic.test.js` |
|
||||||
|
| `generateDashboardsForGraph(root)` | array of `buildDashboard` results, root first, children after | 0..N children | empty array when root config missing | `test/basic/slice35-graph-perf-and-uid-uniqueness.basic.test.js` |
|
||||||
|
| `subtreeChanged(diff, ids)` | boolean | id-in-diff, no-id-in-diff | null diff → true (cold start) | `test/basic/slice36-diff-predicate.basic.test.js` |
|
||||||
|
| `subtreeIdsFor(myId, child)` | Set\<string\> | myId+childId+grandchildren | myId only when child has no grandchildren | `test/basic/slice36-diff-predicate.basic.test.js` |
|
||||||
|
| `collectEmittedFields(dashboard)` | Set\<string\> | populated dashboard | empty set for `null`/`{}`/`{panels:[]}` | `test/basic/slice37-emitted-fields.basic.test.js` |
|
||||||
|
| `cachedChildSources()` | array of child sources | 0..N cached | empty after construction | `test/basic/slice41-manual-regen.basic.test.js` |
|
||||||
|
|
||||||
|
## Anti-patterns enforced
|
||||||
|
|
||||||
|
- ❌ Emitting `{payload: null}` — `handlers.emitDashboardsFor` always builds `payload: { dashboard, overwrite, ... }`. Verified.
|
||||||
|
- ❌ Mixing absent vs null for optional fields — `folderUid` / `folderId` are **absent** when unconfigured, never `null`. Verified.
|
||||||
|
- ❌ Per-call token stamping — token is set on `headers.Authorization` when configured; absent when not. No empty-string sentinel.
|
||||||
|
- ❌ Tab id over-triggering in diff predicate — predicate only matches against dashboardAPI's own id + child + grandchildren, never tab ids. Verified.
|
||||||
|
|
||||||
|
## Migration plan applied
|
||||||
|
|
||||||
|
This manifest is created together with slice #43 — the new outputs added in slices #34–#42 are documented here. Other EVOLV nodes still need their own manifests; tracked in `IMPROVEMENTS_BACKLOG.md`.
|
||||||
73
test/basic/slice36-diff-predicate.basic.test.js
Normal file
73
test/basic/slice36-diff-predicate.basic.test.js
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
|
||||||
|
const DashboardApi = require('../../src/specificClass.js');
|
||||||
|
|
||||||
|
test('subtreeChanged: null diff → always regen (safe default for cold start)', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
assert.equal(api.subtreeChanged(null, new Set(['a', 'b'])), true);
|
||||||
|
assert.equal(api.subtreeChanged(undefined, new Set(['a', 'b'])), true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('subtreeChanged: empty diff arrays → no regen needed', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const diff = { added: [], changed: [], removed: [], rewired: [], linked: [], flowChanged: [] };
|
||||||
|
assert.equal(api.subtreeChanged(diff, new Set(['a', 'b'])), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('subtreeChanged: id in added → regen', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const diff = { added: ['x', 'b'], changed: [], removed: [], rewired: [] };
|
||||||
|
assert.equal(api.subtreeChanged(diff, new Set(['a', 'b'])), true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('subtreeChanged: id in changed → regen', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const diff = { added: [], changed: ['a'], removed: [], rewired: [] };
|
||||||
|
assert.equal(api.subtreeChanged(diff, new Set(['a', 'b'])), true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('subtreeChanged: only unrelated ids → no regen', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const diff = { added: ['z'], changed: ['y'], removed: ['x'], rewired: ['w'] };
|
||||||
|
assert.equal(api.subtreeChanged(diff, new Set(['a', 'b'])), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('subtreeChanged: tab id in diff but not in subtree → no regen', () => {
|
||||||
|
// Tab id over-triggering avoidance: when an unrelated tab changes, its
|
||||||
|
// tab id lands in changed/added but should not affect this dashboardAPI.
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const diff = { added: [], changed: ['unrelated_tab'], removed: [], rewired: [] };
|
||||||
|
assert.equal(api.subtreeChanged(diff, new Set(['dashboardApiId', 'childA'])), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('subtreeIdsFor: includes dashboardAPI id + child id + grandchild ids', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const grandchild = {
|
||||||
|
config: { general: { id: 'gc-1' }, functionality: { softwareType: 'measurement' } },
|
||||||
|
};
|
||||||
|
const grandchildEntry = { child: grandchild, position: 'downstream', softwareType: 'measurement' };
|
||||||
|
const child = {
|
||||||
|
config: { general: { id: 'child-1' }, functionality: { softwareType: 'pumpingStation' } },
|
||||||
|
childRegistrationUtils: {
|
||||||
|
registeredChildren: new Map([['gc-1', grandchildEntry]]),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const ids = api.subtreeIdsFor('dApi-1', child);
|
||||||
|
assert.equal(ids.has('dApi-1'), true);
|
||||||
|
assert.equal(ids.has('child-1'), true);
|
||||||
|
assert.equal(ids.has('gc-1'), true);
|
||||||
|
assert.equal(ids.size, 3);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('subtreeIdsFor: handles child with no grandchildren', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const child = {
|
||||||
|
config: { general: { id: 'child-1' }, functionality: { softwareType: 'measurement' } },
|
||||||
|
};
|
||||||
|
const ids = api.subtreeIdsFor('dApi-1', child);
|
||||||
|
assert.equal(ids.size, 2);
|
||||||
|
assert.ok(ids.has('dApi-1') && ids.has('child-1'));
|
||||||
|
});
|
||||||
40
test/basic/slice37-emitted-fields.basic.test.js
Normal file
40
test/basic/slice37-emitted-fields.basic.test.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
|
||||||
|
const DashboardApi = require('../../src/specificClass.js');
|
||||||
|
|
||||||
|
test('rotatingMachine template panels declare meta.emittedFields', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const dash = api.loadTemplate('machine');
|
||||||
|
assert.ok(dash, 'template loaded');
|
||||||
|
const withFields = dash.panels.filter((p) => p?.meta?.emittedFields);
|
||||||
|
// 13 non-row panels in machine.json get annotated; row panels are skipped.
|
||||||
|
assert.ok(withFields.length >= 10, `expected ≥10 annotated panels, got ${withFields.length}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('collectEmittedFields aggregates fields across panels', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const dash = api.loadTemplate('machine');
|
||||||
|
const fields = api.collectEmittedFields(dash);
|
||||||
|
assert.ok(fields.has('ctrl'), 'ctrl field declared by Ctrl % panel');
|
||||||
|
assert.ok(fields.has('flow'), 'flow field declared by Flow panel');
|
||||||
|
assert.ok(fields.has('efficiency'), 'efficiency field declared by Efficiency panel');
|
||||||
|
assert.ok(fields.has('relDistFromPeak'), 'relDistFromPeak declared by Distance from Peak panel');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('collectEmittedFields returns empty Set for template without meta', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
// measurement.json has no emittedFields metadata yet — its panels predate the annotation.
|
||||||
|
const dash = api.loadTemplate('measurement');
|
||||||
|
const fields = api.collectEmittedFields(dash);
|
||||||
|
assert.equal(fields.size, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('collectEmittedFields handles null/empty dashboard input gracefully', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
assert.equal(api.collectEmittedFields(null).size, 0);
|
||||||
|
assert.equal(api.collectEmittedFields({}).size, 0);
|
||||||
|
assert.equal(api.collectEmittedFields({ panels: [] }).size, 0);
|
||||||
|
});
|
||||||
43
test/basic/slice38-dashed-bounds.basic.test.js
Normal file
43
test/basic/slice38-dashed-bounds.basic.test.js
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
|
||||||
|
const DashboardApi = require('../../src/specificClass.js');
|
||||||
|
|
||||||
|
test('rotatingMachine template carries byRegexp dashed overrides for .min/.max', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const dash = api.loadTemplate('machine');
|
||||||
|
const ts = dash.panels.filter((p) => p.type === 'timeseries');
|
||||||
|
assert.ok(ts.length >= 1, 'has at least one timeseries panel');
|
||||||
|
|
||||||
|
for (const panel of ts) {
|
||||||
|
const overrides = panel?.fieldConfig?.overrides || [];
|
||||||
|
const minOv = overrides.find(
|
||||||
|
(o) => o.matcher?.id === 'byRegexp' && /\.min\$/.test(o.matcher?.options || '')
|
||||||
|
);
|
||||||
|
const maxOv = overrides.find(
|
||||||
|
(o) => o.matcher?.id === 'byRegexp' && /\.max\$/.test(o.matcher?.options || '')
|
||||||
|
);
|
||||||
|
assert.ok(minOv, `panel "${panel.title}" missing .min override`);
|
||||||
|
assert.ok(maxOv, `panel "${panel.title}" missing .max override`);
|
||||||
|
|
||||||
|
const lineStyle = minOv.properties.find((p) => p.id === 'custom.lineStyle');
|
||||||
|
assert.equal(lineStyle?.value?.fill, 'dash', '.min override sets dashed lineStyle');
|
||||||
|
assert.deepEqual(lineStyle?.value?.dash, [10, 10], '.min override sets dash pattern [10,10]');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('dashed overrides are forward-compatible: no effect when fields absent', () => {
|
||||||
|
// The byRegexp matcher only affects series whose name ends in .min/.max.
|
||||||
|
// When the node doesn't emit those fields, the override has no effect on
|
||||||
|
// the rendered panel — series simply don't appear. Verified by the
|
||||||
|
// matcher pattern being a strict regex.
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const dash = api.loadTemplate('machine');
|
||||||
|
const ts = dash.panels.filter((p) => p.type === 'timeseries')[0];
|
||||||
|
const minOv = ts.fieldConfig.overrides.find(
|
||||||
|
(o) => o.matcher?.id === 'byRegexp' && /\.min\$/.test(o.matcher.options || '')
|
||||||
|
);
|
||||||
|
assert.match(minOv.matcher.options, /\$$/, 'matcher anchored to end of name');
|
||||||
|
});
|
||||||
102
test/basic/slice39-no-duplication.basic.test.js
Normal file
102
test/basic/slice39-no-duplication.basic.test.js
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
|
||||||
|
const DashboardApi = require('../../src/specificClass.js');
|
||||||
|
|
||||||
|
function makeChild(id, softwareType) {
|
||||||
|
return {
|
||||||
|
config: {
|
||||||
|
general: { id, name: id },
|
||||||
|
functionality: { softwareType, positionVsParent: 'downstream' },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeRoot(softwareType, children) {
|
||||||
|
const map = new Map();
|
||||||
|
for (const c of children) {
|
||||||
|
map.set(c.config.general.id, {
|
||||||
|
child: c,
|
||||||
|
softwareType: c.config.functionality.softwareType,
|
||||||
|
position: 'downstream',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
config: {
|
||||||
|
general: { id: 'root-1', name: 'PS-North' },
|
||||||
|
functionality: { softwareType, positionVsParent: 'atequipment' },
|
||||||
|
},
|
||||||
|
childRegistrationUtils: { registeredChildren: map },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
test('pumpingStation template has emittedFields on every non-row panel', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const dash = api.loadTemplate('pumpingStation');
|
||||||
|
const annotated = dash.panels.filter((p) => p.type !== 'row' && p?.meta?.emittedFields);
|
||||||
|
const nonRowPanels = dash.panels.filter((p) => p.type !== 'row');
|
||||||
|
assert.equal(annotated.length, nonRowPanels.length,
|
||||||
|
`expected all ${nonRowPanels.length} non-row panels annotated, got ${annotated.length}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('child-covered fields remove duplicate parent panels', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
|
||||||
|
// Parent + 1 child with a fake template that emits 'level' (matches one of
|
||||||
|
// the pumpingStation parent's panels). The parent's "Level" panel should
|
||||||
|
// be removed when the child covers it.
|
||||||
|
const child1 = makeChild('child-1', 'measurement');
|
||||||
|
const root = makeRoot('pumpingStation', [child1]);
|
||||||
|
|
||||||
|
// Pre-count parent panels with the 'level' emitted field.
|
||||||
|
const parentTemplate = api.loadTemplate('pumpingStation');
|
||||||
|
const parentLevelPanels = parentTemplate.panels.filter(
|
||||||
|
(p) => p?.meta?.emittedFields?.includes('level')
|
||||||
|
);
|
||||||
|
assert.ok(parentLevelPanels.length > 0, 'parent has level panels in template');
|
||||||
|
|
||||||
|
// Monkey-patch the child's dashboard to claim it covers 'level'.
|
||||||
|
const origLoad = api.loadTemplate.bind(api);
|
||||||
|
api.loadTemplate = function (type) {
|
||||||
|
const dash = origLoad(type);
|
||||||
|
if (type === 'measurement' && dash) {
|
||||||
|
// Inject emittedFields = ['level'] on first non-row panel.
|
||||||
|
const firstPanel = dash.panels.find((p) => p.type !== 'row');
|
||||||
|
if (firstPanel) (firstPanel.meta ||= {}).emittedFields = ['level'];
|
||||||
|
}
|
||||||
|
return dash;
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = api.generateDashboardsForGraph(root);
|
||||||
|
const rootResult = result[0];
|
||||||
|
const rootLevelPanels = rootResult.dashboard.panels.filter(
|
||||||
|
(p) => p?.meta?.emittedFields?.includes('level')
|
||||||
|
);
|
||||||
|
assert.equal(rootLevelPanels.length, 0,
|
||||||
|
'level panel(s) should be removed from parent when child covers them');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('parent panels are kept when no child covers their fields', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const child1 = makeChild('child-1', 'measurement'); // measurement.json has no emittedFields
|
||||||
|
const root = makeRoot('pumpingStation', [child1]);
|
||||||
|
const result = api.generateDashboardsForGraph(root);
|
||||||
|
const rootResult = result[0];
|
||||||
|
const beforeTemplate = api.loadTemplate('pumpingStation');
|
||||||
|
const beforeNonRow = beforeTemplate.panels.filter((p) => p.type !== 'row').length;
|
||||||
|
const afterNonRow = rootResult.dashboard.panels.filter((p) => p.type !== 'row').length;
|
||||||
|
assert.equal(afterNonRow, beforeNonRow,
|
||||||
|
'no panels should be removed when no child declares overlapping fields');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('row panels are never removed (structural)', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const child1 = makeChild('child-1', 'measurement');
|
||||||
|
const root = makeRoot('pumpingStation', [child1]);
|
||||||
|
const result = api.generateDashboardsForGraph(root);
|
||||||
|
const rootRows = result[0].dashboard.panels.filter((p) => p.type === 'row');
|
||||||
|
const templateRows = api.loadTemplate('pumpingStation').panels.filter((p) => p.type === 'row');
|
||||||
|
assert.equal(rootRows.length, templateRows.length, 'all row panels preserved');
|
||||||
|
});
|
||||||
69
test/basic/slice40-mgc-template.basic.test.js
Normal file
69
test/basic/slice40-mgc-template.basic.test.js
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
|
||||||
|
const DashboardApi = require('../../src/specificClass.js');
|
||||||
|
|
||||||
|
test('MGC template panels are all group-level (no per-pump fields)', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const dash = api.loadTemplate('machineGroup');
|
||||||
|
const PER_PUMP = new Set(['ctrl', 'state', 'runtime', 'pressure.upstream', 'pressure.downstream', 'temperature']);
|
||||||
|
for (const panel of dash.panels || []) {
|
||||||
|
if (panel.type === 'row') continue;
|
||||||
|
const fields = panel?.meta?.emittedFields || [];
|
||||||
|
for (const f of fields) {
|
||||||
|
assert.ok(!PER_PUMP.has(f),
|
||||||
|
`MGC panel "${panel.title}" emits ${f}, which belongs to rotatingMachine (per-pump). Move to children.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('MGC group panels are annotated (mode, scaling, abs/rel peak, totals)', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const dash = api.loadTemplate('machineGroup');
|
||||||
|
const non = dash.panels.filter((p) => p.type !== 'row');
|
||||||
|
const annotated = non.filter((p) => p?.meta?.emittedFields);
|
||||||
|
assert.equal(annotated.length, non.length, 'every non-row MGC panel annotated');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('MGC timeseries panels carry dashed-bounds overrides for .min/.max', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const dash = api.loadTemplate('machineGroup');
|
||||||
|
const ts = dash.panels.filter((p) => p.type === 'timeseries');
|
||||||
|
for (const panel of ts) {
|
||||||
|
const ov = panel?.fieldConfig?.overrides || [];
|
||||||
|
const hasMin = ov.some((o) => o.matcher?.id === 'byRegexp' && /\.min\$/.test(o.matcher?.options || ''));
|
||||||
|
const hasMax = ov.some((o) => o.matcher?.id === 'byRegexp' && /\.max\$/.test(o.matcher?.options || ''));
|
||||||
|
assert.ok(hasMin && hasMax, `MGC ts panel "${panel.title}" missing .min/.max dashed override`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('MGC composer dedups parent panels covered by pump children', () => {
|
||||||
|
// If a rotatingMachine child claims to emit `flow.total` (it shouldn't, but
|
||||||
|
// suppose), the parent MGC's "Total Flow" panel would be removed. Verify
|
||||||
|
// the composer applies the same dedup rule to MGC parents.
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
function makeChildSrc(id) {
|
||||||
|
return { config: { general: { id }, functionality: { softwareType: 'machine', positionVsParent: 'downstream' } } };
|
||||||
|
}
|
||||||
|
const child = makeChildSrc('pump-1');
|
||||||
|
const root = {
|
||||||
|
config: { general: { id: 'mgc-1', name: 'MGC' }, functionality: { softwareType: 'machineGroupControl', positionVsParent: 'atequipment' } },
|
||||||
|
childRegistrationUtils: { registeredChildren: new Map([['pump-1', { child, position: 'downstream', softwareType: 'machine' }]]) },
|
||||||
|
};
|
||||||
|
const origLoad = api.loadTemplate.bind(api);
|
||||||
|
api.loadTemplate = function (t) {
|
||||||
|
const dash = origLoad(t);
|
||||||
|
if (t === 'machine') {
|
||||||
|
// Make the pump's template falsely claim it emits flow.total/flow.group
|
||||||
|
const firstPanel = dash.panels.find((p) => p.type !== 'row');
|
||||||
|
if (firstPanel) (firstPanel.meta ||= {}).emittedFields = ['flow.total', 'flow.group'];
|
||||||
|
}
|
||||||
|
return dash;
|
||||||
|
};
|
||||||
|
const results = api.generateDashboardsForGraph(root);
|
||||||
|
const mgcDash = results[0].dashboard;
|
||||||
|
const totalFlowPanel = mgcDash.panels.find((p) => p.title === 'Total Flow');
|
||||||
|
assert.ok(!totalFlowPanel, 'MGC Total Flow panel should be removed when child claims flow.total/flow.group');
|
||||||
|
});
|
||||||
75
test/basic/slice41-manual-regen.basic.test.js
Normal file
75
test/basic/slice41-manual-regen.basic.test.js
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
|
||||||
|
const DashboardApi = require('../../src/specificClass.js');
|
||||||
|
const handlers = require('../../src/commands/handlers.js');
|
||||||
|
|
||||||
|
function makeCtx(sends, nodeId = 'dApi-1') {
|
||||||
|
return {
|
||||||
|
node: { id: nodeId },
|
||||||
|
RED: { nodes: { getNode: () => null } },
|
||||||
|
send: (m) => sends.push(m),
|
||||||
|
logger: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeChildPayload(id, softwareType = 'measurement') {
|
||||||
|
return {
|
||||||
|
config: {
|
||||||
|
general: { id, name: id },
|
||||||
|
functionality: { softwareType, positionVsParent: 'downstream' },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
test('recordChild caches child source by id; subsequent ones replace by id', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
api.recordChild(makeChildPayload('a'));
|
||||||
|
api.recordChild(makeChildPayload('b'));
|
||||||
|
api.recordChild(makeChildPayload('a')); // replace
|
||||||
|
assert.equal(api.cachedChildSources().length, 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('regenerate-dashboard with no cached children is a no-op (no msgs emitted)', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
const sends = [];
|
||||||
|
handlers.regenerateDashboard(api, { topic: 'regenerate-dashboard', payload: {} }, makeCtx(sends));
|
||||||
|
assert.equal(sends.length, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('regenerate-dashboard re-emits for each cached child, bypassing diff', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
// Pre-populate cache as if two children had registered.
|
||||||
|
api.recordChild(makeChildPayload('m-1'));
|
||||||
|
api.recordChild(makeChildPayload('m-2'));
|
||||||
|
|
||||||
|
// Set a diff that says nothing changed — registerChild would skip, but
|
||||||
|
// regenerateDashboard should ignore the predicate.
|
||||||
|
api.lastFlowsStartedDiff = { added: [], changed: [], removed: [], rewired: [] };
|
||||||
|
|
||||||
|
const sends = [];
|
||||||
|
handlers.regenerateDashboard(api, { topic: 'regenerate-dashboard', payload: {} }, makeCtx(sends));
|
||||||
|
// Each child yields at least one dashboard message (the root for the child's view).
|
||||||
|
assert.ok(sends.length >= 2, `expected ≥2 emitted msgs, got ${sends.length}`);
|
||||||
|
// Every emitted msg carries trigger: 'manual' in meta.
|
||||||
|
for (const m of sends) assert.equal(m.meta?.trigger, 'manual');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('child.register stamps trigger: child.register in emitted msg meta', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
api.lastFlowsStartedDiff = null; // cold-start → always regen
|
||||||
|
const sends = [];
|
||||||
|
handlers.registerChild(api, { topic: 'child.register', payload: makeChildPayload('m-3') }, makeCtx(sends));
|
||||||
|
assert.ok(sends.length >= 1);
|
||||||
|
for (const m of sends) assert.equal(m.meta?.trigger, 'child.register');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('command registry exposes regenerate-dashboard with regen alias', () => {
|
||||||
|
const registry = require('../../src/commands/index.js');
|
||||||
|
const entry = registry.find((e) => e.topic === 'regenerate-dashboard');
|
||||||
|
assert.ok(entry, 'topic registered');
|
||||||
|
assert.deepEqual(entry.aliases, ['regen']);
|
||||||
|
assert.equal(typeof entry.handler, 'function');
|
||||||
|
});
|
||||||
146
test/basic/slice43-output-manifest.basic.test.js
Normal file
146
test/basic/slice43-output-manifest.basic.test.js
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Output-coverage tests per .claude/rules/output-coverage.md and
|
||||||
|
// test/_output-manifest.md. Every output is exercised in both populated
|
||||||
|
// and degraded states.
|
||||||
|
|
||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
|
||||||
|
const DashboardApi = require('../../src/specificClass.js');
|
||||||
|
const handlers = require('../../src/commands/handlers.js');
|
||||||
|
|
||||||
|
function makeChild(id, name = id, softwareType = 'measurement') {
|
||||||
|
return {
|
||||||
|
config: {
|
||||||
|
general: { id, name },
|
||||||
|
functionality: { softwareType, positionVsParent: 'downstream' },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeCtx(nodeId = 'dApi-1') {
|
||||||
|
const sends = [];
|
||||||
|
const logs = [];
|
||||||
|
return {
|
||||||
|
sends,
|
||||||
|
logs,
|
||||||
|
ctx: {
|
||||||
|
node: { id: nodeId },
|
||||||
|
RED: { nodes: { getNode: () => null } },
|
||||||
|
send: (m) => sends.push(m),
|
||||||
|
logger: null,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Port 0 message shape: populated ────────────────────────────────────
|
||||||
|
test('Port 0 emit has all required keys when token + folderUid configured', () => {
|
||||||
|
const api = new DashboardApi({
|
||||||
|
grafanaConnector: { protocol: 'http', host: 'grafana', port: 3000, bearerToken: 'tok', folderUid: 'rnd-folder' },
|
||||||
|
});
|
||||||
|
api.lastFlowsStartedDiff = null; // cold start
|
||||||
|
const { sends, ctx } = makeCtx();
|
||||||
|
handlers.registerChild(api, { topic: 'child.register', payload: makeChild('m-1', 'FT-001') }, ctx);
|
||||||
|
|
||||||
|
assert.ok(sends.length >= 1);
|
||||||
|
const m = sends[0];
|
||||||
|
assert.equal(m.topic, 'create');
|
||||||
|
assert.equal(m.method, 'POST');
|
||||||
|
assert.equal(m.headers['Accept'], 'application/json');
|
||||||
|
assert.equal(m.headers['Content-Type'], 'application/json');
|
||||||
|
assert.equal(m.headers.Authorization, 'Bearer tok');
|
||||||
|
assert.match(m.url, /^http:\/\/grafana:3000\/api\/dashboards\/db$/);
|
||||||
|
assert.equal(m.payload.overwrite, true);
|
||||||
|
assert.ok(m.payload.dashboard, 'dashboard JSON present');
|
||||||
|
assert.equal(m.payload.folderUid, 'rnd-folder');
|
||||||
|
// meta
|
||||||
|
assert.equal(m.meta.nodeId, 'm-1');
|
||||||
|
assert.equal(m.meta.softwareType, 'measurement');
|
||||||
|
assert.equal(typeof m.meta.uid, 'string');
|
||||||
|
assert.equal(m.meta.title, 'FT-001');
|
||||||
|
assert.equal(m.meta.trigger, 'child.register');
|
||||||
|
});
|
||||||
|
|
||||||
|
// ── Port 0 degraded: token absent, folderUid absent ───────────────────
|
||||||
|
test('Port 0 emit omits Authorization header when no bearerToken configured', () => {
|
||||||
|
const api = new DashboardApi({}); // no creds
|
||||||
|
api.lastFlowsStartedDiff = null;
|
||||||
|
const { sends, ctx } = makeCtx();
|
||||||
|
handlers.registerChild(api, { topic: 'child.register', payload: makeChild('m-2') }, ctx);
|
||||||
|
const m = sends[0];
|
||||||
|
assert.equal(m.headers.Authorization, undefined,
|
||||||
|
'Authorization should be absent (not empty string, not null)');
|
||||||
|
assert.equal(m.payload.folderUid, undefined,
|
||||||
|
'folderUid should be absent when empty');
|
||||||
|
assert.equal('folderId' in m.payload, false,
|
||||||
|
'folderId should also be absent (not 0)');
|
||||||
|
});
|
||||||
|
|
||||||
|
// ── Port 0 degraded: no template for softwareType ─────────────────────
|
||||||
|
test('Port 0 emits no message when child softwareType has no template', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
api.lastFlowsStartedDiff = null;
|
||||||
|
const { sends, ctx } = makeCtx();
|
||||||
|
// 'nonexistent' has no config/<>.json file
|
||||||
|
handlers.registerChild(api, { topic: 'child.register', payload: makeChild('m-3', 'm-3', 'nonexistent') }, ctx);
|
||||||
|
assert.equal(sends.length, 0, 'no upsert message should be emitted when template missing');
|
||||||
|
});
|
||||||
|
|
||||||
|
// ── Diff-skip path: no emission, logged outcome:no-diff ───────────────
|
||||||
|
test('Diff-skip suppresses Port 0 emission AND records the skip in source.logger', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
// Set diff so the predicate returns false (no overlap with subtree).
|
||||||
|
api.lastFlowsStartedDiff = { added: ['unrelated'], changed: [], removed: [], rewired: [] };
|
||||||
|
// Stub logger to capture
|
||||||
|
const captured = [];
|
||||||
|
api.logger = { info: (e) => captured.push(e), debug: () => {} };
|
||||||
|
|
||||||
|
const { sends, ctx } = makeCtx('dApi-1');
|
||||||
|
handlers.registerChild(api, { topic: 'child.register', payload: makeChild('m-4') }, ctx);
|
||||||
|
|
||||||
|
assert.equal(sends.length, 0, 'no upsert emitted when subtree unchanged');
|
||||||
|
const skipLog = captured.find((e) => e.event === 'regen-skipped');
|
||||||
|
assert.ok(skipLog, 'skip log emitted');
|
||||||
|
assert.equal(skipLog.outcome, 'no-diff');
|
||||||
|
assert.equal(skipLog.trigger, 'child.register');
|
||||||
|
assert.equal(skipLog.dashboardApiId, 'dApi-1');
|
||||||
|
assert.equal(skipLog.childId, 'm-4');
|
||||||
|
});
|
||||||
|
|
||||||
|
// ── Successful regen logs structured fields per N-4 ───────────────────
|
||||||
|
test('Successful regen logs event=regen-emitted with N-4 fields', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
api.lastFlowsStartedDiff = null; // cold start → always regen
|
||||||
|
const captured = [];
|
||||||
|
api.logger = { info: (e) => captured.push(e), debug: () => {} };
|
||||||
|
|
||||||
|
const { ctx } = makeCtx('dApi-1');
|
||||||
|
handlers.registerChild(api, { topic: 'child.register', payload: makeChild('m-5') }, ctx);
|
||||||
|
|
||||||
|
const emitLog = captured.find((e) => e.event === 'regen-emitted');
|
||||||
|
assert.ok(emitLog, 'regen-emitted log present');
|
||||||
|
assert.equal(emitLog.trigger, 'child.register');
|
||||||
|
assert.equal(emitLog.dashboardApiId, 'dApi-1');
|
||||||
|
assert.equal(emitLog.childId, 'm-5');
|
||||||
|
assert.equal(typeof emitLog.dashboardCount, 'number');
|
||||||
|
});
|
||||||
|
|
||||||
|
// ── Manual regen logs manual-regen-requested + emits with trigger:manual ─
|
||||||
|
test('Manual regen logs manual-regen-requested and stamps trigger=manual', () => {
|
||||||
|
const api = new DashboardApi({});
|
||||||
|
api.recordChild(makeChild('m-6'));
|
||||||
|
const captured = [];
|
||||||
|
api.logger = { info: (e) => captured.push(e), debug: () => {} };
|
||||||
|
|
||||||
|
const { sends, ctx } = makeCtx();
|
||||||
|
handlers.regenerateDashboard(api, { topic: 'regenerate-dashboard', payload: {} }, ctx);
|
||||||
|
|
||||||
|
const reqLog = captured.find((e) => e.event === 'manual-regen-requested');
|
||||||
|
assert.ok(reqLog, 'manual-regen-requested log present');
|
||||||
|
assert.equal(reqLog.cachedChildCount, 1);
|
||||||
|
|
||||||
|
if (sends.length > 0) {
|
||||||
|
assert.equal(sends[0].meta.trigger, 'manual');
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user