Revize a3d61638
Přidáno uživatelem Jakub Hlaváč před téměř 4 roky(ů)
src/app/dashboard/components/dashboard.component.html | ||
---|---|---|
21 | 21 |
</div> |
22 | 22 |
</p-header> |
23 | 23 |
<div> |
24 |
<app-sensors *ngFor="let sensor of unit.sensors" [sensor]="sensor" [unitId]="unit.unit.unitId"></app-sensors> |
|
24 |
<app-sensors *ngFor="let sensor of unit.sensors" [sensor]="sensor" [unitId]="unit.unit.unitId" [phenomenons]="phenomenons"></app-sensors>
|
|
25 | 25 |
</div> |
26 | 26 |
</p-accordionTab> |
27 | 27 |
</p-accordion> |
src/app/dashboard/components/sensor-insert-popup/sensor-insert-popup.component.html | ||
---|---|---|
1 |
<p-dialog [visible]="isVisible" [closable]="false" [draggable]="false" header="Add sensor to unit - {{unit?.unitId}}" [style]="{width: '70vw'}" |
|
1 |
<p-dialog [visible]="isVisible" [modal]="true" [closable]="false" [draggable]="false" header="Add sensor to unit - {{unit?.unitId}}" [style]="{width: '70vw'}"
|
|
2 | 2 |
[baseZIndex]="10000" (onShow)="clearFormArray()"> |
3 | 3 |
|
4 | 4 |
<form [formGroup]="insertForm"> |
... | ... | |
27 | 27 |
</div> |
28 | 28 |
<div class="input-group form-group"> |
29 | 29 |
<div class="input-group-prepend"> |
30 |
<span class="input-group-text">Sensor name</span>
|
|
30 |
<span class="input-group-text">Sensor phenomeon</span>
|
|
31 | 31 |
</div> |
32 | 32 |
<select formControlName="phenomenons" id="phenomenons"> |
33 | 33 |
<option *ngFor="let phenomenon of phenomenons; let i = index" [value]="phenomenons[i].phenomenonId"> |
src/app/dashboard/components/sensor-popup/sensor-popup.component.html | ||
---|---|---|
1 |
<p-dialog [visible]="isVisible" [closable]="false" [draggable]="false" header="Nejlepsi popup" [style]="{width: '50vw'}" [baseZIndex]="10000"> |
|
2 |
{{ sensor | json}} |
|
1 |
<p-dialog [visible]="isVisible" [closable]="false" [modal]="true" [draggable]="false" header="Sensor {{sensor?.sensorId}} editation!" [style]="{width: '50vw'}" [baseZIndex]="10000"> |
|
2 |
<form [formGroup]="insertForm"> |
|
3 |
<div class="input-group form-group"> |
|
4 |
<div class="input-group-prepend"> |
|
5 |
<span class="input-group-text">Sensor name</span> |
|
6 |
</div> |
|
7 |
<input type="text" formControlName="sensorName" class="form-control" id="sensorName" |
|
8 |
placeholder="{{sensor.sensorName}}"/> |
|
9 |
</div> |
|
10 |
<div class="input-group form-group"> |
|
11 |
<div class="input-group-prepend"> |
|
12 |
<span class="input-group-text">Sensor type</span> |
|
13 |
</div> |
|
14 |
<input type="text" formControlName="sensorType" class="form-control" id="sensorType" |
|
15 |
placeholder="{{sensor.sensorType}}"/> |
|
16 |
</div> |
|
17 |
<div class="input-group form-group"> |
|
18 |
<div class="input-group-prepend"> |
|
19 |
<span class="input-group-text">Sensor phenomen</span> |
|
20 |
</div> |
|
21 |
<select formControlName="phenomenon" id="phenomenon"> |
|
22 |
<ng-container *ngFor="let phenomenon of phenomenons; let i = index"> |
|
23 |
<option [value]="phenomenon.phenomenonId" [selected]="phenomenon.phenomenonName === sensor.phenomenon.phenomenonName"> |
|
24 |
{{phenomenon.phenomenonName}} ({{phenomenon.unit}}) |
|
25 |
</option> |
|
26 |
</ng-container> |
|
27 |
</select> |
|
28 |
</div> |
|
29 |
</form> |
|
3 | 30 |
<p-footer> |
4 | 31 |
<div class="row justify-content-end align-items-center"> |
5 | 32 |
<div> |
6 |
<p-button icon="pi pi-check" type="submit" label="Uložit" class="pr-2"></p-button> |
|
33 |
<p-button icon="pi pi-check" (click)="processSensorEdition()" type="submit" label="Uložit" class="pr-2"></p-button>
|
|
7 | 34 |
<p-button icon="pi pi-times" (click)="close()" label="Zavřít" class="pr-2"></p-button> |
8 | 35 |
</div> |
9 | 36 |
</div> |
src/app/dashboard/components/sensor-popup/sensor-popup.component.ts | ||
---|---|---|
1 | 1 |
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; |
2 |
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; |
|
3 |
import {ManagementService} from '../../../shared/api/endpoints/services/management.service'; |
|
2 | 4 |
|
3 | 5 |
@Component({ |
4 | 6 |
selector: 'app-sensor-popup', |
... | ... | |
7 | 9 |
}) |
8 | 10 |
export class SensorPopupComponent implements OnInit { |
9 | 11 |
|
12 |
insertForm: FormGroup; |
|
13 |
|
|
10 | 14 |
@Input() isVisible; |
11 | 15 |
@Input() sensor; |
16 |
@Input() phenomenons; |
|
17 |
@Input() unitId; |
|
12 | 18 |
@Output() isVisibleChange: EventEmitter<boolean> = new EventEmitter<boolean>(); |
13 | 19 |
|
14 |
constructor() { } |
|
20 |
constructor( |
|
21 |
private formBuilder: FormBuilder, |
|
22 |
private managementService: ManagementService |
|
23 |
) { |
|
24 |
this.initForm(); |
|
25 |
} |
|
15 | 26 |
|
16 | 27 |
ngOnInit(): void { |
17 | 28 |
} |
... | ... | |
20 | 31 |
this.isVisibleChange.emit(false); |
21 | 32 |
} |
22 | 33 |
|
34 |
initForm() { |
|
35 |
this.insertForm = this.formBuilder.group({ |
|
36 |
sensorName: ['', Validators.required], |
|
37 |
sensorType: ['', Validators.required], |
|
38 |
phenomenon: ['', Validators.required] |
|
39 |
}); |
|
40 |
setTimeout(() => { |
|
41 |
this.insertForm.controls.phenomenon.setValue(this.sensor.phenomenon.phenomenonId, {onlySelf: true}); |
|
42 |
this.insertForm.controls.sensorType.setValue(this.sensor.sensorType); |
|
43 |
this.insertForm.controls.sensorName.setValue(this.sensor.sensorName); |
|
44 |
}, 0); |
|
45 |
} |
|
46 |
|
|
47 |
processSensorEdition() { |
|
48 |
if (this.insertForm.valid) { |
|
49 |
/* this.managementService.updateSensor({body: { |
|
50 |
unit: { |
|
51 |
unit_id: this.unitId |
|
52 |
}, |
|
53 |
sensors: [ |
|
54 |
{ |
|
55 |
sensor_id: this.sensor.sensorId, |
|
56 |
sensor_type: this.insertForm.controls.sensorType.value, |
|
57 |
sensor_name: this.insertForm.controls.sensorName.value, |
|
58 |
phenomenon: { |
|
59 |
phenomenon_id: this.insertForm.controls.phenomenon.value.phenomenonId |
|
60 |
} |
|
61 |
} |
|
62 |
] |
|
63 |
}}).toPromise();*/ |
|
64 |
} |
|
65 |
} |
|
23 | 66 |
} |
src/app/dashboard/components/sensors/sensors.component.html | ||
---|---|---|
9 | 9 |
</div> |
10 | 10 |
</div> |
11 | 11 |
|
12 |
<app-sensor-popup [(isVisible)]="showSensorPopup" [sensor]="editedSensor"></app-sensor-popup> |
|
12 |
<app-sensor-popup *ngIf="editedSensor" [(isVisible)]="showSensorPopup" [sensor]="editedSensor" [phenomenons]="phenomenons" [unitId]="unitId"></app-sensor-popup> |
src/app/dashboard/components/sensors/sensors.component.ts | ||
---|---|---|
13 | 13 |
|
14 | 14 |
@Input() sensor: Sensor; |
15 | 15 |
@Input() unitId: number; |
16 |
@Input() phenomenons; |
|
16 | 17 |
showSensorPopup = false; |
17 | 18 |
editedSensor: Sensor; |
18 | 19 |
constructor( |
src/app/dashboard/components/unit-insert-popup/unit-insert-popup.component.html | ||
---|---|---|
1 |
<p-dialog [visible]="isVisible" [closable]="false" [draggable]="false" header="Add unit!" [style]="{width: '70vw'}" |
|
1 |
<p-dialog [visible]="isVisible" [modal]="true" [closable]="false" [draggable]="false" header="Add unit!" [style]="{width: '70vw'}"
|
|
2 | 2 |
[baseZIndex]="10000" (onShow)="clearFormArray()"> |
3 | 3 |
|
4 | 4 |
<form [formGroup]="insertForm"> |
src/app/dashboard/components/unit-popup/unit-popup.component.html | ||
---|---|---|
1 |
<p-dialog [visible]="isVisible" [closable]="false" [draggable]="false" header="Edit unit - {{ unit?.unitId}}" [style]="{width: '50vw'}" [baseZIndex]="10000"> |
|
1 |
<p-dialog [visible]="isVisible" [modal]="true" [closable]="false" [draggable]="false" header="Edit unit - {{ unit?.unitId}}" [style]="{width: '50vw'}" [baseZIndex]="10000">
|
|
2 | 2 |
|
3 | 3 |
<form [formGroup]="insertForm"> |
4 | 4 |
<div class="input-group form-group"> |
src/app/shared/api/endpoints/services/management.service.ts | ||
---|---|---|
243 | 243 |
); |
244 | 244 |
} |
245 | 245 |
|
246 |
/** |
|
247 |
* Path part for operation updateSensor |
|
248 |
*/ |
|
249 |
static readonly UpdateSensorPath = '/senslog15/ManagementService?Operation=UpdateSensor'; |
|
250 |
|
|
251 |
/** |
|
252 |
* Update Sensor. |
|
253 |
* |
|
254 |
* |
|
255 |
* |
|
256 |
* This method provides access to the full `HttpResponse`, allowing access to response headers. |
|
257 |
* To access only the response body, use `updateSensor()` instead. |
|
258 |
* |
|
259 |
* This method sends `application/json` and handles request body of type `application/json`. |
|
260 |
*/ |
|
261 |
updateSensor$Response(params: { |
|
262 |
body: { 'unit'?: InsertUnit, 'sensors'?: Array<InsertSensor> } |
|
263 |
}): Observable<StrictHttpResponse<void>> { |
|
264 |
|
|
265 |
const rb = new RequestBuilder(this.rootUrl, ManagementService.UpdateSensorPath, 'put'); |
|
266 |
if (params) { |
|
267 |
rb.body(params.body, 'application/json'); |
|
268 |
} |
|
269 |
|
|
270 |
return this.http.request(rb.build({ |
|
271 |
responseType: 'text', |
|
272 |
accept: '*/*' |
|
273 |
})).pipe( |
|
274 |
filter((r: any) => r instanceof HttpResponse), |
|
275 |
map((r: HttpResponse<any>) => { |
|
276 |
return (r as HttpResponse<any>).clone({ body: undefined }) as StrictHttpResponse<void>; |
|
277 |
}) |
|
278 |
); |
|
279 |
} |
|
280 |
|
|
281 |
/** |
|
282 |
* Update Sensor. |
|
283 |
* |
|
284 |
* |
|
285 |
* |
|
286 |
* This method provides access to only to the response body. |
|
287 |
* To access the full response (for headers, for example), `updateSensor$Response()` instead. |
|
288 |
* |
|
289 |
* This method sends `application/json` and handles request body of type `application/json`. |
|
290 |
*/ |
|
291 |
updateSensor(params: { |
|
292 |
body: { 'unit'?: InsertUnit, 'sensors'?: Array<InsertSensor> } |
|
293 |
}): Observable<void> { |
|
294 |
|
|
295 |
return this.updateSensor$Response(params).pipe( |
|
296 |
map((r: StrictHttpResponse<void>) => r.body as void) |
|
297 |
); |
|
298 |
} |
|
299 |
|
|
246 | 300 |
} |
src/app/shared/api/openapi.yaml | ||
---|---|---|
284 | 284 |
items: |
285 | 285 |
$ref: '#/components/schemas/InsertSensor' |
286 | 286 |
|
287 |
|
|
287 |
/senslog15/ManagementService?Operation=UpdateSensor: |
|
288 |
put: |
|
289 |
tags: |
|
290 |
- management |
|
291 |
summary: Update Sensor |
|
292 |
operationId: updateSensor |
|
293 |
responses: |
|
294 |
200: |
|
295 |
description: updated |
|
296 |
requestBody: |
|
297 |
required: true |
|
298 |
content: |
|
299 |
application/json: |
|
300 |
schema: |
|
301 |
type: object |
|
302 |
properties: |
|
303 |
unit: |
|
304 |
$ref: '#/components/schemas/InsertUnit' |
|
305 |
sensors: |
|
306 |
type: array |
|
307 |
items: |
|
308 |
$ref: '#/components/schemas/InsertSensor' |
|
288 | 309 |
components: |
289 | 310 |
schemas: |
290 | 311 |
InsertUnit: |
Také k dispozici: Unified diff
Re #8790 - Úprava sensoru - formulář, endpoint
+ OpenAPI definition for editing sensor
+ form for sensor edition