update: penamaan file

main
muamars 2026-03-12 10:37:05 +07:00
parent 88aef852e0
commit 89a252e8e7
2 changed files with 14 additions and 1 deletions

View File

@ -1040,6 +1040,13 @@ document.addEventListener('DOMContentLoaded', function() {
alert('Berat belum valid. Isi manual dulu sebelum upload foto timbangan.'); alert('Berat belum valid. Isi manual dulu sebelum upload foto timbangan.');
return; return;
} }
const _ext = (tps.timbangan[itemIndex].file.name.split('.').pop() || 'jpg').toLowerCase();
const _jenis = (tps.timbangan[itemIndex].jenisSampah[0] || 'residu').toLowerCase();
const _beratStr = parseFloat(weight.toFixed(2)).toString().replace('.', '_');
const _newName = `timbangan${itemIndex + 1}-${_jenis}-${_beratStr}.${_ext}`;
tps.timbangan[itemIndex].file = new File([tps.timbangan[itemIndex].file], _newName, { type: tps.timbangan[itemIndex].file.type, lastModified: tps.timbangan[itemIndex].file.lastModified });
alert(`Upload foto timbangan #${itemIndex + 1}\nBerat: ${formatWeightDisplay(weight)} kg\n(Implementasi upload ke server)`); alert(`Upload foto timbangan #${itemIndex + 1}\nBerat: ${formatWeightDisplay(weight)} kg\n(Implementasi upload ke server)`);
tps.timbangan[itemIndex].uploaded = true; tps.timbangan[itemIndex].uploaded = true;

View File

@ -1198,6 +1198,12 @@ async function applyWatermark(file, photoNumber) {
return; return;
} }
const _ext = (timbanganItem.file.name.split('.').pop() || 'jpg').toLowerCase();
const _jenis = timbanganItem.jenisSampah.toLowerCase();
const _beratStr = parseFloat(timbanganItem.weight.toFixed(2)).toString().replace('.', '_');
const _newName = `timbangan${itemIndex + 1}-${_jenis}-${_beratStr}.${_ext}`;
timbanganItem.file = new File([timbanganItem.file], _newName, { type: timbanganItem.file.type, lastModified: timbanganItem.file.lastModified });
alert(`Upload foto timbangan #${itemIndex + 1} untuk ${tps.name}\nJenis: ${timbanganItem.jenisSampah}\nBerat: ${timbanganItem.weight} kg\n(Implementasi upload ke server)`); alert(`Upload foto timbangan #${itemIndex + 1} untuk ${tps.name}\nJenis: ${timbanganItem.jenisSampah}\nBerat: ${timbanganItem.weight} kg\n(Implementasi upload ke server)`);
timbanganItem.uploaded = true; timbanganItem.uploaded = true;