Skip to content

Commit 2c83103

Browse files
committed
IOT-1416: Made the main changes to OpenDataDK data-target in UI (including cleaning up HTTP Push) and controller. Still missing some details, like keyworks-input etc..
1 parent bfc7e5d commit 2c83103

File tree

13 files changed

+776
-181
lines changed

13 files changed

+776
-181
lines changed

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.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export class DatatargetService {
7878
datatarget.openDataDkDataset = null;
7979
}
8080
if (datatarget.setToOpendataDk) {
81+
//TODO: Probably not needed if we have multi-select drop-down..?
8182
datatarget.openDataDkDataset.keywords = datatarget.openDataDkDataset?.keywordsInput?.split(',');
8283
datatarget.openDataDkDataset.keywordsInput = undefined;
8384
}

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">

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { faArrowsAltH } from '@fortawesome/free-solid-svg-icons';
1414
import { DatatargetDetail } from '@applications/datatarget/datatarget-detail/datatarget-detail';
1515
import { MeService } from '@shared/services/me.service';
1616
import { OrganizationAccessScope } from '@shared/enums/access-scopes';
17+
import { DataTargetType } from '@shared/enums/datatarget-type';
1718

1819
@Component({
1920
selector: 'app-httppush-detail',
@@ -22,14 +23,15 @@ import { OrganizationAccessScope } from '@shared/enums/access-scopes';
2223
})
2324
export class HttppushDetailComponent
2425
implements DatatargetDetail, OnInit, OnDestroy {
26+
dataTargetType = DataTargetType;
27+
2528
public datatargetSubscription: Subscription;
2629
public datatarget: Datatarget;
2730
public backButton: BackButton = { label: '', routerLink: undefined };
2831
public dataTargetRelations: PayloadDeviceDatatargetGetByDataTarget[];
2932
private deleteDialogSubscription: Subscription;
3033
public dropdownButton: DropdownButton;
3134
arrowsAltH = faArrowsAltH;
32-
private applicationName: string;
3335
canEdit: boolean;
3436

3537
constructor(
@@ -45,7 +47,6 @@ export class HttppushDetailComponent
4547
ngOnInit(): void {
4648
const id: number = +this.route.snapshot.paramMap.get('datatargetId');
4749
const appId: number = +this.route.snapshot.paramMap.get('id');
48-
this.applicationName = this.route.snapshot.paramMap.get('name');
4950
if (id) {
5051
this.getDatatarget(id);
5152
this.getDatatargetRelations(id);

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,8 @@
1212
</li>
1313
</ul>
1414
</div>
15-
<mat-slide-toggle
16-
[(ngModel)]="datatarget.setToOpendataDk"
17-
id="setToOpendataDk"
18-
name="setToOpendataDk">
19-
{{'DATATARGET.ADD-TO-OPENDATADK' | translate}}
20-
</mat-slide-toggle>
2115
<div class="row mb-2">
22-
<div class="form-group mt-3 col-12">
16+
<div class="form-group col-12">
2317
<label class="form-label" for="name">{{'QUESTION.GIVE-DATATARGET-NAME' | translate}}</label>*
2418
<input type="text" class="form-control" id="name" name="name"
2519
[placeholder]="'QUESTION.GIVE-DATATARGET-NAME-PLACEHOLDER' | translate" maxlength="50" required
@@ -61,10 +55,8 @@
6155
[(ngModel)]="datatarget.authorizationHeader"
6256
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('authorizationHeader'), 'is-valid' : formFailedSubmit && !errorFields.includes('authorizationHeader')}">
6357
</div>
64-
<div *ngIf="datatarget.setToOpendataDk">
65-
<app-opendatadk-edit [openDataDk]="datatarget.openDataDkDataset" [errorFields]="errorFields" [formFailedSubmit]="formFailedSubmit"></app-opendatadk-edit>
66-
</div>
6758
</div>
59+
6860
<div *ngIf="datatargetid === 0">
6961
<h6> {{'QUESTION.DATATARGET.RELATIONS' | translate}} </h6>
7062
</div>

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

Lines changed: 3 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
1+
import { Component, OnInit, 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';
@@ -20,11 +20,7 @@ import { HttpErrorResponse } from '@angular/common/http';
2020
import { PayloadDecoderMappedResponse } from '@payload-decoder/payload-decoder.model';
2121
import { DeleteDialogComponent } from '@shared/components/delete-dialog/delete-dialog.component';
2222
import { ErrorMessageService } from '@shared/error-message.service';
23-
import { OpendatadkDialogService } from '@shared/components/opendatadk-dialog/opendatadk-dialog.service';
24-
import { OpendatadkService } from '@shared/services/opendatadk.service';
2523
import { ScrollToTopService } from '@shared/services/scroll-to-top.service';
26-
import { OpenDataDkDataset } from '../../opendatadk/opendatadk-dataset.model';
27-
import { DataTargetType } from '@shared/enums/datatarget-type';
2824
import { DatatargetEdit } from '@applications/datatarget/datatarget-edit/datatarget-edit';
2925
import { MeService } from '@shared/services/me.service';
3026
import { OrganizationAccessScope } from '@shared/enums/access-scopes';
@@ -52,13 +48,10 @@ export class HttppushEditComponent
5248
public formFailedSubmit = false;
5349
public datatargetid: number;
5450
private applicationId: number;
55-
private applicationName: string;
5651
public application: Application;
5752
public devices: IotDevice[];
5853
public payloadDecoders = [];
5954
private counter: number;
60-
private dataSetExcists = false;
61-
private isMailDialogAlreadyShown = false;
6255

6356
payloadDeviceDatatarget: PayloadDeviceDatatarget[];
6457
newDynamic: any = {};
@@ -75,8 +68,6 @@ export class HttppushEditComponent
7568
private saveSnackService: SnackService,
7669
private dialog: MatDialog,
7770
private errorMessageService: ErrorMessageService,
78-
private opendatadkService: OpendatadkService,
79-
private opendatadkDialogService: OpendatadkDialogService,
8071
private scrollToTopService: ScrollToTopService,
8172
private meService: MeService
8273
) {
@@ -104,7 +95,6 @@ export class HttppushEditComponent
10495

10596
this.datatargetid = +this.route.snapshot.paramMap.get('datatargetId');
10697
this.applicationId = +this.route.snapshot.paramMap.get('id');
107-
this.applicationName = this.route.snapshot.paramMap.get('name');
10898
if (this.datatargetid !== 0) {
10999
this.getDatatarget(this.datatargetid);
110100
this.getPayloadDeviceDatatarget(this.datatargetid);
@@ -113,7 +103,6 @@ export class HttppushEditComponent
113103
this.getDevices();
114104
}
115105
this.getPayloadDecoders();
116-
this.setDataSetExcists();
117106
this.canEdit = this.meService.hasAccessToTargetOrganization(
118107
OrganizationAccessScope.ApplicationWrite,
119108
undefined,
@@ -186,15 +175,8 @@ export class HttppushEditComponent
186175
this.datatargetService.update(this.datatarget).subscribe(
187176
(response: Datatarget) => {
188177
this.datatarget = response;
189-
if (this.datatarget.openDataDkDataset != null) {
190-
this.datatarget.openDataDkDataset.acceptTerms = true;
191-
}
192-
this.shouldShowMailDialog().subscribe((response) => {
193-
this.countToRedirect();
194-
});
195178
},
196179
(error: HttpErrorResponse) => {
197-
this.checkDataTargetModelOpendatadkdatasaet();
198180
this.handleError(error);
199181
this.formFailedSubmit = true;
200182
}
@@ -253,14 +235,10 @@ export class HttppushEditComponent
253235
(response: Datatarget) => {
254236
this.datatargetid = response.id;
255237
this.datatarget = response;
256-
if (this.datatarget.openDataDkDataset != null) {
257-
this.datatarget.openDataDkDataset.acceptTerms = true;
258-
}
259238
this.showSavedSnack();
260239
this.routeToDatatargets();
261240
},
262241
(error: HttpErrorResponse) => {
263-
this.checkDataTargetModelOpendatadkdatasaet();
264242
this.handleError(error);
265243
this.formFailedSubmit = true;
266244
}
@@ -273,12 +251,6 @@ export class HttppushEditComponent
273251
this.formFailedSubmit = false;
274252
}
275253

276-
checkDataTargetModelOpendatadkdatasaet() {
277-
if (!this.datatarget.openDataDkDataset) {
278-
this.datatarget.openDataDkDataset = new OpenDataDkDataset();
279-
}
280-
}
281-
282254
getDevices(): void {
283255
this.applicationSubscription = this.applicationService
284256
.getApplication(this.applicationId)
@@ -338,51 +310,8 @@ export class HttppushEditComponent
338310
this.saveSnackService.showSavedSnack();
339311
}
340312

341-
private setDataSetExcists() {
342-
this.opendatadkService.get().subscribe((response) => {
343-
this.dataSetExcists = response.dataset.length === 0 ? false : true;
344-
});
345-
}
346-
347-
private shouldShowMailDialog(): Observable<any> {
348-
return new Observable((observer) => {
349-
if (
350-
!this.dataSetExcists &&
351-
this.datatarget.setToOpendataDk &&
352-
!this.isMailDialogAlreadyShown
353-
) {
354-
this.isMailDialogAlreadyShown = true;
355-
this.opendatadkDialogService.showDialog().subscribe((response) => {
356-
if (response) {
357-
this.showMailClient();
358-
}
359-
observer.next(response);
360-
});
361-
} else {
362-
observer.next(true);
363-
}
364-
});
365-
}
366-
367-
private showMailClient() {
368-
if (!this.datatarget.openDataDkDataset.url) {
369-
this.datatarget.openDataDkDataset.url = this.datatargetService.getOpendataSharingApiUrl();
370-
}
371-
window.location.href =
372-
'mailto:[email protected]?subject=Oprettelse%20af%20datas%C3%A6t%20i%20OpenDataDK&body=K%C3%A6re%20Frans%0D%0A%0D%0AHermed%20fremsendes%20linket%20til%20DCAT%20kataloget%20%2C%20du%20bedes%20registrere%20p%C3%A5%20Open%20Data%20DK%20platformen.%0D%0A%0D%0ALink%3A ' +
373-
this.datatarget.openDataDkDataset.url;
374-
}
375-
376313
disableSaveButton(): boolean {
377-
let disable = true;
378-
if (!this.datatarget.setToOpendataDk) {
379-
disable = false;
380-
} else if (this.datatarget.openDataDkDataset?.acceptTerms) {
381-
disable = false;
382-
} else {
383-
disable = true;
384-
}
385-
return disable;
314+
return false;
386315
}
387316

388317
ngOnDestroy(): void {

src/app/applications/datatarget/opendatadk/opendatadk-dataset.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class OpenDataDkDataset {
55
description: string;
66
keywords: string[];
77
keywordsInput: string;
8-
license = 'http://portal.opendata.dk/dataset/open-data-dk-licens';
8+
license = 'https://creativecommons.org/publicdomain/zero/1.0/';
99
authorName: string; //required
1010
authorEmail: string; //reqired
1111
url: string; // autogenerated with orgid as input

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
{{openDataDkDataset.keywords ? openDataDkDataset.keywords : ('OPENDATADK.DETAILS.NA' | translate) }}
1919
</p>
2020

21-
<p>
21+
<!-- <p>
2222
<strong>{{ 'OPENDATADK.DETAILS.LICENSE' | translate }}</strong>
2323
{{openDataDkDataset.license}}
24-
</p>
24+
</p> -->
2525

2626
<p>
2727
<strong>{{ 'OPENDATADK.DETAILS.AUTHORNAME' | translate }}</strong>

0 commit comments

Comments
 (0)