Prettied, Linted and updated angular.json according to the latest schematic of Angular CLI.
Now all that is needed is to make it ready for strict compiling. Removed eslint-plugin-prettier as it is not recommended and causes errors for both eslint and prettier Bumped to v8.0.0
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
|
||||
import { Account } from './account';
|
||||
import { ErrorLoggerService } from './error-logger.service';
|
||||
|
||||
@ -70,9 +71,8 @@ export class AccountService {
|
||||
saveOrUpdate(account: Account): Observable<Account> {
|
||||
if (!account.id) {
|
||||
return this.save(account);
|
||||
} else {
|
||||
return this.update(account);
|
||||
}
|
||||
return this.update(account);
|
||||
}
|
||||
|
||||
delete(id: string): Observable<Account> {
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Batch } from './voucher';
|
||||
|
||||
import { Batch } from './batch';
|
||||
import { ErrorLoggerService } from './error-logger.service';
|
||||
|
||||
const url = '/api/batch';
|
||||
|
||||
11
overlord/src/app/core/batch.ts
Normal file
11
overlord/src/app/core/batch.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Product } from './product';
|
||||
|
||||
export class Batch {
|
||||
id: string;
|
||||
name: string;
|
||||
quantityRemaining: number;
|
||||
tax: number;
|
||||
discount: number;
|
||||
rate: number;
|
||||
product: Product;
|
||||
}
|
||||
@ -1,16 +1,17 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NavBarComponent } from './nav-bar/nav-bar.component';
|
||||
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 { LoadingBarHttpClientModule } from '@ngx-loading-bar/http-client';
|
||||
import { LoadingBarRouterModule } from '@ngx-loading-bar/router';
|
||||
import { JwtInterceptor } from './jwt.interceptor';
|
||||
|
||||
import { ErrorInterceptor } from './http-auth-interceptor';
|
||||
import { JwtInterceptor } from './jwt.interceptor';
|
||||
import { NavBarComponent } from './nav-bar/nav-bar.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
||||
5
overlord/src/app/core/db-file.ts
Normal file
5
overlord/src/app/core/db-file.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export class DbFile {
|
||||
id: string;
|
||||
resized: string;
|
||||
thumbnail: string;
|
||||
}
|
||||
11
overlord/src/app/core/employee-benefit.ts
Normal file
11
overlord/src/app/core/employee-benefit.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Employee } from '../employee/employee';
|
||||
|
||||
export class EmployeeBenefit {
|
||||
grossSalary: number;
|
||||
daysWorked: number;
|
||||
esiEmployee: number;
|
||||
pfEmployee: number;
|
||||
esiEmployer: number;
|
||||
pfEmployer: number;
|
||||
employee: Employee;
|
||||
}
|
||||
@ -1,12 +1,15 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { throwError } from 'rxjs';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
@Injectable({
|
||||
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}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Http operation that failed.
|
||||
@ -14,21 +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}`);
|
||||
|
||||
// // 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,13 +1,15 @@
|
||||
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { Router } from '@angular/router';
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http';
|
||||
import { Router } from '@angular/router';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
import { ToasterService } from './toaster.service';
|
||||
import { ConfirmDialogComponent } from '../shared/confirm-dialog/confirm-dialog.component';
|
||||
|
||||
import { ToasterService } from './toaster.service';
|
||||
|
||||
@Injectable()
|
||||
export class ErrorInterceptor implements HttpInterceptor {
|
||||
constructor(
|
||||
@ -52,6 +54,7 @@ export class ErrorInterceptor implements HttpInterceptor {
|
||||
this.router.navigate(['login']);
|
||||
}
|
||||
});
|
||||
return throwError(err);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
8
overlord/src/app/core/incentive.ts
Normal file
8
overlord/src/app/core/incentive.ts
Normal file
@ -0,0 +1,8 @@
|
||||
export class Incentive {
|
||||
id: string;
|
||||
name: string;
|
||||
designation: string;
|
||||
department: string;
|
||||
daysWorked: number;
|
||||
points: number;
|
||||
}
|
||||
13
overlord/src/app/core/inventory.ts
Normal file
13
overlord/src/app/core/inventory.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { Batch } from './batch';
|
||||
import { Product } from './product';
|
||||
|
||||
export class Inventory {
|
||||
id: string;
|
||||
quantity: number;
|
||||
rate: number;
|
||||
tax: number;
|
||||
discount: number;
|
||||
amount: number;
|
||||
product: Product;
|
||||
batch: Batch;
|
||||
}
|
||||
14
overlord/src/app/core/journal.ts
Normal file
14
overlord/src/app/core/journal.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { Account } from './account';
|
||||
import { CostCentre } from './cost-centre';
|
||||
|
||||
export class Journal {
|
||||
id: string;
|
||||
debit: number;
|
||||
amount: number;
|
||||
account: Account;
|
||||
costCentre: CostCentre;
|
||||
|
||||
public constructor(init?: Partial<Journal>) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
@ -14,13 +14,15 @@ export class JwtInterceptor implements HttpInterceptor {
|
||||
// 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}`,
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { AuthService } from '../../auth/auth.service';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { AuthService } from '../../auth/auth.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-nav-bar',
|
||||
templateUrl: './nav-bar.component.html',
|
||||
|
||||
5
overlord/src/app/core/user-group.ts
Normal file
5
overlord/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;
|
||||
@ -14,9 +16,3 @@ export class User {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export class UserGroup {
|
||||
id: string;
|
||||
name: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from './error-logger.service';
|
||||
import { Voucher } from './voucher';
|
||||
|
||||
@ -18,6 +19,21 @@ const serviceName = 'VoucherService';
|
||||
export class VoucherService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
static dataURLtoBlob(dataURL) {
|
||||
const re = /^data:([\w/\-.]+);\w+,(.*)$/;
|
||||
const m = dataURL.match(re);
|
||||
const mimeString = m[1];
|
||||
const byteString = atob(m[2]);
|
||||
const ab = new ArrayBuffer(byteString.length);
|
||||
const dw = new DataView(ab);
|
||||
let i;
|
||||
|
||||
for (i = 0; i < byteString.length; i += 1) {
|
||||
dw.setUint8(i, byteString.charCodeAt(i));
|
||||
}
|
||||
return new Blob([ab], { type: mimeString });
|
||||
}
|
||||
|
||||
get(id: string, type: string): Observable<Voucher> {
|
||||
const endpoint = type.replace(/ /g, '-').toLowerCase();
|
||||
return <Observable<Voucher>>(
|
||||
@ -31,6 +47,7 @@ export class VoucherService {
|
||||
const endpoint = type.replace(/ /g, '-').toLowerCase();
|
||||
const options = {};
|
||||
if (account !== undefined && account !== null) {
|
||||
// eslint-disable-next-line @typescript-eslint/dot-notation
|
||||
options['params'] = new HttpParams().set('a', account);
|
||||
}
|
||||
return <Observable<Voucher>>(
|
||||
@ -69,9 +86,8 @@ export class VoucherService {
|
||||
const endpoint = voucher.type.replace(/ /g, '-').toLowerCase();
|
||||
if (!voucher.id) {
|
||||
return this.save(voucher, endpoint);
|
||||
} else {
|
||||
return this.update(voucher, endpoint);
|
||||
}
|
||||
return this.update(voucher, endpoint);
|
||||
}
|
||||
|
||||
save(voucher: Voucher, endpoint: string): Observable<Voucher> {
|
||||
@ -79,8 +95,8 @@ export class VoucherService {
|
||||
voucher.files
|
||||
.filter((x) => !x.id)
|
||||
.forEach((file) => {
|
||||
fd.append('i', this.dataURLtoBlob(file.resized));
|
||||
fd.append('t', this.dataURLtoBlob(file.thumbnail));
|
||||
fd.append('i', VoucherService.dataURLtoBlob(file.resized));
|
||||
fd.append('t', VoucherService.dataURLtoBlob(file.thumbnail));
|
||||
});
|
||||
voucher.files = voucher.files.filter((x) => x.id);
|
||||
fd.append('data', JSON.stringify(voucher));
|
||||
@ -96,8 +112,8 @@ export class VoucherService {
|
||||
voucher.files
|
||||
.filter((x) => !x.id)
|
||||
.forEach((file) => {
|
||||
fd.append('i', this.dataURLtoBlob(file.resized));
|
||||
fd.append('t', this.dataURLtoBlob(file.thumbnail));
|
||||
fd.append('i', VoucherService.dataURLtoBlob(file.resized));
|
||||
fd.append('t', VoucherService.dataURLtoBlob(file.thumbnail));
|
||||
});
|
||||
voucher.files = voucher.files.filter((x) => x.id);
|
||||
fd.append('data', JSON.stringify(voucher));
|
||||
@ -107,19 +123,4 @@ export class VoucherService {
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'Update Voucher')))
|
||||
);
|
||||
}
|
||||
|
||||
dataURLtoBlob(dataURL) {
|
||||
const re = /^data:([\w/\-\.]+);\w+,(.*)$/;
|
||||
const m = dataURL.match(re);
|
||||
const mimeString = m[1];
|
||||
const byteString = atob(m[2]);
|
||||
const ab = new ArrayBuffer(byteString.length);
|
||||
const dw = new DataView(ab);
|
||||
let i;
|
||||
|
||||
for (i = 0; i < byteString.length; i++) {
|
||||
dw.setUint8(i, byteString.charCodeAt(i));
|
||||
}
|
||||
return new Blob([ab], { type: mimeString });
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
import { Account } from './account';
|
||||
import { User } from './user';
|
||||
import { CostCentre } from './cost-centre';
|
||||
import { Product } from './product';
|
||||
import { Employee } from '../employee/employee';
|
||||
import { DbFile } from './db-file';
|
||||
import { EmployeeBenefit } from './employee-benefit';
|
||||
import { Incentive } from './incentive';
|
||||
import { Inventory } from './inventory';
|
||||
import { Journal } from './journal';
|
||||
import { User } from './user';
|
||||
|
||||
export class Voucher {
|
||||
id: string;
|
||||
@ -26,61 +29,3 @@ export class Voucher {
|
||||
poster: string;
|
||||
reconcileDate: string;
|
||||
}
|
||||
|
||||
export class Journal {
|
||||
id: string;
|
||||
debit: number;
|
||||
amount: number;
|
||||
account: Account;
|
||||
costCentre: CostCentre;
|
||||
|
||||
public constructor(init?: Partial<Journal>) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export class EmployeeBenefit {
|
||||
grossSalary: number;
|
||||
daysWorked: number;
|
||||
esiEmployee: number;
|
||||
pfEmployee: number;
|
||||
esiEmployer: number;
|
||||
pfEmployer: number;
|
||||
employee: Employee;
|
||||
}
|
||||
|
||||
export class Incentive {
|
||||
id: string;
|
||||
name: string;
|
||||
designation: string;
|
||||
department: string;
|
||||
daysWorked: number;
|
||||
points: number;
|
||||
}
|
||||
|
||||
export class Inventory {
|
||||
id: string;
|
||||
quantity: number;
|
||||
rate: number;
|
||||
tax: number;
|
||||
discount: number;
|
||||
amount: number;
|
||||
product: Product;
|
||||
batch: Batch;
|
||||
}
|
||||
|
||||
export class Batch {
|
||||
id: string;
|
||||
name: string;
|
||||
quantityRemaining: number;
|
||||
tax: number;
|
||||
discount: number;
|
||||
rate: number;
|
||||
product: Product;
|
||||
}
|
||||
|
||||
export class DbFile {
|
||||
id: string;
|
||||
resized: string;
|
||||
thumbnail: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user