diff --git a/data/betas.json b/data/betas.json new file mode 100644 index 0000000..f75b76e --- /dev/null +++ b/data/betas.json @@ -0,0 +1 @@ +["486943594893017119","442290526545510421"] \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a222773..2bb0654 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "subsonics-web", - "version": "0.2.2", + "version": "0.2.3", "dependencies": { "cookie": "^0.5.0", "cookie-parser": "^1.4.6", @@ -14,6 +14,7 @@ "ejs": "^3.1.9", "erela.js": "^2.4.0", "express": "^4.18.2", + "express-favicon": "^2.0.4", "nodemon": "^2.0.22", "socket.io": "^4.6.1", "uuid": "^9.0.0", @@ -704,6 +705,14 @@ "node": ">= 0.10.0" } }, + "node_modules/express-favicon": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/express-favicon/-/express-favicon-2.0.4.tgz", + "integrity": "sha512-JDGzumJdwF+WcJf+qwyhdpF1yzducuMCxZa+G6hxR3hor7ae/1CqpAPj8FXCGaGtqBA6ExDMfeszjuYRw5GUuQ==", + "engines": { + "node": ">=4" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -2250,6 +2259,11 @@ "vary": "~1.1.2" } }, + "express-favicon": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/express-favicon/-/express-favicon-2.0.4.tgz", + "integrity": "sha512-JDGzumJdwF+WcJf+qwyhdpF1yzducuMCxZa+G6hxR3hor7ae/1CqpAPj8FXCGaGtqBA6ExDMfeszjuYRw5GUuQ==" + }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", diff --git a/package.json b/package.json index f84a7b2..752045a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "subsonics-web", "author": "Raphix", - "version": "0.2.3", + "version": "0.3.0", "nodemonConfig": { "ext": "js, html", "ignore": [ @@ -18,6 +18,7 @@ "ejs": "^3.1.9", "erela.js": "^2.4.0", "express": "^4.18.2", + "express-favicon": "^2.0.4", "nodemon": "^2.0.22", "socket.io": "^4.6.1", "uuid": "^9.0.0", @@ -26,5 +27,6 @@ "scripts": { "start": "nodemon src/main.js", "dev": "set DEV=true& nodemon src/main.js" - } + }, + "beta_on": true } diff --git a/src/modules/discord-bot.js b/src/modules/discord-bot.js index 53358ff..fefebfd 100644 --- a/src/modules/discord-bot.js +++ b/src/modules/discord-bot.js @@ -6,6 +6,7 @@ const { __glob } = require("./global-variables") const { LogType } = require("../modules/sub-log") const { List } = require("./sub-list") const nodeFinder = require("./nodes-finder") +const subplayer = require("./sub-player") const client = new Client({ intents:[GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMembers], @@ -13,6 +14,11 @@ const client = new Client({ const membersVoices = new Map() +module.exports.getClient = function () { + + return client +} + module.exports.DiscordBot = class { constructor(config, dlog) { @@ -192,6 +198,9 @@ function startErelaManager(dlog, config) { client.channels.fetch(player.options.voiceChannel).then(channel => { plog.log("Nouveau Player instancié dans : " + channel.name) }) + + + process.emit("MUSIC_UPDATE_STATE") }) @@ -201,13 +210,16 @@ function startErelaManager(dlog, config) { client.channels.fetch(player.options.voiceChannel).then(channel => { plog.log("Player supprimé dans : " + channel.name) }) - + + process.emit("MUSIC_UPDATE_STATE") }) client.manager.on("trackStart", (song) => { plog.log("Lecture de '" + song.queue.current.title + "' de '" + song.queue.current.author + "'") list.setCurrent(song) + + process.emit("MUSIC_UPDATE_STATE") }) @@ -222,6 +234,9 @@ function startErelaManager(dlog, config) { } } + + + process.emit("MUSIC_UPDATE_STATE") }) // Emitted whenever a node connects @@ -235,6 +250,7 @@ function startErelaManager(dlog, config) { }) + // THIS IS REQUIRED. Send raw events to Erela.js client.on("raw", d => client.manager.updateVoiceState(d)); } \ No newline at end of file diff --git a/src/modules/global-variables.js b/src/modules/global-variables.js index 4adf0f0..fb47b8f 100644 --- a/src/modules/global-variables.js +++ b/src/modules/global-variables.js @@ -5,12 +5,14 @@ const root = path.resolve(__dirname, '../../') const __glob = { CONFIG: root + path.sep + "data" + path.sep + "config.json", USERS: root + path.sep + "data" + path.sep + "users.json", + BETA_USERS: root + path.sep + "data" + path.sep + "betas.json", ROOT: root, WEB_DIR: root + path.sep + "src" + path.sep + "web", COMMANDS: root + path.sep + "src" + path.sep + "commands", SUBLOG: root + path.sep + "src" + path.sep + "modules" + path.sep + "sub-log.js", SUBPLAYER: root + path.sep + "src" + path.sep + "modules" + path.sep + "sub-player.js", SUBLIST: root + path.sep + "src" + path.sep + "modules" + path.sep + "sub-list.js", + DISCORDBOT: root + path.sep + "src" + path.sep + "modules" + path.sep + "discord-bot.js", PACKAGE: root + path.sep + "package.json", DATA: root + path.sep + "data" + path.sep, NODES: root + path.sep + "data" + path.sep + "nodes.json", @@ -21,7 +23,8 @@ const __web = { ROUTER: webroot + "routes" + path.sep, PUBLIC: webroot + "public", - TEMPLATES: webroot + "templates" + TEMPLATES: webroot + "templates", + ICON: webroot + "public" + path.sep + "images" + path.sep + "logo.ico" } module.exports = { __glob, __web }; diff --git a/src/modules/sub-auth.js b/src/modules/sub-auth.js index 8d979c1..5b4ac09 100644 --- a/src/modules/sub-auth.js +++ b/src/modules/sub-auth.js @@ -1,5 +1,5 @@ const { resolve } = require("path"); -const { __glob } = require("../modules/global-variables"); +const { __glob, __web } = require("../modules/global-variables"); const { LogType } = require('./sub-log'); const fs = require("fs") @@ -7,6 +7,9 @@ const alog = new LogType("Authentification") var users = new Map() var sessions = new Array() +var betausers = new Array() + +var packageJson = JSON.parse(fs.readFileSync(__glob.PACKAGE)) updateUsers() @@ -78,11 +81,31 @@ module.exports.getDiscordUser = function (code, session) { reject("MIGRATE_ACCOUNT_ONLY") } else { - user.auth = authorizationKey - Object.assign(user, userInfo) + + if(packageJson.beta_on == false) { + user.auth = authorizationKey + Object.assign(user, userInfo) + + + resolve(user) + + } else { + + if(betausers.includes(userInfo.user.id)) { + + user.beta = true + Object.assign(user, userInfo) + + + resolve(user) - - resolve(user) + } else { + + reject("NOT_IN_BETA") + } + + } + } @@ -172,18 +195,31 @@ module.exports.removeUser = function (token) { function updateUsers() { + + if(!fs.existsSync(__glob.BETA_USERS)){ + + fs.writeFileSync(__glob.BETA_USERS, '[]') + } if(!fs.existsSync(__glob.USERS)){ fs.writeFileSync(__glob.USERS, '[]') } + const userDB = JSON.parse(fs.readFileSync(__glob.USERS)) + const betausersDB = JSON.parse(fs.readFileSync(__glob.BETA_USERS)) for (const user of userDB) { users.set(user.token, user) } + for (const id of betausersDB) { + + betausers.push(id) + } + alog.log("Actualisation de " + userDB.length + " utilisateurs depuis : " + __glob.USERS) + alog.log("Actualisation de " + betausersDB.length + " utilisateurs bêtas depuis : " + __glob.BETA_USERS) } \ No newline at end of file diff --git a/src/modules/sub-list.js b/src/modules/sub-list.js index 3c25d20..99cc733 100644 --- a/src/modules/sub-list.js +++ b/src/modules/sub-list.js @@ -14,6 +14,11 @@ module.exports.List = class { } + getList() { + + return next + } + destroy() { next = new Array() diff --git a/src/modules/sub-player.js b/src/modules/sub-player.js index aa68c72..8cb341c 100644 --- a/src/modules/sub-player.js +++ b/src/modules/sub-player.js @@ -2,7 +2,9 @@ const { SlashCommandBuilder, EmbedBuilder, DefaultWebSocketManagerOptions } = re const { __glob } = require("../modules/global-variables"); const { LogType } = require("./sub-log"); const { List } = require("./sub-list") -var ytfps = require("ytfps") +const discord = require("./discord-bot") +var ytfps = require("ytfps"); + const list = new List() @@ -70,7 +72,8 @@ module.exports.play = async function (client, interaction) { // [A FINIR POUR WEB] } - + + process.emit("MUSIC_UPDATE_STATE") } @@ -116,9 +119,29 @@ module.exports.pause = function (client, interaction) { } else { - // [A FINIR POUR WEB] + if(!client) { + + client = discord.getClient() + } + + let player = client.manager.players.get("137291455336022018") + + if(player) { + + if(player.playing) { + player.pause(true) + } else { + + player.pause(false) + } + + } + + } + process.emit("MUSIC_UPDATE_STATE") + } module.exports.getState = function(client, interaction) { @@ -149,6 +172,7 @@ module.exports.getState = function(client, interaction) { } + } @@ -193,12 +217,41 @@ module.exports.skip = function (client, interaction) { } else { - // [A FINIR POUR WEB] + if(!client) { + + client = discord.getClient() + } + + let player = client.manager.players.get("137291455336022018") + + if(list.haveSongs()) { + player.stop() + } + + } + process.emit("MUSIC_UPDATE_STATE") +} + +module.exports.seek = function (data) { + + + + client = discord.getClient() + + + let player = client.manager.players.get("137291455336022018") + + player.seek(data) + + process.emit("MUSIC_UPDATE_STATE") + + } + module.exports.previous = function (client, interaction) { if(interaction) { @@ -238,8 +291,91 @@ module.exports.previous = function (client, interaction) { } + } else { + + if(!client) { + + client = discord.getClient() + } + + let player = client.manager.players.get("137291455336022018") + + if(list.havePreviousSongs()){ + list.__next_add(player.queue.current) + player.play(list.previous()) + } + + + } + process.emit("MUSIC_UPDATE_STATE") +} + +const clog = new LogType("Actualisation") + +module.exports.updateMusicState = function (client, action) { + + if(!client) { + + client = discord.getClient() } + let player = client.manager.players.get("137291455336022018") + var currentTitle = "null" + + const data = { + "playing": 0, + "current":null, + "isOnline": false, + "queue": null, + "loop": false, + "durationNow": null, + "durationAll": null, + "volume": null + } + + if(player) { + + data["current"] = player.queue.current + + if(player.queueRepeat == true) { + + data["loop"] = true + } + + data["volume"] = player.volume * 10 + + + if(player.queue.current) { + data["durationNow"] = player.position + data["durationAll"] = player.queue.current.duration + currentTitle = player.queue.current.title + } + + + if(player.playing == true && player.paused == false) { + + data["playing"] = 1 + } else { + data["playing"] = 0 + + } + + data["queue"] = list.getList(); + data["isOnline"] = true + + } + + + if(action == "end") { + + data["current"] = null; + data["isOnline"] = false + } + + clog.log("Actualisation de tous les clients - Titre : " + currentTitle) + return data + + } // FINI @@ -284,7 +420,9 @@ module.exports.leave = function (client, interaction) { } + process.emit("MUSIC_UPDATE_STATE") + } diff --git a/src/modules/sub-web.js b/src/modules/sub-web.js index 19f44aa..f0476e4 100644 --- a/src/modules/sub-web.js +++ b/src/modules/sub-web.js @@ -5,7 +5,7 @@ const log = require("./sub-log"); const auth = require("./sub-auth"); const cook = require("cookie") const wlog = new LogType("Web") - +const subplayer = require(__glob.SUBPLAYER); module.exports.WebServer = class { constructor() { @@ -23,6 +23,7 @@ function init() { const path = require('path'); const cookieParser = require('cookie-parser'); const http = require("http"); + const favicon = require('express-favicon'); const app = express(); @@ -49,7 +50,7 @@ function init() { app.use('/', indexRouter); app.use('/login', loginRouter); app.use("/internal", internalRouter) - + app.use(favicon(__web.ICON)); app.use(function (req, res, next) { next(createError(404)); @@ -134,15 +135,26 @@ function IOConnection(io) { const alog = log.getInstance("Authentification") + process.on("MUSIC_UPDATE_STATE", () => { + + const data = subplayer.updateMusicState() + + io.sockets.emit("/ALWAYS/MUSIC_STATE", data) + + }) + io.on("connection", (socket) => { wlog.log("[SOCKET] - Nouvelle session : " + socket.id) socket.on("disconnect", () => { - + wlog.log("[SOCKET] - Fin de session : " + socket.id) + }) + // SPECIAL + socket.on("GET/DISCORD_LOGIN_LINK", () => { @@ -160,8 +172,54 @@ function IOConnection(io) { io.emit("ANSWER/GET/DISCORD_LOGIN_LINK", discordlink ) }) + GetRequest(socket, "USER_INFO", () => { + var cookies = socket.handshake.headers.cookie + cookies = cook.parse(cookies) + var token = cookies.token + - socket.on("GET/USER_INFO", () => { + const user = auth.getUser(token) + alog.log("Envoi des informations Discord de '" + user.user.username + "' à '" + socket.id + "'" ) + socket.emit("ANSWER/GET/USER_INFO",user) + }) + + GetRequest(socket, "MUSIC_STATE", () => { + var cookies = socket.handshake.headers.cookie + cookies = cook.parse(cookies) + var token = cookies.token + + + const data = subplayer.updateMusicState() + const user = auth.getUser(token) + socket.emit("ANSWER/GET/MUSIC_STATE", "Bienvenue " + user.user.username + " ! ") + io.sockets.emit("/ALWAYS/MUSIC_STATE", data) + }) + + + + + GetRequest(socket, "PAUSE", () => { + + subplayer.pause() + io.emit("ANSWER/GET/PAUSE", "OK") + }) + + + GetRequest(socket, "BACKWARD", () => { + + subplayer.previous() + io.emit("ANSWER/GET/BACKWARD", "OK") + }) + + GetRequest(socket, "FORWARD", () => { + + subplayer.skip() + io.emit("ANSWER/GET/FORWARD", "OK") + }) + + // SEND REQUEST + + socket.on("SEND/SEEK", (data) => { var cookies = socket.handshake.headers.cookie @@ -173,24 +231,67 @@ function IOConnection(io) { if(auth.checkUser(token)) { - const user = auth.getUser(token) - alog.log("Envoi des informations Discord de '" + user.user.username + "' à '" + socket.id + "'" ) - socket.emit("ANSWER/GET/USER_INFO",user) + subplayer.seek(data) } else { - io.emit("ANSWER/GET/USER_INFO", {"error":"USER_DONT_EXIST"}) + io.emit("ANSWER/SEND/SEEK", {"error":"USER_DONT_EXIST"}) } } else { - io.emit("ANSWER/GET/USER_INFO", {"error":"TOKEN_NOT_FINDED"}) + io.emit("ANSWER/SEND/SEEK", {"error":"TOKEN_NOT_FINDED"}) } }) + + + + + + }) + +} + + + + + +function GetRequest (socket, name, func) { + + + socket.on("GET/" + name, () => { + + + var cookies = socket.handshake.headers.cookie + + if(cookies) { + + cookies = cook.parse(cookies) + var token = cookies.token + + if(auth.checkUser(token)) { + + func() + + } else { + + io.emit("ANSWER/GET/" + name, {"error":"USER_DONT_EXIST"}) + } + } else { + io.emit("ANSWER/GET/" + name, {"error":"TOKEN_NOT_FINDED"}) + + } + + + + }) + + +} + -} \ No newline at end of file diff --git a/src/web/public/images/black-image.svg b/src/web/public/images/black-image.svg new file mode 100644 index 0000000..fad9438 --- /dev/null +++ b/src/web/public/images/black-image.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/web/public/images/discord-logo-white.png b/src/web/public/images/discord-logo-white.png new file mode 100644 index 0000000..22ef91a Binary files /dev/null and b/src/web/public/images/discord-logo-white.png differ diff --git a/src/web/public/images/logo.ico b/src/web/public/images/logo.ico new file mode 100644 index 0000000..d90e833 Binary files /dev/null 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 new file mode 100644 index 0000000..a9522a0 Binary files /dev/null and b/src/web/public/images/logo.png differ diff --git a/src/web/public/images/title.png b/src/web/public/images/title.png new file mode 100644 index 0000000..7097877 Binary files /dev/null and b/src/web/public/images/title.png differ diff --git a/src/web/public/javascript/IO.js b/src/web/public/javascript/IO.js index fddda18..f85a099 100644 --- a/src/web/public/javascript/IO.js +++ b/src/web/public/javascript/IO.js @@ -15,7 +15,7 @@ function get(request) { return new Promise((resolve, reject) => { socket.emit("GET/" + request) - console.log("Envoi de la requête : " + request) + console.log("Envoi de la requête GET : " + request) socket.once("ANSWER/GET/" + request, (answer) => { @@ -28,3 +28,27 @@ function get(request) { }) } + +function send(request, data) { + + return new Promise((resolve, reject) => { + + socket.emit("SEND/" + request, data) + console.log("Envoi de la requête SEND : " + request) + + socket.once("ANSWER/SEND/" + request, (answer) => { + + console.log("Réponse pour la requête : " + request) + + resolve(answer) + + }) + + }) + +} + +function getSocket() { + + return socket +} diff --git a/src/web/public/javascript/__index_script.js b/src/web/public/javascript/__index_script.js index 7c81acf..e983052 100644 --- a/src/web/public/javascript/__index_script.js +++ b/src/web/public/javascript/__index_script.js @@ -1,8 +1,243 @@ const userInfoDiv = document.getElementById("userInfo") +const userInfoPopup = document.getElementById("userPopup") +const userInfoglobal = document.getElementById("userInfoglobal") + +const musicTitle = document.getElementById("music_title") +const musicURL = document.getElementById("music_img") + +const durationBar = document.getElementById("duration") +const durationTextAct = document.getElementById("durationTextAct") +const durationTextTotal = document.getElementById("durationTextTotal") + +const backward = document.getElementById("backward") +const play = document.getElementById("play") +const forward = document.getElementById("forward") + +const settings_dialog = document.getElementById("SETTINGS_dialog") +const settings_close = document.getElementById("SETTINGS_close") +const settingsBtn = document.getElementById("settingsBtn") + const userInfo = get("USER_INFO") +settingsBtn.addEventListener("click", () => { + + settings_dialog.showModal() +}) + +settings_close.addEventListener("click",() => { + + settings_dialog.close() +}) + +var durationAll = 0 +var durationProgress = 0 +var isPlaying = false +let interval; + +durationBar.addEventListener("change", () => { + + send("SEEK", durationBar.value) + +}) + + userInfo.then(user => { - userInfoDiv.innerHTML = "

" + user.user.global_name + "

" + user.user.username + "

" + var betastar = "" + + if(user.beta) { + + betastar = "

BETA

" + } + + userInfoDiv.innerHTML = "

" + user.user.global_name + "

" + user.user.username + "

" + betastar + "
" }) + +userInfoDiv.addEventListener("click", () => { + + + userInfoPopup.classList.add("INDEX_userPopup_Visible") + userInfoPopup.classList.remove("INDEX_userPopup") +}) + +userInfoglobal.addEventListener("mouseleave", () => { + + userInfoPopup.classList.add("INDEX_userPopup") + userInfoPopup.classList.remove("INDEX_userPopup_Visible") +}) + +get("MUSIC_STATE").then(data => { + console.log(data) +}) + +play.addEventListener('click', () => { + + get("PAUSE") +}) + +backward.addEventListener('click', () => { + + get("BACKWARD") +}) + + +forward.addEventListener("click", () => { + + get("FORWARD") +}) + +socket.on("/ALWAYS/MUSIC_STATE", (data) => { + + + stopInterval() + console.log(data) + + durationAll = 0 + durationProgress = 0 + isPlaying = false + + if(data.current == null) { + + musicURL.innerHTML = '' + musicTitle.innerHTML = "

Aucun titre joué

" + } else { + + musicURL.innerHTML = '' + musicTitle.innerHTML = "

" + data.current.title + "

" + } + + if(data.durationAll) { + durationBar.disabled = false + durationBar.classList.remove("grised") + setTime() + + durationAll = data.durationAll + durationProgress = data.durationNow + durationBar.value = durationProgress + setTime() + + } else { + + + isPlaying = false + durationAll = 0 + durationProgress = 0 + durationBar.disabled = true + durationBar.classList.add("grised") + durationBar.value = 0 + durationTextAct.innerHTML = "-:--" + durationTextTotal.innerHTML = "-:--" + + } + + + if(data.playing == 1) { + play.innerHTML = '' + isPlaying = true + startInterval() + } else { + + play.innerHTML = '' + isPlaying = false + + } + + + + if(data.current && data.playing == 0) { + setTime() + + } + + + + + +}) + +function startInterval() { + interval = setInterval(() => { + + + if(isPlaying == true) { + setTime() + + } + + }, 1000) + +} + +function stopInterval() { + clearInterval(interval); +} + + + + + + +function setTime() { + + + durationBar.max = durationAll + durationProgress += 1000 + durationBar.value = durationProgress + + + const maxhours = Math.floor(durationAll / 3600000); + const nowhours = Math.floor(durationProgress / 3600000); + + + + var maxmin = Math.trunc(durationAll / 60000) - (Math.floor(durationAll / 60000 / 60) * 60); + var maxsec = Math.floor(durationAll / 1000) - (Math.floor(durationAll / 1000 / 60) * 60); + var nowmin = Math.trunc(durationProgress / 60000) - (Math.floor(durationProgress / 60000 / 60) * 60); + var nowsec = Math.floor(durationProgress / 1000) - (Math.floor(durationProgress / 1000 / 60) * 60); + + console.log(durationAll) + console.log(durationProgress) + console.log("---------------------") + + var now = "" + var max = "" + + + if (maxmin < 10) { + maxmin = `0${maxmin}`; + } + + if (nowmin < 10) { + nowmin = `0${nowmin}`; + } + + if (maxsec < 10) { + maxsec = `0${maxsec}`; + } + + if (nowsec < 10) { + nowsec = `0${nowsec}`; + } + + if(maxhours != 0) { + + max = maxhours + ":" + maxmin + ":" + maxsec + } else { + max = maxmin + ":" + maxsec + + } + + if(nowhours != 0) { + + now = nowhours + ":" + nowmin + ":" + nowsec + } else { + now = nowmin + ":" + nowsec + + } + + + + durationTextAct.innerHTML = now + durationTextTotal.innerHTML = max +} \ No newline at end of file diff --git a/src/web/public/stylesheets/gunship.ttf b/src/web/public/stylesheets/gunship.ttf new file mode 100644 index 0000000..f9dd5a1 Binary files /dev/null and b/src/web/public/stylesheets/gunship.ttf differ diff --git a/src/web/public/stylesheets/style.css b/src/web/public/stylesheets/style.css index e69de29..fc51fa0 100644 --- a/src/web/public/stylesheets/style.css +++ b/src/web/public/stylesheets/style.css @@ -0,0 +1,451 @@ +@font-face { + font-family: 'Gunship'; + src: url(Gunship.ttf); +} + +html { + + min-height: 100%; + min-width: 100%; + margin: 0; + +} + +body { + + background-color: black; + color: white; + font-family: 'Roboto', sans-serif; + background: linear-gradient(90deg, rgba(76,72,140,1) 0%, rgba(0,0,0,1) 100%), + linear-gradient(90deg, rgb(101, 95, 185) 0%, rgb(48, 48, 48) 100%); + +} + +/*LOGIN PAGE*/ + +.LOGIN_Connexion { + + font-family: 'Gunship'; + font-size: 20px; +} + +.LOGIN_box { + + text-align: center; + margin-top: 15vw; + border-radius: 12px; + + /* + background-color: #106f8b; + opacity: 0.8; + background-size: 6px 6px; + background-image: linear-gradient(0deg, #106f8b 50%, #1F859E 50%);*/ + background: linear-gradient(90deg, #515151 0%, #2e2e2e 100%); + align-items: center; + padding: 5%; + width: 500px; + margin-right: auto; + margin-left: auto; + +} + +.LOGIN_logopng { + + width: 60px; + height: 60px; +} + +.LOGIN_DiscordBtn { + + padding: 8px; + border-style: solid; + border-color: #2c3df4; + border-radius: 12px; + background-color: #2c3df4; + color: white; + width: 160px; + transition: all 0.2s ease 0s + +} + + + +.LOGIN_DiscordBtn:hover { + box-shadow: #2c3df4 0px 0px 10px; +} + +.LOGIN_DiscordBtn:active { + background-color: transparent; + box-shadow: #2c3df4 0px 0px 10px; +} + +.LOGIN_DiscordBtn img { + + width: 125px; + +} + +/*Index Page*/ + + +.INDEX_userInfo { + + display: flex; + align-items: center; + flex-direction: row; + text-align: right; +} + +.INDEX_userInfo:hover { + + cursor: pointer; +} + +.INDEX_title { + + color:white; + display: flex; + justify-content: space-between; + + +} + +.INDEX_usrname { + + opacity: 0.8; + font-size: 12px; + margin: 0; +} + + +.INDEX_gbname { + + margin: 0; +} + + +.INDEX_userInfo img { + + + width: 60px; + + +} + +.INDEX_Content { + + padding: 2%; +} + + + +.INDEX_userPopup { + + display: none; +} + +.INDEX_userPopup_Visible { + + display: flex; + flex-direction: column; + background-color: #2e2e2e; + margin-top: 20px; + font-size: 12px; + text-align: center; + color: white; + +} + +#userInfoglobal { + + align-items: right; +} + +.INDEX_signout { + + width: 100%; + color: red; + text-decoration: none; + outline: none; + padding: 10%; +} + +.INDEX_signout:hover { + + background-color: red; + color: white; + cursor: pointer; +} + +.INDEX_line { + + width: 100%; + color: rgb(155, 155, 155); + text-decoration: none; + outline: none; + padding: 10%; +} + +.INDEX_line:hover { + + background-color: rgb(255, 255, 255); + color: rgb(0, 0, 0); + cursor: pointer; +} + + +/*PLAYER*/ + + +.PLAYER_box { + + + background-color: rgba(0, 0, 0, 0.655); + display: flex; + flex-direction: row; + justify-content: space-between; + padding: 1.5%; + align-items: center; + position: absolute; + width: 100%; + bottom: 0; + color: white; + +} + +.PLAYER_middle { + + display: flex; + text-align: center; + align-items: center; + flex-direction: column; +} + +p { + + margin: 0 !important; +} + +.PLAYER_durationbar { + + margin-top: 1vh; + display: flex; + flex-direction: row; + align-items: center; + +} + +.PLAYER_title { + + display: flex; + flex-direction: row; + align-items: center; + width: 30vw; +} + +#duration { + + width: 25vw; + margin-right: 0.5vw; + margin-left: 0.5vw; +} + +#music_img { + + margin-right: 1vw; +} + + +.third { + + color: rgb(47, 47, 47); + background-color: transparent; + border: none; + border-radius: 100%; + text-shadow: 1px 1px 10px white; + font-size: 0.9vw; + margin-left: 0.8vw; + +} + +.primary { + + display: inline-block; + background-color: #ffffff; + color: rgb(0, 0, 0); + border: none; + border-radius: 100%; + width: 50px; + height: 50px; + font-size: 1vw; + + +} + +.primary:active { + + scale: 0.95; +} + +.secondary { + + color: rgb(178, 178, 178); + border: none; + background-color: transparent; + width: 50px; + height: 50px; + font-size: 1vw; + +} + +.secondary:hover { + + color: white; +} + + +.showPicture { + + margin: 0 !important; + margin-bottom: 10px; + width: 4vw; + height: 4vw; +} + +.title { + + width: 100%; +} + +.PLAYER_actionbar { + text-align: right; + width: 30vw; + +} + +.grised { + + filter : invert(50%); +} + +/*SETTINGS*/ + +.SETTINGS_dialog { + + width: 40vw; + height: 25vw; + padding: 0; + background: linear-gradient(90deg, #515151 0%, #2e2e2e 100%); + border: none; + border-radius: 12px; +} + +.SETTINGS_content { + + display: flex; + width: 100%; + flex-direction: row; + +} + +.ssidebar { + width: 12vw; + position: sticky; + height: 25vw; + background-color: #2d2d2d; + border-radius: 12px 0 0 12px; + display: flex; /* Ajout : pour aligner les éléments verticalement à l'intérieur */ + flex-direction: column; /* Ajout : pour aligner les éléments verticalement à l'intérieur */ +} + +.scontent { + flex: 1; + padding: 1vw; + border-radius: 0 12px 12px 0; + + +} + +.slineclose { + + width: 100%; + text-align: right; + +} + +.SETTINGS_close { + + +} + +.dialogTitle { + + color: white; + font-family: 'Gunship', sans-serif; + font-size: 0.85vw; +} + +.ssidebar_line { + + color: white; + width: 100%; + text-align: left; + transition: all 0.1s ease 0s; + padding: 8%; +} + +.ssidebar_line:hover { + + background-color: white; + color: black; + +} + + +.ssidebar_content { + + height: 100%; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + cursor: pointer; +} + +.beta { + + font-family: 'Gunship', sans-serif; + font-size: 10px; + position: fixed; + width: 60px; + transform: translateY(300%); + background-color: rgb(48, 5, 77); + +} + + +.INDEX_picture { + padding-left: 10%; + display: flex; + flex-direction: column; + text-align: center; +} + +.SETTINGS_close { + color: red; + background-color: transparent; + border-radius: 50vw; + border-color: red; + border-style: solid; + padding: 5px; + width: 40px; + height: 40px; + transition: all 0.2s ease 0s; +} + +.SETTINGS_close:hover { + + color: white; + background-color: red; + cursor: pointer; +} \ No newline at end of file diff --git a/src/web/routes/index.js b/src/web/routes/index.js index d53f407..fdd869e 100644 --- a/src/web/routes/index.js +++ b/src/web/routes/index.js @@ -18,4 +18,5 @@ router.get('/', function(req, res, next) { }); + module.exports = router; \ No newline at end of file diff --git a/src/web/routes/internal.js b/src/web/routes/internal.js index 8bc3a6c..2f69a07 100644 --- a/src/web/routes/internal.js +++ b/src/web/routes/internal.js @@ -44,10 +44,16 @@ router.get('/redirect', function(req, res, next) { alog.step.error("get_discord_info_" + req.cookies.session) console.log(error) + + if(error == "MIGRATE_ACCOUNT_ONLY") { res.redirect('/login?error=MIGRATE_ACCOUNT_ONLY') + } else if(error == "NOT_IN_BETA") { + + res.redirect('/login?error=NOT_IN_BETA') + } else { res.redirect('/login?error=CANCEL_LOGIN') diff --git a/src/web/routes/login.js b/src/web/routes/login.js index 8bcc18e..846f942 100644 --- a/src/web/routes/login.js +++ b/src/web/routes/login.js @@ -20,8 +20,40 @@ router.get('/', function(req, res, next) { res.cookie("session", session) } + + var error = "" + + if(req.query.error == "CANCEL_LOGIN") { + + error = "

Une erreur est survenue lors de l'authentification !

" + + } + + if(req.query.error == "MIGRATE_ACCOUNT_ONLY") { + + error = "

Uniquement les comptes migrés sont accéptés !

" + + } + + if(req.query.error == "IS_NOT_IN_CLP") { + + error = "

Que fais-tu là ? Seul les membres du CLP peuvent contrôler le Bot

" + + } + + if(req.query.error == "ACCOUNT_BANNED") { + + error = "

Ton compte a été banni !

" + + } + + if(req.query.error == "NOT_IN_BETA") { + + error = "

Demande à Raphix pour t'inscrire à la Beta !

" + + } - res.render("login") + res.render("login", {login: error}) } }); diff --git a/src/web/templates/error.ejs b/src/web/templates/error.ejs index 16f2fe7..15fdcb3 100644 --- a/src/web/templates/error.ejs +++ b/src/web/templates/error.ejs @@ -1,11 +1,49 @@ - - - - + + Subsonics - Error - - -

ERROR !

- - \ No newline at end of file + + + + +
+

Erreur

+

<%= message %> - <%= error.status %>

+
<%= error.stack %>
+ +
+
+ + + + diff --git a/src/web/templates/index.ejs b/src/web/templates/index.ejs index f82fa53..3e87ba5 100644 --- a/src/web/templates/index.ejs +++ b/src/web/templates/index.ejs @@ -7,11 +7,83 @@ Subsonics - Web -

Subsonics

-
- +
+
+ +
+
+
+
Paramètres
+ Déconnexion +
+
+
+ +
+ + +
+
+ +

Aucun titre joué

+
+ +
+
+ + + +
+
+

0:00

+ +

0:00

+
+
+ +
+ + + + + +
+ +
+ + + +
+
+

Paramètres

+
+
Logs
+
Connexions
+
Gestion d'accès
+
Bêta
+
+ +
+
+
+ + +
+ +

NOT WORKING

+ +
+
+
+ + + + \ No newline at end of file diff --git a/src/web/templates/login.ejs b/src/web/templates/login.ejs index 15ceb0e..552cb3d 100644 --- a/src/web/templates/login.ejs +++ b/src/web/templates/login.ejs @@ -4,14 +4,26 @@ Subsonics - Login + -

Subsonics Login

- -

Fait avec le 💖 par Raphix

+
+
+ + +
+

Connexion

+ <%- login %> + + + +

Fait avec le 💖 par Raphix

+
+ - + + \ No newline at end of file