Modif des services avec l'utilisation d'un "BaseService"
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { environment } from '../environments/environment';
|
||||
|
||||
import { DropZoneResp } from '../models/dropzone';
|
||||
|
||||
import { BaseService } from './base.service';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DropzoneService {
|
||||
|
||||
private readonly headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': environment.apiUrl
|
||||
});
|
||||
constructor(private http: HttpClient) { }
|
||||
export class DropzoneService extends BaseService {
|
||||
constructor(private http: HttpClient) {
|
||||
super();
|
||||
}
|
||||
|
||||
public getListOfDropZones(): Observable<Array<DropZoneResp>> {
|
||||
return this.http
|
||||
.get<Array<DropZoneResp>>(`${environment.apiUrl}/api/DropZone`, {
|
||||
.get<Array<DropZoneResp>>(`${this.apiUrl}/DropZone`, {
|
||||
headers: this.headers
|
||||
})
|
||||
.pipe(
|
||||
@@ -30,7 +30,7 @@ export class DropzoneService {
|
||||
public SetFavoriteDropZone(selectedDz: DropZoneResp): boolean {
|
||||
selectedDz.isFavorite = true;
|
||||
this.http
|
||||
.put(`${environment.apiUrl}/api/DropZone/${selectedDz.id}`, selectedDz, {
|
||||
.put(`${this.apiUrl}/DropZone/${selectedDz.id}`, selectedDz, {
|
||||
headers: this.headers
|
||||
})
|
||||
.subscribe(data => console.log(data));
|
||||
@@ -41,12 +41,11 @@ export class DropzoneService {
|
||||
public RemoveFavoriteDropZone(selectedDz: DropZoneResp): boolean {
|
||||
selectedDz.isFavorite = false;
|
||||
this.http
|
||||
.put(`${environment.apiUrl}/api/DropZone/${selectedDz.id}`, selectedDz, {
|
||||
.put(`${this.apiUrl}/DropZone/${selectedDz.id}`, selectedDz, {
|
||||
headers: this.headers
|
||||
})
|
||||
.subscribe(data => console.log(data));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user