aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_services/predictors.service.ts
blob: a24ee708a47f4118cf1763297ea25aeae8585d25 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Configuration } from '../configuration.service';
import Predictor from '../_data/Predictor';
import { Column } from '../_pages/predict/predict.component';
import { AuthService } from './auth.service';

@Injectable({
  providedIn: 'root'
})
export class PredictorsService {
  constructor(private http: HttpClient, private authService: AuthService) { }

  getPublicPredictors(): Observable<Predictor[]> {
    return this.http.get<Predictor[]>(`${Configuration.settings.apiURL}/predictor/publicpredictors`, { headers: this.authService.authHeader() });
  }
  getPredictor(id: String): Observable<Predictor> {
    return this.http.get<Predictor>(`${Configuration.settings.apiURL}/predictor/getpredictor/` + id, { headers: this.authService.authHeader() });
  }

  usePredictor(predictor: Predictor, inputs: Column[]) {
    return this.http.post(`${Configuration.settings.apiURL}/predictor/usepredictor/` + predictor._id, inputs, { headers: this.authService.authHeader() });
  }

  deletePredictor(predictor: Predictor) {
    return this.http.delete(`${Configuration.settings.apiURL}/predictor/` + predictor._id, { headers: this.authService.authHeader(), responseType: "text" });
  }

  getMyPredictors(): Observable<Predictor[]> {
    return this.http.get<Predictor[]>(`${Configuration.settings.apiURL}/predictor/mypredictors`, { headers: this.authService.authHeader() });
  }
}