Blacked and isorted the python files

Prettied and eslinted the typescript/html files
This commit is contained in:
2020-10-11 10:56:29 +05:30
parent b31db593c2
commit d677cfb1ea
505 changed files with 7560 additions and 5650 deletions

View File

@ -1,87 +1,93 @@
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
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 { Product } from '../core/product';
import { ErrorLoggerService } from '../core/error-logger.service';
import { Product } from '../core/product';
const httpOptions = {
headers: new HttpHeaders({'Content-Type': 'application/json'})
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
};
const url = '/api/products';
const serviceName = 'ProductService';
@Injectable({providedIn: 'root'})
@Injectable({ providedIn: 'root' })
export class ProductService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {
}
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
get(id: string): 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}`))
);
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}`)))
);
}
list(): Observable<Product[]> {
return <Observable<Product[]>>this.http.get<Product[]>(`${url}/list`)
.pipe(
catchError(this.log.handleError(serviceName, 'list'))
);
return <Observable<Product[]>>(
this.http
.get<Product[]>(`${url}/list`)
.pipe(catchError(this.log.handleError(serviceName, 'list')))
);
}
listIsActiveOfCategory(id: string): Observable<Product[]> {
const options = {params: new HttpParams().set('mc', id).set('a', 'true')};
return <Observable<Product[]>>this.http.get<Product[]>(`${url}/query`, options)
.pipe(
catchError(this.log.handleError(serviceName, 'listIsActiveOfCategory'))
);
const options = { params: new HttpParams().set('mc', id).set('a', 'true') };
return <Observable<Product[]>>(
this.http
.get<Product[]>(`${url}/query`, options)
.pipe(catchError(this.log.handleError(serviceName, 'listIsActiveOfCategory')))
);
}
save(product: Product): Observable<Product> {
return <Observable<Product>>this.http.post<Product>(`${url}`, product, httpOptions)
.pipe(
catchError(this.log.handleError(serviceName, 'save'))
);
return <Observable<Product>>(
this.http
.post<Product>(`${url}`, product, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'save')))
);
}
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 <Observable<Product>>(
this.http
.put<Product>(`${url}/${product.id}`, product, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'update')))
);
}
updateSortOrder(list: Product[]): Observable<Product[]> {
return <Observable<Product[]>>this.http.post<Product[]>(`${url}/list`, list, httpOptions)
.pipe(
catchError(this.log.handleError(serviceName, 'updateSortOrder'))
);
return <Observable<Product[]>>(
this.http
.post<Product[]>(`${url}/list`, list, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'updateSortOrder')))
);
}
saveOrUpdate(product: Product): Observable<Product> {
if (!product.id) {
return this.save(product);
} else {
return this.update(product);
}
return this.update(product);
}
delete(id: string): Observable<Product> {
return <Observable<Product>>this.http.delete<Product>(`${url}/${id}`, httpOptions)
.pipe(
catchError(this.log.handleError(serviceName, 'delete'))
);
return <Observable<Product>>(
this.http
.delete<Product>(`${url}/${id}`, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'delete')))
);
}
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'))
);
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')))
);
}
}