Browse Source

WebUI: Show filtered torrents number

adaptive-webui-19844
buinsky 9 years ago
parent
commit
b10f04abbd
  1. 2
      src/webui/abstractwebapplication.cpp
  2. 17
      src/webui/www/public/filters.html
  3. 18
      src/webui/www/public/scripts/client.js
  4. 16
      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();

16
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';
@ -645,6 +645,10 @@ var TorrentsTable = new Class({ @@ -645,6 +645,10 @@ var TorrentsTable = new Class({
if (state == 'downloading' || state == 'forcedDL' || state == 'uploading' || state == 'forcedUP')
return false;
break;
case 'errored':
if (state != 'error' && state != "unknown" && state != "missingFiles")
return false;
break;
}
if (labelName == LABELS_ALL)
@ -659,6 +663,16 @@ var TorrentsTable = new Class({ @@ -659,6 +663,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