|
@@ -95,14 +95,10 @@ export class CustomDashboardComponent implements OnChanges {
|
|
|
*/
|
|
*/
|
|
|
private fetchDataAndDraw(graph: any, range: Date[], containerId: string) {
|
|
private fetchDataAndDraw(graph: any, range: Date[], containerId: string) {
|
|
|
const groupId = graph.graphId;
|
|
const groupId = graph.graphId;
|
|
|
- const sensorIds = [];
|
|
|
|
|
- const sensors = [];
|
|
|
|
|
- const requests = []; // Array to hold all observable requests
|
|
|
|
|
|
|
|
|
|
this.graphViews[groupId] = null;
|
|
this.graphViews[groupId] = null;
|
|
|
console.log(groupId);
|
|
console.log(groupId);
|
|
|
|
|
|
|
|
- for (const source of graph.sources) {
|
|
|
|
|
// 1. Find the sensor metadata
|
|
// 1. Find the sensor metadata
|
|
|
const unit = this.units.find(u => u.unit.unitId === graph.sources[0].unitId);
|
|
const unit = this.units.find(u => u.unit.unitId === graph.sources[0].unitId);
|
|
|
const sensor = unit?.sensors?.find(s => s.sensorId === graph.sources[0].sensorIds[0]);
|
|
const sensor = unit?.sensors?.find(s => s.sensorId === graph.sources[0].sensorIds[0]);
|
|
@@ -115,9 +111,6 @@ export class CustomDashboardComponent implements OnChanges {
|
|
|
const unitId = unit.unit.unitId;
|
|
const unitId = unit.unit.unitId;
|
|
|
const sensorId = sensor.sensorId;
|
|
const sensorId = sensor.sensorId;
|
|
|
|
|
|
|
|
- sensorIds.push(sensorId);
|
|
|
|
|
- sensors.push(sensor);
|
|
|
|
|
-
|
|
|
|
|
// 4. Create the request for this specific source/sensor
|
|
// 4. Create the request for this specific source/sensor
|
|
|
const request = this.observationService.getObservation$Response({
|
|
const request = this.observationService.getObservation$Response({
|
|
|
unit_id: unitId,
|
|
unit_id: unitId,
|
|
@@ -136,27 +129,17 @@ export class CustomDashboardComponent implements OnChanges {
|
|
|
})
|
|
})
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- requests.push(request);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
// Execute all requests and render
|
|
// Execute all requests and render
|
|
|
- if (requests.length > 0) {
|
|
|
|
|
- forkJoin(requests).subscribe(async (results: any[][]) => {
|
|
|
|
|
- const allObservations = results.map(res => res ? res : []);
|
|
|
|
|
-
|
|
|
|
|
- // TODO here i want to load a custom graph with multiple datasets
|
|
|
|
|
- // - each dataset could have different type (line or bar)
|
|
|
|
|
- // - sensorIds, sensors - information about sensors
|
|
|
|
|
- // - allObservations - the recieved data that will be displayed
|
|
|
|
|
-
|
|
|
|
|
|
|
+ forkJoin(request).subscribe(async (results: any[][]) => {
|
|
|
|
|
+ const allObservations = [].concat(...results).filter(obs => obs !== null);
|
|
|
if (allObservations.length > 0) {
|
|
if (allObservations.length > 0) {
|
|
|
- this.graphViews[groupId] = await GraphLoader.getGraph(sensorIds, allObservations, sensors, containerId, false);
|
|
|
|
|
|
|
+ this.graphViews[groupId] = await GraphLoader.getGraph(sensorId, allObservations, sensor, containerId, false);
|
|
|
} else {
|
|
} else {
|
|
|
this.graphViews[groupId] = await GraphLoader.getGraph(null, null, null, containerId, null);
|
|
this.graphViews[groupId] = await GraphLoader.getGraph(null, null, null, containerId, null);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Get all units and theirs sensors from backend
|
|
* Get all units and theirs sensors from backend
|