diff --git a/README.md b/README.md index 877d4ad..9cbcfb2 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ > - Popup Prefab > - Declencher lors de l'action -**Playlist Share** +**Playlist Share (Done)** > - Envoyer des playlist avec la liste des utilisateurs diff --git a/data/playlist.json b/data/playlist.json index 85a4cc4..de8ec1a 100644 --- a/data/playlist.json +++ b/data/playlist.json @@ -143,6 +143,17 @@ "isStream": false, "uri": "https://www.youtube.com/watch?v=ChireNiqxTo", "thumbnail": "https://img.youtube.com/vi/ChireNiqxTo/default.jpg" + }, + { + "track": "QAAAkQIALE1JQ0hBRUwgSkFDS1NPTiAtIEJBRCBbQUpBWMK0UyBFWFRFTkRFRCBNSVhdAAtBamF4U3RyaWtlcgAAAAAACDGoAAszRWE3XzZRdTJ4bwABACtodHRwczovL3d3dy55b3V0dWJlLmNvbS93YXRjaD92PTNFYTdfNlF1MnhvAAd5b3V0dWJlAAAAAAAAAAA=", + "title": "MICHAEL JACKSON - BAD [AJAX´S EXTENDED MIX]", + "identifier": "3Ea7_6Qu2xo", + "author": "AjaxStriker", + "duration": 537000, + "isSeekable": true, + "isStream": false, + "uri": "https://www.youtube.com/watch?v=3Ea7_6Qu2xo", + "thumbnail": "https://img.youtube.com/vi/3Ea7_6Qu2xo/default.jpg" } ] } diff --git a/package.json b/package.json index e7ff6a6..eb9d2b3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "subsonics-web", "author": "Raphix", - "version": "0.8.0", + "version": "0.8.1", "nodemonConfig": { "ext": "js, html", "ignore": [ diff --git a/src/modules/sub-auth.js b/src/modules/sub-auth.js index 07e344a..2fbc42c 100644 --- a/src/modules/sub-auth.js +++ b/src/modules/sub-auth.js @@ -153,6 +153,22 @@ module.exports.getUsers = function () { } +module.exports.getUsersList = function () { + + var userList = new Array() + const userDB = JSON.parse(fs.readFileSync(__glob.USERS)) + + for(var user of userDB) { + + userList.push({"username": user.user.username, "global_name":user.user.global_name, "avatar": user.user.avatar, "id": user.user.id}) + + } + + return userList + +} + + module.exports.getUser = function (token) { return users.get(token) } diff --git a/src/modules/sub-playlist.js b/src/modules/sub-playlist.js index 6bed87e..b2d91da 100644 --- a/src/modules/sub-playlist.js +++ b/src/modules/sub-playlist.js @@ -4,7 +4,8 @@ const { LogType } = require("./sub-log"); var { List } = require("./sub-list") const discord = require("./discord-bot") const subplayer = require("./sub-player") -const fs = require("fs") +const fs = require("fs"); +const { type } = require("os"); var playlists = {} const plog = new LogType("Playlist-Manager") @@ -41,6 +42,23 @@ module.exports.addPlaylist = function (id, name) { } +module.exports.copyPlaylist = function (id, from, dest) { + this.getUser(dest) + check() + let playlistDest = playlists[dest][from] + if(!playlistDest) { + plog.log("Ajout de la playlist à l'utilisateur \"" + id + "\" dans la base de donnée Playlist !") + playlists[dest][from] = playlists[id][from] + + fs.writeFileSync(__glob.PLAYLIST, JSON.stringify(playlists, null, 2)) + } else { + + plog.log("L'utilisateur \"" + dest + "\" à déjà une playlist avec le nom "+ from + " dans la base de donnée Playlist !") + + } + +} + module.exports.removePlaylist = function (id, name) { check() if(playlists[id][name]) { diff --git a/src/modules/sub-web.js b/src/modules/sub-web.js index 0c00a49..0740172 100644 --- a/src/modules/sub-web.js +++ b/src/modules/sub-web.js @@ -274,6 +274,26 @@ function IOConnection(io) { }) + GetRequest(io, socket, "USER_LIST", () => { + var cookies = socket.handshake.headers.cookie + cookies = cook.parse(cookies) + var token = cookies.token + + const user = auth.getUser(token) + + + if(user.admin == true) { + + const users_data = auth.getUsersList() + + socket.emit("ANSWER/GET/USER_LIST", users_data) + + } + + + + }) + @@ -667,7 +687,7 @@ function IOConnection(io) { subplayer.report(null, null, data) const user = auth.getUser(token) - io.emit("NOTIFICATION", {"image_src": "https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.vecteezy.com%2Fvector-art%2F19521981-green-check-mark-vector-icon-with-circle-checkmark-illustration&psig=AOvVaw1-8kuUXImHNwIoVvySyiSK&ust=1694119774978000&source=images&cd=vfe&opi=89978449&ved=0CBAQjRxqFwoTCLjb2YzuloEDFQAAAAAdAAAAABAE", "text": "Votre rapport de bug a été correctement envoyé !" }) + socket.emit("NOTIFICATION", {"image_src": "https://static.vecteezy.com/system/resources/previews/019/521/981/non_2x/green-check-mark-icon-with-circle-checkmark-illustration-free-vector.jpg", "text": "Votre rapport de bug a été correctement envoyé !" }) } else { @@ -998,6 +1018,44 @@ function IOConnection(io) { }) + socket.on("SEND/SEND_PLAYLIST", async (key, dest) => { + + + var cookies = socket.handshake.headers.cookie + + if(cookies) { + + cookies = cook.parse(cookies) + var token = cookies.token + + if(auth.checkUser(token)) { + + + + var user = auth.getUser(token) + var userId = user.user.id + + + subplaylist.copyPlaylist(userId, key, dest) + + io.sockets.emit("DO_UPDATE_PLAYLIST") + socket.emit("NOTIFICATION", {"image_src": "https://static.vecteezy.com/system/resources/previews/019/521/981/non_2x/green-check-mark-icon-with-circle-checkmark-illustration-free-vector.jpg", "text": "La playlist a été correctement envoyé ! (Si le destinataire a déjà une playlist avec le même nom, l'opération est annulé" }) + io.emit("ANSWER/SEND/SEND_PLAYLIST/OK") + + } else { + + io.emit("ANSWER/SEND/SEND_PLAYLIST", {"error":"USER_DONT_EXIST"}) + } + } else { + io.emit("ANSWER/SEND/SEND_PLAYLIST", {"error":"TOKEN_NOT_FINDED"}) + + } + + + + }) + + socket.on("SEND/ADD_SONG_TO_PLAYLIST", async (data, song) => { diff --git a/src/web/public/images/logo-test.ico b/src/web/public/images/logo-test.ico new file mode 100644 index 0000000..d90e833 Binary files /dev/null and b/src/web/public/images/logo-test.ico differ diff --git a/src/web/public/images/logo-test.png b/src/web/public/images/logo-test.png new file mode 100644 index 0000000..a9522a0 Binary files /dev/null and b/src/web/public/images/logo-test.png differ diff --git a/src/web/public/images/logo.ico b/src/web/public/images/logo.ico index d90e833..439327f 100644 Binary files a/src/web/public/images/logo.ico and b/src/web/public/images/logo.ico differ diff --git a/src/web/public/images/logo.png b/src/web/public/images/logo.png index a9522a0..e5f7567 100644 Binary files a/src/web/public/images/logo.png and b/src/web/public/images/logo.png differ diff --git a/src/web/public/javascript/__index_script.js b/src/web/public/javascript/__index_script.js index 9c56cd3..2b9e301 100644 --- a/src/web/public/javascript/__index_script.js +++ b/src/web/public/javascript/__index_script.js @@ -19,9 +19,9 @@ const settingsBtn = document.getElementById("settings_btn") const loop = document.getElementById("loop") -const vol = document.getElementById("vol") +const vol = document.getElementById("volbtn") const shuffle = document.getElementById("shuffle") -const list = document.getElementById("list") +const list = document.getElementById("list_btn") const takeCurrent = document.getElementById("takeCurrent") const volBox = document.getElementById("volumeBox") @@ -72,12 +72,49 @@ homeBtn.style.color = "white" var xMousePos = 0; var yMousePos = 0; + +const tooltip = document.getElementById("tooltip") + document.onmousemove = function(e) { - xMousePos = e.clientX + window.pageXOffset; - yMousePos = e.clientY + window.pageYOffset; + xMousePos = e.clientX + window.scrollX; + yMousePos = e.clientY + window.scrollY; + + tooltip.style.visibility = 'hidden' + tooltip.style.display = 'none' + showToolTip("pplay", "Jouer maintenant", e) + showToolTip("delete", "Supprimer", e) + showToolTip("add", "Ajouter à la liste de lecture", e) + showToolTip("loop", "Répéter le titre", e) + showToolTip("shuffle", "Mélanger la liste de lecture", e) + showToolTip("list_btn", "Liste de lecture", e) + showToolTip("disconnect", "Déconnecter le bot", e) + showToolTip("sendplaylist", "Envoyer la playlist", e) + showToolTip("playlistdelete", "Effacer la playlist", e) + showToolTip("reload", "Relancer le serveur", e) + showToolTip("admin", "Donner les permissions Administrateur", e) + showToolTip("takeCurrent", "Ajouter le titre à une playlist", e) + showToolTip("volbtn", "Volume", e) }; +function showToolTip(id, text, e) { + + if(e.target) { + + if(e.target.id.includes(id) || e.target.parentNode.parentNode.id.includes(id)) { + tooltip.style.visibility = 'visible' + tooltip.style.display = 'unset' + tooltip.style.top = ( yMousePos - ( tooltip.offsetHeight + 20)) + "px" + tooltip.style.width = "150px" + tooltip.style.left =(xMousePos - 75 )+ "px" + tooltip.innerHTML = text + + } + + } + + +} homeBtn.addEventListener("click", () => { @@ -103,6 +140,54 @@ function playPlayList(key) { } +function sendPlayList(key) { + + const playlist_popup = document.getElementById("playlist_popup") + + if(playlist_popup) { + + get("USER_LIST").then(resp => { + + const userToPush = new Array() + + for(var user of resp) { + + userToPush.push(`
${user.global_name}
${user.username}
' + key + '
' + key + '
' + title.title + '
' + title.author + '
' + PFormatduration + '
' + title.title + '
' + title.author + '
' + PFormatduration + '
lava2.horizxon.studio
-Connecté
-lava2.horizxon.studio
-Connecté
-lava2.horizxon.studio
-Déconnecté
-lava2.horizxon.studio
-Déconnecté
-Créer à une playlist
Selectionner la playlist
Ajouter à une playlist
Selectionner la playlist