integrasi building list dan room list

This commit is contained in:
Fuzi_fauzia 2024-05-25 15:38:45 +07:00
parent e76948bb0a
commit 461735705d
7 changed files with 73 additions and 42 deletions

View File

@ -131,7 +131,7 @@
class="btn btn-float btn-square btn-outline-secondary" class="btn btn-float btn-square btn-outline-secondary"
triggers="hover:click:hover" triggers="hover:click:hover"
ngbTooltip="Room" ngbTooltip="Room"
[routerLink]="['/monitoring/monitoring-room']" (click)="viewRoom(data)"
> >
<i class="feather ft-log-in"></i> <i class="feather ft-log-in"></i>
</button> </button>

View File

@ -47,39 +47,28 @@ export class BuildingComponent {
showLabel: false, showLabel: false,
}, },
}; };
this.fetchData(); this.listBuilding();
// this.buildingData();
} }
fetchData() { listBuilding() {
// this.monitoringApiService.getBuildingData().subscribe((res) => { this.monitoringApiService.listBuilding().subscribe((res) => {
// this.data = res; console.log(res.data);
// this.filteredRows = res.data; this.data = res.data;
// console.log(this.filteredRows); this.filteredRows = res.data;
// this.dataTop = [];
// for (let i = 0; i < res.length; i++) {
// if (res[i].topUse.label[i]) {
// this.dataTop.push({
// label: res[i].topUse.label ? res[i].topUse.label : '',
// value: res[i].topUse.value ? res[i].topUse.value : 0,
// });
// }
// }
// });
this.monitoringService.getMonitoringBuildingData().subscribe((res) => {
this.data = res;
this.filteredRows = res;
this.dataTop = []; this.dataTop = [];
for (let i = 0; i < res.length; i++) { const maxItems = 4;
if (res[i].topUse.label[i]) {
this.dataTop.push({ res.data.forEach((item) => {
label: res[i].topUse.label, for (let i = 0; i < maxItems; i++) {
value: res[i].topUse.value, if (item.topUse.label[i] !== undefined) {
}); this.dataTop.push({
label: item.topUse.label,
value: item.topUse.value,
});
}
} }
} });
}); });
} }
@ -114,4 +103,9 @@ export class BuildingComponent {
editRow(row) { editRow(row) {
this.router.navigate(["/monitoring/edit-new-building", row.id]); this.router.navigate(["/monitoring/edit-new-building", row.id]);
} }
viewRoom(row){
console.log(row);
this.router.navigate(["/monitoring/monitoring-room", row.id]);
}
} }

View File

@ -59,7 +59,7 @@ import { UiSwitchModule } from 'ngx-ui-switch';
component: BuildingComponent, component: BuildingComponent,
}, },
{ {
path: 'monitoring-room', path: 'monitoring-room/:id',
component: RoomComponent, component: RoomComponent,
data: { mode: 'room' } data: { mode: 'room' }
}, },

View File

@ -39,7 +39,7 @@
class="text-muted mb-0" class="text-muted mb-0"
style="font-family: Montserrat, sans-serif" style="font-family: Montserrat, sans-serif"
> >
{{ data.product }} {{ data.name }}
</h4> </h4>
</div> </div>
</div> </div>
@ -48,7 +48,8 @@
<div class="card-body card_padding"> <div class="card-body card_padding">
<div class="media d-flex"> <div class="media d-flex">
<div class="media-body text-left"> <div class="media-body text-left">
<h3 class="info">{{ data.value }} kWh</h3> <!-- <h3 class="info">{{ data.value }} kWh</h3> -->
<h3 class="info">265 kWh</h3>
<h6>Consumtion</h6> <h6>Consumtion</h6>
</div> </div>
<div> <div>
@ -61,8 +62,8 @@
<ngb-progressbar <ngb-progressbar
height="7px" height="7px"
width="100%" width="100%"
type="{{ data.type }}" type="warning"
value="{{ data.value }}" value="75"
></ngb-progressbar> ></ngb-progressbar>
</div> </div>
</div> </div>

View File

@ -1,6 +1,7 @@
import { Component, OnInit } from "@angular/core"; import { Component, OnInit } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router"; import { ActivatedRoute, Router } from "@angular/router";
import { TableMonitoringService } from "../monitoring.service"; import { TableMonitoringService } from "../monitoring.service";
import { BuildingService } from "../../service/monitoring-api.service";
@Component({ @Component({
selector: "app-room", selector: "app-room",
@ -17,12 +18,22 @@ export class RoomComponent implements OnInit {
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
private monitoringService: TableMonitoringService, private monitoringService: TableMonitoringService,
private router: Router private router: Router,
private monitoringApiService: BuildingService,
) {} ) {}
ngOnInit() { ngOnInit() {
this.route.data.subscribe((data) => { this.route.data.subscribe((data) => {
this.mode = data.mode; this.mode = data.mode;
console.log(this.mode);
});
this.route.params.subscribe(params => {
const buildingId = params['id'];
console.log(buildingId);
if (buildingId) {
this.fetchData(buildingId);
}
}); });
this.breadcrumb = { this.breadcrumb = {
mainlabel: "Room", mainlabel: "Room",
@ -40,14 +51,21 @@ export class RoomComponent implements OnInit {
}, },
], ],
}; };
this.fetchData();
} }
fetchData() { fetchData(buildingId) {
this.monitoringService.getMonitoringRoomData().subscribe((Response) => { this.monitoringService.getMonitoringRoomData().subscribe((Response) => {
this.data = Response; console.log(Response);
this.filteredRows = Response;
// this.data = Response;
// this.filteredRows = Response;
});
this.monitoringApiService.getRoomByBuildingId(buildingId).subscribe((res) => {
const roomEntities = res.resp.map(entry => entry.roomEntity);
this.data = roomEntities;
this.filteredRows = roomEntities;
console.log(roomEntities, 'roomEntities');
}); });
} }

View File

@ -17,6 +17,15 @@ export class BuildingService {
return this.http.post<any>(url, data, { headers }); return this.http.post<any>(url, data, { headers });
} }
listBuilding(): Observable<any> {
const url = `https://kapi.absys.ninja/hemat/building/dashboard/list`;
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> { getBuildingData(page: number = 1, limit: number = 10): Observable<any> {
const url = `https://kapi.absys.ninja/hemat/building?page=${page}&limit=${limit}`; const url = `https://kapi.absys.ninja/hemat/building?page=${page}&limit=${limit}`;
// const headers = new HttpHeaders().set('Content-Type', 'application/json'); // const headers = new HttpHeaders().set('Content-Type', 'application/json');
@ -27,6 +36,15 @@ export class BuildingService {
return this.http.get<any>(url, { headers }); return this.http.get<any>(url, { headers });
} }
getRoomByBuildingId(buildingId: any): Observable<any> {
const url = `https://kapi.absys.ninja/hemat/room-building/list/byIds?buildingId=${buildingId}`;
const headers = new HttpHeaders({
'Content-Type': 'application/json',
'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT'
});
return this.http.get<any>(url, { headers });
}
getDeviceData(page: number = 1, limit: number = 10): Observable<any> { getDeviceData(page: number = 1, limit: number = 10): Observable<any> {
const url = `https://kapi.absys.ninja/hemat/devices?page=${page}&limit=${limit}`; const url = `https://kapi.absys.ninja/hemat/devices?page=${page}&limit=${limit}`;
const headers = new HttpHeaders({ const headers = new HttpHeaders({

View File

@ -16,7 +16,7 @@ html {
width: 100%; width: 100%;
body { body {
height: 1000px; height: 900px;
&.fixed-navbar { &.fixed-navbar {
padding-top: $navbar-height; padding-top: $navbar-height;
@ -102,7 +102,7 @@ html {
} }
.content-wrapper { .content-wrapper {
padding: 2.1rem 2rem 0; padding: 2.0rem 2rem 0;
overflow: hidden; overflow: hidden;
// padding: 1.8rem 2.2rem 0; // padding: 1.8rem 2.2rem 0;