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

@ -53,7 +53,9 @@ export class RoleDetailComponent implements OnInit, AfterViewInit {
ngAfterViewInit() {
setTimeout(() => {
if (this.nameElement) this.nameElement.nativeElement.focus();
if (this.nameElement) {
this.nameElement.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 { RouterTestingModule } from '@angular/router/testing';
import { RoleListResolver } from './role-list-resolver.service';

View File

@ -8,9 +8,7 @@ import { map } from 'rxjs/operators';
import { Role } from '../role';
/** 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 RoleListDatasource extends DataSource<Role> {
constructor(public data: Role[], private paginator?: MatPaginator, private sort?: MatSort) {
super();
@ -20,11 +18,17 @@ export class RoleListDatasource extends DataSource<Role> {
const dataMutations: (Observable<Role[]> | 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]))),
@ -34,13 +38,17 @@ export class RoleListDatasource extends DataSource<Role> {
disconnect() {}
private getPagedData(data: Role[]) {
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: Role[]) {
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 { RouterTestingModule } from '@angular/router/testing';
import { RoleResolver } from './role-resolver.service';

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 { RoleService } from './role.service';

View File

@ -7,9 +7,6 @@ import { ErrorLoggerService } from '../core/error-logger.service';
import { Role } from './role';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
};
const url = '/api/roles';
const serviceName = 'RoleService';
@ -21,35 +18,27 @@ export class RoleService {
get(id: string | null): Observable<Role> {
const getUrl: string = id === null ? `${url}` : `${url}/${id}`;
return <Observable<Role>>(
this.http
.get<Role>(getUrl)
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`)))
);
return this.http
.get<Role>(getUrl)
.pipe(catchError(this.log.handleError(serviceName, `get id as Observable<Role>=${id}`))) as Observable<Role>;
}
list(): Observable<Role[]> {
return <Observable<Role[]>>(
this.http
.get<Role[]>(`${url}/list`)
.pipe(catchError(this.log.handleError(serviceName, 'list')))
);
return this.http
.get<Role[]>(`${url}/list`)
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<Role[]>;
}
save(role: Role): Observable<Role> {
return <Observable<Role>>(
this.http
.post<Role>(`${url}`, role, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'save')))
);
return this.http
.post<Role>(`${url}`, role)
.pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable<Role>;
}
update(role: Role): Observable<Role> {
return <Observable<Role>>(
this.http
.put<Role>(`${url}/${role.id}`, role, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'update')))
);
return this.http
.put<Role>(`${url}/${role.id}`, role)
.pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable<Role>;
}
saveOrUpdate(role: Role): Observable<Role> {
@ -60,10 +49,8 @@ export class RoleService {
}
delete(id: string): Observable<Role> {
return <Observable<Role>>(
this.http
.delete<Role>(`${url}/${id}`, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'delete')))
);
return this.http
.delete<Role>(`${url}/${id}`)
.pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable<Role>;
}
}