Revize 03d22047
Přidáno uživatelem Jakub Hlaváč před téměř 4 roky(ů)
src/app/dashboard/components/dashboard.component.html | ||
---|---|---|
11 | 11 |
<p-accordionTab *ngFor="let unit of units"> |
12 | 12 |
<p-header [className]="'dashboard-unit-wrapper'"> |
13 | 13 |
<div [className]="'row dashboard-unit'"> |
14 |
<div class="col-md-5">{{ unit.unit.description}}</div>
|
|
15 |
<div class="col-md-7 text-right">
|
|
14 |
<div class="col-md-4">{{ unit.unit.description}}</div>
|
|
15 |
<div class="col-md-8 text-right">
|
|
16 | 16 |
<p-button label="Sensors graph" icon="pi pi-chart-line" [routerLink]="['/dashboard/unit', unit.unit.unitId]"></p-button> |
17 | 17 |
<p-button label="Add sensor" icon="pi pi-cog" (onClick)="addSensor($event, unit.unit)"></p-button> |
18 | 18 |
<p-button label="Edit unit" icon="pi pi-cog" (onClick)="editUnit($event, unit.unit)"></p-button> |
src/app/dashboard/components/dashboard.component.ts | ||
---|---|---|
82 | 82 |
icon: 'pi pi-info-circle', |
83 | 83 |
accept: () => { |
84 | 84 |
console.log('ACCEPTED'); |
85 |
// this.processUnitDeletion(unit); |
|
85 |
// TODO this.processUnitDeletion(unit);
|
|
86 | 86 |
// this.messageService.add({severity:'info', summary:'Confirmed', detail:'Record deleted'}); |
87 | 87 |
}, |
88 | 88 |
reject: () => { |
src/app/dashboard/components/sensors/sensors.component.html | ||
---|---|---|
1 | 1 |
<div class="row"> |
2 |
<div class="col"> |
|
2 |
<div class="col-md-5">
|
|
3 | 3 |
{{ sensor.sensorName }} | {{ sensor.sensorId }} |
4 | 4 |
</div> |
5 |
<div class="col"> |
|
6 |
</div> |
|
7 |
<div class="col"> |
|
5 |
<div class="col-md-7 text-right"> |
|
8 | 6 |
<p-button label="View graph" [routerLink]="['/dashboard/unit', unitId, 'sensor', sensor.sensorId]" title="Sensor" icon="pi pi-chart-line"></p-button> |
9 | 7 |
<p-button label="Edit sensor" icon="pi pi-cog" (onClick)="editSensor($event, sensor)"></p-button> |
8 |
<p-button label="Delete sensor" icon="pi pi-cog" (onClick)="deleteSensor($event, sensor)"></p-button> |
|
10 | 9 |
</div> |
11 | 10 |
</div> |
12 | 11 |
|
src/app/dashboard/components/sensors/sensors.component.ts | ||
---|---|---|
1 | 1 |
import {Component, Input, OnInit} from '@angular/core'; |
2 | 2 |
import {Sensor} from '../../../shared/api/endpoints/models/sensor'; |
3 |
import {ConfirmationService} from 'primeng/api'; |
|
4 |
import {InsertUnit} from '../../../shared/api/endpoints/models/insert-unit'; |
|
5 |
import {ManagementService} from '../../../shared/api/endpoints/services/management.service'; |
|
3 | 6 |
|
4 | 7 |
@Component({ |
5 | 8 |
selector: 'app-sensors', |
... | ... | |
12 | 15 |
@Input() unitId: number; |
13 | 16 |
showSensorPopup = false; |
14 | 17 |
editedSensor: Sensor; |
15 |
constructor() { } |
|
18 |
constructor( |
|
19 |
private confirmationService: ConfirmationService, |
|
20 |
private managementService: ManagementService |
|
21 |
) { } |
|
16 | 22 |
|
17 | 23 |
ngOnInit(): void { |
18 | 24 |
} |
... | ... | |
22 | 28 |
this.editedSensor = sensor; |
23 | 29 |
this.showSensorPopup = true; |
24 | 30 |
} |
31 |
|
|
32 |
deleteSensor($event: any, sensor: Sensor) { |
|
33 |
this.confirmationService.confirm({ |
|
34 |
message: 'Do you want to delete this sensor?', |
|
35 |
header: 'Delete Sensor Confirmation', |
|
36 |
icon: 'pi pi-info-circle', |
|
37 |
accept: () => { |
|
38 |
console.log('ACCEPTED'); |
|
39 |
// TODO this.processSensorDeletion(sensor); |
|
40 |
// this.messageService.add({severity:'info', summary:'Confirmed', detail:'Record deleted'}); |
|
41 |
}, |
|
42 |
reject: () => { |
|
43 |
console.log('REJECTED'); |
|
44 |
}, |
|
45 |
key: 'positionDialog' |
|
46 |
}); |
|
47 |
} |
|
48 |
|
|
49 |
processSensorDeletion(sensor: Sensor) { |
|
50 |
this.managementService.deleteSensor({body: { |
|
51 |
unit: { |
|
52 |
unit_id: this.unitId |
|
53 |
}, |
|
54 |
sensors: [ |
|
55 |
{ |
|
56 |
sensor_id: sensor.sensorId |
|
57 |
} |
|
58 |
] |
|
59 |
}}); |
|
60 |
} |
|
25 | 61 |
} |
src/app/shared/api/endpoints/services/management.service.ts | ||
---|---|---|
189 | 189 |
); |
190 | 190 |
} |
191 | 191 |
|
192 |
/** |
|
193 |
* Path part for operation deleteSensor |
|
194 |
*/ |
|
195 |
static readonly DeleteSensorPath = '/senslog15/ManagementService?Operation=DeleteSensor'; |
|
196 |
|
|
197 |
/** |
|
198 |
* Delete Sensor. |
|
199 |
* |
|
200 |
* |
|
201 |
* |
|
202 |
* This method provides access to the full `HttpResponse`, allowing access to response headers. |
|
203 |
* To access only the response body, use `deleteSensor()` instead. |
|
204 |
* |
|
205 |
* This method sends `application/json` and handles request body of type `application/json`. |
|
206 |
*/ |
|
207 |
deleteSensor$Response(params: { |
|
208 |
body: { 'unit'?: InsertUnit, 'sensors'?: Array<InsertSensor> } |
|
209 |
}): Observable<StrictHttpResponse<{ 'message'?: string }>> { |
|
210 |
|
|
211 |
const rb = new RequestBuilder(this.rootUrl, ManagementService.DeleteSensorPath, 'delete'); |
|
212 |
if (params) { |
|
213 |
rb.body(params.body, 'application/json'); |
|
214 |
} |
|
215 |
|
|
216 |
return this.http.request(rb.build({ |
|
217 |
responseType: 'json', |
|
218 |
accept: 'application/json' |
|
219 |
})).pipe( |
|
220 |
filter((r: any) => r instanceof HttpResponse), |
|
221 |
map((r: HttpResponse<any>) => { |
|
222 |
return r as StrictHttpResponse<{ 'message'?: string }>; |
|
223 |
}) |
|
224 |
); |
|
225 |
} |
|
226 |
|
|
227 |
/** |
|
228 |
* Delete Sensor. |
|
229 |
* |
|
230 |
* |
|
231 |
* |
|
232 |
* This method provides access to only to the response body. |
|
233 |
* To access the full response (for headers, for example), `deleteSensor$Response()` instead. |
|
234 |
* |
|
235 |
* This method sends `application/json` and handles request body of type `application/json`. |
|
236 |
*/ |
|
237 |
deleteSensor(params: { |
|
238 |
body: { 'unit'?: InsertUnit, 'sensors'?: Array<InsertSensor> } |
|
239 |
}): Observable<{ 'message'?: string }> { |
|
240 |
|
|
241 |
return this.deleteSensor$Response(params).pipe( |
|
242 |
map((r: StrictHttpResponse<{ 'message'?: string }>) => r.body as { 'message'?: string }) |
|
243 |
); |
|
244 |
} |
|
245 |
|
|
192 | 246 |
} |
src/app/shared/api/openapi.yaml | ||
---|---|---|
254 | 254 |
unit: |
255 | 255 |
$ref: '#/components/schemas/InsertUnit' |
256 | 256 |
|
257 |
/senslog15/ManagementService?Operation=DeleteSensor: |
|
258 |
delete: |
|
259 |
tags: |
|
260 |
- management |
|
261 |
summary: Delete Sensor |
|
262 |
operationId: deleteSensor |
|
263 |
responses: |
|
264 |
200: |
|
265 |
description: deleted |
|
266 |
content: |
|
267 |
application/json: |
|
268 |
schema: |
|
269 |
type: object |
|
270 |
properties: |
|
271 |
message: |
|
272 |
type: string |
|
273 |
requestBody: |
|
274 |
required: true |
|
275 |
content: |
|
276 |
application/json: |
|
277 |
schema: |
|
278 |
type: object |
|
279 |
properties: |
|
280 |
unit: |
|
281 |
$ref: '#/components/schemas/InsertUnit' |
|
282 |
sensors: |
|
283 |
type: array |
|
284 |
items: |
|
285 |
$ref: '#/components/schemas/InsertSensor' |
|
286 |
|
|
257 | 287 |
|
258 | 288 |
components: |
259 | 289 |
schemas: |
Také k dispozici: Unified diff
Re #8791 - Odstranění sensor - endpoint
+ OpenAPI definition for deleting sensor
+ adding button to delete sensor
+ adding confirm dialog if deleting sensor