]> git.example.dev Git - binbsis50-sm.git/commitdiff
updated: new room creation seems to work as well
author2weiEmu <saalbach.robert@outlook.de>
Mon, 15 Jun 2026 13:26:28 +0000 (15:26 +0200)
committer2weiEmu <saalbach.robert@outlook.de>
Mon, 15 Jun 2026 13:26:28 +0000 (15:26 +0200)
pkg/dbhandling/roomsapi.go
public/index.html
public/js/room.js
public/rooms.html
songmanager

index 7093ac477caa5cf2b693dd507bcfa6e546974514..a4a9a52cc50821a5f4f237e8458c3236d3b77f3e 100644 (file)
@@ -78,7 +78,9 @@ func (dbw *DBWrapper) RoomsAddByNameAndId(w http.ResponseWriter, r *http.Request
 
        err := json.NewDecoder(r.Body).Decode(&assignedSongKeys)
        if err != nil {
+               // https://stackoverflow.com/questions/67140505/http-superfluous-response-writeheader-call
                w.WriteHeader(http.StatusInternalServerError)
+               w.Write([]byte("Failed to parse JSON: " + err.Error()))
                return
        }
 
@@ -87,6 +89,7 @@ func (dbw *DBWrapper) RoomsAddByNameAndId(w http.ResponseWriter, r *http.Request
        c, err := dbw.RedisDb.ZCount(dbw.Ctx, name, "-inf", "+inf").Result()
        if err != nil {
                w.WriteHeader(http.StatusInternalServerError)
+               w.Write([]byte("Failed to count entries on name: " + err.Error()))
                return
        }
 
@@ -100,6 +103,7 @@ func (dbw *DBWrapper) RoomsAddByNameAndId(w http.ResponseWriter, r *http.Request
 
                if err != nil {
                        w.WriteHeader(http.StatusInternalServerError)
+                       w.Write([]byte("Failed to complete ZAdd command: " + err.Error()))
                        return
                }
        }
index 5b4185db415ab8bf2ff2170e26652e4e6458c2c9..b1ec508d394da3fbab6c11a445a4dd696b6515a0 100644 (file)
@@ -10,6 +10,7 @@
 
        <body>
 
+               <a href="/rooms.html">Room Management</a>
                <div id="outerSongList">
                        <h1><u>Song List</u></h1>
 
index d083ea01a0b626948b2445d8aa4723133ae21f91..e32b555a6a7ebded084d9c6b88e75b75632af482 100644 (file)
@@ -1,3 +1,28 @@
+/**
+ * ROOM CREATION
+ **/
+
+let createRoomButton = document.getElementById("createRoomButton")
+
+
+async function createRoomWithName() {
+       let name = prompt("Name the room")
+
+       let response = await fetch("/api/rooms/add/" + name, {
+               method: "PUT",
+               body: JSON.stringify(["0"])
+       })
+       
+       if (response.status != 200) {
+               alert(await response.text())
+               return
+       }
+
+       populateRoomSelect()
+}
+
+createRoomButton.addEventListener("click", (_) => { createRoomWithName() } )
+
 /**
  * ADD / REMOVE FROM ROOMS
  **/
index 1a4ee4ae65098ebb5e00e5995361f161fbc24431..8191ea7d4327fd0ef67a591c0c070b5eb0bdaf13 100644 (file)
@@ -7,6 +7,8 @@
        </head>
 
        <body>
+               <a href="/">Home</a>
+               <button id="createRoomButton">Make a New Room</button>
                <label for="rooms">Select a Room to View</label>
                <select name="rooms" id="roomSelect">
                        
index d0fc5df87ed9781fc0ab8f04e8b85dba8e8be6ca..36a3040f94137519c60db752d227d64f23805069 100755 (executable)
Binary files a/songmanager and b/songmanager differ