bug fix, display correctly http error message inside Toaster service

This commit is contained in:
Sylvain MATHIEU 2022-02-04 13:38:52 +01:00
parent 5102039dbd
commit c400ad551e
6 changed files with 23 additions and 11 deletions

View File

@ -16,6 +16,7 @@ import {ApiInformationService} from "@services/api-information.service";
import {Methods, Permission, PermissionActions} from "@models/api/permission";
import {PermissionsService} from "@services/permissions.service";
import {ToasterService} from "@services/toaster.service";
import {HttpErrorResponse} from "@angular/common/http";
@Component({
selector: 'app-add-permission-line',
@ -72,8 +73,10 @@ export class AddPermissionLineComponent implements OnInit {
.subscribe(() => {
this.toasterService.success(`permission was created`);
this.reset();
}, (error) => {
this.toasterService.error(error);
}, (error: HttpErrorResponse) => {
this.toasterService.error(`
${error.message}
${error.error.message}`);
});
}
}

View File

@ -18,6 +18,7 @@ import {ServerService} from "@services/server.service";
import {Role} from "@models/api/role";
import {FormControl, FormGroup} from "@angular/forms";
import {ToasterService} from "@services/toaster.service";
import {HttpErrorResponse} from "@angular/common/http";
@Component({
selector: 'app-role-detail',
@ -50,10 +51,11 @@ export class RoleDetailComponent implements OnInit {
onUpdate() {
this.roleService.update(this.server, this.role)
.subscribe(() => {
this.toastService.success(`role: ${this.role.name} was updated`);
},
(error) => {
this.toastService.error(error);
this.toastService.success(`role: ${this.role.name} was updated`);
},
(error: HttpErrorResponse) => {
this.toastService.error(`${error.message}
${error.error.message}`);
});
}
}

View File

@ -20,6 +20,7 @@ import {Role} from "@models/api/role";
import {Permission} from "@models/api/permission";
import {Observable} from "rxjs/Rx";
import {forkJoin} from "rxjs";
import {HttpErrorResponse} from "@angular/common/http";
@Component({
selector: 'app-role-permissions',
@ -61,8 +62,9 @@ export class RolePermissionsComponent implements OnInit {
this.toastService.success(`permissions updated`);
this.router.navigate(['/server', this.server.id, 'management', 'roles', this.role.role_id]);
},
(error) => {
this.toastService.error(error);
(error: HttpErrorResponse) => {
this.toastService.error(`${error.message}
${error.error.message}`);
});
}
}

View File

@ -26,6 +26,7 @@ import {RoleService} from "@services/role.service";
import {AddRoleDialogComponent} from "@components/role-management/add-role-dialog/add-role-dialog.component";
import {DeleteRoleDialogComponent} from "@components/role-management/delete-role-dialog/delete-role-dialog.component";
import {forkJoin} from "rxjs";
import {HttpErrorResponse} from "@angular/common/http";
@Component({
@ -95,7 +96,8 @@ export class RoleManagementComponent implements OnInit {
this.toasterService.success(`${role.name} role created`);
this.refresh();
},
(error) => this.toasterService.error(error));
(error: HttpErrorResponse) => this.toasterService.error(`${error.message}
${error.error.message}`));
}
});
}

View File

@ -10,6 +10,7 @@ import {forkJoin} from "rxjs";
import {Observable} from "rxjs/Rx";
import {UserService} from "@services/user.service";
import {User} from "@models/users/user";
import {HttpErrorResponse} from "@angular/common/http";
@Component({
selector: 'app-user-permissions',
@ -54,8 +55,9 @@ export class UserPermissionsComponent implements OnInit {
this.toastService.success(`permissions updated`);
this.router.navigate(['/server', this.server.id, 'management', 'users', this.user.user_id]);
},
(error) => {
this.toastService.error(error);
(error: HttpErrorResponse) => {
this.toastService.error(`${error.message}
${error.error.message}`);
});
}

View File

@ -23,6 +23,7 @@ a.table-link {
.snackbar-error {
background: #b00020 !important;
color: white !important;
white-space: pre-wrap !important;
}
.mat-dialog-actions {