Add: support delete file

This commit is contained in:
2021-12-16 11:41:07 +08:00
parent 0edc7f7141
commit 435e3605f7
5 changed files with 188 additions and 54 deletions

View File

@@ -88,6 +88,29 @@ function FileInfo(props) {
});
}
function deleteFile() {
// show Warning
if (window.confirm("Are you sure you want to delete this file?")) {
fetch(`/api/v1/delete_file`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
id: parseInt(params.id),
}),
})
.then((res) => res.json())
.then((data) => {
if (data.error) {
alert(data.error);
} else {
navigate(-1);
}
});
}
}
useEffect(() => {
refresh();
getTags();
@@ -120,6 +143,13 @@ function FileInfo(props) {
>
Share
</button>
<button
onClick={() => {
deleteFile();
}}
>
Delete
</button>
</div>
<div>
<label htmlFor="foldername">Folder Name:</label>