diff --git a/assets/icons/more.svg b/assets/icons/more.svg new file mode 100644 index 0000000..1278f47 --- /dev/null +++ b/assets/icons/more.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/icons/multiselect.svg b/assets/icons/multiselect.svg new file mode 100644 index 0000000..4dbb4d2 --- /dev/null +++ b/assets/icons/multiselect.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/server/routes/authRoutes.ts b/src/server/routes/authRoutes.ts index 49d6d9b..172e499 100644 --- a/src/server/routes/authRoutes.ts +++ b/src/server/routes/authRoutes.ts @@ -113,23 +113,15 @@ authRoutes.post("/logout", (req,res) => { res.send("logged out") }) -authRoutes.post("/dfv", (req,res) => { +authRoutes.post("/dfv", parser, (req,res) => { let acc = Accounts.getFromToken(req.cookies.auth) if (!acc) { ServeError(res, 401, "not logged in") return } - let body:{[key:string]:any} - try { - body = JSON.parse(req.body) - } catch { - ServeError(res,400,"bad request") - return - } - - if (['public','private','anonymous'].find(e => e == body.defaultFileVisibility)) { - acc.defaultFileVisibility = body.defaultFileVisibility + if (['public','private','anonymous'].find(e => e == req.body.defaultFileVisibility)) { + acc.defaultFileVisibility = req.body.defaultFileVisibility Accounts.save() res.send(`dfv has been set to ${acc.defaultFileVisibility}`) } else { @@ -138,28 +130,19 @@ authRoutes.post("/dfv", (req,res) => { } }) -authRoutes.post("/delete_account", (req,res) => { +authRoutes.post("/delete_account", parser, (req,res) => { let acc = Accounts.getFromToken(req.cookies.auth) if (!acc) { ServeError(res, 401, "not logged in") return } - - let body:{[key:string]:any} - try { - body = JSON.parse(req.body) - } catch { - ServeError(res,400,"bad request") - return - } - let accId = acc.id auth.AuthTokens.filter(e => e.account == accId).forEach((v) => { auth.invalidate(v.token) }) - if (body.deleteFiles) { + if (req.body.deleteFiles) { acc.files.forEach((v) => { files.unlink(v) }) @@ -170,7 +153,7 @@ authRoutes.post("/delete_account", (req,res) => { res.send("account deleted") }) -authRoutes.post("/change_username", (req,res) => { +authRoutes.post("/change_username", parser, (req,res) => { let acc = Accounts.getFromToken(req.cookies.auth) if (!acc) { ServeError(res, 401, "not logged in") @@ -200,7 +183,7 @@ authRoutes.post("/change_username", (req,res) => { res.send("username changed") }) -authRoutes.post("/change_password", (req,res) => { +authRoutes.post("/change_password", parser, (req,res) => { let acc = Accounts.getFromToken(req.cookies.auth) if (!acc) { ServeError(res, 401, "not logged in") diff --git a/src/style/app/pulldown/files.scss b/src/style/app/pulldown/files.scss index d526d7d..24787d1 100644 --- a/src/style/app/pulldown/files.scss +++ b/src/style/app/pulldown/files.scss @@ -68,6 +68,7 @@ .flFile { padding: 3px 8px; + position:relative; @media screen and (max-width: 500px) { padding:7px 12px; @@ -76,10 +77,22 @@ .detail { color:#777777; font-size:14px; + position:relative; @media screen and (max-width: 500px) { font-size:16px; } + + img { + width: 14px; + height: 14px; + + /* this is shit but it's the best way i can think of to do this */ + /* other than flexbox but i don't feel like doing that rn */ + + position:relative; + top:2px; + } } h2 { @@ -97,6 +110,50 @@ margin:0 0 0 0; white-space: nowrap; } + + button { + background-color:#00000000; + border:none; + outline:none; + cursor:pointer; + + &.hitbox { + position:absolute; + left:0px; + top:0px; + height:100%; + width:100%; + z-index:10; + } + + &.more { + min-height:100%; + width:auto; + aspect-ratio: 1 / 1; + z-index:11; + position:relative; + + img { + margin:auto; + } + } + } + + .flexCont { + display: flex; + + .fileInfo { + width:100%; + min-width:0; + } + } + + @media screen and (min-width:500px) { + &:hover { + background-color: #252525; + } + } + } } } diff --git a/src/svelte/elem/prompts/uploads.js b/src/svelte/elem/prompts/uploads.js index a9ce542..2db6879 100644 --- a/src/svelte/elem/prompts/uploads.js +++ b/src/svelte/elem/prompts/uploads.js @@ -62,4 +62,31 @@ export function update_all_files(optPicker) { }) } }) +} + +export function fileOptions(optPicker,file) { + optPicker.picker(file.filename,[ + { + name: file.tag ? "Remove tag" : "Tag file", + icon: `/static/assets/icons/${file.tag ? "tag_remove" : "tag"}.svg`, + description: file.tag || `File has no tag`, + id: "tag" + }, + { + name: "Change file visibility", + icon: `/static/assets/icons/${file.visibility||"public"}.svg`, + description: `File is currently ${file.visibility||"public"}`, + id: "changeFileVisibility" + }, + { + name: "Delete file", + icon: `/static/assets/icons/admin/delete_file.svg`, + description: ``, + id: "delete" + } + ]).then((exp) => { + if (exp && exp.selected) { + + } + }) } \ No newline at end of file diff --git a/src/svelte/elem/pulldowns/Files.svelte b/src/svelte/elem/pulldowns/Files.svelte index abddd75..aa90b59 100644 --- a/src/svelte/elem/pulldowns/Files.svelte +++ b/src/svelte/elem/pulldowns/Files.svelte @@ -1,12 +1,21 @@ + + {#if !$account.username}
@@ -20,9 +29,20 @@
{#each $files as file (file.id)} -
-

{file.filename}

-

{file.id}  —  {file.mime.split(";")[0]}

+
+ +
+
+

{file.filename}

+

+ {file.visibility||"public"}  + {file.id}  —  {file.mime.split(";")[0]} +

+
+ +
{/each}