fix search filter on page big data resume
This commit is contained in:
@@ -17,13 +17,14 @@ sudo nano /etc/supervisor/conf.d/laravel-worker.conf
|
|||||||
|
|
||||||
[program:laravel-worker]
|
[program:laravel-worker]
|
||||||
process_name=%(program_name)s_%(process_num)02d
|
process_name=%(program_name)s_%(process_num)02d
|
||||||
command=php /path-to-your-project/artisan queue:work --tries=3 --timeout=600
|
command=php /home/arifal/development/sibedas-pbg-web/artisan queue:work --queue=default --timeout=14400 --tries=1 --sleep=3
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
numprocs=1
|
numprocs=4
|
||||||
user=www-data
|
|
||||||
redirect_stderr=true
|
redirect_stderr=true
|
||||||
stdout_logfile=/var/log/supervisor/laravel-worker.log
|
stdout_logfile=/home/arifal/development/sibedas-pbg-web/storage/logs/worker.log
|
||||||
|
stopasgroup=true
|
||||||
|
killasgroup=true
|
||||||
```
|
```
|
||||||
|
|
||||||
- Reload Supervisor
|
- Reload Supervisor
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ class BigDataResumeController extends Controller
|
|||||||
$query = BigdataResume::query()->orderBy('id', 'desc');
|
$query = BigdataResume::query()->orderBy('id', 'desc');
|
||||||
|
|
||||||
if($request->filled('search')){
|
if($request->filled('search')){
|
||||||
$query->where('name', 'LIKE', '%'.$request->input('search').'%');
|
$query->where('year', 'LIKE', '%'.$request->input('search').'%');
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $query->paginate(config('app.paginate_per_page', 50));
|
$query = $query->paginate(config('app.paginate_per_page', 50));
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { Grid } from "gridjs/dist/gridjs.umd.js";
|
|||||||
import gridjs from "gridjs/dist/gridjs.umd.js";
|
import gridjs from "gridjs/dist/gridjs.umd.js";
|
||||||
import "gridjs/dist/gridjs.umd.js";
|
import "gridjs/dist/gridjs.umd.js";
|
||||||
import GlobalConfig, { addThousandSeparators } from "../global-config.js";
|
import GlobalConfig, { addThousandSeparators } from "../global-config.js";
|
||||||
import Swal from "sweetalert2";
|
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
|
||||||
class BigdataResume {
|
class BigdataResume {
|
||||||
@@ -13,23 +12,16 @@ class BigdataResume {
|
|||||||
this.table = null;
|
this.table = null;
|
||||||
|
|
||||||
// Initialize functions
|
// Initialize functions
|
||||||
this.initTableDataSettings();
|
this.initEvents();
|
||||||
// this.initEvents();
|
|
||||||
}
|
}
|
||||||
initEvents() {
|
async initEvents() {
|
||||||
document.body.addEventListener("click", async (event) => {
|
await this.initBigdataResumeTable();
|
||||||
const deleteButton = event.target.closest(
|
this.handleSearch();
|
||||||
".btn-delete-data-settings"
|
|
||||||
);
|
|
||||||
if (deleteButton) {
|
|
||||||
event.preventDefault();
|
|
||||||
await this.handleDelete(deleteButton);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
initTableDataSettings() {
|
async initBigdataResumeTable() {
|
||||||
let tableContainer = document.getElementById("table-bigdata-resumes");
|
let tableContainer = document.getElementById("table-bigdata-resumes");
|
||||||
|
|
||||||
this.table = new Grid({
|
this.table = new Grid({
|
||||||
columns: [
|
columns: [
|
||||||
{ name: "ID" },
|
{ name: "ID" },
|
||||||
@@ -53,7 +45,9 @@ class BigdataResume {
|
|||||||
{ name: "Total Proses Dinas Teknis" },
|
{ name: "Total Proses Dinas Teknis" },
|
||||||
{
|
{
|
||||||
name: "Created",
|
name: "Created",
|
||||||
attributes: { style: "width: 200px; white-space: nowrap;" }, // Set width dynamically
|
attributes: {
|
||||||
|
style: "width: 200px; white-space: nowrap;",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
pagination: {
|
pagination: {
|
||||||
@@ -66,11 +60,6 @@ class BigdataResume {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
sort: true,
|
sort: true,
|
||||||
// search: {
|
|
||||||
// server: {
|
|
||||||
// url: (prev, keyword) => `${prev}?search=${keyword}`,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
server: {
|
server: {
|
||||||
url: `${GlobalConfig.apiHost}/api/bigdata-report`,
|
url: `${GlobalConfig.apiHost}/api/bigdata-report`,
|
||||||
headers: {
|
headers: {
|
||||||
@@ -110,61 +99,71 @@ class BigdataResume {
|
|||||||
total: (data) => data.total,
|
total: (data) => data.total,
|
||||||
},
|
},
|
||||||
width: "auto",
|
width: "auto",
|
||||||
}).render(tableContainer);
|
|
||||||
}
|
|
||||||
handleSearch() {}
|
|
||||||
async handleDelete(deleteButton) {
|
|
||||||
const id = deleteButton.getAttribute("data-id");
|
|
||||||
|
|
||||||
const result = await Swal.fire({
|
|
||||||
title: "Are you sure?",
|
|
||||||
text: "You won't be able to revert this!",
|
|
||||||
icon: "warning",
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonColor: "#3085d6",
|
|
||||||
cancelButtonColor: "#d33",
|
|
||||||
confirmButtonText: "Yes, delete it!",
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.isConfirmed) {
|
return new Promise((resolve) => {
|
||||||
try {
|
this.table.render(tableContainer);
|
||||||
let response = await fetch(
|
this.table.on("ready", resolve); // Tunggu event "ready"
|
||||||
`${GlobalConfig.apiHost}/api/data-settings/${id}`,
|
});
|
||||||
{
|
}
|
||||||
method: "DELETE",
|
|
||||||
credentials: "include",
|
handleSearch() {
|
||||||
|
document.getElementById("search-btn").addEventListener("click", () => {
|
||||||
|
let searchValue = document.getElementById("search-box").value;
|
||||||
|
|
||||||
|
if (!this.table) {
|
||||||
|
// Ensure table is initialized
|
||||||
|
console.error("Table element not found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.table
|
||||||
|
.updateConfig({
|
||||||
|
server: {
|
||||||
|
url: `${GlobalConfig.apiHost}/api/bigdata-report?search=${searchValue}`,
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${document
|
Authorization: `Bearer ${document
|
||||||
.querySelector('meta[name="api-token"]')
|
.querySelector('meta[name="api-token"]')
|
||||||
.getAttribute("content")}`,
|
.getAttribute("content")}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
}
|
then: (data) => {
|
||||||
);
|
return data.data.map((item) => [
|
||||||
|
item.id,
|
||||||
if (response.ok) {
|
item.potention_count,
|
||||||
let result = await response.json();
|
addThousandSeparators(item.potention_sum),
|
||||||
this.toastMessage.innerText =
|
item.non_verified_count,
|
||||||
result.message || "Deleted successfully!";
|
addThousandSeparators(item.non_verified_sum),
|
||||||
this.toast.show();
|
item.verified_count,
|
||||||
|
addThousandSeparators(item.verified_sum),
|
||||||
// Refresh Grid.js table
|
item.business_count,
|
||||||
if (typeof this.table !== "undefined") {
|
addThousandSeparators(item.business_sum),
|
||||||
this.table.updateConfig({}).forceRender();
|
item.non_business_count,
|
||||||
}
|
addThousandSeparators(item.non_business_sum),
|
||||||
} else {
|
item.spatial_count,
|
||||||
let error = await response.json();
|
addThousandSeparators(item.spatial_sum),
|
||||||
console.error("Delete failed:", error);
|
item.waiting_click_dpmptsp_count,
|
||||||
this.toastMessage.innerText =
|
addThousandSeparators(
|
||||||
error.message || "Delete failed!";
|
item.waiting_click_dpmptsp_sum
|
||||||
this.toast.show();
|
),
|
||||||
}
|
item.issuance_realization_pbg_count,
|
||||||
} catch (error) {
|
addThousandSeparators(
|
||||||
console.error("Error deleting item:", error);
|
item.issuance_realization_pbg_sum
|
||||||
this.toastMessage.innerText = "An error occurred!";
|
),
|
||||||
this.toast.show();
|
item.process_in_technical_office_count,
|
||||||
}
|
addThousandSeparators(
|
||||||
}
|
item.process_in_technical_office_sum
|
||||||
|
),
|
||||||
|
moment(item.created_at).format(
|
||||||
|
"YYYY-MM-DD H:mm:ss"
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
total: (data) => data.total,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.forceRender();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
document.addEventListener("DOMContentLoaded", function (e) {
|
document.addEventListener("DOMContentLoaded", function (e) {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="card w-100 h-100">
|
<div class="card w-100 h-100">
|
||||||
<div class="card-header d-flex align-items-center">
|
<div class="card-header d-flex align-items-center">
|
||||||
<input type="text" class="form-control me-2 w-auto" />
|
<input type="text" class="form-control me-2 w-auto" id="search-box" />
|
||||||
<button id="search-btn" class="btn btn-md btn-info text-white">Cari</button>
|
<button id="search-btn" class="btn btn-md btn-info text-white">Cari</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|||||||
Reference in New Issue
Block a user