diff --git a/src/app/admin/organisation/organisation-detail/organisation-detail.component.ts b/src/app/admin/organisation/organisation-detail/organisation-detail.component.ts
index d922eb0f..eb3dc35b 100644
--- a/src/app/admin/organisation/organisation-detail/organisation-detail.component.ts
+++ b/src/app/admin/organisation/organisation-detail/organisation-detail.component.ts
@@ -17,6 +17,8 @@ import { environment } from "@environments/environment";
import { Title } from "@angular/platform-browser";
import { MeService } from "@shared/services/me.service";
import { OrganizationAccessScope } from "@shared/enums/access-scopes";
+import { ErrorMessageService } from "@shared/error-message.service";
+import { HttpErrorResponse } from "@angular/common/http";
@Component({
selector: "app-organisation-detail",
@@ -34,6 +36,7 @@ export class OrganisationDetailComponent implements OnInit, OnChanges, OnDestroy
private applicationsSubscription: Subscription;
private deleteDialogSubscription: Subscription;
public dropdownButton: DropdownButton;
+ public errorMessages: string[];
organisation: OrganisationResponse;
public backButton: BackButton = {
@@ -53,7 +56,8 @@ export class OrganisationDetailComponent implements OnInit, OnChanges, OnDestroy
private deleteDialogService: DeleteDialogService,
private location: Location,
private titleService: Title,
- private meService: MeService
+ private meService: MeService,
+ private errorMessageService: ErrorMessageService
) {}
ngOnChanges(changes: SimpleChanges): void {}
@@ -100,6 +104,10 @@ export class OrganisationDetailComponent implements OnInit, OnChanges, OnDestroy
this.deleteDialogSubscription = this.deleteDialogService.showSimpleDialog().subscribe(response => {
if (response) {
this.organisationService.delete(this.organisation.id).subscribe(response => {
+ if (response instanceof HttpErrorResponse) {
+ this.errorMessages = this.errorMessageService.handleErrorMessageWithFields(response).errorMessages;
+ return;
+ }
this.location.back();
});
} else {
diff --git a/src/app/admin/organisation/organisation-list/organisation-tabel/organisation-tabel.component.html b/src/app/admin/organisation/organisation-list/organisation-tabel/organisation-tabel.component.html
index 2292b66c..7c0600b4 100644
--- a/src/app/admin/organisation/organisation-list/organisation-tabel/organisation-tabel.component.html
+++ b/src/app/admin/organisation/organisation-list/organisation-tabel/organisation-tabel.component.html
@@ -1,4 +1,11 @@
-
+
+
+ -
+ {{ error | translate }}
+
+
+
+
diff --git a/src/app/admin/organisation/organisation-list/organisation-tabel/organisation-tabel.component.ts b/src/app/admin/organisation/organisation-list/organisation-tabel/organisation-tabel.component.ts
index 76bfac4f..96873817 100644
--- a/src/app/admin/organisation/organisation-list/organisation-tabel/organisation-tabel.component.ts
+++ b/src/app/admin/organisation/organisation-list/organisation-tabel/organisation-tabel.component.ts
@@ -8,6 +8,8 @@ import { MatPaginator, PageEvent } from "@angular/material/paginator";
import { environment } from "@environments/environment";
import { startWith, switchMap, map, catchError } from "rxjs/operators";
import { DefaultPageSizeOptions } from "@shared/constants/page.constants";
+import { ErrorMessageService } from "@shared/error-message.service";
+import { HttpErrorResponse } from "@angular/common/http";
@Component({
selector: "app-organisation-tabel",
@@ -30,8 +32,13 @@ export class OrganisationTabelComponent implements AfterViewInit {
pageSizeOptions = DefaultPageSizeOptions;
isLoadingResults = true;
+ public errorMessages: string[];
- constructor(private organisationService: OrganisationService, private deleteDialogService: DeleteDialogService) {}
+ constructor(
+ private organisationService: OrganisationService,
+ private deleteDialogService: DeleteDialogService,
+ private errorMessageService: ErrorMessageService
+ ) {}
ngAfterViewInit() {
// If the user changes the sort order, reset back to the first page.
@@ -72,6 +79,10 @@ export class OrganisationTabelComponent implements AfterViewInit {
this.deleteDialogService.showSimpleDialog().subscribe(response => {
if (response) {
this.organisationService.delete(element.id).subscribe(response => {
+ if (response instanceof HttpErrorResponse) {
+ this.errorMessages = this.errorMessageService.handleErrorMessageWithFields(response).errorMessages;
+ return;
+ }
if (response.ok) {
this.refresh();
}
diff --git a/src/app/shared/error-message.service.ts b/src/app/shared/error-message.service.ts
index f686d3fa..0181c9a9 100644
--- a/src/app/shared/error-message.service.ts
+++ b/src/app/shared/error-message.service.ts
@@ -28,12 +28,12 @@ export class ErrorMessageService {
public handleErrorMessageWithFields(error: HttpErrorResponse | Pick
): ErrorMessage {
const errors: ErrorMessage = { errorFields: [], errorMessages: [] };
- if (typeof error.error === "string") {
+ if (typeof error.error?.message === "string") {
+ errors.errorMessages.push(error.error.message);
+ } else if (typeof error.error === "string") {
errors.errorMessages.push(error.error);
} else if (typeof error.error?.error === "string" && !Array.isArray(error.error?.message)) {
errors.errorMessages.push(error.error.error);
- } else if (typeof error.error?.message === "string") {
- errors.errorMessages.push(error.error.message);
} else {
error.error.message.forEach(err => {
if (err.children?.length > 0) {
diff --git a/src/assets/i18n/da.json b/src/assets/i18n/da.json
index 9e969b2a..1ea129ad 100644
--- a/src/assets/i18n/da.json
+++ b/src/assets/i18n/da.json
@@ -1034,7 +1034,8 @@
"INVALID-VALUE-IN-KEY-VALUE-PAIR": "En eller flere værdier er ugyldige. Det skal være en gyldig tekstværdi",
"INVALID-DATE": "Datoen er ugyldig",
"USER-ALREADY-HAVE-MAIL": "Brugeren har allerede sat en email",
- "EMAIL-ALREADY-IN-USE": "Den valgte email er allerede i brug. Kontakt din lokale administrator for hjælp."
+ "EMAIL-ALREADY-IN-USE": "Den valgte email er allerede i brug. Kontakt din lokale administrator for hjælp.",
+ "ORGANIZATION-GATEWAYS-EXISTS": "Denne organisation kan ikke slettes, fordi der er tilknyttet en eller flere gateways. Slet først disse eller flyt dem til en ny organisation."
},
"PROFILES": {
"NAME": "LoRaWAN profiler",