Added loading bar
Fixed product, account and employee details for add new.
This commit is contained in:
@ -3,10 +3,16 @@ import {CommonModule} from '@angular/common';
|
||||
import {NavBarComponent} from './nav-bar/nav-bar.component';
|
||||
import {MatButtonModule, MatIconModule, MatMenuModule, MatToolbarModule} from '@angular/material';
|
||||
import {RouterModule} from '@angular/router';
|
||||
import {HTTP_INTERCEPTORS} from '@angular/common/http';
|
||||
import {HttpAuthInterceptor} from './http-auth-interceptor';
|
||||
import {LoadingBarHttpClientModule} from '@ngx-loading-bar/http-client';
|
||||
import {LoadingBarRouterModule} from '@ngx-loading-bar/router';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
LoadingBarHttpClientModule,
|
||||
LoadingBarRouterModule,
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
MatMenuModule,
|
||||
@ -14,11 +20,18 @@ import {RouterModule} from '@angular/router';
|
||||
RouterModule
|
||||
],
|
||||
declarations: [
|
||||
NavBarComponent
|
||||
NavBarComponent,
|
||||
],
|
||||
exports: [
|
||||
NavBarComponent
|
||||
]
|
||||
NavBarComponent,
|
||||
LoadingBarHttpClientModule,
|
||||
LoadingBarRouterModule
|
||||
],
|
||||
providers: [[{
|
||||
provide: HTTP_INTERCEPTORS,
|
||||
useClass: HttpAuthInterceptor,
|
||||
multi: true
|
||||
}]]
|
||||
})
|
||||
export class CoreModule {
|
||||
}
|
||||
|
||||
31
overlord/src/app/core/http-auth-interceptor.ts
Normal file
31
overlord/src/app/core/http-auth-interceptor.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';
|
||||
|
||||
import {Observable, ObservableInput, of as observableOf} from 'rxjs';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
import {ToasterService} from './toaster.service';
|
||||
import {Router} from '@angular/router';
|
||||
import {ConfirmDialogComponent} from '../shared/confirm-dialog/confirm-dialog.component';
|
||||
import {MatDialog} from '@angular/material';
|
||||
|
||||
@Injectable()
|
||||
export class HttpAuthInterceptor implements HttpInterceptor {
|
||||
|
||||
constructor(private router: Router, private dialog: MatDialog, private toaster: ToasterService) {
|
||||
}
|
||||
|
||||
intercept(req: HttpRequest<any>, next: HttpHandler):
|
||||
Observable<HttpEvent<any>> {
|
||||
return next.handle(req)
|
||||
.pipe(
|
||||
catchError((err: any, caught: Observable<any>): ObservableInput<{}> => {
|
||||
if (err.status === 401) {
|
||||
this.router.navigate(['login']);
|
||||
this.toaster.show('Danger', 'User has been logged out');
|
||||
}
|
||||
return observableOf(caught);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user