Blacked and isorted the python files
Prettied and eslinted the typescript/html files
This commit is contained in:
@ -1,64 +1,66 @@
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { Tax } from '../core/tax';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
|
||||
};
|
||||
const url = '/api/taxes';
|
||||
const serviceName = 'TaxService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class TaxService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
get(id: string): Observable<Tax> {
|
||||
const getUrl: string = (id === null) ? url : `${url}/${id}`;
|
||||
return <Observable<Tax>>this.http.get<Tax>(getUrl)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get id=${id}`))
|
||||
);
|
||||
const getUrl: string = id === null ? url : `${url}/${id}`;
|
||||
return <Observable<Tax>>(
|
||||
this.http.get<Tax>(getUrl).pipe(catchError(this.log.handleError(serviceName, `get id=${id}`)))
|
||||
);
|
||||
}
|
||||
|
||||
list(): Observable<Tax[]> {
|
||||
return <Observable<Tax[]>>this.http.get<Tax[]>(`${url}/list`)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
return <Observable<Tax[]>>(
|
||||
this.http
|
||||
.get<Tax[]>(`${url}/list`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list')))
|
||||
);
|
||||
}
|
||||
|
||||
save(tax: Tax): Observable<Tax> {
|
||||
return <Observable<Tax>>this.http.post<Tax>(url, tax, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'save'))
|
||||
);
|
||||
return <Observable<Tax>>(
|
||||
this.http
|
||||
.post<Tax>(url, tax, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'save')))
|
||||
);
|
||||
}
|
||||
|
||||
update(tax: Tax): Observable<Tax> {
|
||||
return <Observable<Tax>>this.http.put<Tax>(`${url}/${tax.id}`, tax, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'update'))
|
||||
);
|
||||
return <Observable<Tax>>(
|
||||
this.http
|
||||
.put<Tax>(`${url}/${tax.id}`, tax, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'update')))
|
||||
);
|
||||
}
|
||||
|
||||
saveOrUpdate(tax: Tax): Observable<Tax> {
|
||||
if (!tax.id) {
|
||||
return this.save(tax);
|
||||
} else {
|
||||
return this.update(tax);
|
||||
}
|
||||
return this.update(tax);
|
||||
}
|
||||
|
||||
delete(id: string): Observable<Tax> {
|
||||
return <Observable<Tax>>this.http.delete<Tax>(`${url}/${id}`, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'delete'))
|
||||
);
|
||||
return <Observable<Tax>>(
|
||||
this.http
|
||||
.delete<Tax>(`${url}/${id}`, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'delete')))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user