penambahan filter dashboard
This commit is contained in:
parent
5410d966d0
commit
4fdaa8c1bd
|
@ -151,8 +151,6 @@ export class MasterFloorComponent {
|
||||||
.putHeaderDetailParam(result, row.id)
|
.putHeaderDetailParam(result, row.id)
|
||||||
.subscribe((res) => {
|
.subscribe((res) => {
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
console.log(res);
|
|
||||||
|
|
||||||
if (res.status === 400) {
|
if (res.status === 400) {
|
||||||
this.toastr.error(
|
this.toastr.error(
|
||||||
"Warning",
|
"Warning",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="app-content content" style="background-color: #FBFBFB;">
|
<div class="app-content content" style="background-color: #fbfbfb">
|
||||||
<div class="content-wrapper">
|
<div class="content-wrapper">
|
||||||
<div class="content-header row mb-1">
|
<div class="content-header row mb-1">
|
||||||
<app-breadcrumb class="col-12" [breadcrumb]="breadcrumb"></app-breadcrumb>
|
<app-breadcrumb class="col-12" [breadcrumb]="breadcrumb"></app-breadcrumb>
|
||||||
|
@ -6,16 +6,75 @@
|
||||||
<div class="content-body">
|
<div class="content-body">
|
||||||
<section id="social-cards">
|
<section id="social-cards">
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
<div class="col-md-6">
|
<div class="col-3">
|
||||||
<input
|
<div class="form-group">
|
||||||
type="text"
|
<ng-select
|
||||||
class="form-control"
|
class="select-custom"
|
||||||
placeholder="Search..."
|
[items]="dataBuildingList"
|
||||||
[(ngModel)]="searchTerm"
|
[searchable]="true"
|
||||||
(input)="filterRows()"
|
bindLabel="name"
|
||||||
/>
|
bindValue="id"
|
||||||
|
placeholder="Select Building"
|
||||||
|
[(ngModel)]="buildingSelected"
|
||||||
|
>
|
||||||
|
</ng-select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<ng-select
|
||||||
|
class="select-custom"
|
||||||
|
[items]="dataFloorList"
|
||||||
|
[searchable]="true"
|
||||||
|
bindLabel="name"
|
||||||
|
bindValue="id"
|
||||||
|
placeholder="Select Floor"
|
||||||
|
[(ngModel)]="floorSelected"
|
||||||
|
>
|
||||||
|
</ng-select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-3 text-left">
|
||||||
|
<div class="d-flex">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn ml-2"
|
||||||
|
(click)="doFilter()"
|
||||||
|
style="
|
||||||
|
background-color: #37a647 !important;
|
||||||
|
border-color: #37a647 !important;
|
||||||
|
border-radius: 12px;
|
||||||
|
color: #ffffff;
|
||||||
|
"
|
||||||
|
[disabled]="spinnerFilterActive"
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
class="la la-search"
|
||||||
|
style="color: #ffffff !important"
|
||||||
|
*ngIf="!spinnerFilterActive"
|
||||||
|
></i>
|
||||||
|
<i
|
||||||
|
class="la la-spinner spinner"
|
||||||
|
style="color: #ffffff !important"
|
||||||
|
*ngIf="spinnerFilterActive"
|
||||||
|
></i>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn ml-2"
|
||||||
|
style="
|
||||||
|
background-color: #fbfbfb !important;
|
||||||
|
border-color: #242222 !important;
|
||||||
|
color: #242222;
|
||||||
|
border-radius: 12px;
|
||||||
|
"
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row mt-2">
|
<div class="row mt-2">
|
||||||
<div
|
<div
|
||||||
class="col-12 col-sm-12 col-md-12 col-lg-6 col-xl-4"
|
class="col-12 col-sm-12 col-md-12 col-lg-6 col-xl-4"
|
||||||
|
@ -28,7 +87,7 @@
|
||||||
<div class="card-header mb-2 custom-card-header">
|
<div class="card-header mb-2 custom-card-header">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 text-center">
|
<div class="col-12 text-center">
|
||||||
<h4 class="header-title">Building</h4>
|
<h4 class="header-title">{{labelData}}</h4>
|
||||||
<h3 class="header-subtitle">
|
<h3 class="header-subtitle">
|
||||||
{{ data.build_name ? data.build_name : data.name }}
|
{{ data.build_name ? data.build_name : data.name }}
|
||||||
</h3>
|
</h3>
|
||||||
|
@ -58,25 +117,21 @@
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<h3
|
<h3 class="custom-total">{{ data.total }} KWH</h3>
|
||||||
class="custom-total"
|
|
||||||
>
|
|
||||||
{{ data.total }} KWH
|
|
||||||
</h3>
|
|
||||||
<h6 class="custom-label-chart">Consumption</h6>
|
<h6 class="custom-label-chart">Consumption</h6>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group text-center">
|
<div class="form-group text-center">
|
||||||
<button
|
<!-- <button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-min-width mr-1 mb-1 btn-room"
|
class="btn btn-min-width mr-1 mb-1 btn-room"
|
||||||
(click)="viewRoom(data)"
|
(click)="viewRoom(data)"
|
||||||
>
|
>
|
||||||
Room
|
Room
|
||||||
</button>
|
</button> -->
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-min-width mr-1 mb-1 btn-detail"
|
class="btn btn-min-width mr-1 mb-1 btn-room"
|
||||||
(click)="viewRow(data)"
|
(click)="viewRow(data)"
|
||||||
>
|
>
|
||||||
Detail
|
Detail
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { TableMonitoringService } from "../monitoring.service";
|
||||||
import { Router } from "@angular/router";
|
import { Router } from "@angular/router";
|
||||||
import { BuildingService } from "../../service/monitoring-api.service";
|
import { BuildingService } from "../../service/monitoring-api.service";
|
||||||
import { LoginService } from "../../service/login.service";
|
import { LoginService } from "../../service/login.service";
|
||||||
|
import { DeviceService } from "../../service/device.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-building",
|
selector: "app-building",
|
||||||
|
@ -10,7 +11,6 @@ import { LoginService } from "../../service/login.service";
|
||||||
styleUrls: ["./building.component.css"],
|
styleUrls: ["./building.component.css"],
|
||||||
})
|
})
|
||||||
export class BuildingComponent {
|
export class BuildingComponent {
|
||||||
data: any;
|
|
||||||
public breadcrumb: any;
|
public breadcrumb: any;
|
||||||
feedbacksdonutChart: any;
|
feedbacksdonutChart: any;
|
||||||
donutChart1: any;
|
donutChart1: any;
|
||||||
|
@ -18,10 +18,19 @@ export class BuildingComponent {
|
||||||
topUseData: any;
|
topUseData: any;
|
||||||
searchTerm: string = "";
|
searchTerm: string = "";
|
||||||
colorChart: string = "";
|
colorChart: string = "";
|
||||||
|
spinnerFilterActive = false;
|
||||||
|
typeData: any;
|
||||||
|
labelData: any;
|
||||||
|
|
||||||
|
dataBuildingList: any;
|
||||||
|
buildingSelected: any;
|
||||||
|
dataFloorList: any;
|
||||||
|
floorSelected: any;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private monitoringService: TableMonitoringService,
|
private monitoringService: TableMonitoringService,
|
||||||
private monitoringApiService: BuildingService,
|
private monitoringApiService: BuildingService,
|
||||||
|
private deviceService: DeviceService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private authService: LoginService
|
private authService: LoginService
|
||||||
) {}
|
) {}
|
||||||
|
@ -51,38 +60,59 @@ export class BuildingComponent {
|
||||||
showLabel: false,
|
showLabel: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
this.listBuilding();
|
this.listBuilding(this.buildingSelected, this.floorSelected);
|
||||||
|
this.dataListBuilding();
|
||||||
|
this.dataListFloor();
|
||||||
}
|
}
|
||||||
|
|
||||||
listBuilding() {
|
dataListBuilding() {
|
||||||
this.monitoringApiService.listBuilding().subscribe((res) => {
|
this.monitoringApiService.getBuildingList().subscribe((data) => {
|
||||||
this.data = res.data;
|
this.dataBuildingList = data.data.filter(
|
||||||
this.filteredRows = res.data;
|
(item) => item.statusName.toLowerCase() === "aktif"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// buildingData() {
|
dataListFloor() {
|
||||||
// this.monitoringApiService.getBuildingData().subscribe((res) => {
|
this.monitoringApiService.getMasterData().subscribe((data) => {
|
||||||
// console.log(res);
|
const dataMasterFloor = data.results.data.find(
|
||||||
// });
|
(item) => item.name === "master_floor"
|
||||||
// }
|
|
||||||
|
|
||||||
filterRows() {
|
|
||||||
if (!this.searchTerm) {
|
|
||||||
this.filteredRows = [...this.data];
|
|
||||||
} else {
|
|
||||||
this.filteredRows = this.data.filter((row) =>
|
|
||||||
this.rowContainsSearchTerm(row)
|
|
||||||
);
|
);
|
||||||
}
|
const listFloor = dataMasterFloor.headerDetailParam.sort(
|
||||||
|
(a, b) => b.id - a.id
|
||||||
|
);
|
||||||
|
const newArray = listFloor
|
||||||
|
.map((item) => ({
|
||||||
|
id: item.id,
|
||||||
|
name: `${item.name} (${item.code})`,
|
||||||
|
}))
|
||||||
|
.sort((a, b) => b.id - a.id);
|
||||||
|
|
||||||
|
this.dataFloorList = newArray;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
rowContainsSearchTerm(row: any): boolean {
|
listBuilding(buildingId, floorId) {
|
||||||
const searchTermLC = this.searchTerm.toLowerCase();
|
this.deviceService.filterDashboard(buildingId, floorId).subscribe((res) => {
|
||||||
return Object.values(row).some(
|
this.filteredRows = res.data;
|
||||||
(value) =>
|
this.typeData = this.filteredRows[0].type;
|
||||||
value !== null && value.toString().toLowerCase().includes(searchTermLC)
|
console.log(this.filteredRows[0].type);
|
||||||
);
|
if (this.typeData === "building") {
|
||||||
|
this.labelData = "Building";
|
||||||
|
} else if (this.typeData === "floor") {
|
||||||
|
this.labelData = "Floor";
|
||||||
|
} else if (this.typeData === "room") {
|
||||||
|
this.labelData = "Room";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
doFilter() {
|
||||||
|
this.spinnerFilterActive = true;
|
||||||
|
this.listBuilding(this.buildingSelected, this.floorSelected);
|
||||||
|
setTimeout(() => {
|
||||||
|
this.spinnerFilterActive = false;
|
||||||
|
}, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
viewRow(row) {
|
viewRow(row) {
|
||||||
|
|
|
@ -148,18 +148,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="card" style="background-color: #dde1e6 !important">
|
<div class="card" style="background-color: #dde1e6 !important">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div
|
<div
|
||||||
|
(chartClick)="onChartClick($event)"
|
||||||
echarts
|
echarts
|
||||||
[options]="chartOptionBar"
|
[options]="chartOptionBar"
|
||||||
class="echart-container"
|
class="echart-container"
|
||||||
style="
|
style="height: 400px !important; display: block"
|
||||||
height: 400px !important;
|
|
||||||
display: block;
|
|
||||||
"
|
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -37,6 +37,7 @@ export class DetailComponent {
|
||||||
currentTime: string;
|
currentTime: string;
|
||||||
chartOption: any;
|
chartOption: any;
|
||||||
chartOptionBar: any;
|
chartOptionBar: any;
|
||||||
|
chartInstance: any;
|
||||||
|
|
||||||
// chart bar
|
// chart bar
|
||||||
public barChartLabels: string[] = [];
|
public barChartLabels: string[] = [];
|
||||||
|
@ -333,9 +334,19 @@ export class DetailComponent {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
onClick: (params) => {
|
||||||
|
this.onChartClick(params);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onChartClick(params) {
|
||||||
|
console.log(params);
|
||||||
|
|
||||||
|
// Show popup with details
|
||||||
|
// alert(`Day: ${params.name}\nKWH Consumption: ${params.value}`);
|
||||||
|
}
|
||||||
|
|
||||||
seeMore(paramsId) {
|
seeMore(paramsId) {
|
||||||
this.router.navigate(["/monitoring/control-device-see-more/", paramsId]);
|
this.router.navigate(["/monitoring/control-device-see-more/", paramsId]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,4 +98,21 @@ export class DeviceService {
|
||||||
});
|
});
|
||||||
return this.http.get<any>(url, { headers });
|
return this.http.get<any>(url, { headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filterDashboard(building, floor): Observable<any> {
|
||||||
|
const endpoint = `/building/dashboard/list`;
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
building_id: building ? building : 0,
|
||||||
|
floor_id: floor ? floor :0,
|
||||||
|
});
|
||||||
|
// if (category) {
|
||||||
|
// params.append("category_id", category);
|
||||||
|
// }
|
||||||
|
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 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,4 +277,6 @@ export class BuildingService {
|
||||||
// device.mapping.some((map: any) => console.log(map))
|
// device.mapping.some((map: any) => console.log(map))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue