perbaikan routing see more

This commit is contained in:
Fuzi_fauzia 2024-08-19 12:48:09 +07:00
parent 21b75ca610
commit 379bdb24da
5 changed files with 49 additions and 53 deletions

View File

@ -115,8 +115,6 @@ export class BuildingComponent {
} }
viewDetail(row) { viewDetail(row) {
console.log(row.floor_id);
console.log(row.building_id);
if (row.building_id !== undefined && row.floor_id === undefined) { if (row.building_id !== undefined && row.floor_id === undefined) {
this.router.navigate(["/monitoring/view-detail-floor", row.building_id, row.id]); this.router.navigate(["/monitoring/view-detail-floor", row.building_id, row.id]);
} else if (row.building_id !== undefined && row.floor_id !== undefined) { } else if (row.building_id !== undefined && row.floor_id !== undefined) {
@ -124,9 +122,6 @@ export class BuildingComponent {
} else { } else {
this.router.navigate(["/monitoring/view-detail-building", row.id]); this.router.navigate(["/monitoring/view-detail-building", row.id]);
} }
// this.router.navigate(["/monitoring/view-detail", row.id]);
} }
editRow(row) { editRow(row) {

View File

@ -23,7 +23,10 @@ export class ControlDeviceSeemoreComponent {
dataMasterStatus: any; dataMasterStatus: any;
spinnerFilterActive = false; spinnerFilterActive = false;
switchState: boolean; switchState: boolean;
paramsId: any; buildingId: any;
floorId: any;
roomId: any;
modeRoute: any;
public breadcrumb: any; public breadcrumb: any;
spinnerActive: boolean = false; spinnerActive: boolean = false;
@ -40,14 +43,15 @@ export class ControlDeviceSeemoreComponent {
this.authService.startTokenCheck(); this.authService.startTokenCheck();
this.authService.startTrackingActivity(); this.authService.startTrackingActivity();
this.route.params.subscribe((params) => { this.route.params.subscribe((params) => {
const buildingId = params["id"]; this.modeRoute = params["mode"];
this.paramsId = buildingId ? buildingId: 0; this.buildingId = params["buildingId"] ? params["buildingId"] : 0;
this.buildingSelected = parseInt(this.paramsId); this.floorId = params["floorId"] ? params["floorId"] : 0;
this.roomId = params["roomId"] ? params["roomId"] : 0;
this.buildingSelected = parseInt(this.buildingId);
}); });
this.breadcrumb = { this.breadcrumb = {
mainlabel: "Control Device", mainlabel: "Control Device",
linkBack: `/monitoring/view-new-building/${this.buildingSelected}`, linkBack: this.routeBack(''),
isLinkBack: true, isLinkBack: true,
links: [ links: [
{ {
@ -77,6 +81,17 @@ export class ControlDeviceSeemoreComponent {
this.dataListBuilding(); this.dataListBuilding();
} }
routeBack(route){
if (this.modeRoute === 'building') {
route = `/monitoring/view-detail-building/${this.buildingId}`;
} else if (this.modeRoute === 'floor') {
route = `/monitoring/view-detail-floor/${this.buildingId}/${this.floorId}`;
} else if (this.modeRoute === 'room') {
route = `/monitoring/view-detail-room/${this.buildingId}/${this.floorId}/${this.roomId}`;
}
return route
}
fetchData(buildingSelected, categorySelected, statusSelected) { fetchData(buildingSelected, categorySelected, statusSelected) {
this.deviceService this.deviceService
.getDeviceData(buildingSelected, categorySelected, statusSelected) .getDeviceData(buildingSelected, categorySelected, statusSelected)
@ -112,11 +127,7 @@ export class ControlDeviceSeemoreComponent {
dataListBuilding() { dataListBuilding() {
this.monitoringApiService.getBuildingList().subscribe((data) => { this.monitoringApiService.getBuildingList().subscribe((data) => {
console.log(data);
this.dataBuildingList = data.data.filter((item) => item.statusName.toLowerCase() === "aktif" || item.status_id === 71); this.dataBuildingList = data.data.filter((item) => item.statusName.toLowerCase() === "aktif" || item.status_id === 71);
console.log(this.dataBuildingList);
}); });
} }
@ -141,7 +152,7 @@ export class ControlDeviceSeemoreComponent {
} }
doFilterCancel(){ doFilterCancel(){
this.buildingSelected = parseInt(this.paramsId); this.buildingSelected = parseInt(this.buildingId);
this.categorySelected = undefined; this.categorySelected = undefined;
this.statusSelected = undefined; this.statusSelected = undefined;
this.fetchData(this.buildingSelected, 0, 0); this.fetchData(this.buildingSelected, 0, 0);
@ -173,7 +184,7 @@ export class ControlDeviceSeemoreComponent {
command_type: "on_off", command_type: "on_off",
}; };
this.deviceService.deviceSwitch(requestData).subscribe((res) => { this.deviceService.deviceSwitch(requestData).subscribe((res) => {
console.log(res);
}); });
} }
} }

View File

@ -242,7 +242,7 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-6" *ngFor="let item of deviceCategory?.usesd"> <div class="col-6" *ngFor="let item of deviceCategory?.used">
<div <div
class="card" class="card"
style=" style="
@ -299,7 +299,7 @@
font-family: 'Open Sans', sans-serif; font-family: 'Open Sans', sans-serif;
font-weight: 700; font-weight: 700;
" "
(click)="seeMore(paramsId)" (click)="seeMore(buildingId, floorId, roomId)"
> >
See More See More
</button> </button>

View File

@ -55,7 +55,9 @@ export class DetailComponent {
temperature: any; temperature: any;
deviceCategory: any; deviceCategory: any;
chartKwhWater: any; chartKwhWater: any;
paramsId: any; buildingId: any;
floorId: any;
roomId: any;
//...... //......
constructor( constructor(
@ -85,40 +87,29 @@ export class DetailComponent {
this.breadcrumbLink(); this.breadcrumbLink();
this.route.params.subscribe((params) => { this.route.params.subscribe((params) => {
const buildingId = params["buildingId"]; this.buildingId = params["buildingId"] ? params["buildingId"] : 0;
const floorId = params["floorId"]; this.floorId = params["floorId"] ? params["floorId"] : 0;
const roomId = params["roomId"]; this.roomId = params["roomId"] ? params["roomId"] : 0;
console.log(buildingId, 'buildingId');
console.log(floorId, 'floorId');
console.log(roomId, 'roomId');
if (buildingId !== undefined && floorId === undefined && roomId === undefined) { if (this.buildingId !== undefined && this.floorId === undefined && this.roomId === undefined) {
this.dataEnergyMonitoringTopCard(buildingId, 0, 0); this.dataEnergyMonitoringTopCard(this.buildingId, 0, 0);
this.dataEnergyMonitoringSummary(buildingId, 0, 0); this.dataEnergyMonitoringSummary(this.buildingId, 0, 0);
this.dataEnergyDeviceCategory(buildingId, 0, 0); this.dataEnergyDeviceCategory(this.buildingId, 0, 0);
this.dataEnergyChartKwhWater(buildingId, 0, 0); this.dataEnergyChartKwhWater(this.buildingId, 0, 0);
} else if (buildingId !== undefined && floorId !== undefined && roomId === undefined) { } else if (this.buildingId !== undefined && this.floorId !== undefined && this.roomId === undefined) {
this.dataEnergyMonitoringTopCard(buildingId, floorId, 0); this.dataEnergyMonitoringTopCard(this.buildingId, this.floorId, 0);
this.dataEnergyMonitoringSummary(buildingId, floorId, 0); this.dataEnergyMonitoringSummary(this.buildingId, this.floorId, 0);
this.dataEnergyDeviceCategory(buildingId, floorId, 0); this.dataEnergyDeviceCategory(this.buildingId, this.floorId, 0);
this.dataEnergyChartKwhWater(buildingId, floorId, 0); this.dataEnergyChartKwhWater(this.buildingId, this.floorId, 0);
} else if (buildingId !== undefined && floorId !== undefined && roomId !== undefined) { } else if (this.buildingId !== undefined && this.floorId !== undefined && this.roomId !== undefined) {
this.dataEnergyMonitoringTopCard(buildingId, floorId, roomId); this.dataEnergyMonitoringTopCard(this.buildingId, this.floorId, this.roomId);
this.dataEnergyMonitoringSummary(buildingId, floorId, roomId); this.dataEnergyMonitoringSummary(this.buildingId, this.floorId, this.roomId);
this.dataEnergyDeviceCategory(buildingId, floorId, roomId); this.dataEnergyDeviceCategory(this.buildingId, this.floorId, this.roomId);
this.dataEnergyChartKwhWater(buildingId, floorId, roomId); this.dataEnergyChartKwhWater(this.buildingId, this.floorId, this.roomId);
} }
this.paramsId = params["buildingId"];
this.dataDeviceIr(); this.dataDeviceIr();
this.getAirQualityData(); this.getAirQualityData();
// if (buildingId) {
// this.dataEnergyMonitoringTopCard(buildingId);
// this.dataEnergyMonitoringSummary(buildingId);
// this.dataEnergyMonitoringSAir(buildingId);
// this.dataEnergyDeviceCategory(buildingId);
// this.dataEnergyChartKwhWater(buildingId);
// }
}); });
} }
@ -282,7 +273,6 @@ export class DetailComponent {
.getDashboardChartKwhWater(buildingId, floorId, roomId) .getDashboardChartKwhWater(buildingId, floorId, roomId)
.subscribe((res) => { .subscribe((res) => {
this.chartKwhWater = res.data; this.chartKwhWater = res.data;
console.log(this.chartKwhWater);
this.chartKwhWater.forEach((entry) => { this.chartKwhWater.forEach((entry) => {
this.barChartData.push(entry.kwh.toFixed(1)); this.barChartData.push(entry.kwh.toFixed(1));
this.barChartData2.push(entry.cost); this.barChartData2.push(entry.cost);
@ -361,7 +351,7 @@ export class DetailComponent {
// alert(`Day: ${params.name}\nKWH Consumption: ${params.value}`); // alert(`Day: ${params.name}\nKWH Consumption: ${params.value}`);
} }
seeMore(paramsId) { seeMore(buildingId, floorId, roomId) {
this.router.navigate(["/monitoring/control-device-see-more/", paramsId]); this.router.navigate(["/monitoring/control-device-see-more/", buildingId, floorId, roomId, this.mode]);
} }
} }

View File

@ -81,7 +81,7 @@ import { ClipboardModule } from 'ngx-clipboard';
component: WaterComponent, component: WaterComponent,
}, },
{ {
path: 'control-device-see-more/:id', path: 'control-device-see-more/:buildingId/:floorId/:roomId/:mode',
component: ControlDeviceSeemoreComponent, component: ControlDeviceSeemoreComponent,
}, },
{ {