]> git.example.dev Git - binbsis50-sm.git/commitdiff
updateds:
author2weiEmu <saalbach.robert@outlook.de>
Mon, 16 Mar 2026 11:14:46 +0000 (12:14 +0100)
committer2weiEmu <saalbach.robert@outlook.de>
Mon, 16 Mar 2026 11:14:46 +0000 (12:14 +0100)
main.go
pkg/dbhandling/dbhandling.go
public/index.html
public/js/index.js
songmanager
testing/songs/Soul Asylum_Runaway+Train.m4a [new file with mode: 0644]

diff --git a/main.go b/main.go
index d256de530c85aa4a1b0419a994408255d113e1d4..8aca605bed2201be08f4874ccf545e305885fbf1 100644 (file)
--- a/main.go
+++ b/main.go
@@ -47,6 +47,7 @@ func main() {
        mux.HandleFunc("/api/db_status_update", DBwrapper.GetDBStatus)
        mux.HandleFunc("/api/renameSong", DBwrapper.UpdateSongsFilename)
        mux.HandleFunc("/api/updateSong", DBwrapper.UpdateSongStats)
+       mux.HandleFunc("/api/getSongFiles", DBwrapper.GetSongFiles)
        mux.Handle("/", http.FileServer(http.Dir("./public/")))
 
        listenPort := ":" + strconv.Itoa(*paramPort)
index 633598109d3ab07ecd7acc27209fac8956ec20d1..ff63065d020703ed512a0351d347479d0020a7e6 100644 (file)
@@ -198,3 +198,38 @@ func (dbw *DBWrapper) GetDBStatus(w http.ResponseWriter, r *http.Request) {
 
        w.Write(b)
 }
+
+type AllSongFiles struct {
+       SongFileList []string
+}
+
+/**
+ * Get a list of all song files
+ */
+func (dbw *DBWrapper) GetSongFiles(w http.ResponseWriter, r *http.Request) {
+       if r.Method != "GET" {
+               w.WriteHeader(http.StatusMethodNotAllowed)
+               return
+       }
+
+       songFiles, err := os.ReadDir(dbw.PathToSongs)
+       if err != nil {
+               panic(err)
+       }
+       
+       fileNames := make([]string, 0)
+
+       for _, file := range songFiles {
+               fileNames = append(fileNames, file.Name())
+       }
+
+       allSongs := AllSongFiles{
+               SongFileList: fileNames,
+       }
+
+       b, err := json.Marshal(allSongs)
+       if err != nil {
+               panic(err)
+       }
+       w.Write(b)
+}
index 48ef27f76c3cea86f97bec5bd16e50442214f790..96815a7817d9cc8c2d2c392e8850aea4fc56fe90 100644 (file)
                        <p>Filter songs here:</p>
                        <input id="allSongFilterList" type="text"></input>
                        <ul style="max-height: 400px; overflow-y: auto" id="db_status_song_list">
+                       </ul>
+                       <h2>List of Song Files</h2>
+                       <ul style="max-height: 400px; overflow-y: auto" id="song_file_list">
+                               
                        </ul>
 
                        <h2>Which rooms these songs are applied to</h2>
index 911dc32d35ef31f9de576b364794df0db4769dac..6ff33b0572c9e4e3de8ad4e83b1fe455bfe87e00 100644 (file)
@@ -1,8 +1,11 @@
 let AllSongs = null
+let AllFilenames = null
 let currentEditSong = null
 let dbSongList = document.getElementById("db_status_song_list")
 let editElement = document.getElementById("editElement")
 
+let songFileList = document.getElementById("song_file_list")
+
 
 let updateSongFile = document.getElementById("updateSongFile")
 let editArtistName = document.getElementById("editArtistName")
@@ -25,6 +28,9 @@ function getSongUsingKey(key) {
        return null
 }
 
+function songHasValidFilename(song) {
+       return AllFilenames.includes(song.PreviewURL)
+}
 
 function openEditElement(song) {
        editElement.style.display = "block"
@@ -81,7 +87,14 @@ function newSongDisplayWithEdit(song) {
        info.style.margin = "7px 5px 7px 5px"
        info.style.padding = "2px 5px 2px 5px"
        info.style.minWidth = "400px"
-       info.innerText = "(" + song.Key + ") " + song.DisplayTrackName + " by " + song.DisplayArtistNames.replace("~", ", ")
+
+       let check = "❌"
+
+       if (songHasValidFilename(song)) {
+               check = "✅"
+       }
+
+       info.innerText = check + "(" + song.Key + ") " + song.DisplayTrackName + " by " + song.DisplayArtistNames.replace("~", ", ")
 
        let but = document.createElement("button")
        but.innerText = "Edit"
@@ -168,6 +181,21 @@ async function get_updated_status() {
                        room_list.appendChild(new_list)
                }
        })
+
+       fetch("/api/getSongFiles",
+               {'Accept': 'application/json', 'Content-type': 'application/json'}
+               ).then(async (response) => {
+                       const body = await response.json()
+                       songFileList.innerHTML = ""
+                       AllFilenames = body.SongFileList
+
+                       for (let filename of body.SongFileList) {
+                               let li = document.createElement("li")
+                               li.innerText = filename
+                               songFileList.appendChild(li)
+                       }
+
+       })
 }
 
 window.onload = () => {
index e691fdc49ad8ac78c64df886ba2c7a621da0b936..96de83798dc661c3648ac5457bffac14255c7815 100755 (executable)
Binary files a/songmanager and b/songmanager differ
diff --git a/testing/songs/Soul Asylum_Runaway+Train.m4a b/testing/songs/Soul Asylum_Runaway+Train.m4a
new file mode 100644 (file)
index 0000000..e69de29