Merge pull request #11778 from FranciscoPombal/v4_1_x

WebUI: backport #11635 and #11756 to v4_1_x
This commit is contained in:
Mike Tzou 2019-12-30 10:13:35 +08:00 committed by GitHub
commit f16d219646
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 78 additions and 70 deletions

View file

@ -41,6 +41,7 @@ var queueing_enabled = true;
var serverSyncMainDataInterval = 1500; var serverSyncMainDataInterval = 1500;
var customSyncMainDataInterval = null; var customSyncMainDataInterval = null;
let syncRequestInProgress = false;
var clipboardEvent; var clipboardEvent;
var CATEGORIES_ALL = 1; var CATEGORIES_ALL = 1;
@ -334,7 +335,7 @@ window.addEvent('load', function() {
var syncMainData = function() { var syncMainData = function() {
var url = new URI('api/v2/sync/maindata'); var url = new URI('api/v2/sync/maindata');
url.setData('rid', syncMainDataLastResponseId); url.setData('rid', syncMainDataLastResponseId);
new Request.JSON({ const request = new Request.JSON({
url: url, url: url,
noCache: true, noCache: true,
method: 'get', method: 'get',
@ -342,8 +343,8 @@ window.addEvent('load', function() {
var errorDiv = $('error_div'); var errorDiv = $('error_div');
if (errorDiv) if (errorDiv)
errorDiv.set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]'); errorDiv.set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]');
clearTimeout(syncMainDataTimer); syncRequestInProgress = false;
syncMainDataTimer = syncMainData.delay(2000); syncData(2000);
}, },
onSuccess: function(response) { onSuccess: function(response) {
$('error_div').set('html', ''); $('error_div').set('html', '');
@ -426,18 +427,26 @@ window.addEvent('load', function() {
// re-select previously selected rows // re-select previously selected rows
torrentsTable.reselectRows(torrentsTableSelectedRows); torrentsTable.reselectRows(torrentsTableSelectedRows);
} }
clearTimeout(syncMainDataTimer); syncRequestInProgress = false;
syncMainDataTimer = syncMainData.delay(getSyncMainDataInterval()); syncData(getSyncMainDataInterval())
} }
}).send(); });
syncRequestInProgress = true;
request.send();
}; };
updateMainData = function() { updateMainData = function() {
torrentsTable.updateTable(); torrentsTable.updateTable();
clearTimeout(syncMainDataTimer); syncData(100);
syncMainDataTimer = syncMainData.delay(100);
}; };
const syncData = function(delay) {
if (!syncRequestInProgress){
clearTimeout(syncMainDataTimer);
syncMainDataTimer = syncMainData.delay(delay);
}
}
var processServerState = function() { var processServerState = function() {
var transfer_info = friendlyUnit(serverState.dl_info_speed, true); var transfer_info = friendlyUnit(serverState.dl_info_speed, true);
if (serverState.dl_rate_limit > 0) if (serverState.dl_rate_limit > 0)
@ -459,7 +468,7 @@ window.addEvent('load', function() {
$('DHTNodes').set('html', 'QBT_TR(DHT: %1 nodes)QBT_TR[CONTEXT=StatusBar]'.replace("%1", serverState.dht_nodes)); $('DHTNodes').set('html', 'QBT_TR(DHT: %1 nodes)QBT_TR[CONTEXT=StatusBar]'.replace("%1", serverState.dht_nodes));
// Statistics dialog // Statistics dialog
if (document.getElementById("statisticspage")) { if (document.getElementById("statisticsContent")) {
$('AlltimeDL').set('html', friendlyUnit(serverState.alltime_dl, false)); $('AlltimeDL').set('html', friendlyUnit(serverState.alltime_dl, false));
$('AlltimeUL').set('html', friendlyUnit(serverState.alltime_ul, false)); $('AlltimeUL').set('html', friendlyUnit(serverState.alltime_ul, false));
$('TotalWastedSession').set('html', friendlyUnit(serverState.total_wasted_session, false)); $('TotalWastedSession').set('html', friendlyUnit(serverState.total_wasted_session, false));
@ -607,8 +616,7 @@ window.addEvent('load', function() {
$("mainColumn").removeClass("invisible"); $("mainColumn").removeClass("invisible");
customSyncMainDataInterval = null; customSyncMainDataInterval = null;
clearTimeout(syncMainDataTimer); syncData(100);
syncMainDataTimer = syncMainData.delay(100);
hideSearchTab(); hideSearchTab();
}; };

View file

@ -1,3 +1,4 @@
<div id="statisticsContent">
<h3>QBT_TR(User statistics)QBT_TR[CONTEXT=StatsDialog]</h3> <h3>QBT_TR(User statistics)QBT_TR[CONTEXT=StatsDialog]</h3>
<table style="width:100%"> <table style="width:100%">
<tr> <tr>
@ -21,7 +22,6 @@
<td id="TotalPeerConnections" class="statisticsValue"></td> <td id="TotalPeerConnections" class="statisticsValue"></td>
</tr> </tr>
</table> </table>
<h3>QBT_TR(Cache statistics)QBT_TR[CONTEXT=StatsDialog]</h3> <h3>QBT_TR(Cache statistics)QBT_TR[CONTEXT=StatsDialog]</h3>
<table style="width:100%"> <table style="width:100%">
<tr> <tr>
@ -33,7 +33,6 @@
<td id="TotalBuffersSize" class="statisticsValue"></td> <td id="TotalBuffersSize" class="statisticsValue"></td>
</tr> </tr>
</table> </table>
<h3>QBT_TR(Performance statistics)QBT_TR[CONTEXT=StatsDialog]</h3> <h3>QBT_TR(Performance statistics)QBT_TR[CONTEXT=StatsDialog]</h3>
<table style="width:100%"> <table style="width:100%">
<tr> <tr>
@ -57,3 +56,4 @@
<td id="TotalQueuedSize" class="statisticsValue"></td> <td id="TotalQueuedSize" class="statisticsValue"></td>
</tr> </tr>
</table> </table>
</div>