WebUI: Support editing tracker tier

This PR adds the ability to direct modify a tracker's tier from the WebUI. This process is notably different than the GUI, which provides arrows for increasing/decreasing a tracker's tier.

Closes #12233.
PR #22963.
This commit is contained in:
Thomas Piccirello
2025-08-17 11:46:10 -07:00
committed by GitHub
parent b2d6323034
commit 6ef9db89f9
4 changed files with 67 additions and 20 deletions

View File

@@ -26,9 +26,11 @@
const searchParams = new URLSearchParams(window.location.search);
const currentUrl = searchParams.get("url");
if (currentUrl === null)
const currentTier = searchParams.get("tier");
if ((currentUrl === null) || (currentTier === null))
return;
document.getElementById("trackerTier").value = currentTier;
document.getElementById("trackerUrl").value = currentUrl;
document.getElementById("trackerUrl").focus();
@@ -40,8 +42,9 @@
method: "POST",
body: new URLSearchParams({
hash: searchParams.get("hash"),
origUrl: currentUrl,
newUrl: document.getElementById("trackerUrl").value
url: currentUrl,
newUrl: document.getElementById("trackerUrl").value,
tier: document.getElementById("trackerTier").value
})
})
.then((response) => {
@@ -63,6 +66,11 @@
<input type="text" id="trackerUrl" style="width: 90%;">
</div>
<br>
<label for="trackerTier">QBT_TR(Tier:)QBT_TR[CONTEXT=TrackerListWidget]</label>
<div style="text-align: center; padding-top: 10px;">
<input type="number" id="trackerTier" style="width: 90%; max-width: 100px;" min="0" max="255">
</div>
<br>
<input type="button" value="QBT_TR(Edit)QBT_TR[CONTEXT=HttpServer]" id="editTrackerButton">
</div>
</body>

View File

@@ -255,13 +255,21 @@ window.qBittorrent.PropTrackers ??= (() => {
if (current_hash.length === 0)
return;
const trackerUrl = encodeURIComponent(torrentTrackersTable.selectedRowsIds()[0]);
const tracker = torrentTrackersTable.getRow(torrentTrackersTable.getSelectedRowId());
const contentURL = new URL("edittracker.html", window.location);
contentURL.search = new URLSearchParams({
v: "${CACHEID}",
hash: current_hash,
url: tracker.full_data.url,
tier: tracker.full_data.tier
});
new MochaUI.Window({
id: "trackersPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Tracker editing)QBT_TR[CONTEXT=TrackerListWidget]",
loadMethod: "iframe",
contentURL: `edittracker.html?v=${CACHEID}&hash=${current_hash}&url=${trackerUrl}`,
contentURL: contentURL.toString(),
scrollbars: true,
resizable: false,
maximizable: false,
@@ -269,7 +277,7 @@ window.qBittorrent.PropTrackers ??= (() => {
paddingVertical: 0,
paddingHorizontal: 0,
width: window.qBittorrent.Dialog.limitWidthToViewport(500),
height: 150,
height: 200,
onCloseComplete: () => {
updateData();
}