integrasi building list dan room list
This commit is contained in:
parent
e76948bb0a
commit
461735705d
|
@ -131,7 +131,7 @@
|
|||
class="btn btn-float btn-square btn-outline-secondary"
|
||||
triggers="hover:click:hover"
|
||||
ngbTooltip="Room"
|
||||
[routerLink]="['/monitoring/monitoring-room']"
|
||||
(click)="viewRoom(data)"
|
||||
>
|
||||
<i class="feather ft-log-in"></i>
|
||||
</button>
|
||||
|
|
|
@ -47,40 +47,29 @@ export class BuildingComponent {
|
|||
showLabel: false,
|
||||
},
|
||||
};
|
||||
this.fetchData();
|
||||
// this.buildingData();
|
||||
this.listBuilding();
|
||||
}
|
||||
|
||||
fetchData() {
|
||||
// this.monitoringApiService.getBuildingData().subscribe((res) => {
|
||||
// this.data = res;
|
||||
// this.filteredRows = res.data;
|
||||
// console.log(this.filteredRows);
|
||||
|
||||
// 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;
|
||||
listBuilding() {
|
||||
this.monitoringApiService.listBuilding().subscribe((res) => {
|
||||
console.log(res.data);
|
||||
this.data = res.data;
|
||||
this.filteredRows = res.data;
|
||||
|
||||
this.dataTop = [];
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
if (res[i].topUse.label[i]) {
|
||||
const maxItems = 4;
|
||||
|
||||
res.data.forEach((item) => {
|
||||
for (let i = 0; i < maxItems; i++) {
|
||||
if (item.topUse.label[i] !== undefined) {
|
||||
this.dataTop.push({
|
||||
label: res[i].topUse.label,
|
||||
value: res[i].topUse.value,
|
||||
label: item.topUse.label,
|
||||
value: item.topUse.value,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
buildingData() {
|
||||
|
@ -114,4 +103,9 @@ export class BuildingComponent {
|
|||
editRow(row) {
|
||||
this.router.navigate(["/monitoring/edit-new-building", row.id]);
|
||||
}
|
||||
|
||||
viewRoom(row){
|
||||
console.log(row);
|
||||
this.router.navigate(["/monitoring/monitoring-room", row.id]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ import { UiSwitchModule } from 'ngx-ui-switch';
|
|||
component: BuildingComponent,
|
||||
},
|
||||
{
|
||||
path: 'monitoring-room',
|
||||
path: 'monitoring-room/:id',
|
||||
component: RoomComponent,
|
||||
data: { mode: 'room' }
|
||||
},
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
class="text-muted mb-0"
|
||||
style="font-family: Montserrat, sans-serif"
|
||||
>
|
||||
{{ data.product }}
|
||||
{{ data.name }}
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -48,7 +48,8 @@
|
|||
<div class="card-body card_padding">
|
||||
<div class="media d-flex">
|
||||
<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>
|
||||
</div>
|
||||
<div>
|
||||
|
@ -61,8 +62,8 @@
|
|||
<ngb-progressbar
|
||||
height="7px"
|
||||
width="100%"
|
||||
type="{{ data.type }}"
|
||||
value="{{ data.value }}"
|
||||
type="warning"
|
||||
value="75"
|
||||
></ngb-progressbar>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Component, OnInit } from "@angular/core";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { TableMonitoringService } from "../monitoring.service";
|
||||
import { BuildingService } from "../../service/monitoring-api.service";
|
||||
|
||||
@Component({
|
||||
selector: "app-room",
|
||||
|
@ -17,12 +18,22 @@ export class RoomComponent implements OnInit {
|
|||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private monitoringService: TableMonitoringService,
|
||||
private router: Router
|
||||
private router: Router,
|
||||
private monitoringApiService: BuildingService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((data) => {
|
||||
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 = {
|
||||
mainlabel: "Room",
|
||||
|
@ -40,14 +51,21 @@ export class RoomComponent implements OnInit {
|
|||
},
|
||||
],
|
||||
};
|
||||
this.fetchData();
|
||||
|
||||
}
|
||||
|
||||
fetchData() {
|
||||
fetchData(buildingId) {
|
||||
this.monitoringService.getMonitoringRoomData().subscribe((Response) => {
|
||||
this.data = Response;
|
||||
this.filteredRows = Response;
|
||||
console.log(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');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,15 @@ export class BuildingService {
|
|||
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> {
|
||||
const url = `https://kapi.absys.ninja/hemat/building?page=${page}&limit=${limit}`;
|
||||
// const headers = new HttpHeaders().set('Content-Type', 'application/json');
|
||||
|
@ -27,6 +36,15 @@ export class BuildingService {
|
|||
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> {
|
||||
const url = `https://kapi.absys.ninja/hemat/devices?page=${page}&limit=${limit}`;
|
||||
const headers = new HttpHeaders({
|
||||
|
|
|
@ -16,7 +16,7 @@ html {
|
|||
width: 100%;
|
||||
|
||||
body {
|
||||
height: 1000px;
|
||||
height: 900px;
|
||||
|
||||
&.fixed-navbar {
|
||||
padding-top: $navbar-height;
|
||||
|
@ -102,7 +102,7 @@ html {
|
|||
}
|
||||
|
||||
.content-wrapper {
|
||||
padding: 2.1rem 2rem 0;
|
||||
padding: 2.0rem 2rem 0;
|
||||
overflow: hidden;
|
||||
// padding: 1.8rem 2.2rem 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue