2020-02-11 17:27:54 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { HttpHeaders, HttpClient } from '@angular/common/http';
|
|
|
|
import { BaseHttpService } from '../http/base-http.service';
|
|
|
|
import { environment } from 'environments/environment';
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
import { LockModel } from '@app/core/model/lock/lock.model';
|
2020-03-26 17:44:12 +01:00
|
|
|
import { ConfigurationService } from '../configuration/configuration.service';
|
2020-02-11 17:27:54 +01:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class LockService {
|
|
|
|
|
|
|
|
private actionUrl: string;
|
|
|
|
private headers = new HttpHeaders();
|
|
|
|
|
2020-03-26 17:44:12 +01:00
|
|
|
constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) {
|
|
|
|
this.actionUrl = configurationService.server + 'lock/';
|
2020-02-11 17:27:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
checkLockStatus(id: string): Observable<boolean> {
|
2020-04-27 15:21:03 +02:00
|
|
|
return this.http.get(`${this.actionUrl}target/status/${id}`, { headers: this.headers });
|
2020-02-11 17:27:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
unlockTarget(id: string): Observable<any> {
|
2020-04-27 15:21:03 +02:00
|
|
|
return this.http.delete(`${this.actionUrl}target/unlock/${id}`, { headers: this.headers });
|
2020-02-11 17:27:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
getSingle(id: string): Observable<LockModel> {
|
2020-04-27 15:21:03 +02:00
|
|
|
return this.http.get(`${this.actionUrl}target/${id}`, { headers: this.headers });
|
2020-02-11 17:27:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
createOrUpdate(lock: LockModel): Observable<string> {
|
2020-04-27 15:21:03 +02:00
|
|
|
return this.http.post(`${this.actionUrl}`, lock, { headers: this.headers });
|
2020-02-11 17:27:54 +01:00
|
|
|
}
|
|
|
|
}
|