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:
@ -0,0 +1,63 @@
|
||||
import {DataSource} from '@angular/cdk/collections';
|
||||
import {MatPaginator, MatSort} from '@angular/material';
|
||||
import {map} from 'rxjs/operators';
|
||||
import {merge, Observable, of as observableOf} from 'rxjs';
|
||||
import {NetTransactionsItem} from './net-transactions';
|
||||
|
||||
|
||||
export class NetTransactionsDataSource extends DataSource<NetTransactionsItem> {
|
||||
|
||||
constructor(private paginator: MatPaginator, private sort: MatSort, public data: NetTransactionsItem[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<NetTransactionsItem[]> {
|
||||
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]));
|
||||
}));
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
|
||||
private getPagedData(data: NetTransactionsItem[]) {
|
||||
const startIndex = this.paginator.pageIndex * this.paginator.pageSize;
|
||||
return data.splice(startIndex, this.paginator.pageSize);
|
||||
}
|
||||
|
||||
private getSortedData(data: NetTransactionsItem[]) {
|
||||
if (!this.sort.active || this.sort.direction === '') {
|
||||
return data;
|
||||
}
|
||||
|
||||
return data.sort((a, b) => {
|
||||
const isAsc = this.sort.direction === 'asc';
|
||||
switch (this.sort.active) {
|
||||
case 'name':
|
||||
return compare(a.name, b.name, isAsc);
|
||||
case 'type':
|
||||
return compare(a.type, b.type, isAsc);
|
||||
case 'debit':
|
||||
return compare(+a.debit, +b.debit, isAsc);
|
||||
case 'credit':
|
||||
return compare(+a.credit, +b.credit, isAsc);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** Simple sort comparator for example ID/Name columns (for client-side sorting). */
|
||||
function compare(a, b, isAsc) {
|
||||
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {NetTransactionsResolver} from './net-transactions-resolver.service';
|
||||
|
||||
describe('NetTransactionsResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [NetTransactionsResolver]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([NetTransactionsResolver], (service: NetTransactionsResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@ -0,0 +1,20 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {NetTransactions} from './net-transactions';
|
||||
import {NetTransactionsService} from './net-transactions.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NetTransactionsResolver implements Resolve<NetTransactions> {
|
||||
|
||||
constructor(private ser: NetTransactionsService) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<NetTransactions> {
|
||||
const startDate = route.queryParamMap.get('startDate') || null;
|
||||
const finishDate = route.queryParamMap.get('finishDate') || null;
|
||||
return this.ser.list(startDate, finishDate);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
import {NetTransactionsRoutingModule} from './net-transactions-routing.module';
|
||||
|
||||
describe('NetTransactionsRoutingModule', () => {
|
||||
let netTransactionsRoutingModule: NetTransactionsRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
netTransactionsRoutingModule = new NetTransactionsRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(netTransactionsRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,37 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {RouterModule, Routes} from '@angular/router';
|
||||
import {NetTransactionsResolver} from './net-transactions-resolver.service';
|
||||
import {AuthGuard} from '../auth/auth-guard.service';
|
||||
import {NetTransactionsComponent} from './net-transactions.component';
|
||||
|
||||
const netTransactionsRoutes: Routes = [
|
||||
{
|
||||
path: 'NetTransactions',
|
||||
component: NetTransactionsComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Net Transactions'
|
||||
},
|
||||
resolve: {
|
||||
info: NetTransactionsResolver
|
||||
},
|
||||
runGuardsAndResolvers: 'always'
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(netTransactionsRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
NetTransactionsResolver
|
||||
]
|
||||
})
|
||||
export class NetTransactionsRoutingModule {
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
.right {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.selected{
|
||||
background: #fff3cd
|
||||
}
|
||||
|
||||
.unposted{
|
||||
background: #f8d7da
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Net Transactions</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 fxFlex="20" mat-raised-button color="primary" (click)="show()">Show</button>
|
||||
</div>
|
||||
</form>
|
||||
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
|
||||
|
||||
<!-- 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>
|
||||
</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>
|
||||
</ng-container>
|
||||
|
||||
<!-- Debit Column -->
|
||||
<ng-container matColumnDef="debit">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Debit</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{row.debit | currency:'INR' | accounting}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Credit Column -->
|
||||
<ng-container matColumnDef="credit">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Credit</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{row.credit | currency:'INR' | accounting}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
|
||||
</mat-table>
|
||||
|
||||
<mat-paginator #paginator
|
||||
[length]="dataSource.data.length"
|
||||
[pageIndex]="0"
|
||||
[pageSize]="50"
|
||||
[pageSizeOptions]="[25, 50, 100, 250, 300]">
|
||||
</mat-paginator>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
@ -0,0 +1,25 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {NetTransactionsComponent} from './net-transactions.component';
|
||||
|
||||
describe('NetTransactionsComponent', () => {
|
||||
let component: NetTransactionsComponent;
|
||||
let fixture: ComponentFixture<NetTransactionsComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [NetTransactionsComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(NetTransactionsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,71 @@
|
||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||
import {MatPaginator, MatSort} from '@angular/material';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
import {NetTransactionsDataSource} from './net-transactions-datasource';
|
||||
import {NetTransactions} from './net-transactions';
|
||||
import {NetTransactionsService} from './net-transactions.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-net-transactions',
|
||||
templateUrl: './net-transactions.component.html',
|
||||
styleUrls: ['./net-transactions.component.css']
|
||||
})
|
||||
export class NetTransactionsComponent implements OnInit {
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
dataSource: NetTransactionsDataSource;
|
||||
form: FormGroup;
|
||||
info: NetTransactions;
|
||||
selectedRowId: string;
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['type', 'name', 'debit', 'credit'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private fb: FormBuilder
|
||||
) {
|
||||
this.createForm();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { info: NetTransactions }) => {
|
||||
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 NetTransactionsDataSource(this.paginator, this.sort, this.info.body);
|
||||
});
|
||||
}
|
||||
|
||||
show() {
|
||||
const l = this.prepareSubmit();
|
||||
this.router.navigate(['NetTransactions'], {
|
||||
queryParams: {
|
||||
startDate: l.startDate,
|
||||
finishDate: l.finishDate
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
startDate: '',
|
||||
finishDate: '',
|
||||
});
|
||||
}
|
||||
|
||||
prepareSubmit(): NetTransactions {
|
||||
const formModel = this.form.value;
|
||||
|
||||
return {
|
||||
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
|
||||
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
|
||||
body: []
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
import {NetTransactionsModule} from './net-transactions.module';
|
||||
|
||||
describe('NetTransactionsModule', () => {
|
||||
let netTransactionsModule: NetTransactionsModule;
|
||||
|
||||
beforeEach(() => {
|
||||
netTransactionsModule = new NetTransactionsModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(netTransactionsModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
75
overlord/src/app/net-transactions/net-transactions.module.ts
Normal file
75
overlord/src/app/net-transactions/net-transactions.module.ts
Normal file
@ -0,0 +1,75 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {
|
||||
DateAdapter,
|
||||
MAT_DATE_FORMATS,
|
||||
MAT_DATE_LOCALE,
|
||||
MatAutocompleteModule,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatCheckboxModule,
|
||||
MatDatepickerModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatNativeDateModule,
|
||||
MatPaginatorModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatSortModule,
|
||||
MatTableModule
|
||||
} from '@angular/material';
|
||||
import {SharedModule} from '../shared/shared.module';
|
||||
import {ReactiveFormsModule} from '@angular/forms';
|
||||
import {CdkTableModule} from '@angular/cdk/table';
|
||||
import {NetTransactionsRoutingModule} from './net-transactions-routing.module';
|
||||
import {NetTransactionsComponent} from './net-transactions.component';
|
||||
import {MomentDateAdapter} from '@angular/material-moment-adapter';
|
||||
import {A11yModule} from '@angular/cdk/a11y';
|
||||
import {FlexLayoutModule, FlexModule} from '@angular/flex-layout';
|
||||
|
||||
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: [
|
||||
A11yModule,
|
||||
CommonModule,
|
||||
CdkTableModule,
|
||||
FlexModule,
|
||||
FlexLayoutModule,
|
||||
MatAutocompleteModule,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatCheckboxModule,
|
||||
MatDatepickerModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatNativeDateModule,
|
||||
MatPaginatorModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatSortModule,
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
SharedModule,
|
||||
NetTransactionsRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
NetTransactionsComponent
|
||||
],
|
||||
providers: [
|
||||
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
|
||||
{provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
|
||||
]
|
||||
})
|
||||
export class NetTransactionsModule {
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {NetTransactionsService} from './net-transactions.service';
|
||||
|
||||
describe('NetTransactionsService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [NetTransactionsService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([NetTransactionsService], (service: NetTransactionsService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@ -0,0 +1,37 @@
|
||||
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 {NetTransactions} from './net-transactions';
|
||||
import {ErrorLoggerService} from '../core/error-logger.service';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
|
||||
const url = '/api/NetTransactions';
|
||||
const serviceName = 'NetTransactionsService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NetTransactionsService {
|
||||
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
|
||||
list(startDate: string, finishDate): Observable<NetTransactions> {
|
||||
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<NetTransactions>>this.http.get<NetTransactions>(url, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
13
overlord/src/app/net-transactions/net-transactions.ts
Normal file
13
overlord/src/app/net-transactions/net-transactions.ts
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
export class NetTransactionsItem {
|
||||
type: string;
|
||||
name: string;
|
||||
debit: number;
|
||||
credit: string;
|
||||
}
|
||||
|
||||
export class NetTransactions {
|
||||
startDate: string;
|
||||
finishDate: string;
|
||||
body: NetTransactionsItem[];
|
||||
}
|
||||
Reference in New Issue
Block a user