From 3f1648da32f7b83c3487950bd44f8a4595b470d5 Mon Sep 17 00:00:00 2001 From: Reimar Date: Tue, 13 Feb 2024 00:07:28 +0100 Subject: [PATCH] Create upload queue page in frontend --- database.sqlite3 | Bin 20480 -> 20480 bytes index.js | 4 ++++ public/queue/script.js | 6 +++--- public/upload/index.html | 18 ++++++++++-------- public/upload/script.js | 14 ++++++++++++++ 5 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 public/upload/script.js diff --git a/database.sqlite3 b/database.sqlite3 index 23c1a34490b283f5ad8522218ab5a56f77deec08..9fadc384788e16cde36e7e119efb5caeaff68bf2 100644 GIT binary patch delta 612 zcmW;Iy)OfC0LJkbLKTalFEm8a5HAy&yS7KXwrSc9DlsxJNK9fN zV)HVYBvwX?h*e@T7#RJYUvk6qx!>h3_uV^J_s-R$b~SPwNve_C<%^zfLw{HBgEze3 z5qG%6DGsoUZJ3zHIEK-KPK4pofAuf@{XQ7D)*F7qX?P7QnO-bgrLw=3DwyjrsW26* zkLIO9R4z6cmkLr-gJWr_0F^H%GE$%hs=YImrVEARb1U(pwW_rcy=J{e_?-=*T3@!G z(s)#z9ho3}#Fm|_5ME-skhKU8(QnVl*SQIMa&3br%|tYlC=f1U)7lv#oWzQ?Bfsj9 z$fdI4WU;MDs4HqF)8(RF>JZm@t)pU_)~2TNxynMu%9|yhq9_JZ3J&p%Z#-ZQb?l>v z8+_seOGt^#89d@2n4g2OG!BOHaWImXgMmDrVX;`p&08$f%)u%y4i<6BA!<0}Ga^Kj+hKV5-~W74 Bi(UW# delta 75 zcmZozz}T>Wae_1>%S0JxMwX2UOZ3?o`9Cx8f8H#p@RWaI0E;*`Ba0}faGqtEVMb~e Y7Xt$WBmWNu{vS|zP7ZcvQBII702pf%$^ZZW diff --git a/index.js b/index.js index bf0a67b..23358c4 100644 --- a/index.js +++ b/index.js @@ -181,6 +181,9 @@ app.get("/api/logout", authorized(), (req, res) => { app.post("/api/upload-video", authorized(), fileUpload({ limits: { fileSize: 2 ** 26 }, useTempFiles: true }), async (req, res) => { const { title } = req.body; + if (!title) { + return res.status(400).json({ ok: false, error: "bad request" }); + } if (!req.files || !req.files.video) { return res.status(400).json({ ok: false, error: "bad request" }); @@ -206,6 +209,7 @@ app.post("/api/upload-video", authorized(), fileUpload({ limits: { fileSize: 2 * const queueItem = { videoId: id, userId, + title, errors: [], progress: 0, duration, diff --git a/public/queue/script.js b/public/queue/script.js index de0f090..7882a2e 100644 --- a/public/queue/script.js +++ b/public/queue/script.js @@ -36,11 +36,11 @@ async function main() {
  • - - + +
    - ${vid.title} + ${vid.title}

    Uploaded ${uploadedTime} of ${totalTime} (${percentage}%)

    ${percentage}% diff --git a/public/upload/index.html b/public/upload/index.html index 4f24573..9a264cb 100644 --- a/public/upload/index.html +++ b/public/upload/index.html @@ -4,19 +4,21 @@ MaoTube + +

    MaoTube

    -
    - - - - -
    -
    + + + + + +

    +

    + View upload queue
    - diff --git a/public/upload/script.js b/public/upload/script.js new file mode 100644 index 0000000..30436ea --- /dev/null +++ b/public/upload/script.js @@ -0,0 +1,14 @@ +document.getElementById("upload-form").addEventListener("submit", async event => { + event.preventDefault(); + + const data = new FormData(event.target); + console.log(data); + + await fetch("/api/upload-video", { + method: "POST", + body: data, + }); + + + location.href = "/queue"; +});