Skip to content

Commit f1c94c0

Browse files
committed
Fixed bug where HTTP Datatarget updates did not save correctly (IOT-1462). Made minor adjustments to layout of ODDK creation-form (IOT-1464 + IOT-1465) and redirect (IOT-1463), as suggested by feedback after test..
1 parent b225ab1 commit f1c94c0

File tree

5 files changed

+46
-30
lines changed

5 files changed

+46
-30
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,11 @@ export class HttppushEditComponent
167167

168168
updateDatatarget() {
169169
this.resetErrors();
170-
this.counter =
171-
1 +
172-
(this.payloadDeviceDatatarget?.length
173-
? this.payloadDeviceDatatarget?.length
174-
: 0);
170+
this.counter = 1 + (this.payloadDeviceDatatarget?.length ?? 0);
175171
this.datatargetService.update(this.datatarget).subscribe(
176172
(response: Datatarget) => {
177173
this.datatarget = response;
174+
this.countToRedirect();
178175
},
179176
(error: HttpErrorResponse) => {
180177
this.handleError(error);
@@ -236,7 +233,7 @@ export class HttppushEditComponent
236233
this.datatargetid = response.id;
237234
this.datatarget = response;
238235
this.showSavedSnack();
239-
this.routeToDatatargets();
236+
this.routeToCreatedDatatarget();
240237
},
241238
(error: HttpErrorResponse) => {
242239
this.handleError(error);
@@ -288,9 +285,12 @@ export class HttppushEditComponent
288285
this.scrollToTopService.scrollToTop();
289286
}
290287

291-
routeToDatatargets(): void {
292-
this.router.navigate(['applications', this.applicationId.toString()]);
293-
}
288+
routeToDatatargets = () => this.router.navigate(['applications', this.applicationId, 'data-targets']);
289+
routeToCreatedDatatarget = () =>
290+
this.router.navigate(
291+
['applications', this.applicationId, 'datatarget', this.datatarget.id],
292+
{ replaceUrl: true }
293+
);
294294

295295
onCoordinateKey(event: any) {
296296
if (event.target.value.length > event.target.maxLength) {

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,9 @@
44
[canEdit]="canEdit">
55
</app-top-bar>
66

7-
<form
8-
(ngSubmit)="onSubmit()"
9-
#datatargetForm="ngForm"
10-
class="os2-form p-3 mt-4">
11-
<div *ngIf="errorMessages" class="error-messages p-3">
12-
<ul class="mb-0">
13-
<li *ngFor="let error of errorMessages">{{ error | translate }}</li>
14-
</ul>
15-
</div>
16-
17-
<!-- Foldable intro-texts -->
7+
<!-- Foldable intro-texts -->
8+
<div class="os2-form p-3 mt-4">
9+
<h3>{{'GUIDE' | translate}}</h3>
1810
<mat-expansion-panel class="row mb-2">
1911
<mat-expansion-panel-header>
2012
<mat-panel-title>
@@ -31,12 +23,12 @@
3123
{{ 'OPENDATADK.INTRO.GUIDE3' | translate }}
3224
<br><br>
3325
{{ 'OPENDATADK.INTRO.GUIDE4' | translate }}
34-
<a href="http://portal.opendata.dk/dataset/open-data-dk-licens">{{ 'OPENDATADK.INTRO.GUIDE5' | translate }}</a>
26+
<a href="https://creativecommons.org/publicdomain/zero/1.0/deed.da">{{ 'OPENDATADK.INTRO.GUIDE5' | translate }}</a>
3527
<br><br>
3628
</p>
3729
</mat-expansion-panel>
3830
<mat-divider></mat-divider>
39-
<mat-expansion-panel class="row mb-4 mt-2">
31+
<mat-expansion-panel class="row mt-2">
4032
<mat-expansion-panel-header>
4133
<mat-panel-title>
4234
<p>
@@ -57,9 +49,22 @@
5749
</p></li>
5850
</ol>
5951
</mat-expansion-panel>
52+
</div>
53+
54+
<form
55+
(ngSubmit)="onSubmit()"
56+
#datatargetForm="ngForm"
57+
class="os2-form p-3 mt-4">
58+
<h3>{{'FORM.CREATE-NEW-DATATARGET' | translate}}</h3>
59+
60+
<div *ngIf="errorMessages" class="error-messages p-3">
61+
<ul class="mb-0">
62+
<li *ngFor="let error of errorMessages">{{ error | translate }}</li>
63+
</ul>
64+
</div>
6065

6166
<!-- Name of data target -->
62-
<div class="row mb-2">
67+
<div class="row mb-2 mt-4">
6368
<div class="form-group col-12">
6469
<label class="form-label" for="name">
6570
{{'QUESTION.GIVE-DATATARGET-NAME' | translate}}*

src/app/applications/datatarget/opendatadk/opendatadk-edit/opendatadk-edit.component.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
@import 'src/assets/scss/setup/fonts';
22

33
:host {
4+
h3 {
5+
border-bottom-width: 5px;
6+
border-bottom-style: solid;
7+
border-bottom-color: rgb(245, 122, 47);
8+
width: fit-content;
9+
padding-right: 12px;
10+
}
411
.form-info-icon {
512
margin-left: 5px;
613
cursor: pointer;

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export class OpendatadkEditComponent implements DatatargetEdit, OnDestroy {
232232
if (!this.alreadySentOddkMail) {
233233
this.openMailDialog();
234234
} else {
235-
this.routeToDatatargets();
235+
this.routeToCreatedDatatarget();
236236
}
237237
};
238238
// Note: When updating, we send multiple async request, and use this counter to know when everything is done, so we can redirect
@@ -261,9 +261,12 @@ export class OpendatadkEditComponent implements DatatargetEdit, OnDestroy {
261261
this.scrollToTopService.scrollToTop();
262262
}
263263

264-
routeToDatatargets(): void {
265-
this.router.navigate(['applications', this.applicationId.toString(), 'data-targets']);
266-
}
264+
routeToDatatargets = () => this.router.navigate(['applications', this.applicationId, 'data-targets']);
265+
routeToCreatedDatatarget = () =>
266+
this.router.navigate(
267+
['applications', this.applicationId, 'datatarget', this.datatarget.id],
268+
{ replaceUrl: true }
269+
);
267270

268271
// For mail dialog
269272
private getAlreadySentOddkMail = () => {
@@ -292,7 +295,7 @@ export class OpendatadkEditComponent implements DatatargetEdit, OnDestroy {
292295
.sendOpenDataDkMail(result)
293296
.pipe(first())
294297
.toPromise();
295-
this.routeToDatatargets();
298+
this.routeToCreatedDatatarget();
296299
} else {
297300
// User cancelled -> Show the warning
298301
this.openMailWarningDialog();
@@ -307,7 +310,7 @@ export class OpendatadkEditComponent implements DatatargetEdit, OnDestroy {
307310
if (result.neverAgain) {
308311
await this.setAlreadySentOddkMail();
309312
}
310-
this.routeToDatatargets();
313+
this.routeToCreatedDatatarget();
311314
} else {
312315
// User cancelled -> Show the mail-dialog again
313316
this.openMailDialog();

src/assets/i18n/da.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@
269269
"GUIDE2": "Senest modtagede datapakke udstilles via OS2iots API og kan hentes via en URL angivet på det enkelte ODDK-data target og på jeres datasæt på opendata.dk. Der opsamles og udstilles altså ikke historisk data i hverken OS2iot eller på opendata.dk.",
270270
"GUIDE3": "Nye ODDK-data targets høstes automatisk, og I behøver ikke gøre noget aktivt for at gøre dem tilgængelige på opendata.dk. Hvis I sletter et ODDK-data target forsvinder det af sig selv fra opendata.dk.",
271271
"GUIDE4": "Datasæt fra OS2iot publiceres under licensen",
272-
"GUIDE5": "Open DATA DK Licens.",
272+
"GUIDE5": "Creative Commons CC0 1.0 Universel.",
273273
"PROCEDURE_HEADER": "Procedure ved oprettelse af første data target",
274274
"PROCEDURE1": "Bliv medlem af Open Data DK, hvis jeres myndighed ikke allerede er det:",
275275
"PROCEDURE2": "Opret første ODDK-data target i OS2iot",
@@ -1120,6 +1120,7 @@
11201120
},
11211121
"false": "Nej",
11221122
"true": "Ja",
1123+
"GUIDE": "Guide",
11231124
"HTTP_PUSH": "HTTP Push",
11241125
"Forbidden": "Du har ikke rettigheder til at foretage denne handling",
11251126
"Forbidden resource": "Du har ikke rettigheder til at foretage denne handling",

0 commit comments

Comments
 (0)