From: 2weiEmu Date: Tue, 2 Jun 2026 17:48:50 +0000 (+0200) Subject: changed order of if statement check, so that it actually works X-Git-Url: https://git.saalbach.dev/?a=commitdiff_plain;h=6d57c2204775903b4e0241ed5406e18a458c4360;p=binbsis50-sm.git changed order of if statement check, so that it actually works --- diff --git a/pkg/dbhandling/filesapi.go b/pkg/dbhandling/filesapi.go index 3a03ee7..20b62e6 100644 --- a/pkg/dbhandling/filesapi.go +++ b/pkg/dbhandling/filesapi.go @@ -2,6 +2,7 @@ package dbhandling import ( "encoding/json" + "fmt" "io" "net/http" "os" @@ -57,7 +58,8 @@ func (dbw *DBWrapper) FilesCreateWithURL(w http.ResponseWriter, r *http.Request) defer file.Close() resp, err := http.Get(url) - if resp.Status != "200 OK" { + if (err != nil) || (resp.Status != "200 OK") { + fmt.Println("Error", err) w.WriteHeader(http.StatusNotFound) return } diff --git a/public/css/index.css b/public/css/index.css index f4b7374..f52d6c7 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -41,6 +41,10 @@ display: flex; } +.success { + background-color: rgb(106, 230, 130); +} + #editMenu { top: 10vh; left: 25vw; @@ -61,11 +65,18 @@ } #editMenuUpdateButton { - .success { - background-color: rgb(106, 230, 130); - } } } +#songCreationMenu { + top: 10vh; + left: 25vw; + border-radius: 5px; + position: absolute; + border: 2px solid gray; + background-color: rgb(240, 240, 240); + width: 50vw; + display: none; +} diff --git a/public/index.html b/public/index.html index 99a803f..a7b93f9 100644 --- a/public/index.html +++ b/public/index.html @@ -21,8 +21,7 @@
- - +
@@ -35,6 +34,23 @@ +
+

Song Creation Menu

+
+

Create a New Song

+ +
+

Upload a New File with a Link (no YT Links)

+ Link Here
+ Name of File Here + +
+

Upload a New File

+ +
+ +
+
diff --git a/public/js/index.js b/public/js/index.js index b153b48..cf128b6 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -347,6 +347,45 @@ async function updateSongUsingEditMenu() { } } +/** + * SONG CREATION MENU + **/ +let songCreationMenu = document.getElementById("songCreationMenu") + +function closeCreationMenu() { + songCreationMenu.style.display = "none" +} + +function openCreationMenu() { + songCreationMenu.style.display = "block" +} + +let fileUploadLinkLink = document.getElementById("fileUploadLinkLink") +let fileUploadLinkName = document.getElementById("fileUploadLinkName") +let fileUploadLinkUploadButton = document.getElementById("fileUploadLinkUploadButton") + +async function uploadFileWithLinkAndName() { + + let link = fileUploadLinkLink.value + let name = fileUploadLinkName.value // TODO: again do some checking here + + let response = await fetch("/api/files/createWithURL/" + name, { + method: "POST", + body: JSON.stringify(link) + }) + + if (response.status != 200) { + alert("Something went wrong uploading the file... harass admin") + } + else { + fileUploadLinkUploadButton.classList = "success" + + await sleep(500) + + fileUploadLinkUploadButton.classList = "" + } +} + /** * SETUP / RUN AT START SECTION **/ diff --git a/songmanager b/songmanager index 5282f6f..c1f2926 100755 Binary files a/songmanager and b/songmanager differ diff --git a/testing/songs/Spice Girls_Mama.m4a b/testing/songs/Spice Girls_Mama.m4a new file mode 100644 index 0000000..e69de29 diff --git a/testing/songs/elastic_heart b/testing/songs/elastic_heart new file mode 100644 index 0000000..e69de29 diff --git a/testing/songs/elastic_heart.m4a b/testing/songs/elastic_heart.m4a new file mode 100644 index 0000000..e69de29 diff --git a/testing/songs/elastic_heart_sia b/testing/songs/elastic_heart_sia new file mode 100644 index 0000000..e69de29 diff --git a/testing/songs/sia_elastic_heart.m4a b/testing/songs/sia_elastic_heart.m4a new file mode 100644 index 0000000..e69de29