mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-07 05:31:25 -07:00
Merge pull request #10928 from Piccirello/webui-search-filter
Support exclusions in WebUI table filters
This commit is contained in:
commit
2d28f50acd
2 changed files with 40 additions and 24 deletions
|
@ -1274,12 +1274,9 @@ const TorrentsTable = new Class({
|
|||
}
|
||||
}
|
||||
|
||||
if (filterTerms) {
|
||||
for (let i = 0; i < filterTerms.length; ++i) {
|
||||
if (name.indexOf(filterTerms[i]) === -1)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ((filterTerms !== undefined) && (filterTerms !== null)
|
||||
&& (filterTerms.length > 0) && !containsAllTerms(name, filterTerms))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
},
|
||||
|
@ -1523,16 +1520,6 @@ const SearchResultsTable = new Class({
|
|||
},
|
||||
|
||||
getFilteredAndSortedRows: function() {
|
||||
const containsAll = function(text, searchTerms) {
|
||||
text = text.toLowerCase();
|
||||
for (let i = 0; i < searchTerms.length; ++i) {
|
||||
if (text.indexOf(searchTerms[i].toLowerCase()) === -1)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const getSizeFilters = function() {
|
||||
let minSize = (searchSizeFilter.min > 0.00) ? (searchSizeFilter.min * Math.pow(1024, searchSizeFilter.minUnit)) : 0.00;
|
||||
let maxSize = (searchSizeFilter.max > 0.00) ? (searchSizeFilter.max * Math.pow(1024, searchSizeFilter.maxUnit)) : 0.00;
|
||||
|
@ -1577,8 +1564,8 @@ const SearchResultsTable = new Class({
|
|||
for (let i = 0; i < rows.length; ++i) {
|
||||
const row = rows[i];
|
||||
|
||||
if (searchInTorrentName && !containsAll(row.full_data.fileName, searchTerms)) continue;
|
||||
if ((filterTerms.length > 0) && !containsAll(row.full_data.fileName, filterTerms)) continue;
|
||||
if (searchInTorrentName && !containsAllTerms(row.full_data.fileName, searchTerms)) continue;
|
||||
if ((filterTerms.length > 0) && !containsAllTerms(row.full_data.fileName, filterTerms)) continue;
|
||||
if ((sizeFilters.min > 0.00) && (row.full_data.fileSize < sizeFilters.min)) continue;
|
||||
if ((sizeFilters.max > 0.00) && (row.full_data.fileSize > sizeFilters.max)) continue;
|
||||
if ((seedsFilters.min > 0) && (row.full_data.nbSeeders < seedsFilters.min)) continue;
|
||||
|
@ -1913,12 +1900,7 @@ const TorrentFilesTable = new Class({
|
|||
}
|
||||
}
|
||||
|
||||
const lowercaseName = node.name.toLowerCase();
|
||||
const matchesFilter = filterTerms.every(function(term) {
|
||||
return (lowercaseName.indexOf(term) !== -1);
|
||||
});
|
||||
|
||||
if (matchesFilter) {
|
||||
if (containsAllTerms(node.name, filterTerms)) {
|
||||
const row = this.getRow(node);
|
||||
filteredRows.push(row);
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue