From b10f04abbd559d0e6b7c708f457d5edaa4148b6f Mon Sep 17 00:00:00 2001 From: buinsky Date: Mon, 7 Dec 2015 04:05:52 +0300 Subject: [PATCH] WebUI: Show filtered torrents number --- src/webui/abstractwebapplication.cpp | 2 +- src/webui/www/public/filters.html | 17 +++++++++-------- src/webui/www/public/scripts/client.js | 18 ++++++++++++++++++ src/webui/www/public/scripts/dynamicTable.js | 16 +++++++++++++++- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/webui/abstractwebapplication.cpp b/src/webui/abstractwebapplication.cpp index 9e09010e4..cd2e70794 100644 --- a/src/webui/abstractwebapplication.cpp +++ b/src/webui/abstractwebapplication.cpp @@ -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; diff --git a/src/webui/www/public/filters.html b/src/webui/www/public/filters.html index 48cce7baf..e7f43c2e6 100644 --- a/src/webui/www/public/filters.html +++ b/src/webui/www/public/filters.html @@ -1,13 +1,14 @@ QBT_TR(Torrents)QBT_TR
QBT_TR(Labels)QBT_TR diff --git a/src/webui/www/public/scripts/client.js b/src/webui/www/public/scripts/client.js index ba28bcfbb..28bb878b9 100644 --- a/src/webui/www/public/scripts/client.js +++ b/src/webui/www/public/scripts/client.js @@ -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 () { }); }; + 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 () { serverState[key] = tmp[key]; processServerState(); } + updateFiltersList(); if (update_labels) { updateLabelList(); updateContextMenu(); diff --git a/src/webui/www/public/scripts/dynamicTable.js b/src/webui/www/public/scripts/dynamicTable.js index 018ace08c..0184eb050 100644 --- a/src/webui/www/public/scripts/dynamicTable.js +++ b/src/webui/www/public/scripts/dynamicTable.js @@ -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({ 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({ 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();