api.service.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { Injectable } from '@angular/core';
  2. import { HttpClient } from '@angular/common/http';
  3. import { Observable } from 'rxjs';
  4. @Injectable({
  5. providedIn: 'root'
  6. })
  7. export class ApiService {
  8. private apiUrl = 'http://localhost:3000';
  9. constructor(private http: HttpClient) { }
  10. getConfidence(): Observable<any> {
  11. return this.http.get(`${this.apiUrl}/get_confidence`);
  12. }
  13. setConfidence(threshold: number): Observable<any> {
  14. return this.http.post(`${this.apiUrl}/set_confidence`, { threshold });
  15. }
  16. analyze(file: File, modelType: string = 'onnx'): Observable<any> {
  17. const formData = new FormData();
  18. formData.append('file', file);
  19. formData.append('model_type', modelType);
  20. return this.http.post(`${this.apiUrl}/analyze`, formData);
  21. }
  22. getHistory(): Observable<any> {
  23. return this.http.get(`${this.apiUrl}/get_history`);
  24. }
  25. getModelInfo(modelType: string = 'onnx'): Observable<any> {
  26. return this.http.get(`${this.apiUrl}/get_model_info`, { params: { model_type: modelType } });
  27. }
  28. getAnalytics(): Observable<any> {
  29. // This could be used for a dashboard later
  30. return this.http.get(`${this.apiUrl}/get_history`);
  31. }
  32. }