integrasi fimter device
This commit is contained in:
53
src/app/content/hemat-app/service/device.service.ts
Normal file
53
src/app/content/hemat-app/service/device.service.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { HttpClient, HttpHeaders } from "@angular/common/http";
|
||||
import { Observable } from "rxjs";
|
||||
|
||||
const BASE_URL = 'https://kapi.absys.ninja/hemat';
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root",
|
||||
})
|
||||
export class DeviceService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
getDeviceData(id, category, status): Observable<any> {
|
||||
const endpoint = `/devices`;
|
||||
const params = new URLSearchParams({
|
||||
page: "1",
|
||||
limit: "100",
|
||||
building_id: id
|
||||
});
|
||||
if (category) {
|
||||
params.append("category_id", category);
|
||||
}
|
||||
if (status) {
|
||||
params.append("status_id", status);
|
||||
}
|
||||
const url = `${BASE_URL}${endpoint}?${params.toString()}`;
|
||||
const headers = new HttpHeaders({
|
||||
"Content-Type": "application/json",
|
||||
"x-api-key": "j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT",
|
||||
});
|
||||
return this.http.get<any>(url, { headers });
|
||||
}
|
||||
|
||||
getDeviceLIst(): Observable<any> {
|
||||
const endpoint = `/devices`;
|
||||
const url = `${BASE_URL}${endpoint}/list`;
|
||||
const headers = new HttpHeaders({
|
||||
"Content-Type": "application/json",
|
||||
"x-api-key": "j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT",
|
||||
});
|
||||
return this.http.get<any>(url, { headers });
|
||||
}
|
||||
|
||||
getSyncDeviceData(): Observable<any> {
|
||||
const endpoint = `/devices`;
|
||||
const url = `${BASE_URL}${endpoint}/Synchronization`;
|
||||
const headers = new HttpHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT'
|
||||
});
|
||||
return this.http.get<any>(url, { headers });
|
||||
}
|
||||
}
|
||||
@@ -26,15 +26,6 @@ export class BuildingService {
|
||||
return this.http.get<any>(url, { headers });
|
||||
}
|
||||
|
||||
listDevicePerBuilding(id): Observable<any> {
|
||||
const url = `https://kapi.absys.ninja/hemat/devices/aggregate/on?building_id=${id}`;
|
||||
const headers = new HttpHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT'
|
||||
});
|
||||
return this.http.get<any>(url, { headers });
|
||||
}
|
||||
|
||||
getBuildingData(page: number = 1, limit: number = 10): Observable<any> {
|
||||
const url = `https://kapi.absys.ninja/hemat/building?page=${page}&limit=${limit}`;
|
||||
// const headers = new HttpHeaders().set('Content-Type', 'application/json');
|
||||
@@ -54,24 +45,6 @@ export class BuildingService {
|
||||
return this.http.get<any>(url, { headers });
|
||||
}
|
||||
|
||||
getDeviceData(page: number = 1, limit: number = 10): Observable<any> {
|
||||
const url = `https://kapi.absys.ninja/hemat/devices?page=${page}&limit=${limit}`;
|
||||
const headers = new HttpHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT'
|
||||
});
|
||||
return this.http.get<any>(url, { headers });
|
||||
}
|
||||
|
||||
getSyncDeviceData(page: number = 1, limit: number = 10): Observable<any> {
|
||||
const url = `https://kapi.absys.ninja/hemat/devices/Synchronization`;
|
||||
const headers = new HttpHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT'
|
||||
});
|
||||
return this.http.get<any>(url, { headers });
|
||||
}
|
||||
|
||||
getDeviceById(deviceId: any): Observable<any> {
|
||||
const url = `https://kapi.absys.ninja/hemat/devices/${deviceId}`;
|
||||
const headers = new HttpHeaders({
|
||||
|
||||
Reference in New Issue
Block a user