From 5c32fcb1d133381e279125e7836c07cec6fbed00 Mon Sep 17 00:00:00 2001 From: Kees van Kempen Date: Wed, 28 Feb 2024 00:20:06 +0100 Subject: [PATCH 1/2] fix(songs): handle HTTP 413 and remove redundant .json() calls Closes #76 --- marietje/songs/templates/songs/upload.html | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/marietje/songs/templates/songs/upload.html b/marietje/songs/templates/songs/upload.html index b28f8e7..c2d734e 100644 --- a/marietje/songs/templates/songs/upload.html +++ b/marietje/songs/templates/songs/upload.html @@ -179,13 +179,14 @@ }).catch(e => { console.log(e); if (e instanceof Response) { - try { - e.json().then(data => { - this.fileObjects[i].error_message = data.errorMessage; - this.fileObjects[i].success = false; - }); - } catch { - this.fileObjects[i].error_message = "An exception occurred while uploading this file, please try again."; + // Intercept an HTTP 413 error (entity too large), as this might + // be thrown by a (reverse) proxy server and its payload is not + // nicely formatted as the code below expects. + if (e.status === 413) { + this.fileObjects[i].error_message = "The song you tried to upload is too large in size. (HTTP 413 error)"; + this.fileObjects[i].success = false; + } else { + this.fileObjects[i].error_message = `${e.statusText} (${e.status})`; this.fileObjects[i].success = false; } } else { From 77cf681c645b4c14854c97d9343c4effb39f2840 Mon Sep 17 00:00:00 2001 From: Kees van Kempen Date: Wed, 28 Feb 2024 00:24:52 +0100 Subject: [PATCH 2/2] feature(queue): refresh queue after requesting Closes #84 --- marietje/queues/templates/queues/queue.html | 1 + 1 file changed, 1 insertion(+) diff --git a/marietje/queues/templates/queues/queue.html b/marietje/queues/templates/queues/queue.html index 74d1d75..d9ba9c0 100644 --- a/marietje/queues/templates/queues/queue.html +++ b/marietje/queues/templates/queues/queue.html @@ -613,6 +613,7 @@ tata.error('', "An unknown exception occurred.") } }); + queue_vue.refresh(); }, report_song(song_id) {