|
|
@@ -1,27 +1,34 @@
|
|
|
import { Injectable } from '@angular/core';
|
|
|
-import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'
|
|
|
+import { HttpClient, HttpParams, HttpHeaders, HttpResponse } from '@angular/common/http'
|
|
|
import { Observable } from 'rxjs';
|
|
|
import { Environnement } from '../env';
|
|
|
import { Production, ProductionShort, ProductionFile } from '../interfaces/production';
|
|
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
|
|
|
|
-export class ProductionService
|
|
|
+export class ProductionService
|
|
|
{
|
|
|
|
|
|
private baseURL = Environnement.apiUrl + "production";
|
|
|
|
|
|
constructor(private httpClient: HttpClient) { }
|
|
|
-
|
|
|
- getListProduction(): Observable<ProductionShort[]>{ return this.httpClient.get<ProductionShort[]>(`${this.baseURL}/list`); }
|
|
|
+
|
|
|
+ getListProduction(filtreType: string): Observable<ProductionShort[]>
|
|
|
+ {
|
|
|
+ let params = new HttpParams();
|
|
|
+
|
|
|
+ if (filtreType !== null) { params = params.append('type', filtreType); }
|
|
|
+
|
|
|
+ return this.httpClient.get<ProductionShort[]>(`${this.baseURL}/list`, { params: params });
|
|
|
+ }
|
|
|
|
|
|
getProductionFile(id: number): Observable<HttpResponse<Blob>>
|
|
|
{
|
|
|
let headers = new HttpHeaders();
|
|
|
-
|
|
|
+
|
|
|
headers = headers.append('Accept', 'application/zip');
|
|
|
|
|
|
- return this.httpClient.get(`${this.baseURL}/file/${id}`, { headers: headers, observe: 'response', responseType: 'blob' });
|
|
|
+ return this.httpClient.get(`${this.baseURL}/file/${id}`, { headers: headers, observe: 'response', responseType: 'blob' });
|
|
|
}
|
|
|
|
|
|
createProduction(production: Production): Observable<Object>{ return this.httpClient.post(`${this.baseURL}/create`, production); }
|
|
|
@@ -35,5 +42,5 @@ export class ProductionService
|
|
|
uploadProductionFile(id: number, production: ProductionFile): Observable<Object>{ return this.httpClient.put(`${this.baseURL}/upload/${id}`, production); }
|
|
|
|
|
|
deleteProduction(id: number): Observable<Object>{ return this.httpClient.delete(`${this.baseURL}/delete/${id}`); }
|
|
|
-
|
|
|
-}
|
|
|
+
|
|
|
+}
|