some more updates

This commit is contained in:
janis
2023-10-31 17:35:54 +01:00
parent 1dbc816382
commit c06a82b8ca
3 changed files with 25 additions and 8 deletions

View File

@@ -74,14 +74,15 @@ app.get( '/mainNotifier', ( req, res ) => {
app.post( '/statusUpdate', ( req, res ) => { app.post( '/statusUpdate', ( req, res ) => {
if ( req.body.status === 'playingSong' ) { if ( req.body.status === 'playingSong' ) {
} else if ( req.body.status === 'isPlaying' ) { } else if ( req.body.status === 'isPlaying' ) {
} else if ( req.body.status === 'songQueue' ) { } else if ( req.body.status === 'songQueue' ) {
} else if ( req.body.status === 'pos' ) { } else if ( req.body.status === 'pos' ) {
} }
res.send( 'ok' );
} ); } );
@@ -98,8 +99,8 @@ app.get( '/clientStatusUpdate/:status', ( req, res ) => {
} ); } );
app.get( '/openSongs', ( req, res ) => { app.get( '/openSongs', ( req, res ) => {
// res.send( '{ "data": [ "/home/janis/Music/KB2022" ] }' ); res.send( '{ "data": [ "/home/janis/Music/KB2022" ] }' );
res.send( '{ "data": [ "/mnt/storage/SORTED/Music/audio/KB2022" ] }' ); // res.send( '{ "data": [ "/mnt/storage/SORTED/Music/audio/KB2022" ] }' );
// res.send( { 'data': dialog.showOpenDialogSync( { properties: [ 'openDirectory' ], title: 'Open music library folder' } ) } ); // res.send( { 'data': dialog.showOpenDialogSync( { properties: [ 'openDirectory' ], title: 'Open music library folder' } ) } );
} ); } );
@@ -109,7 +110,10 @@ app.get( '/indexDirs', ( req, res ) => {
res.send( indexedData[ req.query.dir ] ); res.send( indexedData[ req.query.dir ] );
} else { } else {
fs.readdir( req.query.dir, { encoding: 'utf-8' }, ( err, dat ) => { fs.readdir( req.query.dir, { encoding: 'utf-8' }, ( err, dat ) => {
if ( err ) res.status( 500 ).send( err ); if ( err ) {
res.status( 404 ).send( 'ERR_DIR_NOT_FOUND' );
return;
};
( async() => { ( async() => {
// TODO: Check for songlist.csv or songlist.json file and use the data provided there for each song to override // TODO: Check for songlist.csv or songlist.json file and use the data provided there for each song to override
// what was found automatically. If no song title was found in songlist or metadata, use filename // what was found automatically. If no song title was found in songlist or metadata, use filename

View File

@@ -21,6 +21,10 @@
<p>Analyzing metadata...</p> <p>Analyzing metadata...</p>
<span class="material-symbols-outlined loading-spinner">autorenew</span> <span class="material-symbols-outlined loading-spinner">autorenew</span>
</div> </div>
<div v-else-if="errorOccurredLoading" class="no-songs">
<h3>This directory does not exist!</h3>
<button @click="loadSongs()">Load songs</button>
</div>
<div v-else class="no-songs"> <div v-else class="no-songs">
<h3>No songs loaded</h3> <h3>No songs loaded</h3>
<button @click="loadSongs()">Load songs</button> <button @click="loadSongs()">Load songs</button>
@@ -200,6 +204,7 @@
songPos: 0, songPos: 0,
repeat: false, repeat: false,
isShowingFancyView: false, isShowingFancyView: false,
errorOccurredLoading: false,
} }
}, },
methods: { methods: {
@@ -276,6 +281,7 @@
for ( let dir in this.loadedDirs ) { for ( let dir in this.loadedDirs ) {
fetch( 'http://localhost:8081/indexDirs?dir=' + this.loadedDirs[ dir ] + ( this.loadCoverArtPreview ? '&coverart=true' : '' ) ).then( res => { fetch( 'http://localhost:8081/indexDirs?dir=' + this.loadedDirs[ dir ] + ( this.loadCoverArtPreview ? '&coverart=true' : '' ) ).then( res => {
if ( res.status === 200 ) { if ( res.status === 200 ) {
this.errorOccurredLoading = false;
res.json().then( json => { res.json().then( json => {
for ( let song in json ) { for ( let song in json ) {
this.songQueue.push( json[ song ] ); this.songQueue.push( json[ song ] );
@@ -286,6 +292,9 @@
this.hasLoadedSongs = true; this.hasLoadedSongs = true;
this.$emit( 'com', { 'type': 'songsLoaded' } ); this.$emit( 'com', { 'type': 'songsLoaded' } );
} ); } );
} else if ( res.status === 404 ) {
this.isLoadingSongs = false;
this.errorOccurredLoading = true;
} }
} ); } );
} }

View File

@@ -156,6 +156,10 @@ export default {
if ( autoplay ) { if ( autoplay ) {
this.control( 'play' ); this.control( 'play' );
this.isPlaying = true; this.isPlaying = true;
this.sendUpdate( 'isPLaying' );
this.sendUpdate( 'playingSong' );
this.sendUpdate( 'songQueue' );
this.sendUpdate( 'pos' );
} }
const minuteCount = Math.floor( this.playingSong.duration / 60 ); const minuteCount = Math.floor( this.playingSong.duration / 60 );
this.durationBeautified = minuteCount + ':'; this.durationBeautified = minuteCount + ':';
@@ -201,7 +205,7 @@ export default {
}, },
}; };
fetch( '/statusUpdate', fetchOptions ).then( res => { fetch( '/statusUpdate', fetchOptions ).then( res => {
console.log( res );
} ); } );
}, },
control( action ) { control( action ) {