All Masters Done!!
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Modifier } from '../core/modifier';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
@ -9,7 +9,7 @@ const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
|
||||
const url = '/v1/modifiers';
|
||||
const url = '/api/modifiers';
|
||||
const serviceName = 'ModifierService';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@ -19,7 +19,7 @@ export class ModifierService {
|
||||
}
|
||||
|
||||
get(id: string): Observable<Modifier> {
|
||||
const getUrl: string = (id === null) ? `${url}/new` : `${url}/${id}`;
|
||||
const getUrl: string = (id === null) ? url : `${url}/${id}`;
|
||||
return <Observable<Modifier>>this.http.get<Modifier>(getUrl)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get id=${id}`))
|
||||
@ -27,15 +27,14 @@ export class ModifierService {
|
||||
}
|
||||
|
||||
list(): Observable<Modifier[]> {
|
||||
const options = {params: new HttpParams().set('l', '')};
|
||||
return <Observable<Modifier[]>>this.http.get<Modifier[]>(url, options)
|
||||
return <Observable<Modifier[]>>this.http.get<Modifier[]>(`${url}/list`)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'getList'))
|
||||
);
|
||||
}
|
||||
|
||||
save(modifier: Modifier): Observable<Modifier> {
|
||||
return <Observable<Modifier>>this.http.post<Modifier>(`${url}/new`, modifier, httpOptions)
|
||||
return <Observable<Modifier>>this.http.post<Modifier>(url, modifier, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'save'))
|
||||
);
|
||||
@ -48,13 +47,6 @@ export class ModifierService {
|
||||
);
|
||||
}
|
||||
|
||||
updateSortOrder(list: Modifier[]): Observable<boolean> {
|
||||
return <Observable<boolean>>this.http.post<Modifier[]>(url, list, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'updateSortOrder'))
|
||||
);
|
||||
}
|
||||
|
||||
saveOrUpdate(modifier: Modifier): Observable<Modifier> {
|
||||
if (!modifier.id) {
|
||||
return this.save(modifier);
|
||||
@ -69,20 +61,4 @@ export class ModifierService {
|
||||
catchError(this.log.handleError(serviceName, 'delete'))
|
||||
);
|
||||
}
|
||||
|
||||
autocomplete(term: string): Observable<Modifier[]> {
|
||||
const options = {params: new HttpParams().set('t', term)};
|
||||
return <Observable<Modifier[]>>this.http.get<Modifier[]>(url, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'autocomplete'))
|
||||
);
|
||||
}
|
||||
|
||||
balance(id: string, date: string): Observable<number> {
|
||||
const options = {params: new HttpParams().set('b', 'true').set('d', date)};
|
||||
return <Observable<number>>this.http.get<number>(`${url}/${id}`, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'balance'))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user