import { HttpClient, HttpEvent, HttpHeaders, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class ArtService {

  constructor(private http: HttpClient) { }

  getAll(id, reportProgress = false) {
    return reportProgress ?
      this.http.get(`/napi/web/art/${id}/data`, { reportProgress, observe: 'events' }) :
      this.http.get(`/napi/web/art/${id}/data`);
  }

  getBin(id: string, type: string) {
    return this.http.get(`/napi/web/art/${id}/bin/${type}`);
  }



  getAllwithProgress(id) {
    return this.http.get(`/napi/web/art/${id}/data`, { reportProgress: true, observe: 'events' });
  }

  /**
   * Create new art.
   * @param data FormData
   */
  create(data: FormData) {
    let headers = new HttpHeaders({
      'Accept': 'application/json',
    });
    let options = { headers };
    return this.http.post('/napi/web/art/', data, options);
  }


  /**
   * update art.
   * @param data FormData
   */
  update(data: FormData, id: string) {
    return this.http.patch(`/napi/web/art/data/${id}`, data);
  }

  sysConfig() {
    return this.http.get(`/napi/web/sysconfig`);
  }

}
