Support using separate download path in WebUI

Signed-off-by: Thomas Piccirello <thomas@piccirello.com>
This commit is contained in:
Thomas Piccirello 2024-09-19 13:41:43 -07:00
commit 4e09974f2a
No known key found for this signature in database
2 changed files with 40 additions and 4 deletions

View file

@ -130,6 +130,16 @@
</tr>
</tbody>
</table>
<fieldset class="settings">
<legend>
<input type="checkbox" id="useDownloadPath" name="useDownloadPath" value="true">
<label for="useDownloadPath">QBT_TR(Use another path for incomplete torrent)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
</legend>
<div class="formRow">
<label for="downloadPath">QBT_TR(Save path:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
<input type="text" id="downloadPath" name="downloadPath" class="pathDirectory" disabled>
</div>
</fieldset>
</fieldset>
<fieldset class="settings" style="text-align: left;">
<legend>QBT_TR(Torrent settings)QBT_TR[CONTEXT=AddNewTorrentDialog]</legend>

View file

@ -123,17 +123,39 @@ window.qBittorrent.AddTorrent ??= (() => {
};
const changeTMM = (item) => {
const savepath = document.getElementById("savepath");
const useDownloadPath = document.getElementById("useDownloadPath");
if (item.selectedIndex === 1) {
document.getElementById("savepath").disabled = true;
savepath.disabled = true;
const categorySelect = document.getElementById("categorySelect");
const categoryName = categorySelect.options[categorySelect.selectedIndex].value;
const category = categories[categoryName];
document.getElementById("savepath").value = (category === undefined) ? "" : category["savePath"];
savepath.value = (category === undefined) ? "" : category["savePath"];
useDownloadPath.disabled = true;
useDownloadPath.checked = false;
changeUseDownloadPath(useDownloadPath);
}
else {
document.getElementById("savepath").disabled = false;
document.getElementById("savepath").value = defaultSavePath;
savepath.disabled = false;
savepath.value = defaultSavePath;
useDownloadPath.disabled = false;
}
changeUseDownloadPath(useDownloadPath);
};
const changeUseDownloadPath = (elem) => {
const downloadPath = document.getElementById("downloadPath");
if (elem.checked) {
downloadPath.disabled = false;
downloadPath.value = defaultSavePath;
}
else {
downloadPath.disabled = true;
downloadPath.value = "";
}
};
@ -220,6 +242,10 @@ window.qBittorrent.AddTorrent ??= (() => {
getCategories();
});
window.addEventListener("DOMContentLoaded", () => {
document.getElementById("useDownloadPath").addEventListener("change", (e) => changeUseDownloadPath(e.target));
});
return exports();
})();
Object.freeze(window.qBittorrent.AddTorrent);