From f7833c9f0c07e164bc985f108067558edb74054b Mon Sep 17 00:00:00 2001 From: buinsky Date: Fri, 22 Jan 2016 08:43:07 +0300 Subject: [PATCH] WebUI: Implement start torrents by category --- src/webui/www/private/index.html | 1 + src/webui/www/public/filters.html | 3 +++ src/webui/www/public/scripts/dynamicTable.js | 11 +++++++++++ src/webui/www/public/scripts/mocha-init.js | 16 ++++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html index db49432ad..332572391 100644 --- a/src/webui/www/private/index.html +++ b/src/webui/www/private/index.html @@ -129,6 +129,7 @@
  • QBT_TR(Add category...)QBT_TR QBT_TR(Add category...)QBT_TR
  • QBT_TR(Remove category)QBT_TR QBT_TR(Remove category)QBT_TR
  • QBT_TR(Remove unused categories)QBT_TR QBT_TR(Remove unused categories)QBT_TR
  • +
  • QBT_TR(Resume torrents)QBT_TR QBT_TR(Resume torrents)QBT_TR
  • diff --git a/src/webui/www/public/filters.html b/src/webui/www/public/filters.html index d35489c19..08d50fff6 100644 --- a/src/webui/www/public/filters.html +++ b/src/webui/www/public/filters.html @@ -28,6 +28,9 @@ }, DeleteUnusedCategories : function (element, ref) { deleteUnusedCategoriesFN(); + }, + StartTorrentsByCategory : function (element, ref) { + startTorrentsByCategoryFN(element.id); } }, offsets : { diff --git a/src/webui/www/public/scripts/dynamicTable.js b/src/webui/www/public/scripts/dynamicTable.js index d669e1d3e..97078e305 100644 --- a/src/webui/www/public/scripts/dynamicTable.js +++ b/src/webui/www/public/scripts/dynamicTable.js @@ -683,6 +683,17 @@ var TorrentsTable = new Class({ return cnt; }, + getFilteredTorrentsHashes : function (filterName, categoryHash) { + var rowsHashes = []; + var rows = this.rows.getValues(); + + for (i = 0; i < rows.length; i++) + if (this.applyFilter(rows[i], filterName, categoryHash)) + rowsHashes.push(rows[i]['rowId']); + + return rowsHashes; + }, + getFilteredAndSortedRows : function () { var filteredRows = new Array(); diff --git a/src/webui/www/public/scripts/mocha-init.js b/src/webui/www/public/scripts/mocha-init.js index 2daba0795..56e3fcdff 100644 --- a/src/webui/www/public/scripts/mocha-init.js +++ b/src/webui/www/public/scripts/mocha-init.js @@ -385,6 +385,22 @@ initializeWindows = function() { setCategoryFilter(CATEGORIES_ALL); }; + startTorrentsByCategoryFN = function (categoryHash) { + var h = torrentsTable.getFilteredTorrentsHashes('all', categoryHash); + if (h.length) { + h.each(function (hash, index) { + new Request({ + url: 'command/resume', + method: 'post', + data: { + hash: hash + } + }).send(); + }); + updateMainData(); + } + }; + ['pauseAll', 'resumeAll'].each(function(item) { addClickEvent(item, function(e) { new Event(e).stop();