From 94f21635689ab0e66ca488376160a2ca58a2b384 Mon Sep 17 00:00:00 2001 From: IrosTheBeggar Date: Sat, 22 Apr 2017 05:14:32 -0400 Subject: [PATCH] Better DB status --- public/js/mstream.js | 89 +++++++++++++++++++++++++++++++++----------- public/mstream.html | 23 +++++++----- 2 files changed, 81 insertions(+), 31 deletions(-) diff --git a/public/js/mstream.js b/public/js/mstream.js index 68a2a2a..02ab777 100755 --- a/public/js/mstream.js +++ b/public/js/mstream.js @@ -44,6 +44,8 @@ $(document).ready(function(){ loadFileExplorer(); // MSTREAMGEN.getCurrentDirectoryContents(); + callOnStart(); + // Remove the overlay $('.login-overlay').fadeOut( "slow" ); @@ -66,7 +68,6 @@ $(document).ready(function(){ loginPanel.needToLogin = true; // TODO: Move this transitionstuff to vue $('.login-overlay').fadeIn( "slow" ); - console.log(loginPanel); // For electron we need to alert the user that user it failed and guide them to the login form return; @@ -75,6 +76,8 @@ $(document).ready(function(){ MSTREAMAPI.currentServer.vPath = response.vPath; // Setup the filebrowser loadFileExplorer(); + + callOnStart(); }); } @@ -86,6 +89,44 @@ $(document).ready(function(){ + var startInterval = false; + + function callOnStart(){ + console.log('CALL ON START') + MSTREAMAPI.dbStatus( function(response, error){ + if(error){ + $('.scan-status').html(''); + $('.scan-status-files').html(''); + clearInterval(startInterval); + startInterval = false; + return; + } + + // if not scanning + if(!response.locked || response.locked === false){ + clearInterval(startInterval); + startInterval = false; + $('.scan-status').html(''); + $('.scan-status-files').html(''); + + return; + } + + // Set Interval + if(startInterval === false){ + startInterval = setInterval( function() { + callOnStart(); + }, 2000); + } + + // Update status + // $('#filelist').append('

Progress: '+ response.files_in_db +'/'+ response.file_count +'

'); + $('.scan-status').html('Scan In Progress'); + $('.scan-status-files').html(response.totalFileCount + ' files in DB'); + }); + } + + ////////////////////////////// Global Variables // These vars track your position within the file explorer var fileExplorerArray = []; @@ -444,7 +485,10 @@ $(document).ready(function(){ } // if the DB is locked if(response.locked){ - $('#filelist').append('

The database is currently being built. Currently ' + response.totalFileCount + ' files are in the DB

'); + + $('#filelist').append('

Scan In Progress

'+response.totalFileCount+' files in DB

'); + + //$('#filelist').append('

The database is currently being built. Currently ' + response.totalFileCount + ' files are in the DB

'); return; } // If you got this far the db is made and working @@ -460,29 +504,32 @@ $(document).ready(function(){ if(error !== false){ return boilerplateFailure(response, error); } + + $('#filelist').append('

Scan In Progress

'); + callOnStart(); // Append the check db button so the user can start checking right away - $('#filelist').append(''); + // $('#filelist').append(''); }); }); - // Check DB build progress - $('body').on('click', '#check_db_progress', function(){ - MSTREAMAPI.dbStatus( function(response, error){ - if(error !== false){ - return boilerplateFailure(response, error); - } - $( "#db_progress_report" ).remove(); - - // if file_count is 0, report that the the build script is not done counting files - if(response.file_count == 0){ - $('#filelist').append('

The create database script is still counting the files in the music collection. This operation can take some time. Try again in a bit

'); - return; - } - - // Append new

tag with id of "db_progress_report" - $('#filelist').append('

Progress: '+ response.files_in_db +'/'+ response.file_count +'

'); - }); - }); + // // Check DB build progress + // $('body').on('click', '#check_db_progress', function(){ + // MSTREAMAPI.dbStatus( function(response, error){ + // if(error !== false){ + // return boilerplateFailure(response, error); + // } + // $( "#db_progress_report" ).remove(); + // + // // if file_count is 0, report that the the build script is not done counting files + // if(response.file_count == 0){ + // $('#filelist').append('

The create database script is still counting the files in the music collection. This operation can take some time. Try again in a bit

'); + // return; + // } + // + // // Append new

tag with id of "db_progress_report" + // $('#filelist').append('

Progress: '+ response.files_in_db +'/'+ response.file_count +'

'); + // }); + // }); //////////////////////////////////// Sort by Albums diff --git a/public/mstream.html b/public/mstream.html index 3f939c7..12593dd 100755 --- a/public/mstream.html +++ b/public/mstream.html @@ -193,21 +193,24 @@
  • -
  • +
    + + +
    +
    -