Add date column to the built-in search engine

Adds a date column to the built-in search engine to show when a torrent was published/uploaded on the engine site.
When a plugin wants to show a date, it can now add a `pub_date` entry to its result dict. The value format is a unix timestamp (an integer representing seconds since epoch).
Plugins with no date support will keep working.

PR #20703.
This commit is contained in:
ducalex 2024-04-29 14:10:24 -04:00 committed by GitHub
parent 775b38079f
commit 42b87963fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 40 additions and 10 deletions

View file

@ -1685,6 +1685,7 @@ window.qBittorrent.DynamicTable = (function() {
this.newColumn('nbSeeders', '', 'QBT_TR(Seeders)QBT_TR[CONTEXT=SearchResultsTable]', 100, true);
this.newColumn('nbLeechers', '', 'QBT_TR(Leechers)QBT_TR[CONTEXT=SearchResultsTable]', 100, true);
this.newColumn('siteUrl', '', 'QBT_TR(Search engine)QBT_TR[CONTEXT=SearchResultsTable]', 250, true);
this.newColumn('pubDate', '', 'QBT_TR(Published On)QBT_TR[CONTEXT=SearchResultsTable]', 200, true);
this.initColumnsFunctions();
},
@ -1701,10 +1702,17 @@ window.qBittorrent.DynamicTable = (function() {
td.set('text', formattedValue);
td.set('title', formattedValue);
};
const displayDate = function(td, row) {
const value = this.getRowValue(row) * 1000;
const formattedValue = (isNaN(value) || (value <= 0)) ? "" : (new Date(value).toLocaleString());
td.set('text', formattedValue);
td.set('title', formattedValue);
};
this.columns['fileSize'].updateTd = displaySize;
this.columns['nbSeeders'].updateTd = displayNum;
this.columns['nbLeechers'].updateTd = displayNum;
this.columns['pubDate'].updateTd = displayDate;
},
getFilteredAndSortedRows: function() {