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,4 +1,4 @@
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
@@ -6,9 +6,6 @@ import { catchError } from 'rxjs/operators';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { User } from '../core/user';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
|
||||
};
|
||||
const url = '/api/users';
|
||||
const serviceName = 'UserService';
|
||||
|
||||
@@ -20,51 +17,39 @@ export class UserService {
|
||||
|
||||
get(id: string | null): Observable<User> {
|
||||
const getUrl: string = id === null ? `${url}` : `${url}/${id}`;
|
||||
return <Observable<User>>(
|
||||
this.http
|
||||
.get<User>(getUrl)
|
||||
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`)))
|
||||
);
|
||||
return this.http
|
||||
.get<User>(getUrl)
|
||||
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable<User>;
|
||||
}
|
||||
|
||||
list(): Observable<User[]> {
|
||||
return <Observable<User[]>>(
|
||||
this.http
|
||||
.get<User[]>(`${url}/list`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list')))
|
||||
);
|
||||
return this.http
|
||||
.get<User[]>(`${url}/list`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<User[]>;
|
||||
}
|
||||
|
||||
listOfNames(): Observable<string[]> {
|
||||
return <Observable<string[]>>(
|
||||
this.http
|
||||
.get<string[]>(`${url}/active`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list')))
|
||||
);
|
||||
return this.http
|
||||
.get<string[]>(`${url}/active`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<string[]>;
|
||||
}
|
||||
|
||||
save(user: User): Observable<User> {
|
||||
return <Observable<User>>(
|
||||
this.http
|
||||
.post<User>(`${url}`, user, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'save')))
|
||||
);
|
||||
return this.http
|
||||
.post<User>(`${url}`, user)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable<User>;
|
||||
}
|
||||
|
||||
update(user: User): Observable<User> {
|
||||
return <Observable<User>>(
|
||||
this.http
|
||||
.put<User>(`${url}/${user.id}`, user, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'update')))
|
||||
);
|
||||
return this.http
|
||||
.put<User>(`${url}/${user.id}`, user)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable<User>;
|
||||
}
|
||||
|
||||
updateMe(user: User): Observable<User> {
|
||||
return <Observable<User>>(
|
||||
this.http
|
||||
.put<User>(`${url}/me`, user, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'update')))
|
||||
);
|
||||
return this.http
|
||||
.put<User>(`${url}/me`, user)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable<User>;
|
||||
}
|
||||
|
||||
saveOrUpdate(user: User): Observable<User> {
|
||||
@@ -75,10 +60,8 @@ export class UserService {
|
||||
}
|
||||
|
||||
delete(id: string): Observable<User> {
|
||||
return <Observable<User>>(
|
||||
this.http
|
||||
.delete<User>(`${url}/${id}`, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'delete')))
|
||||
);
|
||||
return this.http
|
||||
.delete<User>(`${url}/${id}`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable<User>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user