Add: support change filename

Fix: path method use realname
This commit is contained in:
2021-12-16 12:15:35 +08:00
parent b0e57099ba
commit 7efde3cf6f
6 changed files with 98 additions and 8 deletions

View File

@@ -111,6 +111,28 @@ function FileInfo(props) {
}
}
function updateFilename() {
fetch(`/api/v1/update_filename`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
id: parseInt(params.id),
filename: file.filename,
}),
})
.then((res) => res.json())
.then((data) => {
if (data.error) {
alert(data.error);
} else {
alert("Filename updated");
refresh();
}
});
}
useEffect(() => {
refresh();
getTags();
@@ -163,10 +185,21 @@ function FileInfo(props) {
readOnly
/>
<label htmlFor="filename">File Name:</label>
<input type="text" id="filename" value={file.filename} readOnly />
<input
type="text"
id="filename"
value={file.filename}
onChange={(event) => {
setFile({
...file,
filename: event.target.value,
});
}}
/>
<label htmlFor="filesize">File Size:</label>
<input type="text" id="filesize" value={file.filesize} readOnly />
</div>
<button onClick={updateFilename}>Save</button>
<div>
<label>Tags:</label>
<ul>