]> git.example.dev Git - binbsis50-sm.git/commitdiff
changed order of if statement check, so that it actually works
author2weiEmu <saalbach.robert@outlook.de>
Tue, 2 Jun 2026 17:48:50 +0000 (19:48 +0200)
committer2weiEmu <saalbach.robert@outlook.de>
Tue, 2 Jun 2026 17:48:50 +0000 (19:48 +0200)
pkg/dbhandling/filesapi.go
public/css/index.css
public/index.html
public/js/index.js
songmanager
testing/songs/Spice Girls_Mama.m4a [new file with mode: 0644]
testing/songs/elastic_heart [new file with mode: 0644]
testing/songs/elastic_heart.m4a [new file with mode: 0644]
testing/songs/elastic_heart_sia [new file with mode: 0644]
testing/songs/sia_elastic_heart.m4a [new file with mode: 0644]

index 3a03ee760ca0c691216b92a8ea7e113f3a6e6b1b..20b62e6682d447df4d993fa0616648c580319a16 100644 (file)
@@ -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
        }
index f4b73747be9c16227289ee3c8866f3cdc6b8bb73..f52d6c74f8ded47613b91a933f877610da47d51e 100644 (file)
        display: flex;
 }
 
+.success {
+       background-color: rgb(106, 230, 130);
+}
+
 #editMenu {
        top: 10vh;
        left: 25vw;
        }
 
        #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;
+}
index 99a803f037a8847ea2cba01a507312d2d4d48e48..a7b93f9e17019365a25723797843f2103b98d17e 100644 (file)
@@ -21,8 +21,7 @@
                        </div>
 
                        <div>
-                               <button>Create New Song</button> <!-- TODO -->
-                               <button>Upload Song File</button> <!-- TODO -->
+                               <button onclick="openCreationMenu()">Create New Song</button> <!-- TODO -->
                        </div>
                        <div id="innerSongList">
                        </div>
                </div>
        </body>
 
+       <div id="songCreationMenu">
+               <h1>Song Creation Menu</h1>
+               <hr>
+               <h2>Create a New Song</h2>
+
+               <hr>
+               <h2>Upload a New File with a Link (no YT Links)</h2>
+               <input id="fileUploadLinkLink">Link Here</input><br>
+               <input id="fileUploadLinkName">Name of File Here</input>
+               <button id="fileUploadLinkUploadButton" onclick="uploadFileWithLinkAndName()">Upload!</button>
+               <hr>
+               <h2>Upload a New File </h2>
+
+               <hr>
+               <button onclick="closeCreationMenu()" id="editMenuCloseButton">Close</button>
+       </div>
+
 
        <div id="editMenu">
                <div id="innerEditMenu">
index b153b48934496b8e1e790316b8559154473fc6d9..cf128b6ce1966001026e238d567d0fa304551eab 100644 (file)
@@ -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
  **/
index 5282f6f65a260063fde7f2270362157045bca602..c1f2926ab7b0061982c00ba8b7360aa62db90933 100755 (executable)
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 (file)
index 0000000..e69de29
diff --git a/testing/songs/elastic_heart b/testing/songs/elastic_heart
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/testing/songs/elastic_heart.m4a b/testing/songs/elastic_heart.m4a
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/testing/songs/elastic_heart_sia b/testing/songs/elastic_heart_sia
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/testing/songs/sia_elastic_heart.m4a b/testing/songs/sia_elastic_heart.m4a
new file mode 100644 (file)
index 0000000..e69de29