Blacked and isorted the python files
Prettied and eslinted the typescript/html files
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatMenuModule } from '@angular/material/menu';
|
||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||
|
||||
import { ErrorInterceptor } from './http-auth-interceptor';
|
||||
import { JwtInterceptor } from './jwt.interceptor';
|
||||
|
||||
@ -16,14 +17,12 @@ import { JwtInterceptor } from './jwt.interceptor';
|
||||
MatIconModule,
|
||||
MatMenuModule,
|
||||
MatToolbarModule,
|
||||
RouterModule
|
||||
],
|
||||
declarations: [
|
||||
RouterModule,
|
||||
],
|
||||
declarations: [],
|
||||
providers: [
|
||||
{provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true},
|
||||
{provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true},
|
||||
]
|
||||
{ provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
|
||||
{ provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
|
||||
],
|
||||
})
|
||||
export class CoreModule {
|
||||
}
|
||||
export class CoreModule {}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {Section} from './section';
|
||||
import { Section } from './section';
|
||||
|
||||
export class Device {
|
||||
id: string;
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {throwError} from 'rxjs';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { throwError } from 'rxjs';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ErrorLoggerService {
|
||||
constructor() {
|
||||
public static log(serviceName = 'error-logger', message: string) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`${serviceName}Service: ${message}`);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15,22 +17,11 @@ export class ErrorLoggerService {
|
||||
* @param operation - name of the operation that failed
|
||||
* @param result - optional value to return as the observable result
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
|
||||
public handleError<T>(serviceName = 'error-logger', operation = 'operation', result?: T) {
|
||||
return (error: any): Observable<T> => {
|
||||
|
||||
// TODO: send the error to remote logging infrastructure
|
||||
console.error(error); // log to console instead
|
||||
|
||||
// TODO: better job of transforming error for user consumption
|
||||
this.log(serviceName, `${operation} failed: ${error.message}`);
|
||||
|
||||
// // Let the app keep running by returning an empty result.
|
||||
// return of(result as T);
|
||||
ErrorLoggerService.log(serviceName, `${operation} failed: ${error}`);
|
||||
return throwError(error);
|
||||
};
|
||||
}
|
||||
|
||||
public log(serviceName = 'error-logger', message: string) {
|
||||
console.log(serviceName + 'Service: ' + message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,35 +1,35 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpRequest, HttpHandler, HttpEvent, HttpInterceptor} from '@angular/common/http';
|
||||
import {Observable} from 'rxjs';
|
||||
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import {AuthService} from '../auth/auth.service';
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
|
||||
@Injectable()
|
||||
export class JwtInterceptor implements HttpInterceptor {
|
||||
private isRefreshing = false;
|
||||
|
||||
constructor(private authService: AuthService) {
|
||||
}
|
||||
constructor(private authService: AuthService) {}
|
||||
|
||||
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||
// add authorization header with jwt token if available
|
||||
|
||||
// We use this line to debug token refreshing
|
||||
// console.log("intercepting:\nisRefreshing: ", this.isRefreshing, "\n user: ", this.authService.user,"\n needsRefreshing: ", this.authService.needsRefreshing());
|
||||
if (!this.isRefreshing && this.authService.user && this.authService.needsRefreshing()) {
|
||||
this.isRefreshing = true;
|
||||
this.authService.refreshToken().subscribe( x=> this.isRefreshing = false);
|
||||
this.authService.refreshToken().subscribe(() => {
|
||||
this.isRefreshing = false;
|
||||
});
|
||||
}
|
||||
const currentUser = this.authService.user;
|
||||
if (currentUser?.access_token) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
request = request.clone({
|
||||
setHeaders: {
|
||||
Authorization: `Bearer ${currentUser.access_token}`
|
||||
}
|
||||
Authorization: `Bearer ${currentUser.access_token}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return next.handle(request);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import {Product} from './product';
|
||||
// eslint-disable-next-line import/no-cycle
|
||||
import { Product } from './product';
|
||||
|
||||
export class MenuCategory {
|
||||
id: string;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import {MenuCategory} from './menu-category';
|
||||
import {Modifier} from './modifier';
|
||||
import { MenuCategory } from './menu-category';
|
||||
// eslint-disable-next-line import/no-cycle
|
||||
import { Modifier } from './modifier';
|
||||
|
||||
export class ModifierCategory {
|
||||
id: string;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import {ModifierCategory} from './modifier-category';
|
||||
// eslint-disable-next-line import/no-cycle
|
||||
import { ModifierCategory } from './modifier-category';
|
||||
|
||||
export class Modifier {
|
||||
id: string;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// eslint-disable-next-line import/no-cycle
|
||||
import { MenuCategory } from './menu-category';
|
||||
import { SaleCategory } from './sale-category';
|
||||
import { Tax } from './tax';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {Tax} from './tax';
|
||||
import { Tax } from './tax';
|
||||
|
||||
export class SaleCategory {
|
||||
id: string;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {Section} from './section';
|
||||
import { Section } from './section';
|
||||
|
||||
export class Table {
|
||||
id: string;
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ToasterService {
|
||||
|
||||
constructor(private snackBar: MatSnackBar) {
|
||||
}
|
||||
constructor(private snackBar: MatSnackBar) {}
|
||||
|
||||
show(type: string, msg: string) {
|
||||
this.snackBar.open(msg, type, {
|
||||
|
||||
5
bookie/src/app/core/user-group.ts
Normal file
5
bookie/src/app/core/user-group.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export class UserGroup {
|
||||
id: string;
|
||||
name: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
@ -1,3 +1,5 @@
|
||||
import { UserGroup } from './user-group';
|
||||
|
||||
export class User {
|
||||
id: string;
|
||||
name: string;
|
||||
@ -13,9 +15,3 @@ export class User {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export class UserGroup {
|
||||
id: string;
|
||||
name: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user