Blacked and isorted the python files

Prettied and eslinted the typescript/html files
This commit is contained in:
2020-10-11 10:56:29 +05:30
parent b31db593c2
commit d677cfb1ea
505 changed files with 7560 additions and 5650 deletions

View File

@ -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 {}

View File

@ -1,4 +1,4 @@
import {Section} from './section';
import { Section } from './section';
export class Device {
id: string;

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -1,4 +1,5 @@
import {Product} from './product';
// eslint-disable-next-line import/no-cycle
import { Product } from './product';
export class MenuCategory {
id: string;

View File

@ -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;

View File

@ -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;

View File

@ -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';

View File

@ -1,4 +1,4 @@
import {Tax} from './tax';
import { Tax } from './tax';
export class SaleCategory {
id: string;

View File

@ -1,4 +1,4 @@
import {Section} from './section';
import { Section } from './section';
export class Table {
id: string;

View File

@ -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, {

View File

@ -0,0 +1,5 @@
export class UserGroup {
id: string;
name: string;
enabled: boolean;
}

View File

@ -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;
}