mirror of
https://github.com/Radiquum/photos.git
synced 2025-05-11 23:39:42 +05:00
feat/admin: add image deletion
This commit is contained in:
parent
af38ba70fc
commit
596df22588
2 changed files with 72 additions and 10 deletions
|
@ -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 = '';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue