penambahan service monitoring
This commit is contained in:
parent
6239e473b3
commit
cfa140b6ea
|
@ -53,6 +53,8 @@ export class TableApiService {
|
|||
}
|
||||
|
||||
private extractData(res: Response) {
|
||||
console.log(res);
|
||||
|
||||
const body = res;
|
||||
return body || {};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Component } from "@angular/core";
|
||||
import { TableMonitoringService } from "../monitoring.service";
|
||||
import { Router } from "@angular/router";
|
||||
import { BuildingService } from "../../service/monitoring-api.service";
|
||||
|
||||
@Component({
|
||||
selector: "app-building",
|
||||
|
@ -19,6 +20,7 @@ export class BuildingComponent {
|
|||
|
||||
constructor(
|
||||
private monitoringService: TableMonitoringService,
|
||||
private monitoringApiService: BuildingService,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
|
@ -46,6 +48,7 @@ export class BuildingComponent {
|
|||
},
|
||||
};
|
||||
this.fetchData();
|
||||
this.buildingData();
|
||||
}
|
||||
|
||||
fetchData() {
|
||||
|
@ -65,6 +68,12 @@ export class BuildingComponent {
|
|||
});
|
||||
}
|
||||
|
||||
buildingData() {
|
||||
this.monitoringApiService.getBuildingData().subscribe((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
}
|
||||
|
||||
filterRows() {
|
||||
if (!this.searchTerm) {
|
||||
this.filteredRows = [...this.data];
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import { Injectable } from "@angular/core";
|
||||
import { HttpClient, HttpHeaders } from "@angular/common/http";
|
||||
import { Observable } from "rxjs";
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root",
|
||||
})
|
||||
export class BuildingService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
getBuildingData(page: number = 1, limit: number = 10): Observable<any> {
|
||||
const url = `http://167.86.72.99:3100/building?page=${page}&limit=${limit}`;
|
||||
const headers = new HttpHeaders().set('Content-Type', 'application/json');
|
||||
return this.http.get<any>(url, { headers });
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue