Fix: Login deleting old clients was conflicting with login history

Chore: Moved to angular linting using the recommended plugins / settings
This commit is contained in:
2020-12-08 12:09:19 +05:30
parent d5048bc455
commit 57ef355170
176 changed files with 940 additions and 831 deletions

View File

@ -8,9 +8,7 @@ import { map } from 'rxjs/operators';
import { LedgerItem } from './ledger-item';
/** Simple sort comparator for example ID/Name columns (for client-side sorting). */
function compare(a: string | number, b: string | number, isAsc: boolean) {
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
}
const compare = (a: string | number, b: string | number, isAsc: boolean) => (a < b ? -1 : 1) * (isAsc ? 1 : -1);
export class LedgerDataSource extends DataSource<LedgerItem> {
constructor(public data: LedgerItem[], private paginator?: MatPaginator, private sort?: MatSort) {
super();
@ -22,11 +20,17 @@ export class LedgerDataSource extends DataSource<LedgerItem> {
| EventEmitter<PageEvent>
| EventEmitter<Sort>
)[] = [observableOf(this.data)];
if (this.paginator) dataMutations.push((this.paginator as MatPaginator).page);
if (this.sort) dataMutations.push((this.sort as MatSort).sortChange);
if (this.paginator) {
dataMutations.push((this.paginator as MatPaginator).page);
}
if (this.sort) {
dataMutations.push((this.sort as MatSort).sortChange);
}
// Set the paginators length
if (this.paginator) this.paginator.length = this.data.length;
if (this.paginator) {
this.paginator.length = this.data.length;
}
return merge(...dataMutations).pipe(
map(() => this.getPagedData(this.getSortedData([...this.data]))),
@ -36,13 +40,17 @@ export class LedgerDataSource extends DataSource<LedgerItem> {
disconnect() {}
private getPagedData(data: LedgerItem[]) {
if (this.paginator === undefined) return data;
if (this.paginator === undefined) {
return data;
}
const startIndex = this.paginator.pageIndex * this.paginator.pageSize;
return data.splice(startIndex, this.paginator.pageSize);
}
private getSortedData(data: LedgerItem[]) {
if (this.sort === undefined) return data;
if (this.sort === undefined) {
return data;
}
if (!this.sort.active || this.sort.direction === '') {
return data;
}

View File

@ -1,5 +1,5 @@
import { inject, TestBed } from '@angular/core/testing';
import { HttpClientModule } from '@angular/common/http';
import { inject, TestBed } from '@angular/core/testing';
import { LedgerResolver } from './ledger-resolver.service';

View File

@ -1,5 +1,5 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { HttpClientModule } from '@angular/common/http';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';

View File

@ -77,7 +77,9 @@ export class LedgerComponent implements OnInit, AfterViewInit {
ngAfterViewInit() {
setTimeout(() => {
if (this.accountElement) this.accountElement.nativeElement.focus();
if (this.accountElement) {
this.accountElement.nativeElement.focus();
}
}, 0);
}

View File

@ -1,5 +1,5 @@
import { inject, TestBed } from '@angular/core/testing';
import { HttpClientModule } from '@angular/common/http';
import { inject, TestBed } from '@angular/core/testing';
import { LedgerService } from './ledger.service';

View File

@ -25,10 +25,8 @@ export class LedgerService {
if (finishDate !== null) {
options.params = options.params.set('f', finishDate);
}
return <Observable<Ledger>>(
this.http
.get<Ledger>(listUrl, options)
.pipe(catchError(this.log.handleError(serviceName, 'list')))
);
return this.http
.get<Ledger>(listUrl, options)
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<Ledger>;
}
}