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:
@@ -1,6 +1,6 @@
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
import { AccountDetailComponent } from './account-detail.component';
|
||||
|
||||
@@ -68,7 +68,9 @@ export class AccountDetailComponent 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 { AccountListResolver } from './account-list-resolver.service';
|
||||
|
||||
|
||||
@@ -8,9 +8,7 @@ import { map, tap } from 'rxjs/operators';
|
||||
import { Account } from '../../core/account';
|
||||
|
||||
/** Simple sort comparator for example ID/Name columns (for client-side sorting). */
|
||||
function compare(a: string | number | boolean, b: string | number | boolean, isAsc: boolean) {
|
||||
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
||||
}
|
||||
const compare = (a: string | number | boolean, b: string | number | boolean, isAsc: boolean) => (a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
||||
export class AccountListDataSource extends DataSource<Account> {
|
||||
private filterValue = '';
|
||||
|
||||
@@ -35,14 +33,20 @@ export class AccountListDataSource extends DataSource<Account> {
|
||||
| EventEmitter<PageEvent>
|
||||
| EventEmitter<Sort>
|
||||
)[] = [observableOf(this.data), this.filter];
|
||||
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);
|
||||
}
|
||||
|
||||
return merge(...dataMutations)
|
||||
.pipe(
|
||||
map(() => this.getFilteredData([...this.data])),
|
||||
tap((x: Account[]) => {
|
||||
if (this.paginator) this.paginator.length = x.length;
|
||||
if (this.paginator) {
|
||||
this.paginator.length = x.length;
|
||||
}
|
||||
}),
|
||||
)
|
||||
.pipe(map((x: Account[]) => this.getPagedData(this.getSortedData(x))));
|
||||
@@ -64,13 +68,17 @@ export class AccountListDataSource extends DataSource<Account> {
|
||||
}
|
||||
|
||||
private getPagedData(data: Account[]) {
|
||||
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: Account[]) {
|
||||
if (this.sort === undefined) return data;
|
||||
if (this.sort === undefined) {
|
||||
return data;
|
||||
}
|
||||
if (!this.sort.active || this.sort.direction === '') {
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,9 @@ export class AccountListComponent implements OnInit, AfterViewInit {
|
||||
|
||||
ngAfterViewInit() {
|
||||
setTimeout(() => {
|
||||
if (this.filterElement) this.filterElement.nativeElement.focus();
|
||||
if (this.filterElement) {
|
||||
this.filterElement.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 { AccountResolver } from './account-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 { AccountTypeResolver } from './account-type-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 { AccountTypeService } from './account-type.service';
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ export class AccountTypeService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
list(): Observable<AccountType[]> {
|
||||
return <Observable<AccountType[]>>(
|
||||
this.http.get<AccountType[]>(url).pipe(catchError(this.log.handleError(serviceName, 'list')))
|
||||
);
|
||||
return this.http
|
||||
.get<AccountType[]>(url)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<AccountType[]>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user