Revize 05d4a2a9
Přidáno uživatelem Jakub Hlaváč před více než 3 roky(ů)
src/app/dashboard/components/sensor-insert-popup/sensor-insert-popup.component.html | ||
---|---|---|
23 | 23 |
<span class="input-group-text"><i class="fas fa-file-signature"></i></span> |
24 | 24 |
</div> |
25 | 25 |
<select formControlName="sensorType" id="sensorType"> |
26 |
<option [ngValue]="null" disabled>Select sensor type</option>
|
|
26 |
<option value="null" disabled>Select sensor type</option>
|
|
27 | 27 |
<option *ngFor="let sensorType of sensorTypes; let i = index" [value]="sensorTypes[i].sensorType"> |
28 | 28 |
{{sensorTypes[i].sensorType}} |
29 | 29 |
</option> |
... | ... | |
34 | 34 |
<span class="input-group-text"><i class="fas fa-tint"></i></span> |
35 | 35 |
</div> |
36 | 36 |
<select formControlName="phenomenons" id="phenomenons"> |
37 |
<option [ngValue]="null" disabled>Select phenomenon</option>
|
|
37 |
<option value="null" disabled>Select phenomenon</option>
|
|
38 | 38 |
<option *ngFor="let phenomenon of phenomenons; let i = index" [value]="phenomenons[i].phenomenonId"> |
39 | 39 |
{{phenomenons[i].phenomenonName}} ( {{ phenomenons[i].unit}}) |
40 | 40 |
</option> |
src/app/dashboard/components/sensor-insert-popup/sensor-insert-popup.component.ts | ||
---|---|---|
53 | 53 |
return this.formBuilder.group({ |
54 | 54 |
sensorId: ['', Validators.required], |
55 | 55 |
sensorName: ['', Validators.required], |
56 |
sensorType: ['', Validators.required], |
|
57 |
phenomenons: ['', Validators.required] |
|
56 |
sensorType: ['null', Validators.required],
|
|
57 |
phenomenons: ['null', Validators.required]
|
|
58 | 58 |
}); |
59 | 59 |
} |
60 | 60 |
|
src/app/sensor/components/sensor.component.html | ||
---|---|---|
7 | 7 |
</div> |
8 | 8 |
<div class="col-1"></div> |
9 | 9 |
<div class="col-xs-3"> |
10 |
<h5><span class="text-color-sensor-unit">Unit ID: {{unitId}}</span></h5>
|
|
10 |
<h5><span class="text-color-sensor-unit">Unit ID: <a [routerLink]="['/dashboard/unit', unitId]">{{unitId}}</a></span></h5>
|
|
11 | 11 |
</div> |
12 | 12 |
<div class="col-1"></div> |
13 | 13 |
</div> |
src/app/sensor/components/sensor.component.ts | ||
---|---|---|
8 | 8 |
import {HttpResponse} from '@angular/common/http'; |
9 | 9 |
import {map} from 'rxjs/operators'; |
10 | 10 |
import {ToastService} from '../../shared/services/toast.service'; |
11 |
import {Sensor} from '../../shared/api/endpoints/models/sensor'; |
|
12 |
import {SensorsService} from '../../shared/api/endpoints/services/sensors.service'; |
|
11 | 13 |
|
12 | 14 |
declare var require: any |
13 | 15 |
|
... | ... | |
31 | 33 |
showAggregation = false; |
32 | 34 |
aggregationFunction: AggregationModel[]; |
33 | 35 |
selectedAggregationFunction = 'HOUR'; |
36 |
sensor: Sensor; |
|
34 | 37 |
|
35 | 38 |
constructor( |
36 | 39 |
private activatedRoute: ActivatedRoute, |
37 | 40 |
private analyticsService: AnalyticsService, |
38 | 41 |
private observationService: ObservationService, |
39 |
private toastService: ToastService |
|
42 |
private toastService: ToastService, |
|
43 |
private sensorsService: SensorsService |
|
40 | 44 |
) { |
41 | 45 |
this.sensorId = parseInt(this.activatedRoute.snapshot.paramMap.get('sensorId'), 10); |
42 | 46 |
this.unitId = parseInt(this.activatedRoute.snapshot.paramMap.get('unitId'), 10); |
... | ... | |
50 | 54 |
} |
51 | 55 |
|
52 | 56 |
ngOnInit(): void { |
53 |
this.showGraph(); |
|
57 |
this.sensorsService.getUnitSensors({unit_id: this.unitId}).subscribe(sensors => { |
|
58 |
if (sensors) { |
|
59 |
this.sensor = sensors.filter(value => value.sensorId === this.sensorId)[0]; |
|
60 |
this.showGraph(); |
|
61 |
} |
|
62 |
}); |
|
54 | 63 |
} |
55 | 64 |
|
56 | 65 |
showGraph() { |
... | ... | |
94 | 103 |
observations => { |
95 | 104 |
if (observations) { |
96 | 105 |
// GraphLoader.getGraph(this.sensorId, observations[this.sensorId].data, observations[this.sensorId].interval, '#view'); |
97 |
GraphLoader.getGraph(this.sensorId, observations, this.getDummySensor(), '#view', true);
|
|
106 |
GraphLoader.getGraph(this.sensorId, observations, this.sensor, '#view', true);
|
|
98 | 107 |
} else { |
99 | 108 |
GraphLoader.getGraph(null, null, null, '#view', null); |
100 | 109 |
} |
... | ... | |
122 | 131 |
observations => { |
123 | 132 |
if (observations) { |
124 | 133 |
// GraphLoader.getObservationGraph(this.sensorId, observations, '#view'); |
125 |
GraphLoader.getGraph(this.sensorId, observations, this.getDummySensor(), '#view', false);
|
|
134 |
GraphLoader.getGraph(this.sensorId, observations, this.sensor, '#view', false);
|
|
126 | 135 |
} else { |
127 | 136 |
// GraphLoader.getObservationGraph(null, null, null); |
128 | 137 |
GraphLoader.getGraph(null, null, null,'#view', null); |
src/app/sensor/sensor.module.ts | ||
---|---|---|
5 | 5 |
import {CalendarModule} from 'primeng/calendar'; |
6 | 6 |
import {FormsModule} from '@angular/forms'; |
7 | 7 |
import {ListboxModule} from 'primeng/listbox'; |
8 |
import {RouterModule} from '@angular/router'; |
|
8 | 9 |
|
9 | 10 |
|
10 | 11 |
|
11 | 12 |
@NgModule({ |
12 | 13 |
declarations: [SensorComponent], |
13 |
imports: [ |
|
14 |
CommonModule, |
|
15 |
NavBarModule, |
|
16 |
CalendarModule, |
|
17 |
FormsModule, |
|
18 |
ListboxModule |
|
19 |
] |
|
14 |
imports: [ |
|
15 |
CommonModule, |
|
16 |
NavBarModule, |
|
17 |
CalendarModule, |
|
18 |
FormsModule, |
|
19 |
ListboxModule, |
|
20 |
RouterModule |
|
21 |
] |
|
20 | 22 |
}) |
21 | 23 |
export class SensorModule { } |
src/app/shared/nav-bar/components/unit-insert-popup/unit-insert-popup.component.html | ||
---|---|---|
99 | 99 |
<div class="input-group-prepend"> |
100 | 100 |
<span class="input-group-text"><i class="fas fa-file-signature"></i></span> |
101 | 101 |
</div> |
102 |
<input type="text" formControlName="sensorType" class="form-control" id="sensorType" |
|
103 |
placeholder="Sensor type"/> |
|
102 |
<select formControlName="sensorType" id="sensorType"> |
|
103 |
<option value="null" disabled>Select sensor type</option> |
|
104 |
<option *ngFor="let sensorType of sensorTypes; let i = index" [value]="sensorTypes[i].sensorType"> |
|
105 |
{{sensorTypes[i].sensorType}} |
|
106 |
</option> |
|
107 |
</select> |
|
104 | 108 |
</div> |
105 | 109 |
<div class="input-group form-group"> |
106 | 110 |
<div class="input-group-prepend"> |
107 | 111 |
<span class="input-group-text"><i class="fas fa-tint"></i></span> |
108 | 112 |
</div> |
109 | 113 |
<select formControlName="phenomenons" id="phenomenons"> |
110 |
<option [ngValue]="null" disabled>Select phenomenon</option>
|
|
114 |
<option value="null" disabled>Select phenomenon</option>
|
|
111 | 115 |
<option *ngFor="let phenomenon of phenomenons; let i = index" [value]="phenomenons[i].phenomenonId"> |
112 | 116 |
{{phenomenons[i].phenomenonName}} ( {{ phenomenons[i].unit}}) |
113 | 117 |
</option> |
... | ... | |
120 | 124 |
</form> |
121 | 125 |
<p-footer> |
122 | 126 |
<div class="popup-buttons-wrapper"> |
123 |
<p-button type="button" (click)="addSensor()" class="pr-2">Add sensor</p-button> |
|
127 |
<div> |
|
128 |
<p-button type="button" (click)="addSensor()" class="pr-2">Add sensor</p-button> |
|
129 |
<p-button *ngIf="sensors > 0" type="button" (click)="removeSensor()" class="pr-2">Remove last sensor</p-button> |
|
130 |
</div> |
|
124 | 131 |
<div> |
125 | 132 |
<p-button icon="pi pi-times" (click)="close()" label="Close" class="pr-2"></p-button> |
126 | 133 |
<p-button icon="pi pi-check" (click)="processInsertion()" type="submit" label="Save" class="pr-2"></p-button> |
src/app/shared/nav-bar/components/unit-insert-popup/unit-insert-popup.component.ts | ||
---|---|---|
57 | 57 |
|
58 | 58 |
createSensor(): FormGroup { |
59 | 59 |
return this.formBuilder.group({ |
60 |
sensorId: '',
|
|
61 |
sensorName: '',
|
|
62 |
sensorType: '',
|
|
63 |
phenomenons: ['']
|
|
60 |
sensorId: ['', Validators.required],
|
|
61 |
sensorName: ['', Validators.required],
|
|
62 |
sensorType: ['null', Validators.required],
|
|
63 |
phenomenons: ['null', Validators.required]
|
|
64 | 64 |
}); |
65 | 65 |
} |
66 | 66 |
|
src/app/unit/components/unit.component.html | ||
---|---|---|
37 | 37 |
<ng-container *ngFor="let sensor of sensors"> |
38 | 38 |
<div *ngIf="sensor.sensorId.toString().slice(0, 5) === group" class="p-field-checkbox"> |
39 | 39 |
<p-checkbox name="{{group}}" [value]="sensor.sensorId.toString()" [(ngModel)]="selectedSensors" [inputId]="sensor.sensorId.toString()" (onChange)="addSensorToGraph(sensor.sensorId.toString(), $event)"></p-checkbox> |
40 |
<label>{{sensor.sensorId}}</label>
|
|
40 |
<label>{{sensor.sensorName}}</label>
|
|
41 | 41 |
</div> |
42 | 42 |
</ng-container> |
43 | 43 |
</div> |
src/app/unit/components/unit.component.ts | ||
---|---|---|
64 | 64 |
if (!this.sensorGroups.some(group => group === sensorType)) { |
65 | 65 |
this.sensorGroups.push(sensorType); |
66 | 66 |
setTimeout(() => { |
67 |
//GraphLoader.getAnalyticsGraph(null, null, null, '#vega_container_' + sensor.sensorId.toString().slice(0, 5)); |
|
67 |
// GraphLoader.getAnalyticsGraph(null, null, null, '#vega_container_' + sensor.sensorId.toString().slice(0, 5));
|
|
68 | 68 |
GraphLoader.getGraph(null, null, null, '#vega_container_' + sensor.sensorId.toString().slice(0, 5),null ); |
69 | 69 |
}, 0); |
70 | 70 |
} |
... | ... | |
111 | 111 |
if (response.status === 200) { |
112 | 112 |
return response.body; |
113 | 113 |
} else if (response.status === 204) { |
114 |
//GraphLoader.getAnalyticsGraph(null, null, null, '#vega_container_' + selectSens.toString().slice(0, 5)); |
|
114 |
// GraphLoader.getAnalyticsGraph(null, null, null, '#vega_container_' + selectSens.toString().slice(0, 5));
|
|
115 | 115 |
GraphLoader.getGraph(null, null, null, '#vega_container_' + selectSens.toString().slice(0, 5),null ); |
116 | 116 |
this.toastService.showWarningNoData(); |
117 | 117 |
return response.body; |
... | ... | |
127 | 127 |
if (data[key].data) { |
128 | 128 |
const view = '#vega_container_' + key.slice(0, 5); |
129 | 129 |
if (this.selectedSensors.some(sens => sens.toString() === key)) { |
130 |
//GraphLoader.getAnalyticsGraph(key, data[key].data, data[key].interval, view); |
|
131 |
//GraphLoader.getGraph(this.selectedSensors, this.filteredAnalyticsData(groupId), view, true); |
|
130 |
// GraphLoader.getAnalyticsGraph(key, data[key].data, data[key].interval, view);
|
|
131 |
// GraphLoader.getGraph(this.selectedSensors, this.filteredAnalyticsData(groupId), view, true);
|
|
132 | 132 |
} else { |
133 | 133 |
GraphLoader.getGraph(null, null, null, view, null); |
134 | 134 |
} |
... | ... | |
162 | 162 |
// GraphLoader.getAnalyticsGraph(key, data[key].data, data[key].interval, view); |
163 | 163 |
GraphLoader.getGraph(this.selectedSensors, this.analyticsData, this.filteredSensorsInfos(groupId), view, true); |
164 | 164 |
} else { |
165 |
//GraphLoader.getAnalyticsGraph(null, null, null, view); |
|
165 |
// GraphLoader.getAnalyticsGraph(null, null, null, view);
|
|
166 | 166 |
GraphLoader.getGraph(null, null, null, view, null); |
167 | 167 |
} |
168 | 168 |
} |
... | ... | |
181 | 181 |
const groupId = sensorId.toString().slice(0, 5); |
182 | 182 |
const sensorGroupElement = '#vega_container_' + groupId; |
183 | 183 |
if (!this.selectedSensors.find(sensId => sensId.toString().slice(0, 5) === groupId)) { // if group of sensors is empty show empty graph |
184 |
//GraphLoader.getAnalyticsGraph(null, null, null, sensorGroupElement); |
|
184 |
// GraphLoader.getAnalyticsGraph(null, null, null, sensorGroupElement);
|
|
185 | 185 |
GraphLoader.getGraph(null, null, null, sensorGroupElement, null); |
186 | 186 |
} else { |
187 | 187 |
if (this.useAnalyticsData) { // use analytics data |
188 | 188 |
if (event.checked) { // if checked > add to graph |
189 | 189 |
if (this.analyticsData.some(sens => sens.sensorId === sensorId)) { // if already data for selected sensor in memory |
190 |
//GraphLoader.getAnalyticsGraph(sensorId, this.analyticsData.find(sens => sens.sensorId === sensorId).data, |
|
190 |
// GraphLoader.getAnalyticsGraph(sensorId, this.analyticsData.find(sens => sens.sensorId === sensorId).data,
|
|
191 | 191 |
// this.analyticsData.find((sens => sens.sensorId === sensorId).interval, sensorGroupElement); |
192 | 192 |
GraphLoader.getGraph(this.selectedSensors, this.analyticsData, this.filteredSensorsInfos(groupId), sensorGroupElement, true); |
193 | 193 |
|
... | ... | |
195 | 195 |
this.showGraph(false, sensorId); |
196 | 196 |
} |
197 | 197 |
} else { // remove sensor from graph |
198 |
//GraphLoader.getAnalyticsGraph(sensorId, this.analyticsData.find(sens => sens.sensorId === sensorId).data, |
|
198 |
// GraphLoader.getAnalyticsGraph(sensorId, this.analyticsData.find(sens => sens.sensorId === sensorId).data,
|
|
199 | 199 |
// this.analyticsData.find(sens => sens.sensorId === sensorId).interval, sensorGroupElement); |
200 | 200 |
GraphLoader.getGraph(this.selectedSensors, this.analyticsData, this.filteredSensorsInfos(groupId), sensorGroupElement, true); |
201 | 201 |
|
... | ... | |
203 | 203 |
} else { // use observations data |
204 | 204 |
if (event.checked) { // if checked > add to graph |
205 | 205 |
if (this.observationsData.some(sens => sens.sensorId.toString() === sensorId)) { // if already data for selected sensor in memory |
206 |
GraphLoader.getGraph(this.filteredSelectedSensors(groupId), this.filteredObservationData(groupId), this.filteredSensorsInfos(groupId), sensorGroupElement, false); |
|
207 |
//GraphLoader.getMultilineGraph(this.selectedSensors, this.filteredObservationData(groupId), sensorGroupElement) |
|
206 |
GraphLoader.getGraph(this.filteredSelectedSensors(groupId), this.filteredObservationData(groupId), |
|
207 |
this.filteredSensorsInfos(groupId), sensorGroupElement, false); |
|
208 |
// GraphLoader.getMultilineGraph(this.selectedSensors, this.filteredObservationData(groupId), sensorGroupElement) |
|
208 | 209 |
} else { // get data from server for added sensor and show graph for selected sensors |
209 | 210 |
this.showGraph(false, sensorId); |
210 | 211 |
} |
211 | 212 |
} else { // remove sensor from graph |
212 |
//GraphLoader.getMultilineGraph(this.selectedSensors, this.filteredObservationData(groupId), sensorGroupElement) |
|
213 |
GraphLoader.getGraph(this.filteredSelectedSensors(groupId), this.filteredObservationData(groupId), this.filteredSensorsInfos(groupId), sensorGroupElement, false); |
|
213 |
// GraphLoader.getMultilineGraph(this.selectedSensors, this.filteredObservationData(groupId), sensorGroupElement) |
|
214 |
GraphLoader.getGraph(this.filteredSelectedSensors(groupId), this.filteredObservationData(groupId), |
|
215 |
this.filteredSensorsInfos(groupId), sensorGroupElement, false); |
|
214 | 216 |
|
215 | 217 |
} |
216 | 218 |
} |
... | ... | |
236 | 238 |
|
237 | 239 |
|
238 | 240 |
filteredSelectedSensors(sensorGroupId: string): any { |
239 |
return this.selectedSensors.filter(sen => sen.toString().slice(0, 5) == sensorGroupId ); |
|
241 |
return this.selectedSensors.filter(sen => sen.toString().slice(0, 5) === sensorGroupId );
|
|
240 | 242 |
} |
241 | 243 |
|
242 | 244 |
filteredSensorsInfos(sensorGroupId: string): any { |
243 | 245 |
return this.sensors.filter(sen => this.selectedSensors.includes(sen.sensorId.toString()) && |
244 |
sen.sensorId.toString().slice(0, 5) == sensorGroupId); |
|
246 |
sen.sensorId.toString().slice(0, 5) === sensorGroupId);
|
|
245 | 247 |
} |
246 | 248 |
|
247 | 249 |
private getObservations(range: Date[], changedDate: boolean, changedSensorId: string) { |
... | ... | |
276 | 278 |
const view = '#vega_container_' + selectSens.toString().slice(0, 5); |
277 | 279 |
setTimeout(() => { |
278 | 280 |
console.log(this.selectedSensors); |
279 |
//GraphLoader.getMultilineGraph(this.selectedSensors, this.filteredObservationData(selectSens.toString().slice(0, 5)), view); |
|
280 |
GraphLoader.getGraph(this.filteredSelectedSensors(groupId), this.filteredObservationData(groupId), this.filteredSensorsInfos(groupId), view, false); |
|
281 |
// GraphLoader.getMultilineGraph(this.selectedSensors, this.filteredObservationData(selectSens.toString().slice(0, 5)), view); |
|
282 |
GraphLoader.getGraph(this.filteredSelectedSensors(groupId), this.filteredObservationData(groupId), |
|
283 |
this.filteredSensorsInfos(groupId), view, false); |
|
281 | 284 |
}, 10); |
282 | 285 |
} |
283 | 286 |
}) |
... | ... | |
305 | 308 |
this.observationsData.push({sensorId: changedSensorId, sensor: |
306 | 309 |
this.sensors.find(sens => sens.sensorId.toString() === changedSensorId.toString()), data: observations}); |
307 | 310 |
const view = '#vega_container_' + changedSensorId.toString().slice(0, 5); |
308 |
|
|
309 |
GraphLoader.getGraph(this.filteredSelectedSensors(groupId), this.filteredObservationData(groupId), this.filteredSensorsInfos(groupId), view, false);
|
|
311 |
GraphLoader.getGraph(this.filteredSelectedSensors(groupId), this.filteredObservationData(groupId), |
|
312 |
this.filteredSensorsInfos(groupId), view, false); |
|
310 | 313 |
}, err => this.toastService.showError(err.error.message)); |
311 | 314 |
} |
312 | 315 |
} |
Také k dispozici: Unified diff
Re #XXXX - Podpora