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

@@ -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,
});
}
);
}
}
}