integrasi fimter device

This commit is contained in:
2024-06-20 15:50:40 +07:00
parent d1393d6ec5
commit 49d37ee7e1
9 changed files with 1171 additions and 873 deletions

View 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 });
}
}

View File

@@ -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({