diff --git a/web/app/assets/javascripts/clientUpdate.js b/web/app/assets/javascripts/clientUpdate.js index 87a741096..3772c8321 100644 --- a/web/app/assets/javascripts/clientUpdate.js +++ b/web/app/assets/javascripts/clientUpdate.js @@ -4,11 +4,14 @@ context.JK = context.JK || {}; - - context.JK.ClientUpdate = function() { + context.JK.ClientUpdate = function(app) { var self = this; var logger = context.JK.logger; + var ellipsesJiggleTimer = null; + + app.clientUpdating = false; + // updated once a download is started var updateSize = 0; @@ -17,6 +20,7 @@ console.log("update canceled!"); $('#client_update').hide(); $('#client_update_overlay').hide(); + app.clientUpdating = false; } } @@ -76,7 +80,7 @@ function clientUpdateDownloadSuccess(updateLocation) { logger.debug("client update downloaded successfully to: " + updateLocation); - updateClientUpdateDialog("update-restarting"); + updateClientUpdateDialog("update-proceeding"); setTimeout(function() { // This method is synchronous, and does alot of work on a mac in particular, hanging the UI. @@ -95,6 +99,8 @@ function clientUpdateLaunchSuccess(updateLocation) { logger.debug("client update launched successfully to: " + updateLocation); + + updateClientUpdateDialog("update-restarting"); } function clientUpdateLaunchFailure(errorMsg) { @@ -102,6 +108,44 @@ updateClientUpdateDialog("update-error", {error_msg: "Unable to launch client updater. Error reason:
" + errorMsg}); } + + function clientUpdateLaunchStatuses(statuses) { + logger.debug("client update launch statuses"); + + if(statuses) { + for (var i = 0; i < statuses.length; i++) { + var status = statuses[i]; + } + } + } + + function clientUpdateLaunchStatusChange(done, status) { + logger.debug("client update launch status change. starting=" + done + ", status=" + status); + + if(!done) { + var $ellipses = $('.'); + $ellipses.data('count', 1); + var $status = $(''); + $status.text(status); + $status.append($ellipses); + $('#client-updater-updating').append($status); + + ellipsesJiggleTimer = setInterval(function() { + var count = $ellipses.data('count'); + count++; + if(count > 3) { + count = 1; + } + $ellipses.text(Array(count + 1).join(".")); + $ellipses.data('count', count); + }, 500); + } + else { + clearInterval(ellipsesJiggleTimer); + $('#client-updater-updating span.status').last().css('color', 'white').find('span.ellipses').text('...'); + } + + } /********************************************/ /******** END: CALLBACKS FROM BACKEND *******/ /********************************************/ @@ -153,6 +197,7 @@ if(shouldUpdate(currentVersion, version)) { updateSize = response.size; + app.clientUpdating = true; // test metadata in lieu of having a configured server with a client-update available //updateSize = 10000; @@ -185,8 +230,9 @@ context.jamClient.ClientUpdateStartUpdate(updaterFilePath, "JK.ClientUpdate.LaunchUpdateSuccessCallback", - "JK.ClientUpdate.LaunchUpdateFailureCallback"); - + "JK.ClientUpdate.LaunchUpdateFailureCallback", + "JK.ClientUpdate.LaunchUpdateStatusesCallback", + "JK.ClientUpdate.LaunchUpdateStatusChangeCallback"); } function initialize() { @@ -195,6 +241,8 @@ context.JK.ClientUpdate.DownloadFailureCallback = clientUpdateDownloadFailure; context.JK.ClientUpdate.LaunchUpdateSuccessCallback = clientUpdateLaunchSuccess; context.JK.ClientUpdate.LaunchUpdateFailureCallback = clientUpdateLaunchFailure; + context.JK.ClientUpdate.LaunchUpdateStatusesCallback = clientUpdateLaunchStatuses; + context.JK.ClientUpdate.LaunchUpdateStatusChangeCallback = clientUpdateLaunchStatusChange; return self; } diff --git a/web/app/assets/javascripts/session.js b/web/app/assets/javascripts/session.js index 0c3ed9a3f..da4470b94 100644 --- a/web/app/assets/javascripts/session.js +++ b/web/app/assets/javascripts/session.js @@ -140,6 +140,7 @@ // and other parts of the code want to know at any certain times // about the current session, if any (for example, reconnect logic) context.JK.CurrentSessionModel = sessionModel = new context.JK.SessionModel( + context.JK.app, context.JK.JamServer, context.jamClient ); diff --git a/web/app/assets/javascripts/sessionModel.js b/web/app/assets/javascripts/sessionModel.js index 7677b95a2..5a194cb50 100644 --- a/web/app/assets/javascripts/sessionModel.js +++ b/web/app/assets/javascripts/sessionModel.js @@ -7,7 +7,7 @@ context.JK = context.JK || {}; var logger = context.JK.logger; - context.JK.SessionModel = function(server, client) { + context.JK.SessionModel = function(app, server, client) { var clientId = client.clientID; var currentSessionId = null; // Set on join, prior to setting currentSession. var currentSession = null; @@ -378,6 +378,12 @@ function onWebsocketDisconnected(in_error) { + if(app.clientUpdating) { + // we don't want to do a 'cover the whole screen' dialog + // because the client update is already showing. + return; + } + // kill the streaming of the session immediately logger.debug("calling jamClient.LeaveSession for clientId=" + clientId); client.LeaveSession({ sessionID: currentSessionId }); diff --git a/web/app/assets/stylesheets/client/clientUpdate.css.scss b/web/app/assets/stylesheets/client/clientUpdate.css.scss index e5b1c5866..c60eaa5af 100644 --- a/web/app/assets/stylesheets/client/clientUpdate.css.scss +++ b/web/app/assets/stylesheets/client/clientUpdate.css.scss @@ -23,4 +23,12 @@ #client_update h2 { font-weight:bold; font-size:x-large; +} + +#client-updater-updating #update-steps { + margin-top:20px; +} + +#client-updater-updating span.status { + color:gray; } \ No newline at end of file diff --git a/web/app/views/clients/_client_update.html.erb b/web/app/views/clients/_client_update.html.erb index 7861217b0..019843631 100644 --- a/web/app/views/clients/_client_update.html.erb +++ b/web/app/views/clients/_client_update.html.erb @@ -46,8 +46,8 @@ --> - + + +