diff options
author | Andrew Dolgov <[email protected]> | 2012-08-23 22:53:32 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-08-23 22:56:04 +0400 |
commit | 808dd053c6b14822b544ac0e76292f7d74445ec2 (patch) | |
tree | 0266980009a93496fd756d883849fef994d90f2b /js/prefs.js | |
parent | 12806125152712ca04d42701cad473d51684801e (diff) |
implement web-based self updater (closes #395)
Diffstat (limited to 'js/prefs.js')
-rw-r--r-- | js/prefs.js | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/js/prefs.js b/js/prefs.js index 10e33f701..f0ed5ac03 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -2142,15 +2142,37 @@ function updateSelf() { title: __("Update Tiny Tiny RSS"), style: "width: 600px", closable: false, - performUpdate: function() { + performUpdate: function(step) { dijit.byId("self_update_start_btn").attr("disabled", true); + dijit.byId("self_update_stop_btn").attr("disabled", true); + notify_progress("Loading, please wait...", true); new Ajax.Request("backend.php", { - parameters: "?op=pref-prefs&method=performUpdate", + parameters: "?op=pref-prefs&method=performUpdate&step=" + step + + "¶ms=" + param_escape(JSON.stringify(dialog.attr("update-params"))), onComplete: function(transport) { try { - notify(''); - $("self_update_log").innerHTML = transport.responseText; + rv = JSON.parse(transport.responseText); + if (rv) { + notify(''); + + rv['log'].each(function(line) { + $("self_update_log").innerHTML += "<li>" + line + "</li>"; + }); + + dialog.attr("update-params", rv['params']); + + if (!rv['stop']) { + window.setTimeout("dijit.byId('updateSelfDlg').performUpdate("+(step+1)+")", 500); + } else { + dijit.byId("self_update_stop_btn").attr("disabled", false); + } + + } else { + console.log(transport.responseText); + notify_error("Received invalid data from server."); + } + dialog.attr("updated", true); } catch (e) { exception_error("updateSelf/inner", e); @@ -2166,7 +2188,7 @@ function updateSelf() { }, start: function() { if (prompt(__("Live updating is considered experimental. Backup your tt-rss directory before continuing. Please type 'yes' to continue.")) == 'yes') { - dialog.performUpdate(); + dialog.performUpdate(0); } }, href: query}); |