Chore: ng lint using the recommended @angular-eslint style
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Products</mat-card-title>
|
||||
<button mat-button (click)="updateSortOrder()" [disabled]="!(filter | async)">
|
||||
<button mat-button (click)="updateSortOrder()" [disabled]="(filter | async) === ''">
|
||||
Update Order
|
||||
</button>
|
||||
<!-- This should check filtered data and not data-->
|
||||
|
||||
@ -19,52 +19,44 @@ export class ProductService {
|
||||
|
||||
get(id: string | null): Observable<Product> {
|
||||
const getUrl: string = id === null ? `${url}` : `${url}/${id}`;
|
||||
return <Observable<Product>>(
|
||||
this.http
|
||||
.get<Product>(getUrl)
|
||||
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`)))
|
||||
);
|
||||
return this.http
|
||||
.get<Product>(getUrl)
|
||||
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable<Product>;
|
||||
}
|
||||
|
||||
list(): Observable<Product[]> {
|
||||
return <Observable<Product[]>>(
|
||||
this.http
|
||||
.get<Product[]>(`${url}/list`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list')))
|
||||
);
|
||||
return this.http
|
||||
.get<Product[]>(`${url}/list`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<Product[]>;
|
||||
}
|
||||
|
||||
listIsActiveOfCategory(id: string): Observable<Product[]> {
|
||||
const options = { params: new HttpParams().set('mc', id) };
|
||||
return <Observable<Product[]>>(
|
||||
this.http
|
||||
.get<Product[]>(`${url}/query`, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'listIsActiveOfCategory')))
|
||||
);
|
||||
return this.http
|
||||
.get<Product[]>(`${url}/query`, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'listIsActiveOfCategory'))) as Observable<
|
||||
Product[]
|
||||
>;
|
||||
}
|
||||
|
||||
save(product: Product): Observable<Product> {
|
||||
return <Observable<Product>>(
|
||||
this.http
|
||||
.post<Product>(`${url}`, product, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'save')))
|
||||
);
|
||||
return this.http
|
||||
.post<Product>(`${url}`, product, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable<Product>;
|
||||
}
|
||||
|
||||
update(product: Product): Observable<Product> {
|
||||
return <Observable<Product>>(
|
||||
this.http
|
||||
.put<Product>(`${url}/${product.id}`, product, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'update')))
|
||||
);
|
||||
return this.http
|
||||
.put<Product>(`${url}/${product.id}`, product, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable<Product>;
|
||||
}
|
||||
|
||||
updateSortOrder(list: Product[]): Observable<Product[]> {
|
||||
return <Observable<Product[]>>(
|
||||
this.http
|
||||
.post<Product[]>(`${url}/list`, list, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'updateSortOrder')))
|
||||
);
|
||||
return this.http
|
||||
.post<Product[]>(`${url}/list`, list, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'updateSortOrder'))) as Observable<
|
||||
Product[]
|
||||
>;
|
||||
}
|
||||
|
||||
saveOrUpdate(product: Product): Observable<Product> {
|
||||
@ -75,19 +67,15 @@ export class ProductService {
|
||||
}
|
||||
|
||||
delete(id: string): Observable<Product> {
|
||||
return <Observable<Product>>(
|
||||
this.http
|
||||
.delete<Product>(`${url}/${id}`, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'delete')))
|
||||
);
|
||||
return this.http
|
||||
.delete<Product>(`${url}/${id}`, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable<Product>;
|
||||
}
|
||||
|
||||
balance(id: string, date: string): Observable<number> {
|
||||
const options = { params: new HttpParams().set('d', date) };
|
||||
return <Observable<number>>(
|
||||
this.http
|
||||
.get<number>(`${url}/balance`, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'balance')))
|
||||
);
|
||||
return this.http
|
||||
.get<number>(`${url}/balance`, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'balance'))) as Observable<number>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user