fix(surveyor dan penilai): perbaikan upload foto dan print out

This commit is contained in:
majid
2025-02-07 07:29:49 +07:00
parent 8fc5f6ec0b
commit 7c6059d479
21 changed files with 2941 additions and 3867 deletions

View File

@@ -408,13 +408,28 @@
function updatePhotoGallery() {
const gallery = document.querySelector('#upload-dropzone');
gallery.innerHTML = '';
if (!myDropzone) {
console.error('Dropzone is not initialized');
return;
}
gallery.innerHTML = `
<div style="
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(255,255,255,0.7);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;">
<div class="loader"></div>
</div>
`;
$.ajax({
url: "{{ route('surveyor.getFoto') }}",
method: 'GET',
@@ -428,9 +443,9 @@
},
success: function(response) {
if (response.fotos && response.fotos.length) {
response.fotos.forEach(function(foto) {
// Cek jika foto sudah ada di Dropzone
gallery.innerHTML = '';
response.fotos.forEach(function(foto) {
var mockFile = {
name: foto.name,
size: foto.size || 12345,
@@ -448,21 +463,22 @@
sub: foto.sub || '',
param_name: 'upload_foto'
});
});
} else {
console.log('Tidak ada foto yang ditemukan');
gallery.innerHTML = '<p>Tidak ada foto yang ditemukan.</p>';
}
},
error: function(xhr, status, error) {
console.error('Gagal memuat foto:', error);
gallery.innerHTML = '<p>Gagal memuat foto. Silakan coba lagi.</p>';
},
complete: function() {
gallery.innerHTML = gallery.innerHTML.includes('loader') ? '' : gallery
.innerHTML;
}
});
}
// Inisialisasi Dropzone untuk elemen awal dengan pengecekan
function safeInitDropzone(selector, paramName) {
setTimeout(() => {