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:
tanshu committed 2020-12-08 12:09:19 +05:30
1 parent d5048bc455
commit 57ef355170
176 files changed
+940 -831

No files matched your search

@@ -45,7 +45,9 @@ export class CostCentreDetailComponent implements OnInit, AfterViewInit {
ngAfterViewInit() {
setTimeout(() => {
if (this.nameElement) this.nameElement.nativeElement.focus();
if (this.nameElement) {
this.nameElement.nativeElement.focus();
}
}, 0);
}
@@ -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 { RouterTestingModule } from '@angular/router/testing';
import { CostCentreListResolver } from './cost-centre-list-resolver.service';
@@ -8,9 +8,7 @@ import { map } from 'rxjs/operators';
import { CostCentre } from '../../core/cost-centre';
/** 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 CostCentreListDataSource extends DataSource<CostCentre> {
constructor(public data: CostCentre[], private paginator?: MatPaginator, private sort?: MatSort) {
super();
@@ -22,11 +20,17 @@ export class CostCentreListDataSource extends DataSource<CostCentre> {
| 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 CostCentreListDataSource extends DataSource<CostCentre> {
disconnect() {}
private getPagedData(data: CostCentre[]) {
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: CostCentre[]) {
if (this.sort === undefined) return data;
if (this.sort === undefined) {
return data;
}
if (!this.sort.active || this.sort.direction === '') {
return data;
}
@@ -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 { RouterTestingModule } from '@angular/router/testing';
import { CostCentreResolver } from './cost-centre-resolver.service';
@@ -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 { CostCentreService } from './cost-centre.service';
@@ -6,9 +6,6 @@ import { catchError } from 'rxjs/operators';
import { CostCentre } from '../core/cost-centre';
import { ErrorLoggerService } from '../core/error-logger.service';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
};
const url = '/api/cost-centres';
const serviceName = 'CostCentreService';
@@ -20,35 +17,29 @@ export class CostCentreService {
get(id: string | null): Observable<CostCentre> {
const getUrl: string = id === null ? `${url}` : `${url}/${id}`;
return <Observable<CostCentre>>(
this.http
.get<CostCentre>(getUrl)
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`)))
);
return this.http
.get<CostCentre>(getUrl)
.pipe(
catchError(this.log.handleError(serviceName, `get id as Observable<CostCentre>=${id}`)),
) as Observable<CostCentre>;
}
list(): Observable<CostCentre[]> {
return <Observable<CostCentre[]>>(
this.http
.get<CostCentre[]>(`${url}/list`)
.pipe(catchError(this.log.handleError(serviceName, 'list')))
);
return this.http
.get<CostCentre[]>(`${url}/list`)
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<CostCentre[]>;
}
save(costCentre: CostCentre): Observable<CostCentre> {
return <Observable<CostCentre>>(
this.http
.post<CostCentre>(`${url}`, costCentre, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'save')))
);
return this.http
.post<CostCentre>(`${url}`, costCentre)
.pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable<CostCentre>;
}
update(costCentre: CostCentre): Observable<CostCentre> {
return <Observable<CostCentre>>(
this.http
.put<CostCentre>(`${url}/${costCentre.id}`, costCentre, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'update')))
);
return this.http
.put<CostCentre>(`${url}/${costCentre.id}`, costCentre)
.pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable<CostCentre>;
}
saveOrUpdate(costCentre: CostCentre): Observable<CostCentre> {
@@ -59,10 +50,8 @@ export class CostCentreService {
}
delete(id: string): Observable<CostCentre> {
return <Observable<CostCentre>>(
this.http
.delete<CostCentre>(`${url}/${id}`, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'delete')))
);
return this.http
.delete<CostCentre>(`${url}/${id}`)
.pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable<CostCentre>;
}
}