Skip to content

Commit 1b8bd26

Browse files
committed
Merge remote-tracking branch 'origin/stage' into feature/1284_application-metadata
# Conflicts: # src/assets/i18n/da.json
2 parents 3ed358d + ced9d30 commit 1b8bd26

28 files changed

+1113
-908
lines changed

package-lock.json

Lines changed: 706 additions & 865 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"eslint": "^7.3.1",
6464
"jasmine-core": "~3.5.0",
6565
"jasmine-spec-reporter": "~4.2.1",
66-
"karma": "~5.0.0",
66+
"karma": "~5.0.9",
6767
"karma-chrome-launcher": "~3.1.0",
6868
"karma-coverage-istanbul-reporter": "~2.1.0",
6969
"karma-jasmine": "~3.0.1",

src/app/applications/applications-list/applications-table/applications-table.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
{{errorMessage | translate}}
88
</div>
99

10-
<table mat-table [dataSource]="data" class="example-table" matSort matSortActive="created" matSortDisableClear
11-
matSortDirection="desc">
10+
<table mat-table [dataSource]="data" class="example-table" matSort matSortActive="name" matSortDisableClear
11+
matSortDirection="asc">
1212

1313
<!-- Name Column -->
1414
<ng-container matColumnDef="name">
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<mat-expansion-panel class="my-2 mx-3">
2+
<mat-expansion-panel-header>
3+
<mat-panel-title>
4+
<p>
5+
<strong>{{ 'IOTDEVICE.LATEST-DATAPACKAGES' | translate }}</strong>
6+
</p>
7+
</mat-panel-title>
8+
</mat-expansion-panel-header>
9+
<div class="timestamps-container">
10+
<div>
11+
<p *ngFor="
12+
let metadata of sortedMetadata;
13+
let i = index
14+
">
15+
<strong>{{ i + 1 }}</strong>
16+
</p>
17+
</div>
18+
<div>
19+
<p *ngFor="
20+
let metadata of sortedMetadata;
21+
let i = index
22+
">
23+
{{ metadata.sentTime | tableDatePipe }}
24+
</p>
25+
</div>
26+
</div>
27+
</mat-expansion-panel>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.timestamps-container {
2+
display: flex;
3+
}
4+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {
2+
Component,
3+
Input,
4+
OnChanges,
5+
OnInit,
6+
SimpleChanges,
7+
} from '@angular/core';
8+
import { sortBy } from '@shared/helpers/array.helper';
9+
import { ReceivedMessageMetadata } from '@shared/models/received-message-metadata.model';
10+
11+
@Component({
12+
selector: 'app-data-packages-timestamp',
13+
templateUrl: './data-packages-timestamp.component.html',
14+
styleUrls: ['./data-packages-timestamp.component.scss'],
15+
})
16+
export class DataPackagesTimestampComponent implements OnInit, OnChanges {
17+
@Input() receivedMessagesMetadata: ReceivedMessageMetadata[] = [];
18+
sortedMetadata: ReceivedMessageMetadata[] = [];
19+
20+
ngOnInit(): void {}
21+
22+
ngOnChanges(changes: SimpleChanges): void {
23+
const { receivedMessagesMetadata } = changes;
24+
if (
25+
receivedMessagesMetadata.currentValue !==
26+
receivedMessagesMetadata.previousValue
27+
) {
28+
this.sortedMetadata = sortBy(
29+
receivedMessagesMetadata.currentValue,
30+
'sentTime',
31+
'desc'
32+
);
33+
}
34+
}
35+
}

src/app/applications/iot-devices/iot-device-detail/iot-device-detail-generic/iot-device-detail-generic.component.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ <h3>{{ 'IOTDEVICE.DETAIL' | translate }}</h3>
4040
{{ 'IOTDEVICE.NOCOMMENT' | translate}}
4141
</ng-template>
4242
</p>
43+
<ng-container *ngIf="metadataTags.length">
44+
<mat-divider></mat-divider>
45+
<p *ngFor="let tag of metadataTags">
46+
<strong>{{ tag.key }}</strong>
47+
<span>{{ tag.value }}</span>
48+
</p>
49+
</ng-container>
4350
</div>
4451
</div>
4552
<div class="col-md-6 d-flex align-items-stretch">
@@ -72,4 +79,4 @@ <h3>{{ 'IOTDEVICE.LOCATION' | translate }}</h3>
7279
</p>
7380
</div>
7481
</div>
75-
</div>
82+
</div>
Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
1-
import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output } from '@angular/core';
1+
import { Location } from '@angular/common';
2+
import {
3+
Component,
4+
EventEmitter,
5+
Input,
6+
OnChanges,
7+
OnDestroy,
8+
OnInit,
9+
SimpleChanges,
10+
} from '@angular/core';
211
import { IotDevice } from '@applications/iot-devices/iot-device.model';
312
import { IoTDeviceService } from '@applications/iot-devices/iot-device.service';
413
import { TranslateService } from '@ngx-translate/core';
5-
import { Location } from '@angular/common';
6-
import { DeviceType } from '@shared/enums/device-type';
7-
import { MatDialog } from '@angular/material/dialog';
8-
import { DeleteDialogComponent } from '@shared/components/delete-dialog/delete-dialog.component';
9-
import { Subscription } from 'rxjs';
10-
import { DeleteDialogService } from '@shared/components/delete-dialog/delete-dialog.service';
14+
import { jsonToList } from '@shared/helpers/json.helper';
15+
import { KeyValue } from '@shared/types/tuple.type';
1116

1217
@Component({
1318
selector: 'app-iot-device-detail-generic',
1419
templateUrl: './iot-device-detail-generic.component.html',
15-
styleUrls: ['./iot-device-detail-generic.component.scss']
20+
styleUrls: ['./iot-device-detail-generic.component.scss'],
1621
})
17-
export class IotDeviceDetailGenericComponent implements OnInit, OnChanges, OnDestroy {
22+
export class IotDeviceDetailGenericComponent
23+
implements OnInit, OnChanges, OnDestroy {
1824
batteryStatusColor = 'green';
1925
batteryStatusPercentage: number;
26+
metadataTags: KeyValue[] = [];
2027
@Input() device: IotDevice;
2128
@Input() latitude = 0;
2229
@Input() longitude = 0;
@@ -27,16 +34,21 @@ export class IotDeviceDetailGenericComponent implements OnInit, OnChanges, OnDes
2734
constructor(
2835
private translate: TranslateService,
2936
public iotDeviceService: IoTDeviceService,
30-
private location: Location,
37+
private location: Location
38+
) {}
3139

32-
) { }
33-
34-
ngOnInit(): void {
35-
}
40+
ngOnInit(): void {}
3641

37-
ngOnChanges(): void {
42+
ngOnChanges(changes: SimpleChanges): void {
3843
this.batteryStatusPercentage = this.getBatteryProcentage();
3944

45+
if (
46+
changes?.device?.previousValue?.metadata !==
47+
changes?.device?.currentValue?.metadata &&
48+
this.device.metadata
49+
) {
50+
this.metadataTags = jsonToList(this.device.metadata);
51+
}
4052
}
4153

4254
routeBack(): void {
@@ -48,19 +60,19 @@ export class IotDeviceDetailGenericComponent implements OnInit, OnChanges, OnDes
4860
latitude: this.latitude,
4961
draggable: false,
5062
editEnabled: false,
51-
useGeolocation: false
63+
useGeolocation: false,
5264
};
5365
}
5466

5567
getBatteryProcentage(): number {
56-
if (this.device?.lorawanSettings?.deviceStatusBattery === this.CHIRPSTACK_BATTERY_NOT_AVAILIBLE) {
68+
if (
69+
this.device?.lorawanSettings?.deviceStatusBattery ===
70+
this.CHIRPSTACK_BATTERY_NOT_AVAILIBLE
71+
) {
5772
return null;
5873
}
5974
return Math.round(this.device?.lorawanSettings?.deviceStatusBattery);
6075
}
6176

62-
ngOnDestroy(): void {
63-
64-
}
65-
77+
ngOnDestroy(): void {}
6678
}

src/app/applications/iot-devices/iot-device-detail/iot-device-detail.component.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,18 @@
1212
<!-- Datapackage, Downlink, API Key -->
1313
<mat-tab-group animationDuration="200ms">
1414
<mat-tab label="{{'IOTDEVICE.DETAIL-TAB' | translate}}">
15+
<ng-container *ngIf="device.latestReceivedMessage; else noSentTime">
1516
<app-data-package [latestReceivedMessage]="device.latestReceivedMessage">
1617
</app-data-package>
18+
<mat-divider></mat-divider>
19+
<app-data-packages-timestamp [receivedMessagesMetadata]="device.receivedMessagesMetadata">
20+
</app-data-packages-timestamp>
21+
</ng-container>
22+
<ng-template #noSentTime>
23+
<p class="my-2 mx-3">
24+
{{ 'IOTDEVICE.NO-DATAPACKAGE' | translate }}
25+
</p>
26+
</ng-template>
1727
</mat-tab>
1828
<mat-tab label="{{'IOTDEVICE.DOWNLINK-TAB' | translate}}" *ngIf="canStartDownlink">
1929
<app-downlink [device]="device" [errorMessages]="errorMessages"></app-downlink>
@@ -35,4 +45,4 @@
3545
</div>
3646
</div>
3747
</div>
38-
</div>
48+
</div>

src/app/applications/iot-devices/iot-device-edit/iot-device-edit.component.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ <h3>{{'IOTDEVICE.LORAWANSETUP' | translate}}</h3>
123123
<label class="form-label" for="serviceProfileID">{{'QUESTION.CHOOSE-SERVICEPROFILE' | translate}}</label>*
124124
<select id="serviceProfileID" class="form-select" name="serviceProfileID"
125125
[(ngModel)]="iotDevice.lorawanSettings.serviceProfileID" required
126-
[value]="iotDevice.lorawanSettings.serviceProfileID"
127-
[disabled]="editmode"
126+
[value]="iotDevice.lorawanSettings.serviceProfileID" [disabled]="editmode"
128127
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('serviceProfileID'), 'is-valid' : formFailedSubmit && !errorFields.includes('serviceProfileID')}">
129128
<option *ngFor="let serviceProfile of serviceProfiles" [value]="serviceProfile.id"
130129
[selected]="serviceProfile.id === iotDevice.lorawanSettings.serviceProfileID">
@@ -181,8 +180,8 @@ <h3>{{'QUESTION.ABP' | translate}}</h3>
181180
</div>
182181

183182
<div class="form-group mt-5">
184-
<label class="form-label"
185-
for="applicationSessionKey">{{'QUESTION.APPLICATIONSESSIONKEY' | translate}}*</label>
183+
<label class="form-label" for="applicationSessionKey">{{'QUESTION.APPLICATIONSESSIONKEY' |
184+
translate}}*</label>
186185
<input type="text" id="applicationSessionKey" name="applicationSessionKey" maxLength="32"
187186
[placeholder]="'QUESTION.APPLICATIONSESSIONKEY-PLACEHOLDER' | translate" class="form-control"
188187
[(ngModel)]="iotDevice.lorawanSettings.applicationSessionKey"
@@ -222,8 +221,13 @@ <h3>{{'QUESTION.ABP' | translate}}</h3>
222221
</app-sigfox-device-edit>
223222
</ng-container>
224223

224+
<div class="mt-5 row">
225+
<h3>{{ "QUESTION.METADATA" | translate}}</h3>
226+
<app-form-key-value-list [(tags)]="metadataTags" [errorFieldId]="errorMetadataFieldId">
227+
</app-form-key-value-list>
228+
</div>
225229
<div class="form-group mt-5">
226230
<button (click)="routeBack()" class="btn btn-secondary" type="button">{{ 'GEN.CANCEL' | translate}}</button>
227231
<button class="btn btn-primary ml-2" type="submit">{{ 'GEN.SAVE' | translate }}</button>
228232
</div>
229-
</form>
233+
</form>

0 commit comments

Comments
 (0)