import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
import {Tutorial} from '../models/tutorial.model';
import {Bean} from '../models/Bean';
import {NameValueItem} from '../models/name-value-item';

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

  baseUrl : string = 'http://localhost:8080/api/system';
  constructor(private http: HttpClient) { }

  getDataSourceProperties(): Observable<NameValueItem[]>{
    return this.http.get<NameValueItem[]>(this.baseUrl + "/data-source-properties")
  }

  getAllBeans(): Observable<Bean[]> {
    return this.http.get<Bean[]>(this.baseUrl+"/beans");
  }

  getImage(): Observable<Blob> {
    return this.http.get(this.baseUrl+"/image", {responseType: 'blob'});
  }

  getCustomBeans(): Observable<Bean[]> {
    return this.http.get<Bean[]>(this.baseUrl+"/beans/custom");
  }
}
