perbaikan master dan ngecek token jika ada kegiatan

This commit is contained in:
2024-07-16 11:39:44 +07:00
parent 751c36209e
commit dd1deb0812
10 changed files with 501 additions and 240 deletions

View File

@@ -86,7 +86,7 @@ export class MasterBuildingComponent {
if (result) {
if (
this.filteredRows.some(
(value) => value.name.toLowerCase() === result.name.toLowerCase()
(value) => value.name.trim().toLowerCase() === result.name.trim().toLowerCase()
)
) {
this.toastr.error("Warning", "Data yang anda masukan double.", {
@@ -127,23 +127,57 @@ export class MasterBuildingComponent {
modalRef.result.then(
(result) => {
if (result) {
console.log(result);
console.log(this.filteredRows);
if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase() && value.status_id === result.statusId)) {
this.toastr.error("Warning", "Nama Gedung yang anda masukan double.", {
timeOut: 5000,
closeButton: true,
});
if (
this.filteredRows.some(
(value) => value.name.trim().toLowerCase() === result.name.trim().toLowerCase()
)
) {
if (row.name.trim().toLowerCase() === result.name.trim().toLowerCase()) {
this.monitoringApiService
.putMasterBuildingParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
} else {
if (
this.filteredRows.some(
(value) =>
value.name.trim().toLowerCase() === result.name.trim().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();
});
.putMasterBuildingParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
}
}
// if (result) {
// console.log(result);
// console.log(this.filteredRows);
// if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase() && value.status_id === result.statusId)) {
// this.toastr.error("Warning", "Nama Gedung 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)
@@ -165,6 +199,12 @@ export class MasterBuildingComponent {
.deleteMasterBuildingParam(row.id)
.subscribe((res) => {
this.fetchData();
}, (error) => {
console.error(error);
this.toastr.error("Error", "Data sedang digunakan!", {
timeOut: 2000,
closeButton: true,
});
});
}
}

View File

@@ -29,11 +29,13 @@ export class MasterCategoryComponent implements OnInit {
private router: Router,
private monitoringApiService: BuildingService,
private toastr: ToastrService,
private authService: LoginService,
private authService: LoginService
) {}
ngOnInit() {
this.authService.checkTokenAndRedirect();
// this.authService.checkTokenAndRedirect();
this.authService.startTokenCheck();
this.authService.startTrackingActivity();
this.breadcrumb = {
mainlabel: "Master Category",
links: [
@@ -57,7 +59,9 @@ export class MasterCategoryComponent implements OnInit {
(item) => item.name === "master_category"
);
// this.filteredRows = this.dataMasterCategori.headerDetailParam;
this.filteredRows = this.dataMasterCategori.headerDetailParam.sort((a, b) => b.id - a.id);
this.filteredRows = this.dataMasterCategori.headerDetailParam.sort(
(a, b) => b.id - a.id
);
});
}
@@ -77,7 +81,7 @@ export class MasterCategoryComponent implements OnInit {
rowContainsSearchTerm(row: any): boolean {
const searchTermLC = this.searchTerm.toLowerCase();
console.log(searchTermLC);
return Object.values(row).some(
(value) =>
value !== null && value.toString().toLowerCase().includes(searchTermLC)
@@ -87,8 +91,8 @@ export class MasterCategoryComponent implements OnInit {
openAddMasterModal() {
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
backdrop: 'static', // Add this line
keyboard: false // Add this line
backdrop: "static", // Add this line
keyboard: false, // Add this line
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
@@ -96,41 +100,25 @@ export class MasterCategoryComponent implements OnInit {
modalRef.componentInstance.category = true;
modalRef.result.then(
(result) => {
console.log(result);
if (result) {
if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) {
if (
this.filteredRows.some(
(value) => value.name.trim().toLowerCase() === result.name.trim().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();
});
.postHeaderDetailParam(result)
.subscribe((res) => {
console.log(res);
this.fetchData();
});
}
}
// 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}`);
@@ -139,10 +127,12 @@ export class MasterCategoryComponent implements OnInit {
}
editRow(row) {
console.log(row);
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
backdrop: 'static', // Add this line
keyboard: false // Add this line
backdrop: "static",
keyboard: false,
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
@@ -151,42 +141,39 @@ export class MasterCategoryComponent implements OnInit {
modalRef.componentInstance.category = true;
modalRef.result.then(
(result) => {
console.log(result);
if (result) {
if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase() && value.status === result.status)) {
this.toastr.error("Warning", "Data yang anda masukan double.", {
timeOut: 5000,
closeButton: true,
});
if (
this.filteredRows.some(
(value) => value.name.trim().toLowerCase() === result.name.trim().toLowerCase()
)
) {
if (row.name.trim().toLowerCase() === result.name.trim().toLowerCase()) {
this.monitoringApiService
.putHeaderDetailParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
} else {
if (
this.filteredRows.some(
(value) =>
value.name.trim().toLowerCase() === result.name.trim().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();
});
.putHeaderDetailParam(result, row.id)
.subscribe((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}`);
@@ -207,7 +194,7 @@ export class MasterCategoryComponent implements OnInit {
},
(error) => {
console.error(error);
this.toastr.error("Error", "Something went wrong!", {
this.toastr.error("Error", "Data sedang digunakan!", {
timeOut: 2000,
closeButton: true,
});

View File

@@ -30,7 +30,9 @@ export class MasterDurationUseComponent {
) {}
ngOnInit() {
this.authService.checkTokenAndRedirect();
// this.authService.checkTokenAndRedirect();
this.authService.startTokenCheck();
this.authService.startTrackingActivity();
this.breadcrumb = {
mainlabel: "Master Duration Use",
links: [
@@ -93,7 +95,7 @@ export class MasterDurationUseComponent {
console.log(result);
if (result) {
if (result) {
if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) {
if (this.filteredRows.some(value => value.name.trim().toLowerCase() === result.name.trim().toLowerCase())) {
this.toastr.error("Warning", "Data yang anda masukan double.", {
timeOut: 5000,
closeButton: true,
@@ -133,30 +135,39 @@ export class MasterDurationUseComponent {
modalRef.componentInstance.mode = "edit";
modalRef.result.then(
(result) => {
console.log(result);
if (result) {
if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase() && value.status === result.status)) {
this.toastr.error("Warning", "Data yang anda masukan double.", {
timeOut: 5000,
closeButton: true,
});
if (
this.filteredRows.some(
(value) => value.name.trim().toLowerCase() === result.name.trim().toLowerCase()
)
) {
if (row.name.trim().toLowerCase() === result.name.trim().toLowerCase()) {
this.monitoringApiService
.putHeaderDetailParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
} else {
if (
this.filteredRows.some(
(value) =>
value.name.trim().toLowerCase() === result.name.trim().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();
});
.putHeaderDetailParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
}
}
// if (result) {
// this.monitoringApiService
// .putHeaderDetailParam(result, row.id)
// .subscribe((res) => {
// console.log(res);
// this.fetchData();
// });
// }
},
(reason) => {
console.log(`Dismissed: ${reason}`);
@@ -167,11 +178,22 @@ export class MasterDurationUseComponent {
deleteRow(row) {
const confirmDelete = confirm("Are you sure you want to delete this item?");
if (confirmDelete) {
this.monitoringApiService
.deleteHeaderDetailParam(row.id)
.subscribe((res) => {
this.monitoringApiService.deleteHeaderDetailParam(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,
});
}
);
}
}
}

View File

@@ -133,30 +133,39 @@ export class MasterFloorComponent {
modalRef.componentInstance.mode = "edit";
modalRef.result.then(
(result) => {
console.log(result);
if (result) {
if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase() && value.status === result.status)) {
this.toastr.error("Warning", "Data yang anda masukan double.", {
timeOut: 5000,
closeButton: true,
});
if (
this.filteredRows.some(
(value) => value.name.trim().toLowerCase() === result.name.trim().toLowerCase()
)
) {
if (row.name.trim().toLowerCase() === result.name.trim().toLowerCase()) {
this.monitoringApiService
.putHeaderDetailParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
} else {
if (
this.filteredRows.some(
(value) =>
value.name.trim().toLowerCase() === result.name.trim().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();
});
.putHeaderDetailParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
}
}
// if (result) {
// this.monitoringApiService
// .putHeaderDetailParam(result, row.id)
// .subscribe((res) => {
// console.log(res);
// this.fetchData();
// });
// }
},
(reason) => {
console.log(`Dismissed: ${reason}`);
@@ -167,11 +176,22 @@ export class MasterFloorComponent {
deleteRow(row) {
const confirmDelete = confirm("Are you sure you want to delete this item?");
if (confirmDelete) {
this.monitoringApiService
.deleteHeaderDetailParam(row.id)
.subscribe((res) => {
this.monitoringApiService.deleteHeaderDetailParam(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,
});
}
);
}
}
}

View File

@@ -92,7 +92,7 @@ export class MasterRoleComponent {
(result) => {
console.log(result);
if (result) {
if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) {
if (this.filteredRows.some(value => value.name.trim().toLowerCase() === result.name.trim().toLowerCase())) {
this.toastr.error("Warning", "Data yang anda masukan double.", {
timeOut: 5000,
closeButton: true,
@@ -133,30 +133,39 @@ export class MasterRoleComponent {
modalRef.componentInstance.mode = "edit";
modalRef.result.then(
(result) => {
console.log(result);
if (result) {
if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase() && value.status === result.status)) {
this.toastr.error("Warning", "Data yang anda masukan double.", {
timeOut: 5000,
closeButton: true,
});
if (
this.filteredRows.some(
(value) => value.name.trim().toLowerCase() === result.name.trim().toLowerCase()
)
) {
if (row.name.trim().toLowerCase() === result.name.trim().toLowerCase()) {
this.monitoringApiService
.putHeaderDetailParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
} else {
if (
this.filteredRows.some(
(value) =>
value.name.trim().toLowerCase() === result.name.trim().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();
});
.putHeaderDetailParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
}
}
// if (result) {
// this.monitoringApiService
// .putHeaderDetailParam(result, row.id)
// .subscribe((res) => {
// console.log(res);
// this.fetchData();
// });
// }
},
(reason) => {
console.log(`Dismissed: ${reason}`);
@@ -167,11 +176,22 @@ export class MasterRoleComponent {
deleteRow(row) {
const confirmDelete = confirm("Are you sure you want to delete this item?");
if (confirmDelete) {
this.monitoringApiService
.deleteHeaderDetailParam(row.id)
.subscribe((res) => {
this.monitoringApiService.deleteHeaderDetailParam(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,
});
}
);
}
}
}

View File

@@ -92,7 +92,7 @@ export class MasterStatusComponent {
(result) => {
console.log(result);
if (result) {
if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) {
if (this.filteredRows.some(value => value.name.trim().toLowerCase() === result.name.trim().toLowerCase())) {
this.toastr.error("Warning", "Data yang anda masukan double.", {
timeOut: 5000,
closeButton: true,
@@ -133,30 +133,39 @@ export class MasterStatusComponent {
modalRef.componentInstance.mode = "edit";
modalRef.result.then(
(result) => {
console.log(result);
if (result) {
if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase() && value.status === result.status)) {
this.toastr.error("Warning", "Data yang anda masukan double.", {
timeOut: 5000,
closeButton: true,
});
if (
this.filteredRows.some(
(value) => value.name.trim().toLowerCase() === result.name.trim().toLowerCase()
)
) {
if (row.name.trim().toLowerCase() === result.name.trim().toLowerCase()) {
this.monitoringApiService
.putHeaderDetailParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
} else {
if (
this.filteredRows.some(
(value) =>
value.name.trim().toLowerCase() === result.name.trim().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();
});
.putHeaderDetailParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
}
}
// if (result) {
// this.monitoringApiService
// .putHeaderDetailParam(result, row.id)
// .subscribe((res) => {
// console.log(res);
// this.fetchData();
// });
// }
},
(reason) => {
console.log(`Dismissed: ${reason}`);
@@ -167,11 +176,22 @@ export class MasterStatusComponent {
deleteRow(row) {
const confirmDelete = confirm("Are you sure you want to delete this item?");
if (confirmDelete) {
this.monitoringApiService
.deleteHeaderDetailParam(row.id)
.subscribe((res) => {
this.monitoringApiService.deleteHeaderDetailParam(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,
});
}
);
}
}
}

View File

@@ -91,7 +91,7 @@ export class MasterTypeComponent {
modalRef.result.then(
(result) => {
if (result) {
if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase() && value.status === result.status)) {
if (this.filteredRows.some(value => value.name.trim().toLowerCase() === result.name.trim().toLowerCase() && value.status === result.status)) {
this.toastr.error("Warning", "Data yang anda masukan double.", {
timeOut: 5000,
closeButton: true,
@@ -133,28 +133,38 @@ export class MasterTypeComponent {
modalRef.result.then(
(result) => {
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,
});
if (
this.filteredRows.some(
(value) => value.name.trim().toLowerCase() === result.name.trim().toLowerCase()
)
) {
if (row.name.trim().toLowerCase() === result.name.trim().toLowerCase()) {
this.monitoringApiService
.putHeaderDetailParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
} else {
if (
this.filteredRows.some(
(value) =>
value.name.trim().toLowerCase() === result.name.trim().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();
});
.putHeaderDetailParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
}
}
// if (result) {
// this.monitoringApiService
// .putHeaderDetailParam(result, row.id)
// .subscribe((res) => {
// console.log(res);
// this.fetchData();
// });
// }
},
(reason) => {
console.log(`Dismissed: ${reason}`);
@@ -165,11 +175,22 @@ export class MasterTypeComponent {
deleteRow(row) {
const confirmDelete = confirm("Are you sure you want to delete this item?");
if (confirmDelete) {
this.monitoringApiService
.deleteHeaderDetailParam(row.id)
.subscribe((res) => {
this.monitoringApiService.deleteHeaderDetailParam(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,
});
}
);
}
}
}

View File

@@ -91,7 +91,7 @@ export class MasterVoltageComponent {
modalRef.result.then(
(result) => {
if (result) {
if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) {
if (this.filteredRows.some(value => value.name.trim().toLowerCase() === result.name.trim().toLowerCase())) {
this.toastr.error("Warning", "Data yang anda masukan double.", {
timeOut: 5000,
closeButton: true,
@@ -124,20 +124,37 @@ export class MasterVoltageComponent {
modalRef.componentInstance.mode = "edit";
modalRef.result.then(
(result) => {
console.log(result);
if (result) {
if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase() && value.status === result.status) ) {
this.toastr.error("Warning", "Data yang anda masukan double.", {
timeOut: 5000,
closeButton: true,
});
if (
this.filteredRows.some(
(value) => value.name.trim().toLowerCase() === result.name.trim().toLowerCase()
)
) {
if (row.name.trim().toLowerCase() === result.name.trim().toLowerCase()) {
this.monitoringApiService
.putHeaderDetailParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
} else {
if (
this.filteredRows.some(
(value) =>
value.name.trim().toLowerCase() === result.name.trim().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();
});
.putHeaderDetailParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
}
}
},
@@ -150,11 +167,22 @@ export class MasterVoltageComponent {
deleteRow(row) {
const confirmDelete = confirm("Are you sure you want to delete this item?");
if (confirmDelete) {
this.monitoringApiService
.deleteHeaderDetailParam(row.id)
.subscribe((res) => {
this.monitoringApiService.deleteHeaderDetailParam(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,
});
}
);
}
}
}