Skip to content

Commit 874c661

Browse files
Merge branch 'stage' for release v1.5.0
2 parents bfc7e5d + 9424f1e commit 874c661

File tree

69 files changed

+2621
-1178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2621
-1178
lines changed

src/app/admin/organisation/organisation.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface OrganisationResponse {
1616
createdByName: string;
1717
updatedByName: string;
1818
name: string;
19+
openDataDkRegistered: boolean;
1920

2021
payloadDecoders: PayloadDecoder[];
2122
applications: Application[];

src/app/applications/bulk-import/bulk-import.component.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
import { IoTDeviceService } from '@applications/iot-devices/iot-device.service';
1010
import { faDownload, faTrash } from '@fortawesome/free-solid-svg-icons';
1111
import { TranslateService } from '@ngx-translate/core';
12-
import { OrganizationAccessScope } from '@shared/enums/access-scopes';
1312
import { ErrorMessageService } from '@shared/error-message.service';
1413
import { splitList } from '@shared/helpers/array.helper';
1514
import { Download } from '@shared/helpers/download.helper';
@@ -20,7 +19,7 @@ import { Papa } from 'ngx-papaparse';
2019
import { Observable, Subject } from 'rxjs';
2120
import { takeWhile } from 'rxjs/operators';
2221
import { BulkImport } from './bulk-import.model';
23-
import { BulkMapping } from './bulkMapping';
22+
import { BulkMapping } from './bulk-mapping';
2423

2524
@Component({
2625
selector: 'app-bulk-import',
@@ -54,6 +53,14 @@ export class BulkImportComponent implements OnInit {
5453
name: 'lorawan-abp-sample.csv',
5554
url: '../../../assets/docs/iotdevice_lorawan_abp.csv',
5655
},
56+
{
57+
name: 'mqtt-internal-broker-sample.csv',
58+
url: '../../../assets/docs/mqtt_internal_broker_sample.csv',
59+
},
60+
{
61+
name: 'mqtt-external-broker-sample.csv',
62+
url: '../../../assets/docs/mqtt_external_broker_sample.csv',
63+
},
5764
];
5865
download$: Observable<Download>;
5966
private bulkMapper = new BulkMapping();
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
import { IotDevice } from '@applications/iot-devices/iot-device.model';
2+
import { DeviceType } from '@shared/enums/device-type';
3+
import { Buffer } from 'buffer';
4+
5+
export class BulkMapping {
6+
public dataMapper(data: IotDevice, applicationId: number): IotDevice {
7+
switch (data.type.toUpperCase()) {
8+
case DeviceType.LORAWAN:
9+
return this.lorawanMapper(data, applicationId);
10+
case DeviceType.MQTT_INTERNAL_BROKER:
11+
return this.mqttInternalBrokerMapper(data, applicationId);
12+
case DeviceType.MQTT_EXTERNAL_BROKER:
13+
return this.mqttExternalBrokerMapper(data, applicationId);
14+
case DeviceType.GENERIC_HTTP:
15+
return this.baseMapper(data, applicationId);
16+
default:
17+
break;
18+
}
19+
}
20+
21+
private lorawanMapper(data: any, applicationId): IotDevice {
22+
const newDevice = this.baseMapper(data, applicationId);
23+
newDevice.lorawanSettings = {
24+
devEUI: data.devEUI,
25+
skipFCntCheck: data.skipFCntCheck
26+
? this.convertToBoolean(data.skipFCntCheck)
27+
: undefined,
28+
activationType: data.activationType ? data.activationType : undefined,
29+
OTAAapplicationKey: data.OTAAapplicationKey
30+
? data.OTAAapplicationKey
31+
: undefined,
32+
devAddr: data.devAddr ? data.devAddr : undefined,
33+
networkSessionKey: data.networkSessionKey
34+
? data.networkSessionKey
35+
: undefined,
36+
applicationSessionKey: data.applicationSessionKey
37+
? data.applicationSessionKey
38+
: undefined,
39+
serviceProfileID: data.serviceProfileID
40+
? data.serviceProfileID
41+
: undefined,
42+
deviceProfileID: data.deviceProfileID ? data.deviceProfileID : undefined,
43+
fCntUp: data.fCntUp ? +data.fCntUp : undefined,
44+
nFCntDown: data.nFCntDown ? +data.nFCntDown : undefined,
45+
deviceStatusBattery: undefined,
46+
deviceStatusMargin: undefined,
47+
};
48+
newDevice.type = DeviceType.LORAWAN;
49+
return newDevice;
50+
}
51+
52+
private mqttInternalBrokerMapper(data: any, applicationId: number) {
53+
const newDevice = this.baseMapper(data, applicationId);
54+
newDevice.mqttInternalBrokerSettings = {
55+
authenticationType: data.authenticationType,
56+
caCertificate: undefined,
57+
deviceCertificate: undefined,
58+
deviceCertificateKey: undefined,
59+
mqttPort: undefined,
60+
mqttURL: undefined,
61+
mqtttopicname: undefined,
62+
mqttusername: data.mqttusername,
63+
mqttpassword: data.mqttpassword,
64+
};
65+
newDevice.type = DeviceType.MQTT_INTERNAL_BROKER;
66+
return newDevice;
67+
}
68+
69+
private mqttExternalBrokerMapper(data: any, applicationId: number) {
70+
const newDevice = this.baseMapper(data, applicationId);
71+
newDevice.mqttExternalBrokerSettings = {
72+
authenticationType: data.authenticationType,
73+
caCertificate: this.base64Decode(data.caCertificate),
74+
deviceCertificate: this.base64Decode(data.deviceCertificate),
75+
deviceCertificateKey: this.base64Decode(data.deviceCertificateKey),
76+
mqttPort: data.mqttPort ? Number(data.mqttPort) : undefined,
77+
mqttURL: data.mqttURL,
78+
mqtttopicname: data.mqtttopicname,
79+
mqttpassword: data.mqttpassword,
80+
mqttusername: data.mqttusername,
81+
invalidMqttConfig: data.invalidMqttConfig,
82+
};
83+
newDevice.type = DeviceType.MQTT_EXTERNAL_BROKER;
84+
return newDevice;
85+
}
86+
87+
private base64Decode(input: string) {
88+
if (!input) {
89+
return undefined;
90+
}
91+
return Buffer.from(input, 'base64').toString('binary');
92+
}
93+
94+
private convertToBoolean(text: string): boolean {
95+
if (text.toUpperCase() === 'TRUE') {
96+
return true;
97+
} else {
98+
return false;
99+
}
100+
}
101+
102+
private baseMapper(data: any, applicationId: number): IotDevice {
103+
return {
104+
name: data.name,
105+
application: undefined,
106+
location: undefined,
107+
commentOnLocation: data.commentOnLocation,
108+
comment: data.comment,
109+
type: DeviceType.GENERIC_HTTP,
110+
receivedMessagesMetadata: undefined,
111+
metadata: undefined,
112+
apiKey: undefined,
113+
id: undefined,
114+
createdAt: undefined,
115+
updatedAt: undefined,
116+
applicationId: applicationId,
117+
longitude: data.longitude ? Number(data.longitude) : 0,
118+
latitude: data.latitude ? Number(data.latitude) : 0,
119+
latestReceivedMessage: undefined,
120+
lorawanSettings: undefined,
121+
sigfoxSettings: undefined,
122+
mqttInternalBrokerSettings: undefined,
123+
mqttExternalBrokerSettings: undefined,
124+
createdBy: undefined,
125+
updatedBy: undefined,
126+
updatedByName: undefined,
127+
createdByName: undefined,
128+
deviceModelId: data.deviceModelId != '' ? +data.deviceModelId : undefined,
129+
};
130+
}
131+
}

src/app/applications/bulk-import/bulkMapping.ts

Lines changed: 0 additions & 76 deletions
This file was deleted.

src/app/applications/datatarget/datatarget-types.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { HttppushDetailComponent } from './httppush/httppush-detail/httppush-det
99
import { HttppushEditComponent } from './httppush/httppush-edit/httppush-edit.component';
1010
import { MqttDetailComponent } from './mqtt-detail/mqtt-detail.component';
1111
import { MqttEditComponent } from './mqtt-edit/mqtt-edit.component';
12+
import { OpendatadkEditComponent } from './opendatadk/opendatadk-edit/opendatadk-edit.component';
1213

1314
@Injectable({
1415
providedIn: 'root',
@@ -77,7 +78,7 @@ export class DatatargetTypesService {
7778
}
7879

7980
if (dataTargetType === DataTargetType.OPENDATADK) {
80-
return HttppushEditComponent;
81+
return OpendatadkEditComponent;
8182
}
8283

8384
if (dataTargetType === DataTargetType.FIWARE) {

src/app/applications/datatarget/datatarget.model.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ export class DatatargetTypeDescriptor {
4444
readMoreUrl: string;
4545
provider: string;
4646
}
47+
48+
export class OddkMailInfo {
49+
organizationId?: number;
50+
organizationOddkAlias: string;
51+
comment?: string;
52+
sharingUrl?: string
53+
}

src/app/applications/datatarget/datatarget.module.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import { DatatargetEditTypeSelectorDirective } from './datatarget-edit/datatarge
2424
import { MqttEditComponent } from './mqtt-edit/mqtt-edit.component';
2525
import { MqttDetailComponent } from './mqtt-detail/mqtt-detail.component';
2626
import { DatatargetTabComponent } from './datatarget-tab/datatarget-tab.component';
27+
import { OpenDataDkMailDialogComponent } from './opendatadk/opendatadk-edit/opendatadk-mail-dialog/opendatadk-mail-dialog';
28+
import { OpenDataDkWarningDialogComponent } from './opendatadk/opendatadk-edit/opendatadk-warning-dialog/opendatadk-warning-dialog';
2729

2830
@NgModule({
2931
declarations: [
@@ -38,11 +40,14 @@ import { DatatargetTabComponent } from './datatarget-tab/datatarget-tab.componen
3840
OpendatadkComponent,
3941
OpendatadkEditComponent,
4042
OpendatadkDetailComponent,
43+
OpenDataDkMailDialogComponent,
44+
OpenDataDkWarningDialogComponent,
4145
MqttDetailComponent,
4246
MqttEditComponent,
4347
DatatargetDetailTypeSelectorDirective,
4448
DatatargetEditTypeSelectorDirective,
45-
DatatargetTabComponent],
49+
DatatargetTabComponent,
50+
],
4651
imports: [
4752
CommonModule,
4853
RouterModule,
@@ -64,7 +69,7 @@ import { DatatargetTabComponent } from './datatarget-tab/datatarget-tab.componen
6469
FiwareEditComponent,
6570
HttppushDetailComponent,
6671
HttppushEditComponent,
67-
NGMaterialModule
68-
]
72+
NGMaterialModule,
73+
],
6974
})
70-
export class DatatargetModule { }
75+
export class DatatargetModule {}

src/app/applications/datatarget/datatarget.service.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
22
import { Observable } from 'rxjs';
33
import { DatatargetResponse } from '@applications/datatarget/datatarget-response.model';
44
import { RestService } from '@shared/services/rest.service';
5-
import { DatatargetData, Datatarget } from './datatarget.model';
5+
import { DatatargetData, Datatarget, OddkMailInfo } from './datatarget.model';
66
import { map } from 'rxjs/operators';
77
import { OpenDataDkDataset } from './opendatadk/opendatadk-dataset.model';
88
import { SharedVariableService } from '@shared/shared-variable/shared-variable.service';
@@ -77,10 +77,6 @@ export class DatatargetService {
7777
if (!datatarget.setToOpendataDk) {
7878
datatarget.openDataDkDataset = null;
7979
}
80-
if (datatarget.setToOpendataDk) {
81-
datatarget.openDataDkDataset.keywords = datatarget.openDataDkDataset?.keywordsInput?.split(',');
82-
datatarget.openDataDkDataset.keywordsInput = undefined;
83-
}
8480
}
8581

8682
private mapToDatatarget(dataTargetResponse: DatatargetResponse): Datatarget {
@@ -120,4 +116,14 @@ export class DatatargetService {
120116
return this.restService.createResourceUrl('open-data-dk-sharing', this.sharedVariableService.getSelectedOrganisationId());
121117
}
122118

119+
getOpenDataDkRegistered(organizationId: number): Observable<boolean> {
120+
return this.restService.get(this.dataTargetURL + '/getOpenDataDkRegistered', undefined, organizationId);
121+
}
122+
updateOpenDataDkRegistered(organizationId: number): Observable<boolean> {
123+
return this.restService.put(this.dataTargetURL + '/updateOpenDataDkRegistered', undefined, organizationId);
124+
}
125+
sendOpenDataDkMail(mailDto: OddkMailInfo): Observable<boolean> {
126+
mailDto.sharingUrl = this.getOpendataSharingApiUrl();
127+
return this.restService.post(this.dataTargetURL + '/sendOpenDataDkMail', mailDto);
128+
}
123129
}

src/app/applications/datatarget/fiware/fiware-edit/fiware-edit.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, OnInit, Input, OnDestroy } from '@angular/core';
22
import { TranslateService } from '@ngx-translate/core';
33
import { ActivatedRoute, Router } from '@angular/router';
44
import { Datatarget } from '../../datatarget.model';
5-
import { Observable, Subscription } from 'rxjs';
5+
import { Subscription } from 'rxjs';
66
import { Application } from '@applications/application.model';
77
import { IotDevice } from '@applications/iot-devices/iot-device.model';
88
import { faTimesCircle } from '@fortawesome/free-solid-svg-icons';

src/app/applications/datatarget/httppush/httppush-detail/httppush-detail.component.html

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,23 @@
88
<h3>{{ 'DATATARGET.DETAILS' | translate }}</h3>
99
<app-general-details [data]="datatarget"></app-general-details>
1010
<mat-divider></mat-divider>
11-
<p><strong>{{ 'DATATARGET.URL' | translate }}</strong>{{datatarget.url}}</p>
12-
<p><strong>{{ 'DATATARGET.TIMEOUT' | translate }}</strong>{{datatarget.timeout}}</p>
11+
<span *ngIf="datatarget.type !== dataTargetType.OPENDATADK">
12+
<p><strong>{{ 'DATATARGET.URL' | translate }}</strong>{{datatarget.url}}</p>
13+
<p><strong>{{ 'DATATARGET.TIMEOUT' | translate }}</strong>{{datatarget.timeout}}</p>
14+
</span>
1315
<p><strong>{{ 'DATATARGET.TYPE' | translate }}</strong>{{'DATATARGET.' + datatarget.type + '.TYPE' | translate}}</p>
14-
<mat-divider></mat-divider>
15-
<p><strong>{{ 'DATATARGET.AUTHORIZATIONHEADER' | translate }}</strong></p>
16-
<code><pre *ngIf="datatarget.authorizationHeader; else showNoAuthText">{{datatarget.authorizationHeader}}</pre></code>
17-
<ng-template #showNoAuthText>
18-
<p>{{ 'DATATARGET.NO-AUTHORIZATIONHEADER' | translate }}</p>
19-
</ng-template>
16+
<span *ngIf="datatarget.type !== dataTargetType.OPENDATADK">
17+
<mat-divider></mat-divider>
18+
<p><strong>{{ 'DATATARGET.AUTHORIZATIONHEADER' | translate }}</strong></p>
19+
<code><pre *ngIf="datatarget.authorizationHeader; else showNoAuthText">{{datatarget.authorizationHeader}}</pre></code>
20+
<ng-template #showNoAuthText>
21+
<p>{{ 'DATATARGET.NO-AUTHORIZATIONHEADER' | translate }}</p>
22+
</ng-template>
23+
</span>
2024

2125
</div>
2226
</div>
23-
<div class="col-md-6 d-flex align-items-stretch">
27+
<div *ngIf="datatarget.type === dataTargetType.OPENDATADK" class="col-md-6 d-flex align-items-stretch">
2428
<div class="jumbotron jumbotron--m-left jumbotron--full-width">
2529
<h3>{{ 'DATATARGET.OPENDATA-DK.TYPE' | translate }}</h3>
2630
<div *ngIf="datatarget.setToOpendataDk else noOpendataDk">

0 commit comments

Comments
 (0)