Browse Source

Merge pull request #4282 from buinsky/master

WebUI: Show filtered torrents number
adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
719e71264b
  1. 2
      src/webui/abstractwebapplication.cpp
  2. 17
      src/webui/www/public/filters.html
  3. 18
      src/webui/www/public/scripts/client.js
  4. 29
      src/webui/www/public/scripts/dynamicTable.js

2
src/webui/abstractwebapplication.cpp

@ -241,7 +241,7 @@ void AbstractWebApplication::translateDocument(QString& data) @@ -241,7 +241,7 @@ void AbstractWebApplication::translateDocument(QString& data)
"HttpServer", "confirmDeletionDlg", "TrackerList", "TorrentFilesModel",
"options_imp", "Preferences", "TrackersAdditionDlg", "ScanFoldersModel",
"PropTabBar", "TorrentModel", "downloadFromURL", "MainWindow", "misc",
"StatusBar", "AboutDlg", "about", "PeerListWidget"
"StatusBar", "AboutDlg", "about", "PeerListWidget", "StatusFiltersWidget"
};
const size_t context_count = sizeof(contexts) / sizeof(contexts[0]);
int i = 0;

17
src/webui/www/public/filters.html

@ -1,13 +1,14 @@ @@ -1,13 +1,14 @@
QBT_TR(Torrents)QBT_TR
<ul class="filterList">
<li id="all_filter"><a href="#" onclick="setFilter('all');return false;"><img src="images/skin/filterall.png"/>QBT_TR(All)QBT_TR</a></li>
<li id="downloading_filter"><a href="#" onclick="setFilter('downloading');return false;"><img src="images/skin/downloading.png"/>QBT_TR(Downloading)QBT_TR</a></li>
<li id="seeding_filter"><a href="#" onclick="setFilter('seeding');return false;"><img src="images/skin/uploading.png"/>QBT_TR(Seeding)QBT_TR</a></li>
<li id="completed_filter"><a href="#" onclick="setFilter('completed');return false;"><img src="images/skin/completed.png"/>QBT_TR(Completed)QBT_TR</a></li>
<li id="resumed_filter"><a href="#" onclick="setFilter('resumed');return false;"><img src="images/skin/resumed.png"/>QBT_TR(Resumed)QBT_TR</a></li>
<li id="paused_filter"><a href="#" onclick="setFilter('paused');return false;"><img src="images/skin/paused.png"/>QBT_TR(Paused)QBT_TR</a></li>
<li id="active_filter"><a href="#" onclick="setFilter('active');return false;"><img src="images/skin/filteractive.png"/>QBT_TR(Active)QBT_TR</a></li>
<li id="inactive_filter"><a href="#" onclick="setFilter('inactive');return false;"><img src="images/skin/filterinactive.png"/>QBT_TR(Inactive)QBT_TR</a></li>
<li id="all_filter"><a href="#" onclick="setFilter('all');return false;"><img src="images/skin/filterall.png"/>QBT_TR(All (0))QBT_TR</a></li>
<li id="downloading_filter"><a href="#" onclick="setFilter('downloading');return false;"><img src="images/skin/downloading.png"/>QBT_TR(Downloading (0))QBT_TR</a></li>
<li id="seeding_filter"><a href="#" onclick="setFilter('seeding');return false;"><img src="images/skin/uploading.png"/>QBT_TR(Seeding (0))QBT_TR</a></li>
<li id="completed_filter"><a href="#" onclick="setFilter('completed');return false;"><img src="images/skin/completed.png"/>QBT_TR(Completed (0))QBT_TR</a></li>
<li id="resumed_filter"><a href="#" onclick="setFilter('resumed');return false;"><img src="images/skin/resumed.png"/>QBT_TR(Resumed (0))QBT_TR</a></li>
<li id="paused_filter"><a href="#" onclick="setFilter('paused');return false;"><img src="images/skin/paused.png"/>QBT_TR(Paused (0))QBT_TR</a></li>
<li id="active_filter"><a href="#" onclick="setFilter('active');return false;"><img src="images/skin/filteractive.png"/>QBT_TR(Active (0))QBT_TR</a></li>
<li id="inactive_filter"><a href="#" onclick="setFilter('inactive');return false;"><img src="images/skin/filterinactive.png"/>QBT_TR(Inactive (0))QBT_TR</a></li>
<li id="errored_filter"><a href="#" onclick="setFilter('errored');return false;"><img src="images/skin/error.png"/>QBT_TR(Errored (0))QBT_TR</a></li>
</ul>
<br/>
QBT_TR(Labels)QBT_TR

18
src/webui/www/public/scripts/client.js

@ -115,6 +115,7 @@ window.addEvent('load', function () { @@ -115,6 +115,7 @@ window.addEvent('load', function () {
$("resumed_filter").removeClass("selectedFilter");
$("active_filter").removeClass("selectedFilter");
$("inactive_filter").removeClass("selectedFilter");
$("errored_filter").removeClass("selectedFilter");
$(f + "_filter").addClass("selectedFilter");
selected_filter = f;
localStorage.setItem('selected_filter', f);
@ -219,6 +220,22 @@ window.addEvent('load', function () { @@ -219,6 +220,22 @@ window.addEvent('load', function () {
});
};
var updateFilter = function(filter, filterTitle) {
$(filter + '_filter').firstChild.childNodes[1].nodeValue = filterTitle.replace('%1', torrentsTable.getFilteredTorrentsNumber(filter));
};
var updateFiltersList = function() {
updateFilter('all', 'QBT_TR(All (%1))QBT_TR');
updateFilter('downloading', 'QBT_TR(Downloading (%1))QBT_TR');
updateFilter('seeding', 'QBT_TR(Seeding (%1))QBT_TR');
updateFilter('completed', 'QBT_TR(Completed (%1))QBT_TR');
updateFilter('resumed', 'QBT_TR(Resumed (%1))QBT_TR');
updateFilter('paused', 'QBT_TR(Paused (%1))QBT_TR');
updateFilter('active', 'QBT_TR(Active (%1))QBT_TR');
updateFilter('inactive', 'QBT_TR(Inactive (%1))QBT_TR');
updateFilter('errored', 'QBT_TR(Errored (%1))QBT_TR');
};
var updateLabelList = function() {
var labelList = $('filterLabelList');
if (!labelList)
@ -331,6 +348,7 @@ window.addEvent('load', function () { @@ -331,6 +348,7 @@ window.addEvent('load', function () {
serverState[key] = tmp[key];
processServerState();
}
updateFiltersList();
if (update_labels) {
updateLabelList();
updateContextMenu();

29
src/webui/www/public/scripts/dynamicTable.js

@ -480,7 +480,7 @@ var TorrentsTable = new Class({ @@ -480,7 +480,7 @@ var TorrentsTable = new Class({
else if (state == "checkingDL" || state == "checkingUP" ||
state == "queuedForChecking" || state == "checkingResumeData")
state = "checking";
else if (state == "unknown")
else if (state == "unknown" || state == "error" || state == "missingFiles")
state = "error";
var img_path = 'images/skin/' + state + '.png';
@ -616,6 +616,9 @@ var TorrentsTable = new Class({ @@ -616,6 +616,9 @@ var TorrentsTable = new Class({
applyFilter : function (row, filterName, labelName) {
var state = row['full_data'].state;
var inactive = false;
var r;
switch(filterName) {
case 'downloading':
if (state != 'downloading' && !~state.indexOf('DL'))
@ -630,19 +633,25 @@ var TorrentsTable = new Class({ @@ -630,19 +633,25 @@ var TorrentsTable = new Class({
return false;
break;
case 'paused':
if (state != 'pausedDL')
if (!~state.indexOf('paused'))
return false;
break;
case 'resumed':
if (~state.indexOf('paused'))
return false;
break;
case 'inactive':
inactive = true;
case 'active':
if (state != 'downloading' && state != 'forcedDL' && state != 'uploading' && state != 'forcedUP')
if (state == 'stalledDL')
r = (row['full_data'].upspeed > 0)
else
r = state == 'metaDL' || state == 'downloading' || state == 'forcedDL' || state == 'uploading' || state == 'forcedUP';
if (r == inactive)
return false;
break;
case 'inactive':
if (state == 'downloading' || state == 'forcedDL' || state == 'uploading' || state == 'forcedUP')
case 'errored':
if (state != 'error' && state != "unknown" && state != "missingFiles")
return false;
break;
}
@ -659,6 +668,16 @@ var TorrentsTable = new Class({ @@ -659,6 +668,16 @@ var TorrentsTable = new Class({
return true;
},
getFilteredTorrentsNumber : function (filterName) {
var cnt = 0;
var rows = this.rows.getValues();
for (i = 0; i < rows.length; i++)
if (this.applyFilter(rows[i], filterName, LABELS_ALL)) cnt++;
return cnt;
},
getFilteredAndSortedRows : function () {
var filteredRows = new Array();

Loading…
Cancel
Save