Add: support reset filename

This commit is contained in:
2021-12-16 12:25:58 +08:00
parent 64d1e3ff78
commit 214ad6c285
5 changed files with 75 additions and 1 deletions

View File

@@ -133,6 +133,26 @@ function FileInfo(props) {
});
}
function resetFilename() {
fetch(`/api/v1/reset_filename`, {
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 {
refresh();
}
});
}
useEffect(() => {
refresh();
getTags();
@@ -199,7 +219,10 @@ function FileInfo(props) {
<label htmlFor="filesize">File Size:</label>
<input type="text" id="filesize" value={file.filesize} readOnly />
</div>
<button onClick={updateFilename}>Save</button>
<div className="horizontal">
<button onClick={updateFilename}>Save</button>
<button onClick={resetFilename}>Reset</button>
</div>
<div>
<label>Tags:</label>
<ul>