fix(surveyor dan penilai): perbaikan upload foto dan print out
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user