update: penamaan file
parent
88aef852e0
commit
89a252e8e7
|
|
@ -1040,6 +1040,13 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
alert('Berat belum valid. Isi manual dulu sebelum upload foto timbangan.');
|
||||
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)`);
|
||||
tps.timbangan[itemIndex].uploaded = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -1197,7 +1197,13 @@ async function applyWatermark(file, photoNumber) {
|
|||
alert('Berat belum valid. Isi manual dulu sebelum upload foto timbangan.');
|
||||
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)`);
|
||||
|
||||
timbanganItem.uploaded = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue