Added auto role rule list logic #134
This commit is contained in:
@@ -53,7 +53,7 @@ export class DataService {
|
||||
})
|
||||
.pipe(map(d => {
|
||||
if (d.errors && d.errors.length > 0) {
|
||||
throw new Error(d.errors.toString());
|
||||
throw new Error(d.errors.map((x: {message: String}) => x.message).toString());
|
||||
}
|
||||
return d.data;
|
||||
}))
|
||||
|
@@ -1,16 +1,17 @@
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { ErrorHandler, Injectable, Injector } from '@angular/core';
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { ErrorDTO } from 'src/app/models/error/error-dto';
|
||||
import { ServiceErrorCode } from 'src/app/models/error/service-error-code.enum';
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
import { ToastService } from '../toast/toast.service';
|
||||
import { HttpErrorResponse } from "@angular/common/http";
|
||||
import { ErrorHandler, Injectable } from "@angular/core";
|
||||
import { Observable, throwError } from "rxjs";
|
||||
import { ErrorDTO } from "src/app/models/error/error-dto";
|
||||
import { ServiceErrorCode } from "src/app/models/error/service-error-code.enum";
|
||||
import { AuthService } from "../auth/auth.service";
|
||||
import { ToastService } from "../toast/toast.service";
|
||||
|
||||
@Injectable()
|
||||
export class ErrorHandlerService implements ErrorHandler {
|
||||
|
||||
constructor(
|
||||
private injector: Injector
|
||||
private auth: AuthService,
|
||||
private toast: ToastService,
|
||||
) { }
|
||||
|
||||
handleError(error: HttpErrorResponse): Observable<never> {
|
||||
@@ -20,7 +21,7 @@ export class ErrorHandlerService implements ErrorHandler {
|
||||
const errorDto: ErrorDTO = error.error;
|
||||
|
||||
if (errorDto.errorCode === ServiceErrorCode.Unauthorized) {
|
||||
this.injector.get(AuthService).logout();
|
||||
this.auth.logout();
|
||||
return throwError(() => error);
|
||||
}
|
||||
|
||||
@@ -34,11 +35,13 @@ export class ErrorHandlerService implements ErrorHandler {
|
||||
message = error.message;
|
||||
}
|
||||
|
||||
this.injector.get(ToastService).error(header, message);
|
||||
this.toast.error(header, message);
|
||||
} else {
|
||||
console.error(error.message);
|
||||
}
|
||||
|
||||
if (error.status === 401) {
|
||||
this.injector.get(AuthService).logout();
|
||||
this.auth.logout();
|
||||
}
|
||||
return throwError(() => error);
|
||||
}
|
||||
|
@@ -8,7 +8,6 @@ import { NavigationEnd, Router } from "@angular/router";
|
||||
import { ThemeService } from "../theme/theme.service";
|
||||
import { Server } from "../../models/data/server.model";
|
||||
import { UserDTO } from "../../models/auth/auth-user.dto";
|
||||
import { AutoRole } from "../../models/data/auto_role.model";
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root"
|
||||
@@ -18,7 +17,6 @@ export class SidebarService {
|
||||
isSidebarOpen: boolean = true;
|
||||
menuItems$ = new BehaviorSubject<MenuItem[]>(new Array<MenuItem>());
|
||||
server$ = new BehaviorSubject<Server | null>(null);
|
||||
autoRole$ = new BehaviorSubject<AutoRole | null>(null);
|
||||
|
||||
dashboard!: MenuItem;
|
||||
serverDashboard!: MenuItem;
|
||||
|
@@ -1,8 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { LangChangeEvent, TranslateService } from '@ngx-translate/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { Themes } from 'src/app/models/view/themes.enum';
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
import { Injectable } from "@angular/core";
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
import { Themes } from "src/app/models/view/themes.enum";
|
||||
import { AuthService } from "../auth/auth.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -15,9 +14,9 @@ export class ThemeService {
|
||||
isSidebarOpen = false;
|
||||
hasLangChanged = false;
|
||||
|
||||
themeName$ = new Subject<string>();
|
||||
isSidebarOpen$ = new Subject<boolean>();
|
||||
sidebarWidth$ = new Subject<string>();
|
||||
themeName$ = new BehaviorSubject<string>(Themes.Default);
|
||||
isSidebarOpen$ = new BehaviorSubject<boolean>(true);
|
||||
sidebarWidth$ = new BehaviorSubject<string>('175px');
|
||||
|
||||
constructor(
|
||||
private authService: AuthService
|
||||
|
Reference in New Issue
Block a user