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,33 @@
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 {ProfitLossItem} from './profit-loss';
import { map } from 'rxjs/operators';
import { merge, Observable, of as observableOf } from 'rxjs';
import { ProfitLossItem } from './profit-loss';
export class ProfitLossDataSource extends DataSource<ProfitLossItem> {
constructor(private paginator: MatPaginator, private sort: MatSort, public data: ProfitLossItem[]) {
constructor(
private paginator: MatPaginator,
private sort: MatSort,
public data: ProfitLossItem[],
) {
super();
}
connect(): Observable<ProfitLossItem[]> {
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: ProfitLossItem[]) {
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 {ProfitLossResolver} from './profit-loss-resolver.service';
import { ProfitLossResolver } from './profit-loss-resolver.service';
describe('ProfitLossResolver', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [ProfitLossResolver]
providers: [ProfitLossResolver],
});
});

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 {ProfitLoss} from './profit-loss';
import {ProfitLossService} from './profit-loss.service';
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs/internal/Observable';
import { ProfitLoss } from './profit-loss';
import { ProfitLossService } from './profit-loss.service';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class ProfitLossResolver implements Resolve<ProfitLoss> {
constructor(private ser: ProfitLossService) {
}
constructor(private ser: ProfitLossService) {}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<ProfitLoss> {
const startDate = route.queryParamMap.get('startDate') || null;

View File

@ -1,4 +1,4 @@
import {ProfitLossRoutingModule} from './profit-loss-routing.module';
import { ProfitLossRoutingModule } from './profit-loss-routing.module';
describe('ProfitLossRoutingModule', () => {
let profitLossRoutingModule: ProfitLossRoutingModule;

View File

@ -1,9 +1,9 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {RouterModule, Routes} from '@angular/router';
import {ProfitLossResolver} from './profit-loss-resolver.service';
import {AuthGuard} from '../auth/auth-guard.service';
import {ProfitLossComponent} from './profit-loss.component';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { ProfitLossResolver } from './profit-loss-resolver.service';
import { AuthGuard } from '../auth/auth-guard.service';
import { ProfitLossComponent } from './profit-loss.component';
const profitLossRoutes: Routes = [
{
@ -11,27 +11,18 @@ const profitLossRoutes: Routes = [
component: ProfitLossComponent,
canActivate: [AuthGuard],
data: {
permission: 'Profit & Loss'
permission: 'Profit & Loss',
},
resolve: {
info: ProfitLossResolver
info: ProfitLossResolver,
},
runGuardsAndResolvers: 'always'
}
runGuardsAndResolvers: 'always',
},
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(profitLossRoutes)
],
exports: [
RouterModule
],
providers: [
ProfitLossResolver
]
imports: [CommonModule, RouterModule.forChild(profitLossRoutes)],
exports: [RouterModule],
providers: [ProfitLossResolver],
})
export class ProfitLossRoutingModule {
}
export class ProfitLossRoutingModule {}

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,49 +39,50 @@
</div>
</form>
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
<!-- Group Column -->
<ng-container matColumnDef="group">
<mat-header-cell *matHeaderCellDef mat-sort-header>Group</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.group}}</mat-cell>
<mat-footer-cell *matFooterCellDef>{{info.footer?.group}}</mat-footer-cell>
<mat-cell *matCellDef="let row">{{ row.group }}</mat-cell>
<mat-footer-cell *matFooterCellDef>{{ info.footer?.group }}</mat-footer-cell>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.name}}</mat-cell>
<mat-footer-cell *matFooterCellDef>{{info.footer?.name}}</mat-footer-cell>
<mat-cell *matCellDef="let row">{{ row.name }}</mat-cell>
<mat-footer-cell *matFooterCellDef>{{ info.footer?.name }}</mat-footer-cell>
</ng-container>
<!-- Amount Column -->
<ng-container matColumnDef="amount">
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Amount</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{row.amount | currency:'INR'}}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.amount | currency: 'INR' }}</mat-cell>
<mat-footer-cell *matFooterCellDef class="right">
{{info.footer?.amount | currency:'INR'}}
{{ info.footer?.amount | currency: 'INR' }}
</mat-footer-cell>
</ng-container>
<!-- Total Column -->
<ng-container matColumnDef="total">
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Total</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{row.total | currency:'INR'}}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.total | currency: 'INR' }}</mat-cell>
<mat-footer-cell *matFooterCellDef class="right">
{{info.footer?.total | currency:'INR'}}
{{ info.footer?.total | currency: 'INR' }}
</mat-footer-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
<mat-footer-row *matFooterRowDef="displayedColumns"></mat-footer-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 {ProfitLossComponent} from './profit-loss.component';
import { ProfitLossComponent } from './profit-loss.component';
describe('ProfitLossComponent', () => {
let component: ProfitLossComponent;
@ -8,9 +8,8 @@ describe('ProfitLossComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ProfitLossComponent]
})
.compileComponents();
declarations: [ProfitLossComponent],
}).compileComponents();
}));
beforeEach(() => {

View File

@ -1,16 +1,16 @@
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 {ProfitLossDataSource} from './profit-loss-datasource';
import {ProfitLoss} from './profit-loss';
import { ProfitLossDataSource } from './profit-loss-datasource';
import { ProfitLoss } from './profit-loss';
@Component({
selector: 'app-profit-loss',
templateUrl: './profit-loss.component.html',
styleUrls: ['./profit-loss.component.css']
styleUrls: ['./profit-loss.component.css'],
})
export class ProfitLossComponent implements OnInit {
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
@ -22,24 +22,19 @@ export class ProfitLossComponent implements OnInit {
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['group', 'name', 'amount', 'total'];
constructor(
private route: ActivatedRoute,
private router: Router,
private fb: FormBuilder
) {
constructor(private route: ActivatedRoute, private router: Router, private fb: FormBuilder) {
this.createForm();
}
ngOnInit() {
this.route.data
.subscribe((data: { info: ProfitLoss }) => {
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 ProfitLossDataSource(this.paginator, this.sort, this.info.body);
this.route.data.subscribe((data: { info: ProfitLoss }) => {
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 ProfitLossDataSource(this.paginator, this.sort, this.info.body);
});
}
show() {
@ -47,8 +42,8 @@ export class ProfitLossComponent implements OnInit {
this.router.navigate(['profit-loss'], {
queryParams: {
startDate: l.startDate,
finishDate: l.finishDate
}
finishDate: l.finishDate,
},
});
}
@ -66,7 +61,7 @@ export class ProfitLossComponent implements OnInit {
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
body: [],
footer: {group: null, name: null, amount: null, total: null}
footer: { group: null, name: null, amount: null, total: null },
};
}
}

View File

@ -1,4 +1,4 @@
import {ProfitLossModule} from './profit-loss.module';
import { ProfitLossModule } from './profit-loss.module';
describe('ProfitLossModule', () => {
let profitLossModule: ProfitLossModule;

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 {ProfitLossRoutingModule} from './profit-loss-routing.module';
import {ProfitLossComponent} from './profit-loss.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 { ProfitLossRoutingModule } from './profit-loss-routing.module';
import { ProfitLossComponent } from './profit-loss.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,
ProfitLossRoutingModule
],
declarations: [
ProfitLossComponent
ProfitLossRoutingModule,
],
declarations: [ProfitLossComponent],
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 ProfitLossModule {
}
export class ProfitLossModule {}

View File

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

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 {ProfitLoss} from './profit-loss';
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 { ProfitLoss } from './profit-loss';
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/profit-loss';
const serviceName = 'ProfitLossService';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class ProfitLossService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {
}
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
list(startDate: string, finishDate): Observable<ProfitLoss> {
startDate = startDate ? `/${startDate}` : '';
finishDate = finishDate ? `/${finishDate}` : '';
return <Observable<ProfitLoss>>this.http.get<ProfitLoss>(`${url}${startDate}${finishDate}`)
.pipe(
catchError(this.log.handleError(serviceName, 'list'))
);
return <Observable<ProfitLoss>>(
this.http
.get<ProfitLoss>(`${url}${startDate}${finishDate}`)
.pipe(catchError(this.log.handleError(serviceName, 'list')))
);
}
}

View File

@ -1,4 +1,3 @@
export class ProfitLossItem {
group: string;
name: string;