mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-19 15:07:22 -06: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:
@@ -672,6 +672,28 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||||||
tracker.classList.toggle("selectedFilter", (Number(tracker.id) === selectedTracker));
|
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 syncMainDataTimeoutID = -1;
|
||||||
let syncRequestInProgress = false;
|
let syncRequestInProgress = false;
|
||||||
const syncMainData = function() {
|
const syncMainData = function() {
|
||||||
@@ -800,8 +822,11 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||||||
|
|
||||||
response["torrents"][key]["hash"] = key;
|
response["torrents"][key]["hash"] = key;
|
||||||
response["torrents"][key]["rowId"] = key;
|
response["torrents"][key]["rowId"] = key;
|
||||||
if (response["torrents"][key]["state"])
|
if (response["torrents"][key]["state"]) {
|
||||||
response["torrents"][key]["status"] = 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]);
|
torrentsTable.updateRowData(response["torrents"][key]);
|
||||||
if (addTorrentToCategoryList(response["torrents"][key]))
|
if (addTorrentToCategoryList(response["torrents"][key]))
|
||||||
update_categories = true;
|
update_categories = true;
|
||||||
|
|||||||
@@ -1102,6 +1102,10 @@ window.qBittorrent.DynamicTable ??= (() => {
|
|||||||
td.title = status;
|
td.title = status;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.columns["status"].compareRows = function(row1, row2) {
|
||||||
|
return compareNumbers(row1.full_data._statusOrder, row2.full_data._statusOrder);
|
||||||
|
};
|
||||||
|
|
||||||
// priority
|
// priority
|
||||||
this.columns["priority"].updateTd = function(td, row) {
|
this.columns["priority"].updateTd = function(td, row) {
|
||||||
const queuePos = this.getRowValue(row);
|
const queuePos = this.getRowValue(row);
|
||||||
|
|||||||
Reference in New Issue
Block a user