fix tourisms routing
This commit is contained in:
@@ -58,7 +58,7 @@ class TourismController extends Controller
|
|||||||
$modelInstance = Tourism::find($id);
|
$modelInstance = Tourism::find($id);
|
||||||
// Pastikan model ditemukan
|
// Pastikan model ditemukan
|
||||||
if (!$modelInstance) {
|
if (!$modelInstance) {
|
||||||
return redirect()->route('tourisms.index') ->with('error', 'Pariwisata tidak ditemukan');
|
return redirect()->route('web-tourisms.index') ->with('error', 'Pariwisata tidak ditemukan');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mengambil dan memetakan village_name dan district_name
|
// Mengambil dan memetakan village_name dan district_name
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ class UsersRoleMenuSeeder extends Seeder
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"name" => "Pariwisata",
|
"name" => "Pariwisata",
|
||||||
"url" => "tourisms.index",
|
"url" => "web-tourisms.index",
|
||||||
"icon" => null,
|
"icon" => null,
|
||||||
"parent_id" => $data->id,
|
"parent_id" => $data->id,
|
||||||
"sort_order" => 5,
|
"sort_order" => 5,
|
||||||
@@ -209,7 +209,7 @@ class UsersRoleMenuSeeder extends Seeder
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"name" => "Lap Pariwisata",
|
"name" => "Lap Pariwisata",
|
||||||
"url" => "tourisms.index",
|
"url" => "tourisms-report.index",
|
||||||
"icon" => null,
|
"icon" => null,
|
||||||
"parent_id" => $laporan->id,
|
"parent_id" => $laporan->id,
|
||||||
"sort_order" => 1,
|
"sort_order" => 1,
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
}, 3000);
|
}, 3000);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.href = "/data/tourisms";
|
window.location.href = "/data/web-tourisms";
|
||||||
}, 3000);
|
}, 3000);
|
||||||
} else {
|
} else {
|
||||||
if (authLogo) {
|
if (authLogo) {
|
||||||
|
|||||||
@@ -18,58 +18,61 @@ console.log(dropzonePreviewNode);
|
|||||||
url: `${GlobalConfig.apiHost}/api/tourisms/import`,
|
url: `${GlobalConfig.apiHost}/api/tourisms/import`,
|
||||||
// url: "https://httpbin.org/post",
|
// url: "https://httpbin.org/post",
|
||||||
method: "post",
|
method: "post",
|
||||||
acceptedFiles: ".xls,.xlsx", // Use acceptedFiles for better validation
|
acceptedFiles: ".xls,.xlsx", // Use acceptedFiles for better validation
|
||||||
previewTemplate: previewTemplate,
|
previewTemplate: previewTemplate,
|
||||||
previewsContainer: "#dropzone-preview",
|
previewsContainer: "#dropzone-preview",
|
||||||
autoProcessQueue: false, // Disable auto post
|
autoProcessQueue: false, // Disable auto post
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${document
|
Authorization: `Bearer ${document
|
||||||
.querySelector('meta[name="api-token"]')
|
.querySelector('meta[name="api-token"]')
|
||||||
.getAttribute("content")}`
|
.getAttribute("content")}`,
|
||||||
},
|
},
|
||||||
init: function() {
|
init: function () {
|
||||||
// Listen for the success event
|
// Listen for the success event
|
||||||
this.on("success", function(file, response) {
|
this.on("success", function (file, response) {
|
||||||
console.log("File successfully uploaded:", file);
|
console.log("File successfully uploaded:", file);
|
||||||
console.log("API Response:", response);
|
console.log("API Response:", response);
|
||||||
|
|
||||||
// Show success toast
|
// Show success toast
|
||||||
showToast('bxs-check-square', 'green', response.message);
|
showToast("bxs-check-square", "green", response.message);
|
||||||
document.getElementById("submit-upload").innerHTML = "Upload Files";
|
document.getElementById("submit-upload").innerHTML =
|
||||||
|
"Upload Files";
|
||||||
// Tunggu sebentar lalu reload halaman
|
// Tunggu sebentar lalu reload halaman
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.href = "/data/tourisms";
|
window.location.href = "/data/web-tourisms";
|
||||||
}, 2000);
|
}, 2000);
|
||||||
});
|
});
|
||||||
// Listen for the error event
|
// Listen for the error event
|
||||||
this.on("error", function(file, errorMessage) {
|
this.on("error", function (file, errorMessage) {
|
||||||
console.error("Error uploading file:", file);
|
console.error("Error uploading file:", file);
|
||||||
console.error("Error message:", errorMessage);
|
console.error("Error message:", errorMessage);
|
||||||
// Handle the error response
|
// Handle the error response
|
||||||
|
|
||||||
// Show error toast
|
// Show error toast
|
||||||
showToast('bxs-error-alt', 'red', errorMessage.message);
|
showToast("bxs-error-alt", "red", errorMessage.message);
|
||||||
document.getElementById("submit-upload").innerHTML = "Upload Files";
|
document.getElementById("submit-upload").innerHTML =
|
||||||
|
"Upload Files";
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
})));
|
})));
|
||||||
|
|
||||||
// Add event listener to control the submission manually
|
// Add event listener to control the submission manually
|
||||||
document.querySelector("#submit-upload").addEventListener("click", function() {
|
document.querySelector("#submit-upload").addEventListener("click", function () {
|
||||||
console.log("Ini adalah value dropzone", dropzone.files[0]);
|
console.log("Ini adalah value dropzone", dropzone.files[0]);
|
||||||
const formData = new FormData()
|
const formData = new FormData();
|
||||||
console.log("Dropzonefiles",dropzone.files);
|
console.log("Dropzonefiles", dropzone.files);
|
||||||
|
|
||||||
this.innerHTML = '<span class="spinner-border spinner-border-sm me-1" role="status" aria-hidden="true"></span>Loading...';
|
this.innerHTML =
|
||||||
|
'<span class="spinner-border spinner-border-sm me-1" role="status" aria-hidden="true"></span>Loading...';
|
||||||
|
|
||||||
// Pastikan ada file dalam queue sebelum memprosesnya
|
// Pastikan ada file dalam queue sebelum memprosesnya
|
||||||
if (dropzone.files.length > 0) {
|
if (dropzone.files.length > 0) {
|
||||||
formData.append('file', dropzone.files[0])
|
formData.append("file", dropzone.files[0]);
|
||||||
console.log("ini adalah form data on submit", ...formData);
|
console.log("ini adalah form data on submit", ...formData);
|
||||||
dropzone.processQueue(); // Ini akan manual memicu upload
|
dropzone.processQueue(); // Ini akan manual memicu upload
|
||||||
} else {
|
} else {
|
||||||
// Show error toast when no file is selected
|
// Show error toast when no file is selected
|
||||||
showToast('bxs-error-alt', 'red', "Please add a file first.");
|
showToast("bxs-error-alt", "red", "Please add a file first.");
|
||||||
document.getElementById("submit-upload").innerHTML = "Upload Files";
|
document.getElementById("submit-upload").innerHTML = "Upload Files";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -82,63 +85,69 @@ dropzone.on("addedfile", function (file) {
|
|||||||
console.log("Ukuran File:", (file.size / 1024).toFixed(2) + " KB");
|
console.log("Ukuran File:", (file.size / 1024).toFixed(2) + " KB");
|
||||||
});
|
});
|
||||||
|
|
||||||
dropzone.on("complete", function(file) {
|
dropzone.on("complete", function (file) {
|
||||||
dropzone.removeFile(file);
|
dropzone.removeFile(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add event listener to download file template
|
// Add event listener to download file template
|
||||||
document.getElementById('downloadtemptourisms').addEventListener('click', function() {
|
document
|
||||||
var url = `${GlobalConfig.apiHost}/api/download-template-tourism`;
|
.getElementById("downloadtemptourisms")
|
||||||
fetch(url, {
|
.addEventListener("click", function () {
|
||||||
method: 'GET',
|
var url = `${GlobalConfig.apiHost}/api/download-template-tourism`;
|
||||||
headers: {
|
fetch(url, {
|
||||||
Authorization: `Bearer ${document
|
method: "GET",
|
||||||
.querySelector('meta[name="api-token"]')
|
headers: {
|
||||||
.getAttribute("content")}`
|
Authorization: `Bearer ${document
|
||||||
},
|
.querySelector('meta[name="api-token"]')
|
||||||
})
|
.getAttribute("content")}`,
|
||||||
.then(response => {
|
},
|
||||||
if (response.ok) {
|
})
|
||||||
return response.blob(); // Jika respons OK, konversi menjadi blob
|
.then((response) => {
|
||||||
} else {
|
if (response.ok) {
|
||||||
return response.json(); // Jika respons gagal, konversi menjadi JSON untuk menangani pesan error
|
return response.blob(); // Jika respons OK, konversi menjadi blob
|
||||||
}
|
} else {
|
||||||
})
|
return response.json(); // Jika respons gagal, konversi menjadi JSON untuk menangani pesan error
|
||||||
.then((blob) => {
|
}
|
||||||
console.log(blob);
|
})
|
||||||
const url = window.URL.createObjectURL(blob);
|
.then((blob) => {
|
||||||
const a = document.createElement('a');
|
console.log(blob);
|
||||||
a.style.display = 'none';
|
const url = window.URL.createObjectURL(blob);
|
||||||
a.href = url;
|
const a = document.createElement("a");
|
||||||
a.download = 'template_pariwisata.xlsx';
|
a.style.display = "none";
|
||||||
document.body.appendChild(a);
|
a.href = url;
|
||||||
a.click();
|
a.download = "template_pariwisata.xlsx";
|
||||||
window.URL.revokeObjectURL(url);
|
document.body.appendChild(a);
|
||||||
})
|
a.click();
|
||||||
.catch((error) => {
|
window.URL.revokeObjectURL(url);
|
||||||
console.error("Gagal mendownload file:", error);
|
})
|
||||||
showToast('bxs-error-alt', 'red', "Template file is not already exist.");
|
.catch((error) => {
|
||||||
})
|
console.error("Gagal mendownload file:", error);
|
||||||
})
|
showToast(
|
||||||
|
"bxs-error-alt",
|
||||||
|
"red",
|
||||||
|
"Template file is not already exist."
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Function to show toast
|
// Function to show toast
|
||||||
function showToast(iconClass, iconColor, message) {
|
function showToast(iconClass, iconColor, message) {
|
||||||
const toastElement = document.getElementById('toastUploadTourisms');
|
const toastElement = document.getElementById("toastUploadTourisms");
|
||||||
const toastBody = toastElement.querySelector('.toast-body');
|
const toastBody = toastElement.querySelector(".toast-body");
|
||||||
const toastHeader = toastElement.querySelector('.toast-header');
|
const toastHeader = toastElement.querySelector(".toast-header");
|
||||||
|
|
||||||
// Remove existing icon (if any) before adding the new one
|
// Remove existing icon (if any) before adding the new one
|
||||||
const existingIcon = toastHeader.querySelector('.bx');
|
const existingIcon = toastHeader.querySelector(".bx");
|
||||||
if (existingIcon) {
|
if (existingIcon) {
|
||||||
toastHeader.querySelector('.auth-logo').removeChild(existingIcon); // Remove the existing icon
|
toastHeader.querySelector(".auth-logo").removeChild(existingIcon); // Remove the existing icon
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the new icon to the toast header
|
// Add the new icon to the toast header
|
||||||
const icon = document.createElement('i');
|
const icon = document.createElement("i");
|
||||||
icon.classList.add('bx', iconClass);
|
icon.classList.add("bx", iconClass);
|
||||||
icon.style.fontSize = '25px';
|
icon.style.fontSize = "25px";
|
||||||
icon.style.color = iconColor;
|
icon.style.color = iconColor;
|
||||||
toastHeader.querySelector('.auth-logo').appendChild(icon);
|
toastHeader.querySelector(".auth-logo").appendChild(icon);
|
||||||
|
|
||||||
// Set the toast message
|
// Set the toast message
|
||||||
toastBody.textContent = message;
|
toastBody.textContent = message;
|
||||||
@@ -147,4 +156,3 @@ function showToast(iconClass, iconColor, message) {
|
|||||||
const toast = new bootstrap.Toast(toastElement); // Inisialisasi Bootstrap Toast
|
const toast = new bootstrap.Toast(toastElement); // Inisialisasi Bootstrap Toast
|
||||||
toast.show();
|
toast.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ Route::group(['middleware' => 'auth'], function(){
|
|||||||
Route::get('/umkm/bulk-create', [UmkmController::class, 'bulkCreate'])->name('umkm.bulk-create');
|
Route::get('/umkm/bulk-create', [UmkmController::class, 'bulkCreate'])->name('umkm.bulk-create');
|
||||||
|
|
||||||
// Resource route, kecuali create karena dibuat terpisah
|
// Resource route, kecuali create karena dibuat terpisah
|
||||||
Route::resource('/tourisms', TourismController::class)->except(['create', 'show']);
|
Route::resource('/web-tourisms', TourismController::class)->except(['create', 'show']);
|
||||||
// Rute khusus untuk create dan bulk-create
|
// Rute khusus untuk create dan bulk-create
|
||||||
Route::get('/tourisms/create', [TourismController::class, 'create'])->name('tourisms.create');
|
Route::get('/tourisms/create', [TourismController::class, 'create'])->name('tourisms.create');
|
||||||
Route::get('/tourisms/bulk-create', [TourismController::class, 'bulkCreate'])->name('tourisms.bulk-create');
|
Route::get('/tourisms/bulk-create', [TourismController::class, 'bulkCreate'])->name('tourisms.bulk-create');
|
||||||
|
|||||||
Reference in New Issue
Block a user