feat/admin: add image deletion

This commit is contained in:
Kentai Radiquum 2025-02-18 21:18:22 +05:00
parent af38ba70fc
commit 596df22588
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
2 changed files with 72 additions and 10 deletions

View file

@ -47,6 +47,9 @@
<script>
let tags = "{{ tags }}".split(':') || [];
if (tags[0] == '') {
tags = [];
}
let urls = [];
let datepicker = null;
@ -155,6 +158,28 @@
const btnDelete = document.getElementById('btn-delete');
const btnSubmit = document.getElementById('btn-submit');
btnDelete.addEventListener('click', () => {
if (confirm('Are you sure you want to delete this post?')) {
fetch(`{{ url_for('ApiDelete', file=name) }}`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
},
})
.then(res => res.json())
.then(data => {
alert(data.message);
window.location.href = "{{url_for('Home')}}";
})
.catch(err => {
console.log(err);
alert(err.message);
});
}
});
// btnReset.addEventListener('click', () => {
// tagInp.value = '';
// tagCon.innerHTML = '';