74 lines
2.9 KiB
HTML
74 lines
2.9 KiB
HTML
<div style="display: grid; grid-template-columns: auto 1fr; column-gap: 1ch; padding: 1ch">
|
|
<div>
|
|
Nomor/Judul Dokumen:<br>
|
|
<input type="text"id="judul" style="width: 50ch;" maxlength="126"><br>
|
|
Abstrak:<br>
|
|
<textarea id="abstrak" style="width: 50ch; height: 8em; resize: none;" maxlength="1148" placeholder="Ringkasan isi dokumen untuh kemudahan"></textarea><br>
|
|
<file-input id="pdf" accept="application/pdf" style="width: 50ch;"></file-input><br>
|
|
<div style="margin-top: .5em; display: grid; grid-template-columns: 1fr auto;">
|
|
<span id="warn" style="color: var(--negative-accent); white-space: nowrap; text-overflow: ellipsis; overflow: hidden;"></span>
|
|
<a-button id="sub">Simpan</a-button>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<iframe style="width: calc(85vw - 52ch); height: 80vh; background-color: dimgray; border: none;"></iframe>
|
|
</div>
|
|
</div>
|
|
|
|
<script type="module">
|
|
const thisDialog = moly.lastDialog();
|
|
const data = thisDialog.data;
|
|
const frm = µ('iframe')[0];
|
|
let file = null;
|
|
function µ(selector)
|
|
{
|
|
if (selector) return $(thisDialog.box).find(selector);
|
|
return $(thisDialog.box);
|
|
}
|
|
µ('#sub').click(async()=>
|
|
{
|
|
if(!file) return;
|
|
const loadid = moly.loadScreen.show("Memroses berkas...","bar","#"+µ('div[id^="db"]')[0].id);
|
|
const data ={
|
|
judul: µ('#judul').val(),
|
|
abstrak: µ('#abstrak').val(),
|
|
pdf: file?.data
|
|
}
|
|
if (data.judul.length < 1 || data.abstrak.length < 1|| data.pdf?.length < 1)
|
|
{
|
|
moly.alert.show("Detil Regulasi Belum Lengkap","Harap isikan seluruh kilom yang ditampilkan.")
|
|
moly.loadScreen.close(loadid);
|
|
return;
|
|
}
|
|
const rg = await postJson("/api/addreg",data);
|
|
if (rg.status != 201)
|
|
{
|
|
moly.alert.show("Gagal Menambah Entri Regulasi","Entri Dokumen Regulasi tidak berhasil ditambahkan. Silakan ulangi kembali beberapa saat lagi.");
|
|
moly.loadScreen.close(loadid);
|
|
return;
|
|
}
|
|
moly.loadScreen.close(loadid);
|
|
thisDialog.resolve(true);
|
|
})
|
|
µ('#pdf').change(async()=>
|
|
{
|
|
µ('#sub').prop("disabled",false);
|
|
µ('#warn').text("");
|
|
if(µ('#pdf')[0]._input.files.length < 1)
|
|
{
|
|
file = null;
|
|
return;
|
|
}
|
|
const loadid = moly.loadScreen.show("Memroses berkas...","bar","#"+µ('div[id^="db"]')[0].id);
|
|
file = await moly.file.serialise(µ('#pdf')[0]._input.files[0]);
|
|
frm.src = "data:application/pdf;base64," + file.data;
|
|
const exist = thisDialog.data.find(r=>r.id.includes(file.crc32))
|
|
if (exist)
|
|
{
|
|
µ('#warn').text("Sudah ada dengan Judul: "+ exist.judul);
|
|
µ('#sub').prop("disabled",true);
|
|
}
|
|
moly.loadScreen.close(loadid);
|
|
})
|
|
|
|
</script> |