@@ -30,35 +32,25 @@
@@ -67,7 +59,9 @@
@@ -75,30 +69,36 @@
- 1.234.242
+ {{
+ dataCompAct?.est_cost
+ }}
- 1.545.232
+ {{
+ dataCompAct?.real_cost
+ }}
@@ -107,6 +107,276 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ rowIndex + 1 }}
+
+
+
+
+ Building
+
+
+ {{ value }}
+
+
+
+
+ Category
+
+
+ {{ value }}
+
+
+
+
+ Estimation Cost
+
+
+ {{
+ value.toLocaleString("id-ID", {
+ style: "currency",
+ currency: "IDR"
+ })
+ }}
+
+
+
+
+ Total Use
+
+
+ {{ value }} kWh
+
+
+
+
+ Tanggal
+
+
+ {{ value | date : "MM/yyyy" }}
+
+
+
+
+ Status
+
+
+ {{ value === 2 ? "Aktif" : "Tidak Aktif" }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/content/hemat-app/cost-management/cost-management.component.ts b/src/app/content/hemat-app/cost-management/cost-management.component.ts
index ad108e0..fc4d24c 100644
--- a/src/app/content/hemat-app/cost-management/cost-management.component.ts
+++ b/src/app/content/hemat-app/cost-management/cost-management.component.ts
@@ -1,50 +1,51 @@
-import { Component, OnInit } from '@angular/core';
-import { Router } from '@angular/router';
-import { TableApiService } from 'src/app/_services/table-api.service';
+import { Component, OnInit } from "@angular/core";
+import { Router } from "@angular/router";
+import { TableApiService } from "src/app/_services/table-api.service";
+import { BuildingService } from "../service/monitoring-api.service";
+import { DatePipe } from "@angular/common";
+import { CostManagementService } from "../service/cost-management.service";
+import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
+import { ModalAddActualComponent } from "./modal-add-actual/modal-add-actual.component";
@Component({
- selector: 'app-cost-management',
- templateUrl: './cost-management.component.html',
- styleUrls: ['./cost-management.component.css']
+ selector: "app-cost-management",
+ templateUrl: "./cost-management.component.html",
+ styleUrls: ["./cost-management.component.css"],
})
-export class CostManagementComponent implements OnInit{
+export class CostManagementComponent implements OnInit {
public breadcrumb: any;
data: any;
filteredRows: any[];
+ data_cost: any;
searchTerm: string = "";
+ kwhTerm: string = "";
+ costTerm: string = "";
rows: any = [];
+ dataMasterCategori: any;
+ dataBuildingList: any;
+ public focucedElement = "";
+ spinnerActive = false;
+ spinnerActiveActual = false;
- donutChart1: any;
donutChart2: any;
- dataChart = {
- donut: {
- series: [50, 50],
- labels: [],
- },
- };
- dataChart2 = {
- donut: {
- series: [50, 50],
- labels: [],
- },
- };
barChart: any;
- dataBar = {
- "Bar": {
- "labels": [],
- "series": [
- [
- 80,
- 60
- ]
- ]
- },
- }
+
+ dateSelected: any;
+ buildingSelected: any;
+ categorySelected: any;
+ dataComp: any;
+ dataCompPrev: any;
+ dataCompAct: any;
+ storedData: any;
constructor(
private tableApiservice: TableApiService,
- private router: Router
+ private router: Router,
+ private monitoringApiService: BuildingService,
+ private costService: CostManagementService,
+ private datePipe: DatePipe,
+ private modalService: NgbModal
) {}
ngOnInit() {
@@ -61,78 +62,223 @@ export class CostManagementComponent implements OnInit{
},
],
};
- this.fetchData();
+ this.storedData = JSON.parse(localStorage.getItem("currentUser"));
+ this.buildingSelected = this.storedData.buildingId;
+ const currentDate = new Date();
+ this.dateSelected = currentDate.toISOString().slice(0, 7);
- this.barChart = {
- type: 'Bar',
- data: this.dataBar.Bar,
- options: {
- fullwidth: true,
- axisX: {
- showGrid: false,
- showLabel: false,
- offset: 100
- },
-
- axisY: {
- showGrid: false,
- showLabel: false
- }
- }
- };
+ this.fetchData(this.storedData.buildingId, this.dateSelected, this.categorySelected);
+ this.dataListMaster();
+ this.dataListBuilding();
- this.donutChart1 = {
- type: "Pie",
- data: this.dataChart.donut,
- options: {
- fullwidth: true,
- height: "300px",
- donut: true,
- donutWidth: 70,
- startAngle: 270,
- total: 200,
- showLabel: true,
- },
- };
- this.donutChart2 = {
- type: "Pie",
- data: this.dataChart2.donut,
- options: {
- chartPadding: 0,
- fullwidth: true,
- height: "150px",
- donut: true,
- showLabel: true,
- startAngle: 0,
- labelInterpolationFnc: function (value) {
- const total = 82;
- return total + "C";
- },
- },
- events: {
- draw(data: any): void {
- if (data.type === "label") {
- if (data.index === 0) {
- data.element.attr({
- dx: data.element.root().width() / 2,
- dy: data.element.root().height() / 2,
- });
- } else {
- data.element.remove();
- }
- }
- },
- },
- };
+ this.dataCompWaterElectCost(this.storedData.buildingId);
+ this.dataCompPrevMonthCost(this.storedData.buildingId);
+ this.dataCompActEstCost(this.storedData.buildingId);
+
}
- fetchData() {
- this.tableApiservice.getTableInitialisationData().subscribe((response) => {
- this.data = response;
- this.filteredRows = this.data.rows;
+ fetchData(id, period, category) {
+ this.costService.getCostManagement(id, period, category).subscribe((response) => {
+ this.data = response.results.data;
+ this.filteredRows = this.data;
+ this.kwhTerm = response.results.kwh;
+ this.costTerm = response.results.cost;
+
+ this.data_cost = this.filteredRows.map((item) => ({
+ building: item.name,
+ categoryName: item.category_name,
+ estimationCost: item.estimation_cost,
+ totalUse: item.total_use,
+ endDate: item.end_date,
+ statusId: item.status_id,
+ }));
});
}
+ dataListMaster() {
+ this.monitoringApiService.getMasterListData().subscribe((data) => {
+ const dataCategory = data.data.find(
+ (item) => item.name === "master_category"
+ ).headerDetailParam;
+ this.dataMasterCategori = dataCategory.filter(
+ (item) => item.status === "2"
+ );
+ });
+ }
+
+ dataListBuilding() {
+ this.monitoringApiService.getBuildingList().subscribe((data) => {
+ this.dataBuildingList = data.data.filter((item) => item.statusId === 2);
+ });
+ }
+
+ dataCompWaterElectCost(buildingId) {
+ this.costService.getCompWaterElectCost(buildingId).subscribe((data) => {
+ this.dataComp = data.data;
+ const dataChart2 = {
+ donut: {
+ series: [this.dataComp.elect, this.dataComp.water],
+ labels: [],
+ },
+ };
+ this.donutChart2 = {
+ type: "Pie",
+ data: dataChart2.donut,
+ options: {
+ chartPadding: 0,
+ fullwidth: true,
+ height: "150px",
+ donut: true,
+ showLabel: true,
+ startAngle: 0,
+ // labelInterpolationFnc: function (value) {
+ // const total = 82;
+ // return total + "C";
+ // },
+ },
+ events: {
+ draw(data: any): void {
+ if (data.type === "label") {
+ if (data.index === 0) {
+ data.element.attr({
+ dx: data.element.root().width() / 2,
+ dy: data.element.root().height() / 2,
+ });
+ } else {
+ data.element.remove();
+ }
+ }
+ },
+ },
+ };
+
+ // this.dataChart2.donut.labels = ["Water", "Electricity"];
+ });
+ }
+
+ dataCompPrevMonthCost(buildingId) {
+ this.costService.getCompPrevMonthCost(buildingId).subscribe((data) => {
+ this.dataCompPrev = data.data;
+ const randomValue = Math.floor(Math.random() * (100 - 50 + 1)) + 50;
+ const dataBar = {
+ Bar: {
+ labels: [[this.dataCompPrev[0].name], [this.dataCompPrev[1].name]],
+ series: [[randomValue], [this.dataCompPrev[1].value]],
+ },
+ };
+ this.barChart = {
+ type: "Bar",
+ data: dataBar.Bar,
+ options: {
+ fullwidth: true,
+ width: "100px",
+ height: "150px",
+ seriesBarDistance: 100,
+ axisX: {
+ showGrid: false,
+ showLabel: false,
+ offset: 5,
+ },
+ axisY: {
+ showGrid: false,
+ showLabel: false,
+ scaleMinSpace: 30,
+ },
+ classNames: {
+ bar: "ct-bar", // Menambahkan kelas CSS ke batang
+ },
+ },
+ responsiveOptions: [
+ [
+ "screen and (max-width: 640px)",
+ {
+ seriesBarDistance: 100,
+ axisX: {
+ labelInterpolationFnc: function (value) {
+ return value[0];
+ },
+ },
+ },
+ ],
+ ],
+ };
+ });
+ }
+
+ dataCompActEstCost(buildingId) {
+ this.costService.getCompActEstCost(buildingId).subscribe((data) => {
+ this.dataCompAct = data.data[0];
+ });
+ }
+
+ syncData() {
+ const dataDate = {
+ buildingId: this.buildingSelected,
+ periode: this.dateSelected,
+ };
+ this.spinnerActive = true;
+ this.costService.getSyncCost(dataDate).subscribe((data) => {
+ console.log(data);
+ });
+ setTimeout(() => {
+ this.spinnerActive = false;
+ this.fetchData(this.buildingSelected, this.dateSelected, this.categorySelected );
+ }, 3000);
+ }
+
+ actualData() {
+ this.spinnerActiveActual = true;
+ this.costService
+ .getRealCostByBuildingId(4, this.dateSelected)
+ .subscribe((data) => {
+ console.log(data.data[0]);
+ // this.costTerm = data.data[0].est_cost
+ });
+ setTimeout(() => {
+ this.spinnerActiveActual = false;
+ this.fetchData(this.buildingSelected, this.dateSelected, this.categorySelected );
+ }, 3000);
+ }
+
+ doFilter() {
+ const requestData = {
+ building: this.buildingSelected,
+ category: this.categorySelected,
+ date: this.dateSelected,
+ searchTerm: this.searchTerm,
+ };
+ this.fetchData(this.buildingSelected, this.dateSelected, this.categorySelected );
+ this.dataCompWaterElectCost(this.buildingSelected);
+ this.dataCompPrevMonthCost(this.buildingSelected);
+ this.dataCompActEstCost(this.buildingSelected);
+ }
+
+ addFieldValue() {
+ const modalRef = this.modalService.open(ModalAddActualComponent, {
+ size: "sm",
+ });
+ modalRef.componentInstance.newAttribute = {
+ id: null,
+ name: "",
+ };
+
+ modalRef.result.then(
+ (result) => {
+ if (result) {
+ this.rows.push(result);
+ this.rows = [...this.rows];
+ }
+ },
+ (reason) => {
+ console.log(`Dismissed: ${reason}`);
+ }
+ );
+ }
+
+ focusElement(focucedElement: any) {
+ this.focucedElement = focucedElement;
+ }
+
filterRows() {
if (!this.searchTerm) {
this.filteredRows = [...this.data.rows];
@@ -147,8 +293,7 @@ export class CostManagementComponent implements OnInit{
const searchTermLC = this.searchTerm.toLowerCase();
return Object.values(row).some(
(value) =>
- value !== null &&
- value.toString().toLowerCase().includes(searchTermLC)
+ value !== null && value.toString().toLowerCase().includes(searchTermLC)
);
}
@@ -169,4 +314,6 @@ export class CostManagementComponent implements OnInit{
onTouchStart(event: Event) {
event.preventDefault(); // Add this if necessary
}
+
+
}
diff --git a/src/app/content/hemat-app/cost-management/cost-management.module.ts b/src/app/content/hemat-app/cost-management/cost-management.module.ts
index 50595eb..60faa44 100644
--- a/src/app/content/hemat-app/cost-management/cost-management.module.ts
+++ b/src/app/content/hemat-app/cost-management/cost-management.module.ts
@@ -1,5 +1,5 @@
import { NgModule } from '@angular/core';
-import { CommonModule } from '@angular/common';
+import { CommonModule, DatePipe } from '@angular/common';
import { CostManagementComponent } from './cost-management.component';
import { RouterModule } from '@angular/router';
import { BreadcrumbModule } from 'src/app/_layout/breadcrumb/breadcrumb.module';
@@ -15,13 +15,16 @@ import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { NgChartsModule } from 'ng2-charts';
import { ChartistModule } from 'ng-chartist';
+import { MatchHeightModule } from '../../partials/general/match-height/match-height.module';
+import { ModalAddActualComponent } from './modal-add-actual/modal-add-actual.component';
@NgModule({
declarations: [
CostManagementComponent,
- AddEditCostComponent
+ AddEditCostComponent,
+ ModalAddActualComponent
],
imports: [
CommonModule,
@@ -36,6 +39,7 @@ import { ChartistModule } from 'ng-chartist';
NgxDatatableModule,
NgChartsModule,
ChartistModule,
+ MatchHeightModule,
BlockUIModule.forRoot({
template: BlockTemplateComponent
}),
@@ -60,6 +64,9 @@ import { ChartistModule } from 'ng-chartist';
data: { mode: 'view' }
}
])
- ]
+ ],
+ providers: [
+ DatePipe // Add DatePipe to providers
+ ],
})
export class CostManagementModule { }
diff --git a/src/app/content/hemat-app/cost-management/modal-add-actual/modal-add-actual.component.css b/src/app/content/hemat-app/cost-management/modal-add-actual/modal-add-actual.component.css
new file mode 100644
index 0000000..fa6d7fd
--- /dev/null
+++ b/src/app/content/hemat-app/cost-management/modal-add-actual/modal-add-actual.component.css
@@ -0,0 +1,56 @@
+/* modal-add-edit.component.css */
+::ng-deep .modal-backdrop.show {
+ z-index: auto !important;
+ }
+
+ ::ng-deep .input-group-append .btn {
+ border-top-left-radius: 0;
+ border-bottom-left-radius: 0;
+ border-radius: 0;
+ border-left: 0;
+ flex-grow: 0;
+ border-left: 1px solid #ced4da;
+ padding: 0.375rem 0.75rem;
+ }
+
+ ::ng-deep .input-group {
+ display: flex;
+ flex-wrap: nowrap; /* Prevents wrapping of the items */
+ align-items: center;
+ }
+
+ ::ng-deep .form-control {
+ flex-grow: 1; /* Ensures select takes up available space */
+ padding-right: 0.5rem;
+ }
+
+ ::ng-deep .input-group select,
+ ::ng-deep .input-group .input-group-append .btn {
+ padding-right: 5px; /* Adjust padding if necessary */
+ }
+
+ ::ng-deep .input-group .form-control {
+ margin-right: 2px; /* Adjust margin to make space */
+ }
+
+
+ .form-group {
+ margin-bottom: 1rem;
+ }
+
+ .form-control {
+ display: block;
+ width: 100%;
+ height: calc(1.5em + 0.75rem + 2px);
+ padding: 0.375rem 0.75rem;
+ font-size: 1rem;
+ font-weight: 400;
+ line-height: 1.5;
+ color: #495057;
+ background-color: #fff;
+ background-clip: padding-box;
+ border: 1px solid #ced4da;
+ border-radius: 0.25rem;
+ transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
+ }
+
\ No newline at end of file
diff --git a/src/app/content/hemat-app/cost-management/modal-add-actual/modal-add-actual.component.html b/src/app/content/hemat-app/cost-management/modal-add-actual/modal-add-actual.component.html
new file mode 100644
index 0000000..04c3eab
--- /dev/null
+++ b/src/app/content/hemat-app/cost-management/modal-add-actual/modal-add-actual.component.html
@@ -0,0 +1,31 @@
+
+
+
diff --git a/src/app/content/hemat-app/cost-management/modal-add-actual/modal-add-actual.component.spec.ts b/src/app/content/hemat-app/cost-management/modal-add-actual/modal-add-actual.component.spec.ts
new file mode 100644
index 0000000..0043ae8
--- /dev/null
+++ b/src/app/content/hemat-app/cost-management/modal-add-actual/modal-add-actual.component.spec.ts
@@ -0,0 +1,23 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { ModalAddActualComponent } from './modal-add-actual.component';
+
+describe('ModalAddActualComponent', () => {
+ let component: ModalAddActualComponent;
+ let fixture: ComponentFixture
;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ ModalAddActualComponent ]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(ModalAddActualComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/content/hemat-app/cost-management/modal-add-actual/modal-add-actual.component.ts b/src/app/content/hemat-app/cost-management/modal-add-actual/modal-add-actual.component.ts
new file mode 100644
index 0000000..05a79d2
--- /dev/null
+++ b/src/app/content/hemat-app/cost-management/modal-add-actual/modal-add-actual.component.ts
@@ -0,0 +1,29 @@
+import { Component, Input } from '@angular/core';
+import { FormBuilder, FormGroup, Validators } from '@angular/forms';
+import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
+
+@Component({
+ selector: 'app-modal-add-actual',
+ templateUrl: './modal-add-actual.component.html',
+ styleUrls: ['./modal-add-actual.component.css']
+})
+export class ModalAddActualComponent {
+ @Input() newAttribute: any = {};
+ myForm: FormGroup;
+
+ constructor(public activeModal: NgbActiveModal, private fb: FormBuilder) {
+ this.createForm();
+ }
+
+ createForm() {
+ this.myForm = this.fb.group({
+ name: ['', Validators.required],
+ });
+ }
+
+ addRow() {
+ if (this.myForm.valid) {
+ this.activeModal.close(this.myForm.value);
+ }
+ }
+}
diff --git a/src/app/content/hemat-app/device/device.component.html b/src/app/content/hemat-app/device/device.component.html
index 073ec4a..2ceb3db 100644
--- a/src/app/content/hemat-app/device/device.component.html
+++ b/src/app/content/hemat-app/device/device.component.html
@@ -94,7 +94,7 @@
[items]="singleSelectArray"
[searchable]="true"
bindLabel="item_text"
- placeholder="Select Month"
+ placeholder="Select Type"
[(ngModel)]="singlebasicSelected"
>
diff --git a/src/app/content/hemat-app/device/device.component.ts b/src/app/content/hemat-app/device/device.component.ts
index aae3eec..38ea9d9 100644
--- a/src/app/content/hemat-app/device/device.component.ts
+++ b/src/app/content/hemat-app/device/device.component.ts
@@ -67,16 +67,14 @@ export class DeviceComponent implements OnInit {
console.log(this.filteredRows);
this.totalOn = this.filteredRows.filter((row) => row.statusEntity.name.toLowerCase() === 'aktif').length
this.totalOff = this.filteredRows.filter((row) => row.statusEntity.name.toLowerCase() === 'nonaktif').length
- // console.log(totalon);
-
});
}
filterRows() {
if (!this.searchTerm) {
- this.filteredRows = [...this.data.rows];
+ this.filteredRows = [...this.data.results.data];
} else {
- this.filteredRows = this.data.rows.filter((row) =>
+ this.filteredRows = this.data.results.data.filter((row) =>
this.rowContainsSearchTerm(row)
);
}
@@ -135,14 +133,10 @@ export class DeviceComponent implements OnInit {
this.monitoringApiService.getSyncDeviceData().subscribe((res) => {
console.log(res);
});
-
- // Lakukan proses tambahan (misalnya, panggil API atau proses yang memakan waktu)
+
setTimeout(() => {
- // Selesaikan proses tambahan di sini
-
- // Nonaktifkan spinner setelah proses selesai
this.spinnerActive = false;
this.fetchData();
- }, 3000); // Ganti 3000 dengan waktu yang sesuai dengan proses tambahan Anda (dalam milidetik)
+ }, 3000);
}
}
diff --git a/src/app/content/hemat-app/monitoring/detail/detail.component.html b/src/app/content/hemat-app/monitoring/detail/detail.component.html
index 8f3b8ce..d3d417f 100644
--- a/src/app/content/hemat-app/monitoring/detail/detail.component.html
+++ b/src/app/content/hemat-app/monitoring/detail/detail.component.html
@@ -83,7 +83,7 @@
- Appointment
+