From 13e5ee01d2e7fdade83e54994cf41e04394c45b0 Mon Sep 17 00:00:00 2001 From: Fuzi_fauzia Date: Fri, 12 Jul 2024 15:16:53 +0700 Subject: [PATCH] perbaikan master --- src/app/_layout/footer/footer.component.html | 2 +- .../add-edit-master-building.component.ts | 4 +- .../master-building.component.ts | 77 +++++++++++---- .../master-category.component.ts | 97 ++++++++++++------- .../master-duration-use.component.ts | 48 +++++++-- .../master-floor/master-floor.component.ts | 38 +++++++- .../master-role/master-role.component.ts | 38 +++++++- .../master-room/master-room.component.ts | 4 +- .../master-status/master-status.component.ts | 38 +++++++- .../master-type/master-type.component.ts | 40 +++++++- .../master-voltage.component.ts | 23 +++-- src/app/login/login.component.html | 2 +- 12 files changed, 322 insertions(+), 89 deletions(-) diff --git a/src/app/_layout/footer/footer.component.html b/src/app/_layout/footer/footer.component.html index 095d4ee..e23c6c8 100644 --- a/src/app/_layout/footer/footer.component.html +++ b/src/app/_layout/footer/footer.component.html @@ -13,7 +13,7 @@ href="https://allbestsistem.com/" target="_blank" style="background-color: #000000 !important;" - >Smart Building Management Systems (V@2024-07-11.03) + >Smart Building Management Systems (V@2024-07-12.01)

diff --git a/src/app/content/hemat-app/master/master-building/add-edit-master-building/add-edit-master-building.component.ts b/src/app/content/hemat-app/master/master-building/add-edit-master-building/add-edit-master-building.component.ts index d2e1f75..9f250fe 100644 --- a/src/app/content/hemat-app/master/master-building/add-edit-master-building/add-edit-master-building.component.ts +++ b/src/app/content/hemat-app/master/master-building/add-edit-master-building/add-edit-master-building.component.ts @@ -48,7 +48,7 @@ export class AddEditMasterBuildingComponent { owner: ["", Validators.required], address: ["", Validators.required], phone: ["", [Validators.required, Validators.pattern(/^[0-9]{10,15}$/)]], - kwh: ["", [Validators.required, Validators.maxLength(15), Validators.pattern(/^[0-9]{10,15}$/)]], + kwh: ["", [Validators.required, Validators.maxLength(15), Validators.pattern(/^[0-9]{2,15}$/)]], }); } @@ -61,7 +61,7 @@ export class AddEditMasterBuildingComponent { address: [this.dataRow.address, Validators.required], phone: [this.dataRow.phone, [Validators.required, Validators.pattern(/^[0-9]{10,15}$/)]], owner: [this.dataRow.owner,Validators.required], - kwh: [this.dataRow.kwh, [Validators.required, Validators.maxLength(15), Validators.pattern(/^[0-9]{10,15}$/)]], + kwh: [this.dataRow.kwh, [Validators.required, Validators.maxLength(15), Validators.pattern(/^[0-9]{2,15}$/)]], }); } diff --git a/src/app/content/hemat-app/master/master-building/master-building.component.ts b/src/app/content/hemat-app/master/master-building/master-building.component.ts index c0475da..9f8f1a7 100644 --- a/src/app/content/hemat-app/master/master-building/master-building.component.ts +++ b/src/app/content/hemat-app/master/master-building/master-building.component.ts @@ -1,16 +1,17 @@ -import { Component } from '@angular/core'; -import { AddEditMasterComponent } from '../add-edit-master/add-edit-master.component'; -import { TableApiService } from 'src/app/_services/table-api.service'; -import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; -import { Router } from '@angular/router'; -import { BuildingService } from '../../service/monitoring-api.service'; -import { AddEditMasterBuildingComponent } from './add-edit-master-building/add-edit-master-building.component'; -import { LoginService } from '../../service/login.service'; +import { Component } from "@angular/core"; +import { AddEditMasterComponent } from "../add-edit-master/add-edit-master.component"; +import { TableApiService } from "src/app/_services/table-api.service"; +import { NgbModal } from "@ng-bootstrap/ng-bootstrap"; +import { Router } from "@angular/router"; +import { BuildingService } from "../../service/monitoring-api.service"; +import { AddEditMasterBuildingComponent } from "./add-edit-master-building/add-edit-master-building.component"; +import { LoginService } from "../../service/login.service"; +import { ToastrService } from "ngx-toastr"; @Component({ - selector: 'app-master-building', - templateUrl: './master-building.component.html', - styleUrls: ['./master-building.component.css'] + selector: "app-master-building", + templateUrl: "./master-building.component.html", + styleUrls: ["./master-building.component.css"], }) export class MasterBuildingComponent { data: any; @@ -24,7 +25,8 @@ export class MasterBuildingComponent { private modalService: NgbModal, private router: Router, private monitoringApiService: BuildingService, - private authService: LoginService + private authService: LoginService, + private toastr: ToastrService ) {} ngOnInit() { @@ -74,20 +76,38 @@ export class MasterBuildingComponent { openAddMasterModal() { const modalRef = this.modalService.open(AddEditMasterBuildingComponent, { size: "lg", - backdrop: 'static', - keyboard: false + backdrop: "static", + keyboard: false, }); modalRef.componentInstance.mode = "add"; modalRef.result.then( (result) => { if (result) { - this.monitoringApiService - .postMasterBuildingParam(result) - .subscribe((res) => { - this.fetchData(); + if ( + this.filteredRows.some( + (value) => value.name.toLowerCase() === result.name.toLowerCase() + ) + ) { + this.toastr.error("Warning", "Data yang anda masukan double.", { + timeOut: 5000, + closeButton: true, }); + } else { + this.monitoringApiService + .postMasterBuildingParam(result) + .subscribe((res) => { + this.fetchData(); + }); + } } + // if (result) { + // this.monitoringApiService + // .postMasterBuildingParam(result) + // .subscribe((res) => { + // this.fetchData(); + // }); + // } }, (reason) => { console.log(`Dismissed: ${reason}`); @@ -98,8 +118,8 @@ export class MasterBuildingComponent { editRow(row) { const modalRef = this.modalService.open(AddEditMasterBuildingComponent, { size: "lg", - backdrop: 'static', - keyboard: false + backdrop: "static", + keyboard: false, }); modalRef.componentInstance.dataRow = row; @@ -107,12 +127,27 @@ export class MasterBuildingComponent { modalRef.result.then( (result) => { if (result) { - this.monitoringApiService + if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) { + this.toastr.error("Warning", "Data yang anda masukan double.", { + timeOut: 5000, + closeButton: true, + }); + } else { + this.monitoringApiService .putMasterBuildingParam(result, row.id) .subscribe((res) => { this.fetchData(); }); + } } + + // if (result) { + // this.monitoringApiService + // .putMasterBuildingParam(result, row.id) + // .subscribe((res) => { + // this.fetchData(); + // }); + // } }, (reason) => { console.log(`Dismissed: ${reason}`); diff --git a/src/app/content/hemat-app/master/master-category/master-category.component.ts b/src/app/content/hemat-app/master/master-category/master-category.component.ts index 7a00483..44b8366 100644 --- a/src/app/content/hemat-app/master/master-category/master-category.component.ts +++ b/src/app/content/hemat-app/master/master-category/master-category.component.ts @@ -29,7 +29,7 @@ export class MasterCategoryComponent implements OnInit { private router: Router, private monitoringApiService: BuildingService, private toastr: ToastrService, - private authService: LoginService + private authService: LoginService, ) {} ngOnInit() { @@ -98,23 +98,39 @@ export class MasterCategoryComponent implements OnInit { (result) => { console.log(result); if (result) { - this.monitoringApiService.postHeaderDetailParam(result).subscribe( - (res) => { + if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) { + this.toastr.error("Warning", "Data yang anda masukan double.", { + timeOut: 5000, + closeButton: true, + }); + } else { + this.monitoringApiService + .postHeaderDetailParam(result) + .subscribe((res) => { + console.log(res); this.fetchData(); - this.toastr.success("Success", "Save Completed.", { - timeOut: 2000, - closeButton: true, - }); - }, - (error) => { - console.error(error); - this.toastr.error("Error", "Something went wrong!", { - timeOut: 2000, - closeButton: true, - }); - } - ); + }); + } } + + // if (result) { + // this.monitoringApiService.postHeaderDetailParam(result).subscribe( + // (res) => { + // this.fetchData(); + // this.toastr.success("Success", "Save Completed.", { + // timeOut: 2000, + // closeButton: true, + // }); + // }, + // (error) => { + // console.error(error); + // this.toastr.error("Error", "Something went wrong!", { + // timeOut: 2000, + // closeButton: true, + // }); + // } + // ); + // } }, (reason) => { console.log(`Dismissed: ${reason}`); @@ -137,25 +153,40 @@ export class MasterCategoryComponent implements OnInit { (result) => { console.log(result); if (result) { - this.monitoringApiService + if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) { + this.toastr.error("Warning", "Data yang anda masukan double.", { + timeOut: 5000, + closeButton: true, + }); + } else { + this.monitoringApiService .putHeaderDetailParam(result, row.id) - .subscribe( - (res) => { - this.fetchData(); - this.toastr.success("Success", "Update Completed.", { - timeOut: 2000, - closeButton: true, - }); - }, - (error) => { - console.error(error); - this.toastr.error("Error", "Something went wrong!", { - timeOut: 2000, - closeButton: true, - }); - } - ); + .subscribe((res) => { + console.log(res); + this.fetchData(); + }); + } } + // if (result) { + // this.monitoringApiService + // .putHeaderDetailParam(result, row.id) + // .subscribe( + // (res) => { + // this.fetchData(); + // this.toastr.success("Success", "Update Completed.", { + // timeOut: 2000, + // closeButton: true, + // }); + // }, + // (error) => { + // console.error(error); + // this.toastr.error("Error", "Something went wrong!", { + // timeOut: 2000, + // closeButton: true, + // }); + // } + // ); + // } }, (reason) => { console.log(`Dismissed: ${reason}`); diff --git a/src/app/content/hemat-app/master/master-duration-use/master-duration-use.component.ts b/src/app/content/hemat-app/master/master-duration-use/master-duration-use.component.ts index f18cc20..21f20fe 100644 --- a/src/app/content/hemat-app/master/master-duration-use/master-duration-use.component.ts +++ b/src/app/content/hemat-app/master/master-duration-use/master-duration-use.component.ts @@ -5,6 +5,7 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { Router } from '@angular/router'; import { BuildingService } from '../../service/monitoring-api.service'; import { LoginService } from '../../service/login.service'; +import { ToastrService } from 'ngx-toastr'; @Component({ selector: 'app-master-duration-use', @@ -24,7 +25,8 @@ export class MasterDurationUseComponent { private modalService: NgbModal, private router: Router, private monitoringApiService: BuildingService, - private authService: LoginService + private authService: LoginService, + private toastr: ToastrService ) {} ngOnInit() { @@ -90,12 +92,27 @@ export class MasterDurationUseComponent { (result) => { console.log(result); if (result) { - this.monitoringApiService - .postHeaderDetailParam(result) - .subscribe((res) => { - console.log(res); - this.fetchData(); - }); + if (result) { + if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) { + this.toastr.error("Warning", "Data yang anda masukan double.", { + timeOut: 5000, + closeButton: true, + }); + } else { + this.monitoringApiService + .postHeaderDetailParam(result) + .subscribe((res) => { + console.log(res); + this.fetchData(); + }); + } + } + // this.monitoringApiService + // .postHeaderDetailParam(result) + // .subscribe((res) => { + // console.log(res); + // this.fetchData(); + // }); } }, (reason) => { @@ -118,13 +135,28 @@ export class MasterDurationUseComponent { (result) => { console.log(result); if (result) { - this.monitoringApiService + if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) { + this.toastr.error("Warning", "Data yang anda masukan double.", { + timeOut: 5000, + closeButton: true, + }); + } else { + this.monitoringApiService .putHeaderDetailParam(result, row.id) .subscribe((res) => { console.log(res); this.fetchData(); }); + } } + // if (result) { + // this.monitoringApiService + // .putHeaderDetailParam(result, row.id) + // .subscribe((res) => { + // console.log(res); + // this.fetchData(); + // }); + // } }, (reason) => { console.log(`Dismissed: ${reason}`); diff --git a/src/app/content/hemat-app/master/master-floor/master-floor.component.ts b/src/app/content/hemat-app/master/master-floor/master-floor.component.ts index fd68abf..7d8dfd4 100644 --- a/src/app/content/hemat-app/master/master-floor/master-floor.component.ts +++ b/src/app/content/hemat-app/master/master-floor/master-floor.component.ts @@ -5,6 +5,7 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { Router } from '@angular/router'; import { BuildingService } from '../../service/monitoring-api.service'; import { LoginService } from '../../service/login.service'; +import { ToastrService } from 'ngx-toastr'; @Component({ selector: 'app-master-floor', @@ -24,7 +25,8 @@ export class MasterFloorComponent { private modalService: NgbModal, private router: Router, private monitoringApiService: BuildingService, - private authService: LoginService + private authService: LoginService, + private toastr: ToastrService, ) {} ngOnInit() { @@ -90,13 +92,28 @@ export class MasterFloorComponent { (result) => { console.log(result); if (result) { - this.monitoringApiService + if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) { + this.toastr.error("Warning", "Data yang anda masukan double.", { + timeOut: 5000, + closeButton: true, + }); + } else { + this.monitoringApiService .postHeaderDetailParam(result) .subscribe((res) => { console.log(res); this.fetchData(); }); + } } + // if (result) { + // this.monitoringApiService + // .postHeaderDetailParam(result) + // .subscribe((res) => { + // console.log(res); + // this.fetchData(); + // }); + // } }, (reason) => { console.log(`Dismissed: ${reason}`); @@ -118,13 +135,28 @@ export class MasterFloorComponent { (result) => { console.log(result); if (result) { - this.monitoringApiService + if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) { + this.toastr.error("Warning", "Data yang anda masukan double.", { + timeOut: 5000, + closeButton: true, + }); + } else { + this.monitoringApiService .putHeaderDetailParam(result, row.id) .subscribe((res) => { console.log(res); this.fetchData(); }); + } } + // if (result) { + // this.monitoringApiService + // .putHeaderDetailParam(result, row.id) + // .subscribe((res) => { + // console.log(res); + // this.fetchData(); + // }); + // } }, (reason) => { console.log(`Dismissed: ${reason}`); diff --git a/src/app/content/hemat-app/master/master-role/master-role.component.ts b/src/app/content/hemat-app/master/master-role/master-role.component.ts index 75a2c6e..7082e07 100644 --- a/src/app/content/hemat-app/master/master-role/master-role.component.ts +++ b/src/app/content/hemat-app/master/master-role/master-role.component.ts @@ -5,6 +5,7 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { Router } from '@angular/router'; import { BuildingService } from '../../service/monitoring-api.service'; import { LoginService } from '../../service/login.service'; +import { ToastrService } from 'ngx-toastr'; @Component({ selector: 'app-master-role', @@ -24,7 +25,8 @@ export class MasterRoleComponent { private modalService: NgbModal, private router: Router, private monitoringApiService: BuildingService, - private authService: LoginService + private authService: LoginService, + private toastr: ToastrService, ) {} ngOnInit() { @@ -90,13 +92,28 @@ export class MasterRoleComponent { (result) => { console.log(result); if (result) { - this.monitoringApiService + if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) { + this.toastr.error("Warning", "Data yang anda masukan double.", { + timeOut: 5000, + closeButton: true, + }); + } else { + this.monitoringApiService .postHeaderDetailParam(result) .subscribe((res) => { console.log(res); this.fetchData(); }); + } } + // if (result) { + // this.monitoringApiService + // .postHeaderDetailParam(result) + // .subscribe((res) => { + // console.log(res); + // this.fetchData(); + // }); + // } }, (reason) => { console.log(`Dismissed: ${reason}`); @@ -118,13 +135,28 @@ export class MasterRoleComponent { (result) => { console.log(result); if (result) { - this.monitoringApiService + if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) { + this.toastr.error("Warning", "Data yang anda masukan double.", { + timeOut: 5000, + closeButton: true, + }); + } else { + this.monitoringApiService .putHeaderDetailParam(result, row.id) .subscribe((res) => { console.log(res); this.fetchData(); }); + } } + // if (result) { + // this.monitoringApiService + // .putHeaderDetailParam(result, row.id) + // .subscribe((res) => { + // console.log(res); + // this.fetchData(); + // }); + // } }, (reason) => { console.log(`Dismissed: ${reason}`); diff --git a/src/app/content/hemat-app/master/master-room/master-room.component.ts b/src/app/content/hemat-app/master/master-room/master-room.component.ts index 907dd21..ca7be15 100644 --- a/src/app/content/hemat-app/master/master-room/master-room.component.ts +++ b/src/app/content/hemat-app/master/master-room/master-room.component.ts @@ -5,6 +5,7 @@ import { NgbModal } from "@ng-bootstrap/ng-bootstrap"; import { Router } from "@angular/router"; import { BuildingService } from "../../service/monitoring-api.service"; import { LoginService } from "../../service/login.service"; +import { ToastrService } from "ngx-toastr"; @Component({ selector: "app-master-room", @@ -21,7 +22,8 @@ export class MasterRoomComponent { constructor( private modalService: NgbModal, private monitoringApiService: BuildingService, - private authService: LoginService + private authService: LoginService, + private toastr: ToastrService, ) {} ngOnInit() { diff --git a/src/app/content/hemat-app/master/master-status/master-status.component.ts b/src/app/content/hemat-app/master/master-status/master-status.component.ts index 6ddb73c..e95fe85 100644 --- a/src/app/content/hemat-app/master/master-status/master-status.component.ts +++ b/src/app/content/hemat-app/master/master-status/master-status.component.ts @@ -5,6 +5,7 @@ import { TableApiService } from 'src/app/_services/table-api.service'; import { BuildingService } from '../../service/monitoring-api.service'; import { AddEditMasterComponent } from '../add-edit-master/add-edit-master.component'; import { LoginService } from '../../service/login.service'; +import { ToastrService } from 'ngx-toastr'; @Component({ selector: 'app-master-status', @@ -24,7 +25,8 @@ export class MasterStatusComponent { private modalService: NgbModal, private router: Router, private monitoringApiService: BuildingService, - private authService: LoginService + private authService: LoginService, + private toastr: ToastrService, ) {} ngOnInit() { @@ -90,13 +92,28 @@ export class MasterStatusComponent { (result) => { console.log(result); if (result) { - this.monitoringApiService + if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) { + this.toastr.error("Warning", "Data yang anda masukan double.", { + timeOut: 5000, + closeButton: true, + }); + } else { + this.monitoringApiService .postHeaderDetailParam(result) .subscribe((res) => { console.log(res); this.fetchData(); }); + } } + // if (result) { + // this.monitoringApiService + // .postHeaderDetailParam(result) + // .subscribe((res) => { + // console.log(res); + // this.fetchData(); + // }); + // } }, (reason) => { console.log(`Dismissed: ${reason}`); @@ -118,13 +135,28 @@ export class MasterStatusComponent { (result) => { console.log(result); if (result) { - this.monitoringApiService + if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) { + this.toastr.error("Warning", "Data yang anda masukan double.", { + timeOut: 5000, + closeButton: true, + }); + } else { + this.monitoringApiService .putHeaderDetailParam(result, row.id) .subscribe((res) => { console.log(res); this.fetchData(); }); + } } + // if (result) { + // this.monitoringApiService + // .putHeaderDetailParam(result, row.id) + // .subscribe((res) => { + // console.log(res); + // this.fetchData(); + // }); + // } }, (reason) => { console.log(`Dismissed: ${reason}`); diff --git a/src/app/content/hemat-app/master/master-type/master-type.component.ts b/src/app/content/hemat-app/master/master-type/master-type.component.ts index 8af4853..d76de90 100644 --- a/src/app/content/hemat-app/master/master-type/master-type.component.ts +++ b/src/app/content/hemat-app/master/master-type/master-type.component.ts @@ -5,6 +5,7 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { Router } from '@angular/router'; import { BuildingService } from '../../service/monitoring-api.service'; import { LoginService } from '../../service/login.service'; +import { ToastrService } from 'ngx-toastr'; @Component({ selector: 'app-master-type', @@ -24,7 +25,8 @@ export class MasterTypeComponent { private modalService: NgbModal, private router: Router, private monitoringApiService: BuildingService, - private authService: LoginService + private authService: LoginService, + private toastr: ToastrService ) {} ngOnInit() { @@ -88,15 +90,29 @@ export class MasterTypeComponent { modalRef.componentInstance.mode = "add"; modalRef.result.then( (result) => { - console.log(result); if (result) { - this.monitoringApiService + if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) { + this.toastr.error("Warning", "Data yang anda masukan double.", { + timeOut: 5000, + closeButton: true, + }); + } else { + this.monitoringApiService .postHeaderDetailParam(result) .subscribe((res) => { console.log(res); this.fetchData(); }); + } } + // if (result) { + // this.monitoringApiService + // .postHeaderDetailParam(result) + // .subscribe((res) => { + // console.log(res); + // this.fetchData(); + // }); + // } }, (reason) => { console.log(`Dismissed: ${reason}`); @@ -116,15 +132,29 @@ export class MasterTypeComponent { modalRef.componentInstance.mode = "edit"; modalRef.result.then( (result) => { - console.log(result); if (result) { - this.monitoringApiService + if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) { + this.toastr.error("Warning", "Data yang anda masukan double.", { + timeOut: 5000, + closeButton: true, + }); + } else { + this.monitoringApiService .putHeaderDetailParam(result, row.id) .subscribe((res) => { console.log(res); this.fetchData(); }); + } } + // if (result) { + // this.monitoringApiService + // .putHeaderDetailParam(result, row.id) + // .subscribe((res) => { + // console.log(res); + // this.fetchData(); + // }); + // } }, (reason) => { console.log(`Dismissed: ${reason}`); diff --git a/src/app/content/hemat-app/master/master-voltage/master-voltage.component.ts b/src/app/content/hemat-app/master/master-voltage/master-voltage.component.ts index fe70cd3..a821e7a 100644 --- a/src/app/content/hemat-app/master/master-voltage/master-voltage.component.ts +++ b/src/app/content/hemat-app/master/master-voltage/master-voltage.component.ts @@ -125,14 +125,21 @@ export class MasterVoltageComponent { modalRef.result.then( (result) => { console.log(result); - // if (result) { - // this.monitoringApiService - // .putHeaderDetailParam(result, row.id) - // .subscribe((res) => { - // console.log(res); - // this.fetchData(); - // }); - // } + if (result) { + if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) { + this.toastr.error("Warning", "Data yang anda masukan double.", { + timeOut: 5000, + closeButton: true, + }); + } else { + this.monitoringApiService + .putHeaderDetailParam(result, row.id) + .subscribe((res) => { + console.log(res); + this.fetchData(); + }); + } + } }, (reason) => { console.log(`Dismissed: ${reason}`); diff --git a/src/app/login/login.component.html b/src/app/login/login.component.html index 2e46b47..3eb237f 100644 --- a/src/app/login/login.component.html +++ b/src/app/login/login.component.html @@ -138,7 +138,7 @@

- (v@2024.07.11.03) + (v@2024.07.12.01)