diff --git a/frontend/src/app.js b/frontend/src/app.js index 140197f..bf7cd2b 100644 --- a/frontend/src/app.js +++ b/frontend/src/app.js @@ -13,16 +13,93 @@ app.use( cors() ); let indexedData = {}; let coverArtIndex = {}; -const allowedFileTypes = [ '.mp3', '.wav', '.flac' ] +const allowedFileTypes = [ '.mp3', '.wav', '.flac' ]; + +let connectedClients = []; + +let currentDetails = { + 'songQueue': [], + 'currentlyPlaying': '', + 'pos': 0, + 'isPlaying': false +}; + +let connectedMain = {}; + app.get( '/', ( request, response ) => { - response.send( 'Hello world' ); + response.sendFile( path.join( __dirname + '/client/showcase.html' ) ); +} ); + +app.get( '/showcase.js', ( req, res ) => { + res.sendFile( path.join( __dirname + '/client/showcase.js' ) ); +} ); + +app.get( '/showcase.css', ( req, res ) => { + res.sendFile( path.join( __dirname + '/client/showcase.css' ) ); +} ); + +app.get( '/clientDisplayNotifier', ( req, res ) => { + res.writeHead( 200, { + 'Content-Type': 'text/event-stream', + 'Cache-Control': 'no-cache', + 'Connection': 'keep-alive', + } ); + res.status( 200 ); + res.flushHeaders(); + let det = { 'type': 'basics', 'data': currentDetails }; + res.write( `data: ${ JSON.stringify( det ) }\n\n` ); + connectedClients.push( res ); +} ); + +app.get( '/mainNotifier', ( req, res ) => { + const ipRetrieved = req.headers[ 'x-forwarded-for' ]; + const ip = ipRetrieved ? ipRetrieved.split( /, / )[ 0 ] : req.connection.remoteAddress; + if ( ip === '::ffff:127.0.0.1' ) { + res.writeHead( 200, { + 'Content-Type': 'text/event-stream', + 'Cache-Control': 'no-cache', + 'Connection': 'keep-alive', + } ); + res.status( 200 ); + res.flushHeaders(); + let det = { 'type': 'basics', 'data': currentDetails }; + res.write( `data: ${ JSON.stringify( det ) }\n\n` ); + connectedMain = res; + } else { + res.send( 'wrong' ); + } } ); +app.post( '/statusUpdate', ( req, res ) => { + if ( req.body.status === 'playingSong' ) { + + } else if ( req.body.status === 'isPlaying' ) { + + } else if ( req.body.status === 'songQueue' ) { + + } else if ( req.body.status === 'pos' ) { + + } +} ); + + +app.get( '/clientStatusUpdate/:status', ( req, res ) => { + if ( req.params.status === 'disconnect' ) { + + } else if ( req.params.status === 'fullScreenExit' ) { + + } else if ( req.params.status === 'inactive' ) { + + } else if ( req.params.status === 'reactivated' ) { + + } +} ); + app.get( '/openSongs', ( req, res ) => { - res.send( '{ "data": [ "/home/janis/Music/KB2022" ] }' ); - // res.send( '{ "data": [ "/mnt/storage/SORTED/Music/audio/KB2022" ] }' ); + // res.send( '{ "data": [ "/home/janis/Music/KB2022" ] }' ); + res.send( '{ "data": [ "/mnt/storage/SORTED/Music/audio/KB2022" ] }' ); // res.send( { 'data': dialog.showOpenDialogSync( { properties: [ 'openDirectory' ], title: 'Open music library folder' } ) } ); } ); diff --git a/frontend/src/client/index.html b/frontend/src/client/index.html deleted file mode 100644 index e69de29..0000000 diff --git a/frontend/src/client/showcase.css b/frontend/src/client/showcase.css index e69de29..82e8457 100644 --- a/frontend/src/client/showcase.css +++ b/frontend/src/client/showcase.css @@ -0,0 +1,94 @@ +.material-symbols-outlined { + font-variation-settings: + 'FILL' 0, + 'wght' 400, + 'GRAD' 0, + 'opsz' 24 +} + +.voting-wrapper { + display: flex; + justify-content: center; + align-items: center; + flex-direction: row; +} + +.voting { + border-radius: 500px; + border: 1px black solid; + font-size: 150%; + cursor: pointer; +} + +.voting-counter { + margin: 0; + font-size: 150%; + margin-left: 10px; + margin-right: 10px; +} + +body { + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; +} + +.content { + justify-content: flex-start; +} + +.input { + width: 30vw; + padding: 20px; + border-radius: 20px; + border: none; + margin-bottom: 1vh; + margin-top: 5px; +} + +.entry { + border: black 2px solid; + padding: 1% 10%; + width: 40vw; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; +} + +.selected { + background-color: green; +} + +.comment { + width: 50%; + text-align: center; +} + +.wrapper { + width: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + margin-bottom: 5vh; +} + +.bottom-bar { + position: fixed; + width: 100%; + margin: 0; + background-color: lightgray; + left: 0; + bottom: 0; + display: flex; + justify-content: center; + padding: 0; + padding-top: 0.5vh; + padding-bottom: 5vh, +} + +.content { + display: block !important; +} \ No newline at end of file diff --git a/frontend/src/client/showcase.html b/frontend/src/client/showcase.html index 6c9b57b..2518d56 100644 --- a/frontend/src/client/showcase.html +++ b/frontend/src/client/showcase.html @@ -8,107 +8,12 @@