diff --git a/src/app/_layout/settings/menu-settings.config.ts b/src/app/_layout/settings/menu-settings.config.ts index c74d47c..7e21d17 100644 --- a/src/app/_layout/settings/menu-settings.config.ts +++ b/src/app/_layout/settings/menu-settings.config.ts @@ -1018,10 +1018,7 @@ export const MenuSettingsConfig: MenuConfig = { page: "null", submenu: { items: [ - // { - // title: "Monitoring List", - // page: "/list-monitoring", - // }, + { title: "Master Category", page: "/master/master-category", @@ -1062,6 +1059,10 @@ export const MenuSettingsConfig: MenuConfig = { title: "Master Building", page: "/master/master-building", }, + { + title: "Master Monitoring List", + page: "/list-monitoring", + }, ], }, }, diff --git a/src/app/content/hemat-app/list-monitoring/add-edit-list/add-edit-list.component.html b/src/app/content/hemat-app/list-monitoring/add-edit-list/add-edit-list.component.html index 874913f..12f24c0 100644 --- a/src/app/content/hemat-app/list-monitoring/add-edit-list/add-edit-list.component.html +++ b/src/app/content/hemat-app/list-monitoring/add-edit-list/add-edit-list.component.html @@ -1,4 +1,4 @@ -
+
@@ -7,13 +7,13 @@
-
+
-

+

{{ isEditMode() ? "Edit List Monitoring" @@ -29,14 +29,14 @@ (ngSubmit)="onProjectInfoSubmit()" >
-

- +

+ General Information

-
@@ -69,7 +69,7 @@
-
@@ -118,6 +118,7 @@ id="roomId" class="form-control" formControlName="roomId" + (change)="validateDouble($event, i)" [ngClass]="{ 'is-invalid': submitted && f.roomId.errors @@ -134,9 +135,9 @@ class="btn btn-danger" type="button" style=" - color: #000000 !important; - border-color: #bef264 !important; - background-color: #bef264 !important; + color: #ffffff !important; + border-color: #37A647 !important; + background-color: #37A647 !important; " (click)="removePhone(i)" > @@ -149,10 +150,11 @@ - + + --> diff --git a/src/app/content/hemat-app/list-monitoring/list-monitoring.component.ts b/src/app/content/hemat-app/list-monitoring/list-monitoring.component.ts index 513caab..b430425 100644 --- a/src/app/content/hemat-app/list-monitoring/list-monitoring.component.ts +++ b/src/app/content/hemat-app/list-monitoring/list-monitoring.component.ts @@ -4,6 +4,7 @@ import { TableApiService } from "src/app/_services/table-api.service"; import { BuildingService } from "../service/monitoring-api.service"; import Swal from "sweetalert2"; import { LoginService } from "../service/login.service"; +import { ToastrService } from "ngx-toastr"; @Component({ selector: "app-list-monitoring", @@ -18,24 +19,24 @@ export class ListMonitoringComponent { rows: any = []; constructor( - private tableApiservice: TableApiService, private router: Router, private monitoringApiService: BuildingService, - private authService: LoginService + private authService: LoginService, + private toastr: ToastrService, ) {} ngOnInit() { this.authService.startTokenCheck(); this.authService.startTrackingActivity(); this.breadcrumb = { - mainlabel: "Cost Management", + mainlabel: "List Monitoring", links: [ { name: "Home", isLink: false, }, { - name: "Cost Management", + name: "List Monitoring", isLink: false, }, ], @@ -52,19 +53,20 @@ export class ListMonitoringComponent { filterRows() { if (!this.searchTerm) { - this.filteredRows = [...this.data.rows]; + this.filteredRows = [...this.data.results.data]; } else { - this.filteredRows = this.data.rows.filter((row) => - this.rowContainsSearchTerm(row) + const searchTermLC = this.searchTerm.toLowerCase(); + this.filteredRows = this.data.results.data.filter((row) => + this.rowContainsSearchTerm(row, searchTermLC) ); } } - rowContainsSearchTerm(row: any): boolean { - const searchTermLC = this.searchTerm.toLowerCase(); - return Object.values(row).some( - (value) => - value !== null && value.toString().toLowerCase().includes(searchTermLC) + rowContainsSearchTerm(row: any, searchTermLC: string): boolean { + return ( + row.buildingEntity.name.toLowerCase().includes(searchTermLC) || + row.roomEntity.name.toLowerCase().includes(searchTermLC) || + row.statusEntity.name.toLowerCase().includes(searchTermLC) ); } @@ -77,59 +79,25 @@ export class ListMonitoringComponent { } deleteRow(row) { - const swalWithBootstrapButtons = Swal.mixin({ - customClass: { - confirmButton: "btn-confirm", - cancelButton: "btn-cancel", - popup: "custom-swal-background", - }, - }); - swalWithBootstrapButtons.fire({ - title: "Are you sure?", - text: "Do you want to delete?", - icon: "question", - showCancelButton: true, - confirmButtonText: "Yes", - cancelButtonText: "No", - }).then((result) => { - if (result.isConfirmed) { - Swal.fire({ - title: "Loading...", - text: "Please wait", - allowOutsideClick: false, - customClass: { - popup: "custom-swal-background", - }, - didOpen: () => { - Swal.showLoading(); - }, - }); - setTimeout(() => { - this.monitoringApiService - .deleteRoomBuilding(row.id) - .subscribe((data) => { - Swal.fire({ - title: "Confirmed!", - text: "You clicked Yes.", - icon: "success", - customClass: { - popup: "custom-swal-background", - }, - }); - this.fetchData(); - }); - }, 2000); - } else if (result.isDismissed) { - Swal.fire({ - title: "Cancelled", - text: "You clicked No.", - icon: "error", - customClass: { - popup: "custom-swal-background", - }, - }); - } - }); + const confirmDelete = confirm("Are you sure you want to delete this item?"); + if (confirmDelete) { + this.monitoringApiService.deleteRoomBuilding(row.id).subscribe( + (res) => { + this.fetchData(); + this.toastr.success("Success", "Delete Completed.", { + timeOut: 2000, + closeButton: true, + }); + }, + (error) => { + console.error(error); + this.toastr.error("Error", "Data sedang digunakan!", { + timeOut: 2000, + closeButton: true, + }); + } + ); + } } onTouchStart(event: Event) { diff --git a/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.html b/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.html index e92e66d..8f52007 100644 --- a/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.html +++ b/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.html @@ -23,7 +23,7 @@ Name is required.
-
+
-
+
diff --git a/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.ts b/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.ts index a7b300b..72be9d2 100644 --- a/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.ts +++ b/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.ts @@ -35,7 +35,6 @@ export class AddEditMasterRoomComponent { this.createForm(); this.listDataStatus(); this.listDataBuilding(); - console.log(this.dataRow); if (this.mode === "add") { this.labelRoom = "Add New Row" } else { @@ -49,20 +48,17 @@ export class AddEditMasterRoomComponent { createForm() { this.myForm = this.fb.group({ name: ["", Validators.required], - statusId: ["", Validators.required], - buildingId: ["", Validators.required], description: ["", Validators.required], }); } editForm() { + console.log(this.dataRow); + this.myForm = this.fb.group({ id: this.dataRow.id, - roomId: this.dataRow.roomId, - name: [this.dataRow.roomEntity.name, Validators.required], - statusId: [this.dataRow.statusId, Validators.required], - buildingId: [this.dataRow.buildingId, Validators.required], - description: [this.dataRow.roomEntity.description, Validators.required], + name: [this.dataRow.name, Validators.required], + description: [this.dataRow.description, Validators.required], }); } diff --git a/src/app/content/hemat-app/master/master-room/master-room.component.html b/src/app/content/hemat-app/master/master-room/master-room.component.html index 7a23e97..38321d4 100644 --- a/src/app/content/hemat-app/master/master-room/master-room.component.html +++ b/src/app/content/hemat-app/master/master-room/master-room.component.html @@ -42,7 +42,7 @@
@@ -75,28 +75,12 @@ let-value="value" ngx-datatable-cell-template > -

{{ value.name }}

+

{{ value }}

- - Building - - -

{{ value.name }}

-
-
- - @@ -104,28 +88,13 @@ Description -

{{ value.description }}

+

{{ value }}

- - - Status - - -

{{ value.name }}

-
-
{ + this.monitoringApiService.getMasterRoomData().subscribe((res) => { this.data = res; this.filteredRows = this.data.results.data.sort((a, b) => b.id - a.id); // this.data.results.data.sort((a, b) => b.id - a.id); @@ -67,18 +67,16 @@ export class MasterRoomComponent { rowContainsSearchTerm(row: any, searchTermLC: string): boolean { return ( - row.roomEntity.name.toLowerCase().includes(searchTermLC) || - row.roomEntity.description.toLowerCase().includes(searchTermLC) || - row.buildingEntity.name.toLowerCase().includes(searchTermLC) || - row.statusEntity.name.toLowerCase().includes(searchTermLC) + row.name.toLowerCase().includes(searchTermLC) || + row.description.toLowerCase().includes(searchTermLC) ); } openAddMasterModal() { const modalRef = this.modalService.open(AddEditMasterRoomComponent, { size: "lg", - backdrop: "static", // Add this line - keyboard: false, // Add this line + backdrop: "static", + keyboard: false, }); modalRef.componentInstance.mode = "add"; @@ -92,16 +90,7 @@ export class MasterRoomComponent { this.monitoringApiService .postMasterRoomParam(filteredData) .subscribe((res) => { - const transformedData = { - buildingId: result.buildingId, - roomId: [res.data.id], - statusId: result.statusId, - }; - this.monitoringApiService - .postBatchBuilding(transformedData) - .subscribe((res) => { - this.fetchData(); - }); + this.fetchData(); }); } }, @@ -129,19 +118,9 @@ export class MasterRoomComponent { description: result.description, }; this.monitoringApiService - .putMasterRoomParam(filteredData, row.roomId) + .putMasterRoomParam(filteredData, row.id) .subscribe((res) => { - console.log(res); - const transformedData = { - buildingId: result.buildingId, - roomId: res.data.id, - statusId: result.statusId, - }; - this.monitoringApiService - .puttBuildingRoom(transformedData, row.id) - .subscribe((res) => { - this.fetchData(); - }); + this.fetchData(); }); } }, @@ -155,14 +134,19 @@ export class MasterRoomComponent { const confirmDelete = confirm("Are you sure you want to delete this item?"); if (confirmDelete) { this.monitoringApiService - .deleteHeaderDetailParam(row.roomEntity.id) - .subscribe((res) => { - this.monitoringApiService - .deleteRoomBuilding(row.id) - .subscribe((res) => { - this.fetchData(); + .deleteRoom(row.id) + .subscribe( + (res) => { + this.fetchData(); + }, + (error) => { + console.error(error); + this.toastr.error("Error", "Data sedang digunakan!", { + timeOut: 2000, + closeButton: true, }); - }); + } + ); } } } diff --git a/src/app/content/hemat-app/service/monitoring-api.service.ts b/src/app/content/hemat-app/service/monitoring-api.service.ts index 33427f9..063638e 100644 --- a/src/app/content/hemat-app/service/monitoring-api.service.ts +++ b/src/app/content/hemat-app/service/monitoring-api.service.ts @@ -102,6 +102,15 @@ export class BuildingService { return this.http.get(url, { headers }); } + getListRoomDataUnmap(): Observable { + const url = `https://kapi.absys.ninja/hemat/room/list/unmap`; + const headers = new HttpHeaders({ + "Content-Type": "application/json", + "x-api-key": "j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT", + }); + return this.http.get(url, { headers }); + } + getMasterRoomData(page: number = 1, limit: number = 100): Observable { const url = `https://kapi.absys.ninja/hemat/room?page=${page}&limit=${limit}`; const headers = new HttpHeaders({ @@ -190,6 +199,15 @@ export class BuildingService { return this.http.put(url, data, { headers }); } + deleteRoom(id: any): Observable { + const url = `https://kapi.absys.ninja/hemat/room/${id}`; + const headers = new HttpHeaders({ + "Content-Type": "application/json", + "x-api-key": "j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT", + }); + return this.http.delete(url, { headers }); + } + postBatchBuilding(data: any): Observable { const url = `https://kapi.absys.ninja/hemat/room-building/post-batch/room`; const headers = new HttpHeaders({