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,10 +1,8 @@
|
||||
import {DataSource} from '@angular/cdk/collections';
|
||||
import {Observable, of as observableOf} from 'rxjs';
|
||||
import {CashFlowItem} from './cash-flow';
|
||||
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { CashFlowItem } from './cash-flow';
|
||||
|
||||
export class CashFlowDataSource extends DataSource<CashFlowItem> {
|
||||
|
||||
constructor(private data: CashFlowItem[]) {
|
||||
super();
|
||||
}
|
||||
@ -13,6 +11,5 @@ export class CashFlowDataSource extends DataSource<CashFlowItem> {
|
||||
return observableOf(this.data);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
disconnect() {}
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {CashFlowResolver} from './cash-flow-resolver.service';
|
||||
import { CashFlowResolver } from './cash-flow-resolver.service';
|
||||
|
||||
describe('CashFlowResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [CashFlowResolver]
|
||||
providers: [CashFlowResolver],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1,16 +1,14 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {CashFlow} from './cash-flow';
|
||||
import {CashFlowService} from './cash-flow.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { CashFlow } from './cash-flow';
|
||||
import { CashFlowService } from './cash-flow.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CashFlowResolver implements Resolve<CashFlow> {
|
||||
|
||||
constructor(private ser: CashFlowService) {
|
||||
}
|
||||
constructor(private ser: CashFlowService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<CashFlow> {
|
||||
const id = route.paramMap.get('id');
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {CashFlowRoutingModule} from './cash-flow-routing.module';
|
||||
import { CashFlowRoutingModule } from './cash-flow-routing.module';
|
||||
|
||||
describe('CashFlowRoutingModule', () => {
|
||||
let cashFlowRoutingModule: CashFlowRoutingModule;
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {RouterModule, Routes} from '@angular/router';
|
||||
import {CashFlowResolver} from './cash-flow-resolver.service';
|
||||
import {AuthGuard} from '../auth/auth-guard.service';
|
||||
import {CashFlowComponent} from './cash-flow.component';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { CashFlowResolver } from './cash-flow-resolver.service';
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { CashFlowComponent } from './cash-flow.component';
|
||||
|
||||
const cashFlowRoutes: Routes = [
|
||||
{
|
||||
@ -11,39 +11,30 @@ const cashFlowRoutes: Routes = [
|
||||
component: CashFlowComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Cash Flow'
|
||||
permission: 'Cash Flow',
|
||||
},
|
||||
resolve: {
|
||||
info: CashFlowResolver
|
||||
info: CashFlowResolver,
|
||||
},
|
||||
runGuardsAndResolvers: 'always'
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: CashFlowComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Cash Flow'
|
||||
permission: 'Cash Flow',
|
||||
},
|
||||
resolve: {
|
||||
info: CashFlowResolver
|
||||
info: CashFlowResolver,
|
||||
},
|
||||
runGuardsAndResolvers: 'always'
|
||||
}
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(cashFlowRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
CashFlowResolver
|
||||
]
|
||||
imports: [CommonModule, RouterModule.forChild(cashFlowRoutes)],
|
||||
exports: [RouterModule],
|
||||
providers: [CashFlowResolver],
|
||||
})
|
||||
export class CashFlowRoutingModule {
|
||||
}
|
||||
export class CashFlowRoutingModule {}
|
||||
|
||||
@ -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,21 +39,28 @@
|
||||
</div>
|
||||
</form>
|
||||
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
|
||||
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row"><a [routerLink]="row.url" [queryParams]="{startDate: info.startDate, finishDate: info.finishDate}">{{row.name}} </a></mat-cell>
|
||||
<mat-cell *matCellDef="let row"
|
||||
><a
|
||||
[routerLink]="row.url"
|
||||
[queryParams]="{ startDate: info.startDate, finishDate: info.finishDate }"
|
||||
>{{ row.name }}
|
||||
</a></mat-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' | clear}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{
|
||||
row.amount | currency: 'INR' | clear
|
||||
}}</mat-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-table>
|
||||
</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 {CashFlowComponent} from './cash-flow.component';
|
||||
import { CashFlowComponent } from './cash-flow.component';
|
||||
|
||||
describe('CashFlowComponent', () => {
|
||||
let component: CashFlowComponent;
|
||||
@ -8,9 +8,8 @@ describe('CashFlowComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [CashFlowComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [CashFlowComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {CashFlowDataSource} from './cash-flow-datasource';
|
||||
import {CashFlow} from './cash-flow';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { CashFlowDataSource } from './cash-flow-datasource';
|
||||
import { CashFlow } from './cash-flow';
|
||||
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-cash-flow',
|
||||
templateUrl: './cash-flow.component.html',
|
||||
styleUrls: ['./cash-flow.component.css']
|
||||
styleUrls: ['./cash-flow.component.css'],
|
||||
})
|
||||
export class CashFlowComponent implements OnInit {
|
||||
dataSource: CashFlowDataSource;
|
||||
@ -24,20 +24,19 @@ export class CashFlowComponent implements OnInit {
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
startDate: '',
|
||||
finishDate: ''
|
||||
finishDate: '',
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { info: CashFlow }) => {
|
||||
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 CashFlowDataSource(CashFlow.Data(this.info));
|
||||
this.route.data.subscribe((data: { info: CashFlow }) => {
|
||||
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 CashFlowDataSource(CashFlow.Data(this.info));
|
||||
});
|
||||
}
|
||||
|
||||
show() {
|
||||
@ -45,8 +44,8 @@ export class CashFlowComponent implements OnInit {
|
||||
this.router.navigate(['cash-flow'], {
|
||||
queryParams: {
|
||||
startDate: info.startDate,
|
||||
finishDate: info.finishDate
|
||||
}
|
||||
finishDate: info.finishDate,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@ -55,7 +54,7 @@ export class CashFlowComponent implements OnInit {
|
||||
|
||||
return {
|
||||
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
|
||||
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY')
|
||||
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {CashFlowModule} from './cash-flow.module';
|
||||
import { CashFlowModule } from './cash-flow.module';
|
||||
|
||||
describe('CashFlowModule', () => {
|
||||
let cashFlowModule: CashFlowModule;
|
||||
|
||||
@ -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 {CashFlowRoutingModule} from './cash-flow-routing.module';
|
||||
import {CashFlowComponent} from './cash-flow.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 { CashFlowRoutingModule } from './cash-flow-routing.module';
|
||||
import { CashFlowComponent } from './cash-flow.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,
|
||||
CashFlowRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
CashFlowComponent
|
||||
CashFlowRoutingModule,
|
||||
],
|
||||
declarations: [CashFlowComponent],
|
||||
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 CashFlowModule {
|
||||
}
|
||||
export class CashFlowModule {}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {CashFlowService} from './cash-flow.service';
|
||||
import { CashFlowService } from './cash-flow.service';
|
||||
|
||||
describe('CashFlowService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [CashFlowService]
|
||||
providers: [CashFlowService],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1,38 +1,36 @@
|
||||
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 {CashFlow} from './cash-flow';
|
||||
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 { CashFlow } from './cash-flow';
|
||||
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/cash-flow';
|
||||
const serviceName = 'CashFlowService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CashFlowService {
|
||||
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
list(id: string, startDate: string, finishDate: string): Observable<CashFlow> {
|
||||
const options = {params: new HttpParams()};
|
||||
const options = { params: new HttpParams() };
|
||||
if (startDate !== null) {
|
||||
options.params = options.params.set('s', startDate);
|
||||
}
|
||||
if (finishDate !== null) {
|
||||
options.params = options.params.set('f', finishDate);
|
||||
}
|
||||
const listUrl = (id === null) ? ( (startDate || finishDate) ? `${url}/data` : url) : `${url}/${id}`;
|
||||
return <Observable<CashFlow>>this.http.get<CashFlow>(listUrl, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
const listUrl = id === null ? (startDate || finishDate ? `${url}/data` : url) : `${url}/${id}`;
|
||||
return <Observable<CashFlow>>(
|
||||
this.http
|
||||
.get<CashFlow>(listUrl, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list')))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -11,7 +11,12 @@ export class CashFlowItem {
|
||||
export class CashFlow {
|
||||
startDate: string;
|
||||
finishDate: string;
|
||||
body?: { operating: CashFlowItem[], investing: CashFlowItem[], financing: CashFlowItem[], details: CashFlowItem[] };
|
||||
body?: {
|
||||
operating: CashFlowItem[];
|
||||
investing: CashFlowItem[];
|
||||
financing: CashFlowItem[];
|
||||
details: CashFlowItem[];
|
||||
};
|
||||
footer?: CashFlowItem[];
|
||||
|
||||
static Data(value): CashFlowItem[] {
|
||||
|
||||
Reference in New Issue
Block a user