WebUI: Implement Share limit action

PR #22989.
Closes #22984.
This commit is contained in:
Mark Yu
2025-07-20 04:39:31 -04:00
committed by GitHub
parent c962a6b1d7
commit 8f709b5fbc
8 changed files with 41 additions and 8 deletions

View File

@@ -385,7 +385,7 @@ const initializeWindows = () => {
const hash = hashes[i];
const row = torrentsTable.getRow(hash).full_data;
const origValues = `${row.ratio_limit}|${row.seeding_time_limit}|${row.inactive_seeding_time_limit}|${row.max_ratio}`
+ `|${row.max_seeding_time}|${row.max_inactive_seeding_time}`;
+ `|${row.max_seeding_time}|${row.max_inactive_seeding_time}|${row.share_limit_action}`;
// initialize value
if (shareRatio === null)
@@ -414,8 +414,8 @@ const initializeWindows = () => {
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: window.qBittorrent.Dialog.limitWidthToViewport(424),
height: 220
width: window.qBittorrent.Dialog.limitWidthToViewport(500),
height: 250
});
};

View File

@@ -12,8 +12,11 @@
const UseGlobalLimit = -2;
const NoLimit = -1;
let limitReachedActionsEl;
window.addEventListener("DOMContentLoaded", (event) => {
limitReachedActionsEl = document.getElementById("limitReachedActions");
window.addEventListener("keydown", (event) => {
switch (event.key) {
case "Enter":
@@ -36,7 +39,8 @@
inactiveSeedingTimeLimit: Number(origValues[2]),
maxRatio: Number(origValues[3]),
maxSeedingTime: Number(origValues[4]),
maxInactiveSeedingTime: Number(origValues[5])
maxInactiveSeedingTime: Number(origValues[5]),
shareLimitAction: String(origValues[6])
};
// select default when orig values not passed. using double equals to compare string and int
@@ -65,6 +69,8 @@
document.getElementById("setInactiveMinutes").checked = true;
document.getElementById("inactiveMinutes").value = values.inactiveSeedingTimeLimit;
}
limitReachedActionsEl.value = values.shareLimitAction;
}
shareLimitChanged();
@@ -81,6 +87,7 @@
let ratioLimitValue = 0.00;
let seedingTimeLimitValue = 0;
let inactiveSeedingTimeLimitValue = 0;
let shareLimitActionValue = "Default";
if (shareLimit === "default") {
ratioLimitValue = seedingTimeLimitValue = inactiveSeedingTimeLimitValue = UseGlobalLimit;
@@ -92,6 +99,7 @@
ratioLimitValue = document.getElementById("setRatio").checked ? document.getElementById("ratio").value : -1;
seedingTimeLimitValue = document.getElementById("setTotalMinutes").checked ? document.getElementById("totalMinutes").value : -1;
inactiveSeedingTimeLimitValue = document.getElementById("setInactiveMinutes").checked ? document.getElementById("inactiveMinutes").value : -1;
shareLimitActionValue = limitReachedActionsEl.value;
}
else {
return;
@@ -103,7 +111,8 @@
hashes: searchParams.get("hashes"),
ratioLimit: ratioLimitValue,
seedingTimeLimit: seedingTimeLimitValue,
inactiveSeedingTimeLimit: inactiveSeedingTimeLimitValue
inactiveSeedingTimeLimit: inactiveSeedingTimeLimitValue,
shareLimitAction: shareLimitActionValue
})
})
.then((response) => {
@@ -140,6 +149,7 @@
document.getElementById("setRatio").disabled = !customShareLimit;
document.getElementById("setTotalMinutes").disabled = !customShareLimit;
document.getElementById("setInactiveMinutes").disabled = !customShareLimit;
limitReachedActionsEl.disabled = !customShareLimit;
enableInputBoxes();
@@ -182,6 +192,16 @@
<label id="inactiveMinutesLabel" for="setInactiveMinutes">QBT_TR(inactive minutes)QBT_TR[CONTEXT=UpDownRatioDialog]</label>
<input type="number" id="inactiveMinutes" value="0" step="1" min="0" class="shareLimitInput" aria-labelledby="inactiveMinutesLabel">
</div>
<div style="margin-left: 40px; margin-bottom: 5px;">
<label id="actionListLabel" for="limitReachedActions">QBT_TR(Action when the limit is reached)QBT_TR[CONTEXT=UpDownRatioDialog]</label>
<select id="limitReachedActions" aria-labelledby="actionListLabel">
<option value="Default">QBT_TR(Default)QBT_TR[CONTEXT=UpDownRatioDialog]</option>
<option value="Stop">QBT_TR(Stop torrent)QBT_TR[CONTEXT=UpDownRatioDialog]</option>
<option value="Remove">QBT_TR(Remove torrent)QBT_TR[CONTEXT=UpDownRatioDialog]</option>
<option value="RemoveWithContent">QBT_TR(Remove torrent and its content)QBT_TR[CONTEXT=UpDownRatioDialog]</option>
<option value="EnableSuperSeeding">QBT_TR(Enable super seeding for torrent)QBT_TR[CONTEXT=UpDownRatioDialog]</option>
</select>
</div>
<div style="text-align: center; padding-top: 10px;">
<input type="button" value="QBT_TR(Save)QBT_TR[CONTEXT=HttpServer]" id="save">
</div>