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:
@ -1,33 +1,28 @@
|
||||
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 { map } from 'rxjs/operators';
|
||||
import { merge, Observable, of as observableOf } from 'rxjs';
|
||||
|
||||
export class BalanceSheetDataSource extends DataSource<any> {
|
||||
|
||||
constructor(private paginator: MatPaginator, private sort: MatSort, public data: any[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<any[]> {
|
||||
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: any[]) {
|
||||
const startIndex = this.paginator.pageIndex * this.paginator.pageSize;
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {BalanceSheetResolver} from './balance-sheet-resolver.service';
|
||||
import { BalanceSheetResolver } from './balance-sheet-resolver.service';
|
||||
|
||||
describe('BalanceSheetResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [BalanceSheetResolver]
|
||||
providers: [BalanceSheetResolver],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1,16 +1,14 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {BalanceSheet} from './balance-sheet';
|
||||
import {BalanceSheetService} from './balance-sheet.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { BalanceSheet } from './balance-sheet';
|
||||
import { BalanceSheetService } from './balance-sheet.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class BalanceSheetResolver implements Resolve<BalanceSheet> {
|
||||
|
||||
constructor(private ser: BalanceSheetService) {
|
||||
}
|
||||
constructor(private ser: BalanceSheetService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<BalanceSheet> {
|
||||
const date = route.paramMap.get('date');
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {BalanceSheetRoutingModule} from './balance-sheet-routing.module';
|
||||
import { BalanceSheetRoutingModule } from './balance-sheet-routing.module';
|
||||
|
||||
describe('BalanceSheetRoutingModule', () => {
|
||||
let balanceSheetRoutingModule: BalanceSheetRoutingModule;
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {RouterModule, Routes} from '@angular/router';
|
||||
import {BalanceSheetResolver} from './balance-sheet-resolver.service';
|
||||
import {AuthGuard} from '../auth/auth-guard.service';
|
||||
import {BalanceSheetComponent} from './balance-sheet.component';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { BalanceSheetResolver } from './balance-sheet-resolver.service';
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { BalanceSheetComponent } from './balance-sheet.component';
|
||||
|
||||
const balanceSheetRoutes: Routes = [
|
||||
{
|
||||
@ -11,37 +11,28 @@ const balanceSheetRoutes: Routes = [
|
||||
component: BalanceSheetComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Balance Sheet'
|
||||
permission: 'Balance Sheet',
|
||||
},
|
||||
resolve: {
|
||||
info: BalanceSheetResolver
|
||||
}
|
||||
info: BalanceSheetResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: ':date',
|
||||
component: BalanceSheetComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Balance Sheet'
|
||||
permission: 'Balance Sheet',
|
||||
},
|
||||
resolve: {
|
||||
info: BalanceSheetResolver
|
||||
}
|
||||
}
|
||||
info: BalanceSheetResolver,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(balanceSheetRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
BalanceSheetResolver
|
||||
]
|
||||
imports: [CommonModule, RouterModule.forChild(balanceSheetRoutes)],
|
||||
exports: [RouterModule],
|
||||
providers: [BalanceSheetResolver],
|
||||
})
|
||||
export class BalanceSheetRoutingModule {
|
||||
}
|
||||
export class BalanceSheetRoutingModule {}
|
||||
|
||||
@ -4,11 +4,22 @@
|
||||
</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>
|
||||
<input matInput [matDatepicker]="dateInput" (focus)="dateInput.open()" placeholder="Date"
|
||||
formControlName="date" autocomplete="off">
|
||||
<input
|
||||
matInput
|
||||
[matDatepicker]="dateInput"
|
||||
(focus)="dateInput.open()"
|
||||
placeholder="Date"
|
||||
formControlName="date"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<mat-datepicker-toggle matSuffix [for]="dateInput"></mat-datepicker-toggle>
|
||||
<mat-datepicker #dateInput></mat-datepicker>
|
||||
</mat-form-field>
|
||||
@ -16,48 +27,54 @@
|
||||
</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>
|
||||
|
||||
<!-- SubAmount Column -->
|
||||
<ng-container matColumnDef="subAmount">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Amount</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{row.subAmount | currency:'INR' | clear}}</mat-cell>
|
||||
<mat-footer-cell *matFooterCellDef class="right">{{info.footer?.subAmount | currency:'INR' | clear}}
|
||||
<mat-cell *matCellDef="let row" class="right">{{
|
||||
row.subAmount | currency: 'INR' | clear
|
||||
}}</mat-cell>
|
||||
<mat-footer-cell *matFooterCellDef class="right"
|
||||
>{{ info.footer?.subAmount | currency: 'INR' | clear }}
|
||||
</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.amount | currency:'INR' | clear}}</mat-cell>
|
||||
<mat-footer-cell *matFooterCellDef class="right">{{info.footer?.amount | currency:'INR' | clear}}
|
||||
<mat-cell *matCellDef="let row" class="right">{{
|
||||
row.amount | currency: 'INR' | clear
|
||||
}}</mat-cell>
|
||||
<mat-footer-cell *matFooterCellDef class="right"
|
||||
>{{ info.footer?.amount | currency: 'INR' | clear }}
|
||||
</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, 5000]">
|
||||
<mat-paginator
|
||||
#paginator
|
||||
[length]="dataSource.data.length"
|
||||
[pageIndex]="0"
|
||||
[pageSize]="50"
|
||||
[pageSizeOptions]="[25, 50, 100, 250, 300, 5000]"
|
||||
>
|
||||
</mat-paginator>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {BalanceSheetComponent} from './balance-sheet.component';
|
||||
import { BalanceSheetComponent } from './balance-sheet.component';
|
||||
|
||||
describe('BalanceSheetComponent', () => {
|
||||
let component: BalanceSheetComponent;
|
||||
@ -8,9 +8,8 @@ describe('BalanceSheetComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [BalanceSheetComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [BalanceSheetComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import {BalanceSheetDataSource} from './balance-sheet-datasource';
|
||||
import {BalanceSheet} from './balance-sheet';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import { BalanceSheetDataSource } from './balance-sheet-datasource';
|
||||
import { BalanceSheet } from './balance-sheet';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-balance-sheet',
|
||||
templateUrl: './balance-sheet.component.html',
|
||||
styleUrls: ['./balance-sheet.component.css']
|
||||
styleUrls: ['./balance-sheet.component.css'],
|
||||
})
|
||||
export class BalanceSheetComponent implements OnInit {
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
@ -27,18 +27,17 @@ export class BalanceSheetComponent implements OnInit {
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
date: ''
|
||||
date: '',
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { info: BalanceSheet }) => {
|
||||
this.info = data.info;
|
||||
this.form.setValue({
|
||||
date: moment(this.info.date, 'DD-MMM-YYYY').toDate()
|
||||
});
|
||||
this.route.data.subscribe((data: { info: BalanceSheet }) => {
|
||||
this.info = data.info;
|
||||
this.form.setValue({
|
||||
date: moment(this.info.date, 'DD-MMM-YYYY').toDate(),
|
||||
});
|
||||
});
|
||||
this.dataSource = new BalanceSheetDataSource(this.paginator, this.sort, this.info.body);
|
||||
}
|
||||
|
||||
@ -49,6 +48,6 @@ export class BalanceSheetComponent implements OnInit {
|
||||
|
||||
getDate(): string {
|
||||
const formModel = this.form.value;
|
||||
return moment(formModel.date).format('DD-MMM-YYYY');
|
||||
return moment(formModel.date).format('DD-MMM-YYYY');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {BalanceSheetModule} from './balance-sheet.module';
|
||||
import { BalanceSheetModule } from './balance-sheet.module';
|
||||
|
||||
describe('BalanceSheetModule', () => {
|
||||
let balanceSheetModule: BalanceSheetModule;
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
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 { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
@ -11,13 +16,13 @@ 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 {CdkTableModule} from '@angular/cdk/table';
|
||||
import {BalanceSheetRoutingModule} from './balance-sheet-routing.module';
|
||||
import {BalanceSheetComponent} from './balance-sheet.component';
|
||||
import {MomentDateAdapter} from '@angular/material-moment-adapter';
|
||||
import {FlexLayoutModule} from '@angular/flex-layout';
|
||||
import {ReactiveFormsModule} from '@angular/forms';
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { BalanceSheetRoutingModule } from './balance-sheet-routing.module';
|
||||
import { BalanceSheetComponent } from './balance-sheet.component';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
|
||||
export const MY_FORMATS = {
|
||||
parse: {
|
||||
@ -49,15 +54,12 @@ export const MY_FORMATS = {
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
SharedModule,
|
||||
BalanceSheetRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
BalanceSheetComponent
|
||||
BalanceSheetRoutingModule,
|
||||
],
|
||||
declarations: [BalanceSheetComponent],
|
||||
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 BalanceSheetModule {
|
||||
}
|
||||
export class BalanceSheetModule {}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {BalanceSheetService} from './balance-sheet.service';
|
||||
import { BalanceSheetService } from './balance-sheet.service';
|
||||
|
||||
describe('BalanceSheetService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [BalanceSheetService]
|
||||
providers: [BalanceSheetService],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1,31 +1,29 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {HttpClient, HttpHeaders} from '@angular/common/http';
|
||||
import {BalanceSheet} from './balance-sheet';
|
||||
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 } from '@angular/common/http';
|
||||
import { BalanceSheet } from './balance-sheet';
|
||||
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/balance-sheet';
|
||||
const serviceName = 'BalanceSheetService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class BalanceSheetService {
|
||||
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
list(date: string): Observable<BalanceSheet> {
|
||||
const listUrl = (date === null) ? url : `${url}/${date}`;
|
||||
return <Observable<BalanceSheet>>this.http.get<BalanceSheet>(listUrl)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
const listUrl = date === null ? url : `${url}/${date}`;
|
||||
return <Observable<BalanceSheet>>(
|
||||
this.http
|
||||
.get<BalanceSheet>(listUrl)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list')))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user