Moved from tslint to eslint as tslint was depreciated.

Added prettier and also prettied all the typescript files using prettier

ESLint is using the AirBnB rules which are the most strict to lint the files.
This commit is contained in:
2020-10-01 20:51:22 +05:30
parent 40e79ff949
commit 1350870f9e
545 changed files with 8455 additions and 7036 deletions

View File

@ -1,34 +1,29 @@
import {DataSource} from '@angular/cdk/collections';
import { DataSource } from '@angular/cdk/collections';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import {map} from 'rxjs/operators';
import {merge, Observable, of as observableOf} from 'rxjs';
import {DaybookItem} from './daybook';
import { map } from 'rxjs/operators';
import { merge, Observable, of as observableOf } from 'rxjs';
import { DaybookItem } from './daybook';
export class DaybookDataSource extends DataSource<DaybookItem> {
constructor(private paginator: MatPaginator, private sort: MatSort, public data: DaybookItem[]) {
super();
}
connect(): Observable<DaybookItem[]> {
const dataMutations = [
observableOf(this.data),
this.paginator.page,
this.sort.sortChange
];
const dataMutations = [observableOf(this.data), this.paginator.page, this.sort.sortChange];
// Set the paginators length
this.paginator.length = this.data.length;
return merge(...dataMutations).pipe(map(() => {
return this.getPagedData(this.getSortedData([...this.data]));
}));
return merge(...dataMutations).pipe(
map(() => {
return this.getPagedData(this.getSortedData([...this.data]));
}),
);
}
disconnect() {
}
disconnect() {}
private getPagedData(data: DaybookItem[]) {
const startIndex = this.paginator.pageIndex * this.paginator.pageSize;

View File

@ -1,11 +1,11 @@
import {inject, TestBed} from '@angular/core/testing';
import { inject, TestBed } from '@angular/core/testing';
import {DaybookResolver} from './daybook-resolver.service';
import { DaybookResolver } from './daybook-resolver.service';
describe('DaybookResolver', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [DaybookResolver]
providers: [DaybookResolver],
});
});

View File

@ -1,16 +1,14 @@
import {Injectable} from '@angular/core';
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
import {Observable} from 'rxjs/internal/Observable';
import {Daybook} from './daybook';
import {DaybookService} from './daybook.service';
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs/internal/Observable';
import { Daybook } from './daybook';
import { DaybookService } from './daybook.service';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class DaybookResolver implements Resolve<Daybook> {
constructor(private ser: DaybookService) {
}
constructor(private ser: DaybookService) {}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Daybook> {
const startDate = route.queryParamMap.get('startDate') || null;

View File

@ -1,4 +1,4 @@
import {DaybookRoutingModule} from './daybook-routing.module';
import { DaybookRoutingModule } from './daybook-routing.module';
describe('DaybookRoutingModule', () => {
let daybookRoutingModule: DaybookRoutingModule;

View File

@ -1,9 +1,9 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {RouterModule, Routes} from '@angular/router';
import {DaybookResolver} from './daybook-resolver.service';
import {AuthGuard} from '../auth/auth-guard.service';
import {DaybookComponent} from './daybook.component';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { DaybookResolver } from './daybook-resolver.service';
import { AuthGuard } from '../auth/auth-guard.service';
import { DaybookComponent } from './daybook.component';
const daybookRoutes: Routes = [
{
@ -11,27 +11,18 @@ const daybookRoutes: Routes = [
component: DaybookComponent,
canActivate: [AuthGuard],
data: {
permission: 'Daybook'
permission: 'Daybook',
},
resolve: {
info: DaybookResolver
info: DaybookResolver,
},
runGuardsAndResolvers: 'always'
}
runGuardsAndResolvers: 'always',
},
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(daybookRoutes)
],
exports: [
RouterModule
],
providers: [
DaybookResolver
]
imports: [CommonModule, RouterModule.forChild(daybookRoutes)],
exports: [RouterModule],
providers: [DaybookResolver],
})
export class DaybookRoutingModule {
}
export class DaybookRoutingModule {}

View File

@ -3,10 +3,10 @@
justify-content: flex-end;
}
.selected{
background: #fff3cd
.selected {
background: #fff3cd;
}
.unposted{
background: #f8d7da
.unposted {
background: #f8d7da;
}

View File

@ -4,17 +4,34 @@
</mat-card-title-group>
<mat-card-content>
<form [formGroup]="form" fxLayout="column">
<div fxLayout="row" fxLayout.lt-md="column" fxLayoutGap="20px" fxLayoutGap.lt-md="0px"
fxLayoutAlign="space-around start">
<div
fxLayout="row"
fxLayout.lt-md="column"
fxLayoutGap="20px"
fxLayoutGap.lt-md="0px"
fxLayoutAlign="space-around start"
>
<mat-form-field fxFlex="40">
<input matInput [matDatepicker]="startDate" (focus)="startDate.open()" placeholder="Start Date"
formControlName="startDate" autocomplete="off">
<input
matInput
[matDatepicker]="startDate"
(focus)="startDate.open()"
placeholder="Start Date"
formControlName="startDate"
autocomplete="off"
/>
<mat-datepicker-toggle matSuffix [for]="startDate"></mat-datepicker-toggle>
<mat-datepicker #startDate></mat-datepicker>
</mat-form-field>
<mat-form-field fxFlex="40">
<input matInput [matDatepicker]="finishDate" (focus)="finishDate.open()" placeholder="Finish Date"
formControlName="finishDate" autocomplete="off">
<input
matInput
[matDatepicker]="finishDate"
(focus)="finishDate.open()"
placeholder="Finish Date"
formControlName="finishDate"
autocomplete="off"
/>
<mat-datepicker-toggle matSuffix [for]="finishDate"></mat-datepicker-toggle>
<mat-datepicker #finishDate></mat-datepicker>
</mat-form-field>
@ -22,59 +39,70 @@
</div>
</form>
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
<!-- Date Column -->
<ng-container matColumnDef="date">
<mat-header-cell *matHeaderCellDef mat-sort-header>Date</mat-header-cell>
<mat-cell *matCellDef="let row"><a [routerLink]="row.url">{{row.date}}</a></mat-cell>
<mat-cell *matCellDef="let row"
><a [routerLink]="row.url">{{ row.date }}</a></mat-cell
>
</ng-container>
<!-- Type Column -->
<ng-container matColumnDef="type">
<mat-header-cell *matHeaderCellDef mat-sort-header>Type</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.type}}</mat-cell>
<mat-cell *matCellDef="let row">{{ row.type }}</mat-cell>
</ng-container>
<!-- Narration Column -->
<ng-container matColumnDef="narration">
<mat-header-cell *matHeaderCellDef mat-sort-header>Narration</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.narration}}</mat-cell>
<mat-cell *matCellDef="let row">{{ row.narration }}</mat-cell>
</ng-container>
<!-- DebitText Column -->
<ng-container matColumnDef="debitText">
<mat-header-cell *matHeaderCellDef mat-sort-header>Debit Accounts</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.debitText}}</mat-cell>
<mat-cell *matCellDef="let row">{{ row.debitText }}</mat-cell>
</ng-container>
<!-- Debit Column -->
<ng-container matColumnDef="debitAmount">
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Amount</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{row.debitAmount | currency:'INR'}}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{
row.debitAmount | currency: 'INR'
}}</mat-cell>
</ng-container>
<!-- CreditText Column -->
<ng-container matColumnDef="creditText">
<mat-header-cell *matHeaderCellDef mat-sort-header>Credit Accounts</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.creditText}}</mat-cell>
<mat-cell *matCellDef="let row">{{ row.creditText }}</mat-cell>
</ng-container>
<!-- Credit Column -->
<ng-container matColumnDef="creditAmount">
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Amount</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{row.creditAmount | currency:'INR'}}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{
row.creditAmount | currency: 'INR'
}}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;" [class.selected]="selectedRowId === row.id"
[class.unposted]="!row.posted && selectedRowId !== row.id" (click)="selectRow(row.id)"></mat-row>
<mat-row
*matRowDef="let row; columns: displayedColumns"
[class.selected]="selectedRowId === row.id"
[class.unposted]="!row.posted && selectedRowId !== row.id"
(click)="selectRow(row.id)"
></mat-row>
</mat-table>
<mat-paginator #paginator
[length]="dataSource.data.length"
[pageIndex]="0"
[pageSize]="50"
[pageSizeOptions]="[25, 50, 100, 250, 300]">
<mat-paginator
#paginator
[length]="dataSource.data.length"
[pageIndex]="0"
[pageSize]="50"
[pageSizeOptions]="[25, 50, 100, 250, 300]"
>
</mat-paginator>
</mat-card-content>
</mat-card>

View File

@ -1,6 +1,6 @@
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {DaybookComponent} from './daybook.component';
import { DaybookComponent } from './daybook.component';
describe('DaybookComponent', () => {
let component: DaybookComponent;
@ -8,9 +8,8 @@ describe('DaybookComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [DaybookComponent]
})
.compileComponents();
declarations: [DaybookComponent],
}).compileComponents();
}));
beforeEach(() => {

View File

@ -1,18 +1,18 @@
import {Component, OnInit, ViewChild} from '@angular/core';
import {FormBuilder, FormGroup} from '@angular/forms';
import { Component, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import {ActivatedRoute, Router} from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import * as moment from 'moment';
import {DaybookDataSource} from './daybook-datasource';
import {Daybook} from './daybook';
import {DaybookService} from './daybook.service';
import {map} from 'rxjs/operators';
import { DaybookDataSource } from './daybook-datasource';
import { Daybook } from './daybook';
import { DaybookService } from './daybook.service';
import { map } from 'rxjs/operators';
@Component({
selector: 'app-daybook',
templateUrl: './daybook.component.html',
styleUrls: ['./daybook.component.css']
styleUrls: ['./daybook.component.css'],
})
export class DaybookComponent implements OnInit {
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
@ -22,26 +22,34 @@ export class DaybookComponent implements OnInit {
info: Daybook;
selectedRowId: string;
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['date', 'type', 'narration', 'debitText', 'debitAmount', 'creditText', 'creditAmount'];
displayedColumns = [
'date',
'type',
'narration',
'debitText',
'debitAmount',
'creditText',
'creditAmount',
];
constructor(
private route: ActivatedRoute,
private router: Router,
private fb: FormBuilder,
private ser: DaybookService
private ser: DaybookService,
) {
this.createForm();
}
ngOnInit() {
this.route.data.subscribe((data: { info: Daybook }) => {
this.info = data.info;
this.form.setValue({
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate()
});
this.dataSource = new DaybookDataSource(this.paginator, this.sort, this.info.body);
this.info = data.info;
this.form.setValue({
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate(),
});
this.dataSource = new DaybookDataSource(this.paginator, this.sort, this.info.body);
});
}
selectRow(id: string): void {
@ -53,8 +61,8 @@ export class DaybookComponent implements OnInit {
this.router.navigate(['daybook'], {
queryParams: {
startDate: l.startDate,
finishDate: l.finishDate
}
finishDate: l.finishDate,
},
});
}
@ -71,7 +79,7 @@ export class DaybookComponent implements OnInit {
return {
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
body: []
body: [],
};
}
}

View File

@ -1,4 +1,4 @@
import {DaybookModule} from './daybook.module';
import { DaybookModule } from './daybook.module';
describe('DaybookModule', () => {
let daybookModule: DaybookModule;

View File

@ -1,10 +1,15 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MatNativeDateModule } from '@angular/material/core';
import {
DateAdapter,
MAT_DATE_FORMATS,
MAT_DATE_LOCALE,
MatNativeDateModule,
} from '@angular/material/core';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
@ -13,14 +18,14 @@ import { MatPaginatorModule } from '@angular/material/paginator';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatSortModule } from '@angular/material/sort';
import { MatTableModule } from '@angular/material/table';
import {SharedModule} from '../shared/shared.module';
import {ReactiveFormsModule} from '@angular/forms';
import {CdkTableModule} from '@angular/cdk/table';
import {DaybookRoutingModule} from './daybook-routing.module';
import {DaybookComponent} from './daybook.component';
import {MomentDateAdapter} from '@angular/material-moment-adapter';
import {A11yModule} from '@angular/cdk/a11y';
import {FlexLayoutModule} from '@angular/flex-layout';
import { SharedModule } from '../shared/shared.module';
import { ReactiveFormsModule } from '@angular/forms';
import { CdkTableModule } from '@angular/cdk/table';
import { DaybookRoutingModule } from './daybook-routing.module';
import { DaybookComponent } from './daybook.component';
import { MomentDateAdapter } from '@angular/material-moment-adapter';
import { A11yModule } from '@angular/cdk/a11y';
import { FlexLayoutModule } from '@angular/flex-layout';
export const MY_FORMATS = {
parse: {
@ -55,15 +60,12 @@ export const MY_FORMATS = {
MatTableModule,
ReactiveFormsModule,
SharedModule,
DaybookRoutingModule
],
declarations: [
DaybookComponent
DaybookRoutingModule,
],
declarations: [DaybookComponent],
providers: [
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
{provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
]
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
{ provide: MAT_DATE_FORMATS, useValue: MY_FORMATS },
],
})
export class DaybookModule {
}
export class DaybookModule {}

View File

@ -1,11 +1,11 @@
import {inject, TestBed} from '@angular/core/testing';
import { inject, TestBed } from '@angular/core/testing';
import {DaybookService} from './daybook.service';
import { DaybookService } from './daybook.service';
describe('DaybookService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [DaybookService]
providers: [DaybookService],
});
});

View File

@ -1,32 +1,30 @@
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 {Daybook} from './daybook';
import {ErrorLoggerService} from '../core/error-logger.service';
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 { Daybook } from './daybook';
import { ErrorLoggerService } from '../core/error-logger.service';
const httpOptions = {
headers: new HttpHeaders({'Content-Type': 'application/json'})
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
};
const url = '/api/daybook';
const serviceName = 'DaybookService';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class DaybookService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {
}
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
list(startDate: string, finishDate): Observable<Daybook> {
startDate = startDate ? `/${startDate}` : '';
finishDate = finishDate ? `/${finishDate}` : '';
return <Observable<Daybook>>this.http.get<Daybook>(`${url}${startDate}${finishDate}`)
.pipe(
catchError(this.log.handleError(serviceName, 'list'))
);
return <Observable<Daybook>>(
this.http
.get<Daybook>(`${url}${startDate}${finishDate}`)
.pipe(catchError(this.log.handleError(serviceName, 'list')))
);
}
}

View File

@ -1,4 +1,3 @@
export class DaybookItem {
id: string;
date: string;