Skip to content

Commit 699c006

Browse files
author
Jeppe Elkjær Jørgensen
committed
IOT-262 add detail page
1 parent 1477b8e commit 699c006

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

src/app/shared/services/payloadDeviceDatatarget.service.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,19 @@ export class PayloadDeviceDatatargetService {
3434
return this.restService.get(this.BASEURL + this.BYDATATARGETURL, null, id);
3535
}
3636

37+
mapToDatatargetDevicePayload(dto: PayloadDeviceDatatargetGetByDataTargetResponse): PayloadDeviceDatatarget[] {
38+
const payloadDeviceDatatargetList = [];
39+
dto.data.forEach(
40+
(element) => {
41+
payloadDeviceDatatargetList.push({
42+
id: element.id,
43+
iotDeviceIds: element.iotDevices.map((x) => x.id),
44+
payloadDecoderId: element.payloadDecoder?.id,
45+
dataTargetId: element.dataTarget.id
46+
});
47+
}
48+
);
49+
return payloadDeviceDatatargetList;
50+
}
51+
3752
}

src/app/views/datatarget/datatarget/datatarget.component.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,26 @@ <h4>{{ 'DATATARGET.TYPE' | translate }}</h4>
3535
<p>{{datatarget.type}}</p>
3636
</div>
3737
</div>
38+
<div class="col-12 py-4">
39+
<div class="col-12 col-sm-12">
40+
<h4>{{ 'DATATARGET.RELATIONS' | translate }}</h4>
41+
</div>
42+
<div class="col-12 pt-2 col-sm-8" *ngFor="let relation of dataTargetRelations">
43+
<p>{{'DATATARGET.DATATARGET' | translate}}</p>
44+
<ul>
45+
<li>
46+
{{relation.dataTarget.name}}
47+
</li>
48+
</ul>
49+
50+
<p>{{'DATATARGET.IOTDEVICE' | translate}}</p>
51+
<div *ngFor="let device of relation.iotDevices">
52+
<ul>
53+
<li>{{device.name}}</li>
54+
</ul>
55+
</div>
56+
</div>
57+
</div>
3858
</div>
3959
</div>
4060
</div>

src/app/views/datatarget/datatarget/datatarget.component.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { ActivatedRoute } from '@angular/router';
77
import { TranslateService } from '@ngx-translate/core';
88
import { DatatargetService } from 'src/app/shared/services/datatarget.service';
99
import { DatatargetResponse } from 'src/app/models/datatarget-response';
10+
import { PayloadDeviceDatatargetService } from '@shared/services/payloadDeviceDatatarget.service';
11+
import { PayloadDeviceDatatarget, PayloadDeviceDatatargetGetByDataTarget } from '@app/models/payload-device-data';
1012

1113
@Component({
1214
selector: 'app-datatarget',
@@ -100,16 +102,19 @@ export class DatatargetComponent implements OnInit {
100102
];
101103
public pageOffset: 0;
102104
public pageTotal: number;
105+
public dataTargetRelations: PayloadDeviceDatatargetGetByDataTarget[];
103106

104107
constructor(
105108
private route: ActivatedRoute,
109+
private datatargetRelationServicer: PayloadDeviceDatatargetService,
106110
private datatargetService: DatatargetService,
107111
public translate: TranslateService) { }
108112

109113
ngOnInit(): void {
110114
const id: number = +this.route.snapshot.paramMap.get('datatargetId');
111115
if (id) {
112116
this.getDatatarget(id);
117+
this.getDatatargetRelations(id);
113118
}
114119
this.translate.get(['NAV.MY-DATATARGET'])
115120
.subscribe(translations => {
@@ -124,4 +129,11 @@ export class DatatargetComponent implements OnInit {
124129
});
125130
}
126131

132+
getDatatargetRelations(id: number) {
133+
this.datatargetRelationServicer.getByDataTarget(id)
134+
.subscribe( (response) => {
135+
this.dataTargetRelations = response.data;
136+
});
137+
}
138+
127139
}

src/assets/i18n/da.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@
5656
"TIMEOUT": "Timeout",
5757
"TYPE": "Type",
5858
"NAME": "Datatarget navn",
59-
"DELETE": "Slet"
59+
"DELETE": "Slet",
60+
"RELATIONS": "Tilknyttede IoT enheder og payload decoders",
61+
"DATATARGET": "Data Target navn:",
62+
"IOTDEVICE": "IoT Device navn:"
6063
},
6164
"APPLICATION-TABLE": {
6265
"NAME": "NAVN",

0 commit comments

Comments
 (0)