aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_pages/my-predictors/my-predictors.component.ts
blob: 17c496fd7de27844a2e2fa2f0d872b72e391140e (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
34
35
36
37
38
39
40
41
import { Component, OnInit } from '@angular/core';
import Predictor from 'src/app/_data/Predictor';
import { PredictorsService } from 'src/app/_services/predictors.service';

@Component({
  selector: 'app-my-predictors',
  templateUrl: './my-predictors.component.html',
  styleUrls: ['./my-predictors.component.css']
})
export class MyPredictorsComponent implements OnInit {
  predictors: Predictor[] = [];
  constructor(private predictorsS : PredictorsService) {
  }
  ngOnInit(): void {
    this.getAllMyPredictors();

  }

  delete(predictor: Predictor){
    if(window.confirm("IZABRANI MODEL ĆE BITI IZBRISAN"))
      {
      this.predictorsS.deletePredictor(predictor).subscribe((response) => {
        this.getAllMyPredictors();
      }, (error) =>{
          if (error.error == "Predictor with name = {name} deleted") {
            alert("Greška pri brisanju modela!");
          }
        });
    }
    
    
  }

  getAllMyPredictors(): void{
    this.predictorsS.getMyPredictors().subscribe(m => {
      this.predictors = m;
    });
  }


}