All files / src/shared/services measure.service.ts

7.69% Statements 1/13
100% Branches 0/0
0% Functions 0/5
7.69% Lines 1/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 42 43              1x                                                                      
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Inject, Injectable } from '@angular/core';
import { Observable } from 'rxjs';
 
@Injectable({
  providedIn: 'root'
})
export class MeasureService {
  private readonly baseRoute = 'api/RecordRawDepth/';
 
  private readonly getIsCapturingRoute = `${this.baseRoute}IsCapturing`;
 
  private readonly getCurrentRecordIdRoute = `${this.baseRoute}CurrentRecordId`;
  private readonly getCurrentSampleIdxRoute = `${this.baseRoute}CurrentSampleIdx`;
  private readonly recordSamplesRoute = `${this.baseRoute}RecordSamples`;
 
  // eslint-disable-next-line @typescript-eslint/naming-convention
  private readonly headers = new HttpHeaders({ 'Content-Type': 'application/json' });
 
  public constructor(
    private readonly http: HttpClient,
    // eslint-disable-next-line new-cap
    @Inject('BASE_URL') private readonly baseUrl: string
  ) {
  }
 
  public isCapturing(): Observable<boolean> {
    return this.http.get<boolean>(this.baseUrl + this.getIsCapturingRoute);
  }
 
  public getCurrentRecordId(): Observable<number> {
    return this.http.get<number>(this.baseUrl + this.getCurrentRecordIdRoute);
  }
 
  public getCurrentSampleIdx(): Observable<number> {
    return this.http.get<number>(this.baseUrl + this.getCurrentSampleIdxRoute);
  }
 
  public startCapture(captureId: number): Observable<string> {
    return this.http.put(this.baseUrl + this.recordSamplesRoute, `{ "name" : "captureId", "value": ${captureId}}`, { headers: this.headers, responseType: 'text' });
  }
}