Moved to Angular 6.0

----

Pending
* Table width for the points column in incentive
* Linting
* keyboard navigation where it was used earlier
* can remove the unused totals calculated serverside in productledger
* spinner and loading bars
* Activate Guard for Employee Function tabs
* Progress for Fingerprint uploads
* deleted reconcile and receipe features as they were not being used
* focus the right control on component load
This commit is contained in:
tanshu
2018-06-09 17:05:11 +05:30
parent b3cb01da02
commit 6be1dd5a3a
1380 changed files with 23914 additions and 18722 deletions
@@ -0,0 +1,18 @@
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();
}
connect(): Observable<CashFlowItem[]> {
return observableOf(this.data);
}
disconnect() {
}
}
@@ -0,0 +1,15 @@
import {inject, TestBed} from '@angular/core/testing';
import {CashFlowResolver} from './cash-flow-resolver.service';
describe('CashFlowResolver', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [CashFlowResolver]
});
});
it('should be created', inject([CashFlowResolver], (service: CashFlowResolver) => {
expect(service).toBeTruthy();
}));
});
@@ -0,0 +1,21 @@
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'
})
export class CashFlowResolver implements Resolve<CashFlow> {
constructor(private ser: CashFlowService) {
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<CashFlow> {
const id = route.paramMap.get('id');
const startDate = route.queryParamMap.get('startDate') || null;
const finishDate = route.queryParamMap.get('finishDate') || null;
return this.ser.list(id, startDate, finishDate);
}
}
@@ -0,0 +1,13 @@
import {CashFlowRoutingModule} from './cash-flow-routing.module';
describe('CashFlowRoutingModule', () => {
let cashFlowRoutingModule: CashFlowRoutingModule;
beforeEach(() => {
cashFlowRoutingModule = new CashFlowRoutingModule();
});
it('should create an instance', () => {
expect(cashFlowRoutingModule).toBeTruthy();
});
});
@@ -0,0 +1,49 @@
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 = [
{
path: 'CashFlow',
component: CashFlowComponent,
canActivate: [AuthGuard],
data: {
permission: 'Cash Flow'
},
resolve: {
info: CashFlowResolver
},
runGuardsAndResolvers: 'always'
},
{
path: 'CashFlow/:id',
component: CashFlowComponent,
canActivate: [AuthGuard],
data: {
permission: 'Cash Flow'
},
resolve: {
info: CashFlowResolver
},
runGuardsAndResolvers: 'always'
}
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(cashFlowRoutes)
],
exports: [
RouterModule
],
providers: [
CashFlowResolver
]
})
export class CashFlowRoutingModule {
}
@@ -0,0 +1,4 @@
.right {
display: flex;
justify-content: flex-end;
}
@@ -0,0 +1,42 @@
<mat-card>
<mat-card-title-group>
<mat-card-title>Cash Flow</mat-card-title>
</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">
<mat-form-field fxFlex="40">
<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">
<mat-datepicker-toggle matSuffix [for]="finishDate"></mat-datepicker-toggle>
<mat-datepicker #finishDate></mat-datepicker>
</mat-form-field>
<button mat-raised-button color="primary" (click)="show()" fxFlex="20c">Show</button>
</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 [href]="row.url">{{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>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
</mat-card-content>
</mat-card>
@@ -0,0 +1,25 @@
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {CashFlowComponent} from './cash-flow.component';
describe('CashFlowComponent', () => {
let component: CashFlowComponent;
let fixture: ComponentFixture<CashFlowComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [CashFlowComponent]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CashFlowComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,62 @@
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 {Ledger} from '../ledger/ledger';
@Component({
selector: 'app-cash-flow',
templateUrl: './cash-flow.component.html',
styleUrls: ['./cash-flow.component.css']
})
export class CashFlowComponent implements OnInit {
dataSource: CashFlowDataSource;
form: FormGroup;
info: CashFlow;
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['name', 'amount'];
constructor(private route: ActivatedRoute, private router: Router, private fb: FormBuilder) {
this.createForm();
}
createForm() {
this.form = this.fb.group({
startDate: '',
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));
});
}
show() {
const info = this.getInfo();
this.router.navigate(['CashFlow'], {
queryParams: {
startDate: info.startDate,
finishDate: info.finishDate
}
});
}
getInfo(): CashFlow {
const formModel = this.form.value;
return {
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY')
};
}
}
@@ -0,0 +1,13 @@
import {CashFlowModule} from './cash-flow.module';
describe('CashFlowModule', () => {
let cashFlowModule: CashFlowModule;
beforeEach(() => {
cashFlowModule = new CashFlowModule();
});
it('should create an instance', () => {
expect(cashFlowModule).toBeTruthy();
});
});
@@ -0,0 +1,69 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {
DateAdapter,
MAT_DATE_FORMATS,
MAT_DATE_LOCALE,
MatButtonModule,
MatCardModule,
MatCheckboxModule,
MatDatepickerModule,
MatIconModule,
MatInputModule,
MatNativeDateModule,
MatPaginatorModule,
MatProgressSpinnerModule,
MatSortModule,
MatTableModule
} from '@angular/material';
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, FlexModule} from '@angular/flex-layout';
import {ReactiveFormsModule} from '@angular/forms';
export const MY_FORMATS = {
parse: {
dateInput: 'DD-MMM-YYYY',
},
display: {
dateInput: 'DD-MMM-YYYY',
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'DD-MMM-YYYY',
monthYearA11yLabel: 'MMM YYYY',
},
};
@NgModule({
imports: [
CommonModule,
CdkTableModule,
FlexModule,
FlexLayoutModule,
MatButtonModule,
MatCardModule,
MatCheckboxModule,
MatDatepickerModule,
MatIconModule,
MatInputModule,
MatNativeDateModule,
MatPaginatorModule,
MatProgressSpinnerModule,
MatSortModule,
MatTableModule,
ReactiveFormsModule,
SharedModule,
CashFlowRoutingModule
],
declarations: [
CashFlowComponent
],
providers: [
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
{provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
]
})
export class CashFlowModule {
}
@@ -0,0 +1,15 @@
import {inject, TestBed} from '@angular/core/testing';
import {CashFlowService} from './cash-flow.service';
describe('CashFlowService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [CashFlowService]
});
});
it('should be created', inject([CashFlowService], (service: CashFlowService) => {
expect(service).toBeTruthy();
}));
});
@@ -0,0 +1,38 @@
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'})
};
const url = '/api/CashFlow';
const serviceName = 'AccountService';
@Injectable({
providedIn: 'root'
})
export class CashFlowService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {
}
list(id: string, startDate: string, finishDate: string): Observable<CashFlow> {
const listUrl = (id === null) ? url : `${url}/${id}`;
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);
}
return <Observable<CashFlow>>this.http.get<CashFlow>(listUrl, options)
.pipe(
catchError(this.log.handleError(serviceName, 'list'))
);
}
}
+36
View File
@@ -0,0 +1,36 @@
export class CashFlowItem {
name: string;
url: string;
amount: number;
constructor(name: string) {
this.name = name;
}
}
export class CashFlow {
startDate: string;
finishDate: string;
body?: { operating: CashFlowItem[], investing: CashFlowItem[], financing: CashFlowItem[], details: CashFlowItem[] };
footer?: CashFlowItem[];
static Data(value): CashFlowItem[] {
const d: CashFlowItem[] = [];
if (value.body.operating && value.body.operating.length) {
d.push(new CashFlowItem('Cash flows from Operating activities'));
d.push(...value.body.operating);
}
if (value.body.investing && value.body.investing.length) {
d.push(new CashFlowItem('Cash flows from Investing activities'));
d.push(...value.body.investing);
}
if (value.body.financing && value.body.financing.length) {
d.push(new CashFlowItem('Cash flows from Financing activities'));
d.push(...value.body.financing);
}
if (value.body.details && value.body.details.length) {
d.push(...value.body.details);
}
return d;
}
}