From 04eb40376e7ddaeb51e4a621991b11b64d91e9e0 Mon Sep 17 00:00:00 2001
From: skomerko <168652295+skomerko@users.noreply.github.com>
Date: Sun, 11 Aug 2024 10:08:13 +0200
Subject: [PATCH] WebUI: Allow to filter torrent list by save path
This PR adds ability to filter torrent list by save path. Everything should work exactly like in GUI.
Closes #19393.
PR #21175.
---
src/webui/www/private/css/style.css | 4 ++++
src/webui/www/private/index.html | 5 +++++
src/webui/www/private/scripts/client.js | 5 ++---
src/webui/www/private/scripts/dynamicTable.js | 7 ++++---
4 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/webui/www/private/css/style.css b/src/webui/www/private/css/style.css
index 5fc361c4a..7de894368 100644
--- a/src/webui/www/private/css/style.css
+++ b/src/webui/www/private/css/style.css
@@ -449,6 +449,10 @@ a.propButton img {
width: 26px;
}
+#torrentsFilterSelect {
+ padding: 2px 4px;
+}
+
#torrentFilesFilterToolbar {
float: right;
margin-right: 30px;
diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html
index 4fb09c62b..d2fb8c4b8 100644
--- a/src/webui/www/private/index.html
+++ b/src/webui/www/private/index.html
@@ -133,6 +133,11 @@
+
+
diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js
index f26a1bdfa..e8980c474 100644
--- a/src/webui/www/private/scripts/client.js
+++ b/src/webui/www/private/scripts/client.js
@@ -1563,9 +1563,8 @@ window.addEventListener("DOMContentLoaded", () => {
torrentsTable.updateTable();
}, window.qBittorrent.Misc.FILTER_INPUT_DELAY);
});
- $("torrentsFilterRegexBox").addEventListener("change", () => {
- torrentsTable.updateTable();
- });
+
+ document.getElementById("torrentsFilterToolbar").addEventListener("change", (e) => { torrentsTable.updateTable(); });
$("transfersTabLink").addEventListener("click", showTransfersTab);
$("searchTabLink").addEventListener("click", showSearchTab);
diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js
index 1b12b8d3b..e68f2398c 100644
--- a/src/webui/www/private/scripts/dynamicTable.js
+++ b/src/webui/www/private/scripts/dynamicTable.js
@@ -1357,7 +1357,6 @@ window.qBittorrent.DynamicTable ??= (() => {
applyFilter: function(row, filterName, categoryHash, tagHash, trackerHash, filterTerms) {
const state = row["full_data"].state;
- const name = row["full_data"].name.toLowerCase();
let inactive = false;
switch (filterName) {
@@ -1487,12 +1486,14 @@ window.qBittorrent.DynamicTable ??= (() => {
}
if ((filterTerms !== undefined) && (filterTerms !== null)) {
+ const filterBy = document.getElementById("torrentsFilterSelect").value;
+ const textToSearch = row["full_data"][filterBy].toLowerCase();
if (filterTerms instanceof RegExp) {
- if (!filterTerms.test(name))
+ if (!filterTerms.test(textToSearch))
return false;
}
else {
- if ((filterTerms.length > 0) && !window.qBittorrent.Misc.containsAllTerms(name, filterTerms))
+ if ((filterTerms.length > 0) && !window.qBittorrent.Misc.containsAllTerms(textToSearch, filterTerms))
return false;
}
}