* VRFS-696 - support new callbacks to update UI as application updates. also suppress websocket-connection popup if updating

This commit is contained in:
Seth Call 2013-09-20 03:02:32 +00:00
parent 17fade7bf0
commit 03acb21428
7 changed files with 100 additions and 18 deletions

View File

@ -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: <br/>" + 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 = $('<span class="ellipses">.</span>');
$ellipses.data('count', 1);
var $status = $('<span class="status"></span>');
$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;
}

View File

@ -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
);

View File

@ -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 });

View File

@ -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;
}

View File

@ -46,8 +46,8 @@
-->
</script>
<script type="text/template" id="template-update-restarting">
<h2 align="center">Application update download complete</h2>
<script type="text/template" id="template-update-proceeding">
<h2 align="center">Application is Updating</h2>
<br />
<div class="progress-bar">
@ -56,12 +56,32 @@
<br />
<br />
<div align="center">
<div id="client-updater-updating" align="center">
Please wait while the application updates.
<div id='update-steps'></div>
<!--
Installation of update is about to start.<br />
This application will close automatically in a moment.
This application will close automatically in a moment.-->
</div>
</script>
<script type="text/template" id="template-update-restarting">
<h2 align="center">Application is Restarting</h2>
<br />
<div class="progress-bar">
<div class="progress-bar-progress w100"></div>
</div>
<br />
<br />
<div align="center">
This application will close automatically in a moment.
If it does not close, please restart it manually.
</div>
</script>
<script type="text/template" id="template-update-error">
<h2 align="center">Application Update Error</h2>
<br />

View File

@ -81,12 +81,6 @@
<% end %>
// do a client update check upon initialization
var clientUpdate = new JK.ClientUpdate()
clientUpdate.initialize().check()
// Some things can't be initialized until we're connected. Put them here.
function _initAfterConnect() {
@ -159,10 +153,15 @@
if (JK.currentUserId) {
JK.app = JK.JamKazam();
// do a client update early check upon initialization
var clientUpdate = new JK.ClientUpdate(JK.app)
clientUpdate.initialize().check()
JK.app.initialize();
JK.JamServer.connect(); // singleton here defined in JamServer.js
// this ensures that there is always a CurrentSessionModel, even if it's for a non-active session
JK.CurrentSessionModel = new JK.SessionModel(JK.JamServer, window.jamClient);
JK.CurrentSessionModel = new JK.SessionModel(JK.app, JK.JamServer, window.jamClient);
// Run a check to see if we're logged in yet. Only after that should
// we initialize the other screens.

View File

@ -47,5 +47,5 @@ SampleApp::Application.configure do
# this is totally awful and silly; the reason this exists is so that if you upload an artifact
# through jam-admin, then jam-web can point users at it. I think 99% of devs won't even see or care about this config, and 0% of users
config.jam_admin_root_url = 'http://192.168.1.122:3333'
config.jam_admin_root_url = 'http://192.168.1.152:3333'
end