globalThis.Foto = { content: `
`, action: function(){ globalThis.dataMaster['katfo'] = [ {kode: 'foto', name: 'Foto'}, {kode: 'banner', name: 'Banner'}, {kode: 'pbb', name: 'PBB'}, {kode: 'sertifikat', name: 'Sertifikat'}, {kode: 'blueprint', name: 'Blueprint'} ]; var fotoFilter = localStorage.getItem('fotoFilter'); console.log(fotoFilter); setTimeout(function(){ document.getElementById('app-content-title').innerText = "Data Foto"; table('foto') .title('Foto') .createForm({ idprop: { form: 'input', type: 'readonly', placeholder: 'Inputkan properti id', title: 'id properti', default: fotoFilter }, urut: { form: 'input', type: 'number', placeholder: 'Inputkan urut', title: 'Urut' }, kategori: { form: 'input', type: 'select', table: 'katfo', view: ['name'], value: 'kode', placeholder: 'Inputkan kategori', title: 'Kategori' } }) .row({ id: 'Id Foto', }) .filter({ idprop: fotoFilter }) .back('properti') .displayNone([0]) .addRow({ details: { key: ['id', 'urut', 'kategori'], position: 'center', title: 'Details', id: 'action-{{id}}', template: `
id foto : {{id}}
Urutan : {{urut}}
Kategori : {{kategori}}
` }, action: { key: ['id'], position: 'center', title: 'Upload Image', id: 'action-{{id}}', template: `
`, load: function(a, gs){ const file = document.querySelector('#action-'+a.id) file.addEventListener('change', function(){ var file = this.files[0]; document.getElementById('detail-'+a.id).style.display = 'block'; document.getElementById('detail-'+a.id).innerHTML = ` nama file : ${file.name}
ukuran : ${file.size / 1000}kb
type file : ${file.type}kb `; const reader = new FileReader(); reader.addEventListener("load", function () { var base64 = reader.result; var rendr = base64.split("base64,"); rendr = rendr[1]; rendr = rendr.match(/.{1,150000}/g); var length = rendr.length; var start = 0; document.getElementById('upload-file-s-'+a.id).addEventListener('click', function(){ document.getElementById('detail-'+a.id).style.display = 'none'; document.getElementById('upload-file-'+a.id).style.display = 'block'; uploadProsses() }, false) function uploadProsses(){ if (start < length) { document.getElementById('upload-file-'+a.id).innerText = Math.round(((start+1) / length) * 100)+'%'; $.ajax({ url: '/admin/upload', method: 'POST', dataType: 'text', data: { _token: $('meta[name=csrf-token]').attr('content'), ok: rendr[start], start: start, tipe: 'upload' }, success: function(e){ console.log(e.length) start += 1; uploadProsses(); } }) }else{ $.ajax({ url: '/admin/upload', method: 'POST', dataType: 'text', data: { _token: $('meta[name=csrf-token]').attr('content'), tipe: '../../sistem-api/androapi/upload/foto/'+a.id+'.jpg' }, success: function(e){ console.log('saved') document.getElementById('images-'+a.id).style.backgroundImage = 'url("https://masuksini.com/sistem-api/androapi/upload/foto/'+a.id+'.jpg?v='+Date.now()+'")'; document.getElementById('detail-'+a.id).style.display = 'none'; document.getElementById('upload-file-'+a.id).style.display = 'none'; } }) } } // uploadProsses() }, false); if (file) { reader.readAsDataURL(file); } }, false) } } }) .load() }) } }