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}

`) + + } + + playlist_popup.innerHTML = userToPush.join("") + playlist_popup.style.width = '170px' + playlist_popup.style.top = (yMousePos - 30) + "px" + playlist_popup.style.left = (xMousePos - 165) + "px" + playlist_popup.classList.remove("invisible") + + + playlist_popup.addEventListener("mouseleave", () => { + + playlist_popup.classList.add("invisible") + + }) + + for(var user of resp) { + + const userElement = document.getElementById(resp.indexOf(user)) + + userElement.addEventListener("click", () => { + + playlist_popup.classList.add("invisible") + send("SEND_PLAYLIST", key, resp[userElement.id].id) + }) + } + + //send("SEND_PLAYLIST", key, user.id) + + }) + } + + + +} socket.on("DO_UPDATE_PLAYLIST", () => { @@ -116,7 +201,7 @@ socket.on("ANSWER/GET/PLAYLIST", (data) => { var selectionData = new Array() - contentToPush.push('
Créer une playlist
') + contentToPush.push('
Créer une playlist
') for (const [key, value] of Object.entries(data)) { @@ -170,8 +255,9 @@ socket.on("ANSWER/GET/PLAYLIST", (data) => { }); - const addPlaylist = document.getElementById("addPlaylist") - const addPlaylist_dialog = document.getElementById("addPlaylist_dialog") + const addPlaylist = document.getElementById("createPlaylist") + const addPlaylist_dialog = document.getElementById("createPlaylist_dialog") + const addPlaylist_close = document.getElementById("createPlaylist_close") const apText = document.getElementById("apText") const apCreate = document.getElementById("apCreate") @@ -249,7 +335,8 @@ function loadPlaylist(key, value) { } - playlistToPush.push('

' + key + '


' + playlist_songs.join("")) + playlistToPush.push(``) + playlistToPush.push('

' + key + '


' + playlist_songs.join("")) if(playlistToPush.join("") == "") { @@ -332,7 +419,7 @@ searchBtn.addEventListener("click", () => { pmaxsec = `0${pmaxsec}`; } - + if(pmaxhours != 0) { if (pmaxmin < 10) { @@ -354,7 +441,7 @@ searchBtn.addEventListener("click", () => { } PFormatduration = pmax - contentToPush.push('

' + title.title + '

' + title.author + '

' + PFormatduration + '

Lire maintenant
Ajouter à une playlist
Copier le lien

Ajouter à une playlist

Selectionner la playlist

') + contentToPush.push('

' + title.title + '

' + title.author + '

' + PFormatduration + '

Lire maintenant
Ajouter à une playlist
Copier le lien

Ajouter à une playlist

Selectionner la playlist

') } if(contentToPush.join("") == "") { @@ -373,7 +460,7 @@ searchBtn.addEventListener("click", () => { const testPopup = document.getElementById(data.indexOf(title) + "_popup") const playNow = document.getElementById(data.indexOf(title) + "_playNow") const copy = document.getElementById(data.indexOf(title) + "_copy") - const addPlaylist = document.getElementById(data.indexOf(title) + "_addPlaylist") + const addPlaylist = document.getElementById(data.indexOf(title) + "_goPlaylist") const PlaylistManager = document.getElementById(data.indexOf(title) + "playlistManager") const playlistManager_close = document.getElementById(data.indexOf(title) + "playlistManager_close") @@ -589,6 +676,8 @@ socket.on("NOTIFICATION", (data) => { }) + + const cPlaylistManager = document.getElementById("current_playlistManager") const cplaylistManager_close = document.getElementById("current_playlistManager_close") const cplaylistSelection = document.getElementById("current_playlistSelection") diff --git a/src/web/public/javascript/__settings_script.js b/src/web/public/javascript/__settings_script.js index 4ff63d0..b86c320 100644 --- a/src/web/public/javascript/__settings_script.js +++ b/src/web/public/javascript/__settings_script.js @@ -236,70 +236,6 @@ socket.on("ALWAYS/USERS",(data) => { socket.on("ALWAYS/NODES",(data) => { - /*settings_content.innerHTML = ` -
- -
-
-
-
- -

lava2.horizxon.studio

-

Connecté

-
-
- - -
- -
-
-
- -

lava2.horizxon.studio

-

Connecté

-
-
- - -
- -
-
-
- -

lava2.horizxon.studio

-

Déconnecté

-
-
- - -
- -
-
-
- -

lava2.horizxon.studio

-

Déconnecté

-
-
- - -
- -
- - `*/ - const settings_content = document.getElementById("settings_content") if(settings_content && wasOnNodes) { diff --git a/src/web/public/stylesheets/style.css b/src/web/public/stylesheets/style.css index 0c7319e..6306f91 100644 --- a/src/web/public/stylesheets/style.css +++ b/src/web/public/stylesheets/style.css @@ -16,7 +16,9 @@ body { background-color: black; color: white; font-family: 'Roboto', sans-serif; - background: linear-gradient(225deg, #342348 0%, #1C1A31 100%);; + background: linear-gradient(225deg, #342348 0%, #1C1A31 100%); + overflow-x: hidden; + } @@ -360,8 +362,7 @@ p { .report_dialog { - width: 40vw; - height: 25vw; + width: 50%; padding: 0; background: linear-gradient(90deg, #515151 0%, #2e2e2e 100%); border: none; @@ -980,8 +981,8 @@ p { display: flex; justify-content: end; align-items: center; - gap: 10%; - width: 10%; + gap: 5%; + width: 20%; } @@ -1134,6 +1135,7 @@ p { .alert_div { + visibility: hidden; width: 20%; position: absolute; top: -10%; @@ -1165,4 +1167,18 @@ p { .alert_div_on { transition: all 2s; top: 4% !important; -} \ No newline at end of file + visibility: visible; +} + +.tooltip-text { + visibility: hidden; + position: absolute; + z-index: 50; + width: 100px; + color: white; + background-color: #2e2e2e; + padding: 7px; + border-radius: 12px; + text-align: center; + opacity: 0.5; +} diff --git a/src/web/templates/index.ejs b/src/web/templates/index.ejs index 06e0fb6..d065413 100644 --- a/src/web/templates/index.ejs +++ b/src/web/templates/index.ejs @@ -7,6 +7,7 @@ Subsonics - Web + Tooltip Text
@@ -47,10 +48,10 @@
- +

Créer une playlist

- +
@@ -96,11 +97,11 @@

0:00

-

Créer à une playlist

Selectionner la playlist

+

Ajouter à une playlist

Selectionner la playlist

- +

100%

@@ -108,7 +109,7 @@
- +