fix handle token login when loop and fix width column on task fix color default danger success scss, fix add timeout on php.ini, add scraping for execute from api, add check api for handle disabled button sync
This commit is contained in:
@@ -37,7 +37,9 @@ class UsersTable {
|
||||
url: `${GlobalConfig.apiHost}/api/users`,
|
||||
credentials: "include",
|
||||
headers: {
|
||||
Authorization: `Bearer ${localStorage.getItem("token")}`,
|
||||
Authorization: `Bearer ${document
|
||||
.querySelector('meta[name="api-token"]')
|
||||
.getAttribute("content")}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
then: (data) =>
|
||||
|
||||
@@ -11,15 +11,15 @@ class RequestAssignment {
|
||||
new Grid({
|
||||
columns: [
|
||||
"ID",
|
||||
"Name",
|
||||
"Condition",
|
||||
{name: "Name", width: "15%"},
|
||||
{name: "Condition", width: "7%"},
|
||||
"Registration Number",
|
||||
"Document Number",
|
||||
"Address",
|
||||
{name: "Address", width: "30%"},
|
||||
"Status",
|
||||
"Function Type",
|
||||
"Consultation Type",
|
||||
"Due Date",
|
||||
{name: "Due Date", width: "7%"},
|
||||
],
|
||||
search: {
|
||||
server: {
|
||||
@@ -40,7 +40,9 @@ class RequestAssignment {
|
||||
url: `${GlobalConfig.apiHost}/api/request-assignments`,
|
||||
credentials: "include",
|
||||
headers: {
|
||||
Authorization: `Bearer ${localStorage.getItem("token")}`,
|
||||
Authorization: `Bearer ${document
|
||||
.querySelector('meta[name="api-token"]')
|
||||
.getAttribute("content")}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
then: (data) =>
|
||||
|
||||
@@ -22,8 +22,8 @@ class SyncronizeTask {
|
||||
console.log("cell data", cell);
|
||||
return gridjs.html(`
|
||||
<div class="d-flex justify-items-end gap-10">
|
||||
<a href="/settings/general/${cell}/edit" class="btn btn-warning me-2">Update</a>
|
||||
<button class="btn btn-delete btn-delete-global-settings" data-id="${cell}">Delete</button>
|
||||
<a href="/settings/general/${cell}/edit" class="btn btn-yellow me-2">Update</a>
|
||||
<button class="btn btn-red btn-delete btn-delete-global-settings" data-id="${cell}">Delete</button>
|
||||
</div>
|
||||
`);
|
||||
},
|
||||
|
||||
@@ -6,7 +6,7 @@ import GlobalConfig from "../../global-config.js";
|
||||
class SyncronizeTask {
|
||||
init() {
|
||||
this.initTableImportDatasources();
|
||||
this.onSyncSubmit();
|
||||
this.handleSubmitSync();
|
||||
}
|
||||
initTableImportDatasources() {
|
||||
new Grid({
|
||||
@@ -46,20 +46,71 @@ class SyncronizeTask {
|
||||
},
|
||||
}).render(document.getElementById("table-import-datasources"));
|
||||
}
|
||||
onSyncSubmit() {
|
||||
const form = document.getElementById("sync-form");
|
||||
if (form) {
|
||||
form.addEventListener("submit", function (event) {
|
||||
event.preventDefault(); // Prevent the default form submission
|
||||
|
||||
const button = document.getElementById("btn-sync-submit");
|
||||
if (button) {
|
||||
button.disabled = true;
|
||||
button.innerText = "Processing...";
|
||||
}
|
||||
form.submit();
|
||||
});
|
||||
}
|
||||
handleSubmitSync() {
|
||||
const button = document.getElementById("btn-sync-submit");
|
||||
|
||||
// Check if the button should be enabled or disabled based on the status
|
||||
fetch(`${GlobalConfig.apiHost}/api/import-datasource/check-datasource`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${document
|
||||
.querySelector('meta[name="api-token"]')
|
||||
.getAttribute("content")}`,
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error("Network response was not ok");
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
console.log("data check button sync", data.can_execute);
|
||||
button.disabled = !data.can_execute;
|
||||
|
||||
// If the button is enabled, add click event to trigger sync
|
||||
if (!button.disabled) {
|
||||
button.addEventListener("click", function(e) {
|
||||
button.disabled = true; // Disable button to prevent multiple clicks
|
||||
button.textContent = "Syncing..."; // Change button text to show syncing
|
||||
|
||||
// Trigger the scraping API call
|
||||
fetch(`${GlobalConfig.apiHost}/api/scraping`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${document
|
||||
.querySelector('meta[name="api-token"]')
|
||||
.getAttribute("content")}`,
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error("Network response was not ok");
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
console.log("data sync button", data);
|
||||
alert("Synchronization executed successfully");
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(err => {
|
||||
console.error("Fetch error:", err);
|
||||
alert("An error occurred during synchronization");
|
||||
})
|
||||
.finally(() => {
|
||||
button.disabled = false; // Re-enable the button after the request is complete
|
||||
button.textContent = "Sync Data"; // Reset button text
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error("Fetch error:", err);
|
||||
alert("An error occurred while checking the datasource");
|
||||
});
|
||||
}
|
||||
}
|
||||
document.addEventListener("DOMContentLoaded", function (e) {
|
||||
|
||||
@@ -64,10 +64,10 @@ $blue: #1a80f8;
|
||||
$indigo: #53389f;
|
||||
$purple: #7e67fe;
|
||||
$pink: #ff86c8;
|
||||
$red: #ed321f;
|
||||
$red: #bd1300;
|
||||
$orange: #f0934e;
|
||||
$yellow: #fb9f68;
|
||||
$green: #21d760;
|
||||
$yellow: #dfdc40;
|
||||
$green: #00c91b;
|
||||
$teal: #040505;
|
||||
$cyan: #1ab0f8;
|
||||
// scss-docs-end color-variables
|
||||
@@ -81,7 +81,7 @@ $purple: $purple;
|
||||
$pink: $pink;
|
||||
$danger: $red;
|
||||
$orange: $orange;
|
||||
$warning: $orange;
|
||||
$warning: $yellow;
|
||||
$success: $green;
|
||||
$info: $cyan;
|
||||
$light: $gray-200;
|
||||
|
||||
@@ -11,25 +11,25 @@
|
||||
</div>
|
||||
|
||||
<!-- App Search-->
|
||||
<form class="app-search d-none d-md-block me-auto">
|
||||
<!-- <form class="app-search d-none d-md-block me-auto">
|
||||
<div class="position-relative">
|
||||
<input type="search" class="form-control" placeholder="admin,widgets..."
|
||||
autocomplete="off" value="">
|
||||
<iconify-icon icon="solar:magnifer-outline" class="search-widget-icon"></iconify-icon>
|
||||
</div>
|
||||
</form>
|
||||
</form> -->
|
||||
</div>
|
||||
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<!-- Theme Color (Light/Dark) -->
|
||||
<div class="topbar-item">
|
||||
<!-- <div class="topbar-item">
|
||||
<button type="button" class="topbar-button" id="light-dark-mode">
|
||||
<iconify-icon icon="solar:moon-outline"
|
||||
class="fs-22 align-middle light-mode"></iconify-icon>
|
||||
<!-- <iconify-icon icon="solar:sun-2-outline"
|
||||
class="fs-22 align-middle dark-mode"></iconify-icon> -->
|
||||
<iconify-icon icon="solar:sun-2-outline"
|
||||
class="fs-22 align-middle dark-mode"></iconify-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<!-- Notification -->
|
||||
<div class="dropdown topbar-item">
|
||||
@@ -156,7 +156,7 @@
|
||||
<!-- item-->
|
||||
<h6 class="dropdown-header">Welcome!</h6>
|
||||
|
||||
<a class="dropdown-item" href="#">
|
||||
<!-- <a class="dropdown-item" href="#">
|
||||
<iconify-icon icon="solar:user-outline"
|
||||
class="align-middle me-2 fs-18"></iconify-icon><span class="align-middle">My
|
||||
Account</span>
|
||||
@@ -176,7 +176,7 @@
|
||||
<iconify-icon icon="solar:lock-keyhole-outline"
|
||||
class="align-middle me-2 fs-18"></iconify-icon><span class="align-middle">Lock
|
||||
screen</span>
|
||||
</a>
|
||||
</a> -->
|
||||
|
||||
<div class="dropdown-divider my-1"></div>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
@include('layouts.partials/page-title', ['title' => 'Se', 'subtitle' => 'Syncronize'])
|
||||
|
||||
<div class="row">
|
||||
<div class="row d-flex justify-content-center">
|
||||
@if (session('error'))
|
||||
<div class="alert alert-danger">
|
||||
{{ session('error') }}
|
||||
@@ -20,7 +20,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<div class="columns-md">
|
||||
<div class="col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form action="{{ route('general.store') }}" method="POST">
|
||||
@@ -51,5 +51,4 @@
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
@vite(['resources/js/tables/common-table.js'])
|
||||
@endsection
|
||||
@@ -10,10 +10,11 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-xl-12 d-flex justify-content-end">
|
||||
<form action="{{route('settings.sync')}}" method="post" id="sync-form">
|
||||
<!-- <form action="{{route('settings.sync')}}" method="post" id="sync-form">
|
||||
@csrf
|
||||
<button type="submit" class="btn btn-success width-lg" id="btn-sync-submit">Sync SIMBG</button>
|
||||
</form>
|
||||
<button type="button" class="btn btn-success width-lg" id="btn-sync-submit">Sync SIMBG</button>
|
||||
</form> -->
|
||||
<button type="button" class="btn btn-success width-lg" id="btn-sync-submit">Sync SIMBG</button>
|
||||
</div>
|
||||
<div>
|
||||
<div id="table-import-datasources"></div>
|
||||
|
||||
Reference in New Issue
Block a user