* VRFS-2209 - fix progress bar by fixing the update size variable. also show countdown

This commit is contained in:
Seth Call 2014-09-16 21:13:36 -05:00
parent 468be9da4e
commit 8338a7ecb7
3 changed files with 45 additions and 13 deletions

View File

@ -10,11 +10,11 @@
var logger = context.JK.logger;
var ellipsesJiggleTimer = null;
var forceShow = false; // manual test helper
// updated once a download is started
var updateUri = null;
var updateSize = 0;
app.clientUpdating = false;
// updated once a download is started
var updateSize = 0;
function cancelUpdate(e) {
if ((e.ctrlKey || e.metaKey) && e.keyCode == 78) {
@ -27,8 +27,10 @@
// responsible for updating the contents of the update dialog
// as well as registering for any event handlers
function updateClientUpdateDialog(templateId, options) {
options = options || {};
var template = $('#template-' + templateId).html();
var templateHtml = context.JK.fillTemplate(template, options);
var templateHtml = context._.template(template, options, {variable: 'data'});
$('#client_update .dialog-inner').html(templateHtml);
@ -69,12 +71,13 @@
/***************************************/
function clientUpdateDownloadProgress(bytesReceived, bytesTotal, downloadSpeedMegSec, timeRemaining) {
// this fires way too many times to leave in. uncomment if debugging update feature
//logger.debug("bytesReceived: " + bytesReceived, ", bytesTotal: " + bytesTotal, ", downloadSpeed: " + downloadSpeedMegSec, ", timeRemaining: " + timeRemaining );
//logger.debug("bytesReceived: " + bytesReceived, ", bytesTotal: " + bytesTotal, ", downloadSpeed: " + downloadSpeedMegSec, ", timeRemaining: " + timeRemaining + ", updateSize: " + updateSize);
bytesReceived = Number(bytesReceived)
bytesTotal = Number(bytesTotal)
// bytesTotal from Qt is not trust worthy; trust server's answer instead
$('#progress-bar').width(((bytesReceived / updateSize) * 100).toString() + "%")
var progressWidth = ((bytesReceived / updateSize) * 100).toString() + "%";
$('#progress-bar').width(progressWidth)
//$("#progressbar_detail").text(parseInt(bytesReceived) + "/" + parseInt(updateSize))
}
@ -98,10 +101,27 @@
}
function clientUpdateLaunchSuccess(updateLocation) {
logger.debug("client update launched successfully to: " + updateLocation);
function clientUpdateLaunchSuccess(userTimeToRead) {
if(userTimeToRead === undefined) {
userTimeToRead = 1000; // older clients didn't pass this in, and exit very quickly
}
updateClientUpdateDialog("update-restarting");
logger.debug("client update launching in: " + userTimeToRead);
// set timer to update countdown
var rounded = Math.round(userTimeToRead / 1000);
// simple countdown timer
var timer = setInterval(function(){
var $countdown = $('#client_update .countdown-secs');
var countdown = parseInt($countdown.text());
$countdown.text(countdown - 1);
if(countdown == 0) {
clearInterval(timer);
}
}, rounded * 1000);
updateClientUpdateDialog("update-restarting", {countdown: rounded, os: context.JK.GetOSAsString()});
}
function clientUpdateLaunchFailure(errorMsg) {
@ -167,7 +187,7 @@
}
}
function runCheck(product, version, uri, updateSize, currentVersion) {
function runCheck(product, version, uri, size, currentVersion) {
if(currentVersion === undefined) {
currentVersion = context.jamClient.ClientUpdateVersion();
@ -191,6 +211,7 @@
if (shouldUpdate(currentVersion, version)) {
app.clientUpdating = true;
updateUri = uri;
updateSize = size;
if(context.JK.CurrentSessionModel && context.JK.CurrentSessionModel.inSession()) {
logger.debug("deferring client update because in session")
@ -210,7 +231,7 @@
// check if updated is needed
function check() {
var os = context.jamClient.GetOSAsString();
var os = context.JK.GetOSAsString();
// check kill switch before all other logic
if (!gon.check_for_client_updates) {

View File

@ -22,6 +22,12 @@
display:block;
}
.countdown-secs {
font-size:24px;
display:inline-block;
width:15px;
}
h2 {
font-weight:bold;
font-size:x-large;

View File

@ -75,8 +75,13 @@
<br />
<br />
<div align="center">
This application will close automatically in a moment.
If it does not close, please restart it manually.
{% if(data.os == 'MacOSX') { %}
This application will close automatically in <span class="countdown-secs">{{data.countdown}}</span> {{data.countdown == 1 ? 'second' : 'seconds'}}.
If it does not close, please restart it manually or download the latest JamKazam from <a href="/downloads" rel="external">our downloads page</a>.
{% } else { %}
The updater will launch automatically in <span class="countdown-secs">{{data.countdown}}</span> seconds.
If you do not see a Windows updater, please restart it manually or download the latest JamKazam from <a href="/downloads" rel="external">our downloads page</a>.
{% } %}
</div>
</script>
@ -90,7 +95,7 @@
<p class="fix">Download the latest JamKazam from <a href="/downloads" rel="external">our downloads page</a>.</p>
</div>
<div class="error-detail">
{error_msg}
{{data.error_msg}}
</div>
</div>