mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-22 01:06:03 +03:00
WebUI: Improve sort order in Status column
This commit adds custom compare function to Status column (same sort order as in the GUI). Closes #15499. PR #21570.
This commit is contained in:
parent
8e941a06f1
commit
7031c52d16
2 changed files with 31 additions and 2 deletions
|
@ -672,6 +672,28 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||
tracker.classList.toggle("selectedFilter", (Number(tracker.id) === selectedTracker));
|
||||
};
|
||||
|
||||
const statusSortOrder = Object.freeze({
|
||||
"unknown": -1,
|
||||
"forcedDL": 0,
|
||||
"downloading": 1,
|
||||
"forcedMetaDL": 2,
|
||||
"metaDL": 3,
|
||||
"stalledDL": 4,
|
||||
"forcedUP": 5,
|
||||
"uploading": 6,
|
||||
"stalledUP": 7,
|
||||
"checkingResumeData": 8,
|
||||
"queuedDL": 9,
|
||||
"queuedUP": 10,
|
||||
"checkingUP": 11,
|
||||
"checkingDL": 12,
|
||||
"stoppedDL": 13,
|
||||
"stoppedUP": 14,
|
||||
"moving": 15,
|
||||
"missingFiles": 16,
|
||||
"error": 17
|
||||
});
|
||||
|
||||
let syncMainDataTimeoutID = -1;
|
||||
let syncRequestInProgress = false;
|
||||
const syncMainData = function() {
|
||||
|
@ -800,8 +822,11 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||
|
||||
response["torrents"][key]["hash"] = key;
|
||||
response["torrents"][key]["rowId"] = key;
|
||||
if (response["torrents"][key]["state"])
|
||||
response["torrents"][key]["status"] = response["torrents"][key]["state"];
|
||||
if (response["torrents"][key]["state"]) {
|
||||
const state = response["torrents"][key]["state"];
|
||||
response["torrents"][key]["status"] = state;
|
||||
response["torrents"][key]["_statusOrder"] = statusSortOrder[state];
|
||||
}
|
||||
torrentsTable.updateRowData(response["torrents"][key]);
|
||||
if (addTorrentToCategoryList(response["torrents"][key]))
|
||||
update_categories = true;
|
||||
|
|
|
@ -1102,6 +1102,10 @@ window.qBittorrent.DynamicTable ??= (() => {
|
|||
td.title = status;
|
||||
};
|
||||
|
||||
this.columns["status"].compareRows = function(row1, row2) {
|
||||
return compareNumbers(row1.full_data._statusOrder, row2.full_data._statusOrder);
|
||||
};
|
||||
|
||||
// priority
|
||||
this.columns["priority"].updateTd = function(td, row) {
|
||||
const queuePos = this.getRowValue(row);
|
||||
|
|
Loading…
Reference in a new issue