hhhidk what im doing :verygood:

This commit is contained in:
May 2023-08-28 20:40:49 -07:00
parent 3ad5215a48
commit 1eced462fe
5 changed files with 76 additions and 5 deletions

View file

@ -0,0 +1 @@
<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m11.256 13 .238-1.5h1.481l-.237 1.5h-1.482Z" fill="#8aadf4"/><path d="M17.75 2.001a2.25 2.25 0 0 1 2.245 2.096L20 4.25v15.498a2.25 2.25 0 0 1-2.096 2.245l-.154.005H6.25a2.25 2.25 0 0 1-2.245-2.096L4 19.75V4.251a2.25 2.25 0 0 1 2.096-2.245l.154-.005h11.5Zm-5.355 13.16a.75.75 0 1 0 1.482.234l.142-.895h.731a.75.75 0 0 0 0-1.5h-.494l.238-1.5h.756a.75.75 0 0 0 0-1.5h-.519l.162-1.025a.75.75 0 1 0-1.481-.234l-.2 1.259h-1.48l.161-1.025a.75.75 0 1 0-1.481-.234l-.2 1.259H9.25a.75.75 0 1 0 0 1.5h.725L9.738 13H8.75a.75.75 0 1 0 0 1.5h.75l-.105.66a.75.75 0 0 0 1.482.235l.142-.895H12.5l-.105.66Z" fill="#DDDDDD"/></svg>

After

Width:  |  Height:  |  Size: 716 B

View file

@ -11,7 +11,7 @@
"author": "nbitzz",
"license": "Unlicense",
"engines": {
"node": ">=v18"
"node": ">=v16.11"
},
"dependencies": {
"@types/body-parser": "^1.19.2",

View file

@ -84,8 +84,6 @@ adminRoutes.post("/elevate", parser, (req,res) => {
})
adminRoutes.post("/delete", parser, (req,res) => {
let acc = res.locals.acc as Accounts.Account
if (typeof req.body.target !== "string") {
res.status(404)
@ -153,8 +151,6 @@ adminRoutes.post("/delete_account", parser, async (req,res) => {
})
adminRoutes.post("/transfer", parser, (req,res) => {
let acc = res.locals.acc as Accounts.Account
if (typeof req.body.target !== "string" || typeof req.body.owner !== "string") {
res.status(404)
@ -192,4 +188,37 @@ adminRoutes.post("/transfer", parser, (req,res) => {
res.send()
}) // wasting a reassignment but whatee
})
adminRoutes.post("/transfer", parser, (req,res) => {
if (typeof req.body.target !== "string" || typeof req.body.new !== "string") {
res.status(404)
res.send()
return
}
let targetFile = files.getFilePointer(req.body.target)
if (!targetFile) {
res.status(404)
res.send()
return
}
if (files.getFilePointer(req.body.new)) {
res.status(400)
res.send()
return
}
delete files.files[req.body.target]
files.writeFile(req.body.new, targetFile).then(() => {
res.send()
}).catch(() => {
files.files[req.body.target] = req.body.new
res.status(500)
res.send()
})
})

View file

@ -75,6 +75,42 @@ export function chgOwner(optPicker) {
})
}
export function chgId(optPicker) {
optPicker.picker("Change file ID",[
{
name: "Target file",
icon: "/static/assets/icons/file.svg",
id: "file",
inputSettings: {}
},
{
name: "New ID",
icon: "/static/assets/icons/change_file_id.svg",
id: "new",
inputSettings: {}
},
{
name: "Update",
icon: "/static/assets/icons/update.svg",
description: "File will not be available at its old ID",
id: true
}
]).then((exp) => {
if (exp && exp.selected) {
fetch(`/admin/idchange`,{method:"POST", body:JSON.stringify({
target: exp.file,
new: exp.new
})}).then((response) => {
if (response.status != 200) {
optPicker.picker(`${response.status} ${response.headers.get("x-backup-status-message") || response.statusText || ""}`,[])
}
})
}
})
}
export function delFile(optPicker) {
optPicker.picker("Delete file",[
{

View file

@ -228,6 +228,11 @@
<p>Change file owner</p>
</button>
<button on:click={() => admOpts.chgId(optPicker)}>
<img src="/static/assets/icons/admin/change_file_id.svg" alt="change file id">
<p>Change file ID<span><br />Potentially buggy, usage not recommended</span></p>
</button>
<button on:click={() => admOpts.delFile(optPicker)}>
<img src="/static/assets/icons/admin/delete_file.svg" alt="delete file">
<p>Delete file</p>