Initial Commit

This commit is contained in:
2021-01-05 13:02:52 +05:30
commit ec992df1da
520 changed files with 38712 additions and 0 deletions

10
otis/src/app/core/act.ts Normal file
View File

@ -0,0 +1,10 @@
export class Act {
id: string | undefined;
name: string;
public constructor(init?: Partial<Act>) {
this.id = undefined;
this.name = '';
Object.assign(this, init);
}
}

View File

@ -0,0 +1,18 @@
export class Advocate {
id: string | undefined;
name: string;
mobile: string;
landline: string;
address: string;
email: string;
public constructor(init?: Partial<Advocate>) {
this.id = undefined;
this.name = '';
this.mobile = '';
this.landline = '';
this.address = '';
this.email = '';
Object.assign(this, init);
}
}

View File

@ -0,0 +1,10 @@
export class CaseType {
id: string | undefined;
name: string;
public constructor(init?: Partial<CaseType>) {
this.id = undefined;
this.name = '';
Object.assign(this, init);
}
}

67
otis/src/app/core/case.ts Normal file
View File

@ -0,0 +1,67 @@
import { Act } from './act';
import { CaseType } from './case-type';
import { Court } from './court';
import { CourtStatus } from './court-status';
import { Department } from './department';
import { Nature } from './nature';
import { Office } from './office';
import { OfficeStatus } from './office-status';
export class Case {
id: string | undefined;
officeFileNumber: string;
courtCaseNumber: string;
year: string;
title: string;
docketNumber: string;
receiptDate: string;
limitationDate: string;
filingDate: string;
appearOnBehalfOf: string;
questionOfLaw: string;
aorName: string;
opposingCouncilAor: string;
opposingCouncilDetail: string;
lowerCourtCaseNumber: string;
dateOfImpugnedJudgement: string;
briefDescription: string;
remarks: string;
slpCounter: string;
contactDetail: string;
caseConnectedWith: string;
bunchCases: string;
court?: Court;
department?: Department;
office?: Office;
caseType?: CaseType;
act?: Act;
nature?: Nature;
officeStatus?: OfficeStatus;
courtStatus?: CourtStatus;
public constructor(init?: Partial<Case>) {
this.id = undefined;
this.officeFileNumber = '';
this.courtCaseNumber = '';
this.year = '';
this.title = '';
this.docketNumber = '';
this.receiptDate = '';
this.limitationDate = '';
this.filingDate = '';
this.appearOnBehalfOf = '';
this.questionOfLaw = '';
this.aorName = '';
this.opposingCouncilAor = '';
this.opposingCouncilDetail = '';
this.lowerCourtCaseNumber = '';
this.dateOfImpugnedJudgement = '';
this.briefDescription = '';
this.remarks = '';
this.slpCounter = '';
this.contactDetail = '';
this.caseConnectedWith = '';
this.bunchCases = '';
Object.assign(this, init);
}
}

View File

@ -0,0 +1,23 @@
import { Department } from './department';
import { Office } from './office';
export class Contact {
id: string | undefined;
name: string;
mobile: string;
landline: string;
address: string;
email: string;
office?: Office;
department?: Department;
public constructor(init?: Partial<Contact>) {
this.id = undefined;
this.name = '';
this.mobile = '';
this.landline = '';
this.address = '';
this.email = '';
Object.assign(this, init);
}
}

View File

@ -0,0 +1,28 @@
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 { ErrorInterceptor } from './http-auth-interceptor';
import { JwtInterceptor } from './jwt.interceptor';
@NgModule({
imports: [
CommonModule,
MatButtonModule,
MatIconModule,
MatMenuModule,
MatToolbarModule,
RouterModule,
],
declarations: [],
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
],
})
export class CoreModule {}

View File

@ -0,0 +1,10 @@
export class CourtStatus {
id: string | undefined;
name: string;
public constructor(init?: Partial<CourtStatus>) {
this.id = undefined;
this.name = '';
Object.assign(this, init);
}
}

View File

@ -0,0 +1,10 @@
export class Court {
id: string | undefined;
name: string;
public constructor(init?: Partial<Court>) {
this.id = undefined;
this.name = '';
Object.assign(this, init);
}
}

View File

@ -0,0 +1,10 @@
export class Department {
id: string | undefined;
name: string;
public constructor(init?: Partial<Department>) {
this.id = undefined;
this.name = '';
Object.assign(this, init);
}
}

View File

@ -0,0 +1,28 @@
import { Injectable } from '@angular/core';
import { throwError } from 'rxjs';
import { Observable } from 'rxjs/internal/Observable';
@Injectable({
providedIn: 'root',
})
export class ErrorLoggerService {
public static log(serviceName = 'error-logger', message: string) {
// eslint-disable-next-line no-console
console.log(`${serviceName}Service: ${message}`);
}
/**
* Handle Http operation that failed.
* Let the app continue.
*
* @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: unknown): Observable<T> => {
ErrorLoggerService.log(serviceName, `${operation} failed: ${error}`);
return throwError(error);
};
}
}

View File

@ -0,0 +1,63 @@
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 { AuthService } from '../auth/auth.service';
import { ConfirmDialogComponent } from '../shared/confirm-dialog/confirm-dialog.component';
import { ToasterService } from './toaster.service';
@Injectable()
export class ErrorInterceptor implements HttpInterceptor {
constructor(
private authService: AuthService,
private router: Router,
private dialog: MatDialog,
private toaster: ToasterService,
) {}
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
return next.handle(request).pipe(
catchError((err) => {
// We don't want to refresh token for some requests like login or refresh token itself
// So we verify url and we throw an error if it's the case
if (request.url.includes('/refresh') || request.url.includes('/token')) {
// We do another check to see if refresh token failed
// In this case we want to logout user and to redirect it to login page
if (request.url.includes('/refresh')) {
this.authService.logout();
}
return throwError(err);
}
// If error status is different than 401 we want to skip refresh token
// So we check that and throw the error if it's the case
if (err.status !== 401) {
const error = err.error.message || err.error.detail || err.statusText;
return throwError(error);
}
// auto logout if 401 response returned from api
this.authService.logout();
this.toaster.show('Error', 'User has been logged out');
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
width: '250px',
data: {
title: 'Logged out!',
content:
'You have been logged out.\n' +
'You can press Cancel to stay on page and login in another tab to resume here,' +
' or you can press Ok to navigate to the login page.',
},
});
dialogRef.afterClosed().subscribe((result: boolean) => {
if (result) {
this.router.navigate(['login']);
}
});
return throwError(err);
}),
);
}
}

View File

@ -0,0 +1,35 @@
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { AuthService } from '../auth/auth.service';
@Injectable()
export class JwtInterceptor implements HttpInterceptor {
private isRefreshing = false;
constructor(private authService: AuthService) {}
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
// add authorization header with jwt token if available
// We use this line to debug token refreshing
if (!this.isRefreshing && this.authService.user && this.authService.needsRefreshing()) {
this.isRefreshing = true;
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}`,
},
});
}
return next.handle(request);
}
}

View File

@ -0,0 +1,10 @@
export class Nature {
id: string | undefined;
name: string;
public constructor(init?: Partial<Nature>) {
this.id = undefined;
this.name = '';
Object.assign(this, init);
}
}

View File

@ -0,0 +1,10 @@
export class OfficeStatus {
id: string | undefined;
name: string;
public constructor(init?: Partial<OfficeStatus>) {
this.id = undefined;
this.name = '';
Object.assign(this, init);
}
}

View File

@ -0,0 +1,17 @@
import { Department } from './department';
export class Office {
id: string | undefined;
name: string;
address: string;
email: string;
department?: Department;
public constructor(init?: Partial<Office>) {
this.id = undefined;
this.name = '';
this.address = '';
this.email = '';
Object.assign(this, init);
}
}

View File

@ -0,0 +1,15 @@
import { inject, TestBed } from '@angular/core/testing';
import { ToasterService } from './toaster.service';
describe('ToasterService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [ToasterService],
});
});
it('should be created', inject([ToasterService], (service: ToasterService) => {
expect(service).toBeTruthy();
}));
});

View File

@ -0,0 +1,15 @@
import { Injectable } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';
@Injectable({
providedIn: 'root',
})
export class ToasterService {
constructor(private snackBar: MatSnackBar) {}
show(type: string, msg: string) {
this.snackBar.open(msg, type, {
duration: 3000,
});
}
}

View File

@ -0,0 +1,12 @@
export class UserGroup {
id: string | undefined;
name: string;
enabled: boolean;
public constructor(init?: Partial<UserGroup>) {
this.id = undefined;
this.name = '';
this.enabled = false;
Object.assign(this, init);
}
}

25
otis/src/app/core/user.ts Normal file
View File

@ -0,0 +1,25 @@
import { UserGroup } from './user-group';
export class User {
id: string | undefined;
name: string;
password: string;
lockedOut: boolean;
roles: UserGroup[];
perms: string[];
access_token?: string;
exp: number;
ver: string;
public constructor(init?: Partial<User>) {
this.id = undefined;
this.name = '';
this.password = '';
this.lockedOut = true;
this.roles = [];
this.perms = [];
this.exp = 0;
this.ver = '';
Object.assign(this, init);
}
}