mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-14 17:23:07 -07:00
WebUI: Add confirm dialog for Auto TMM
Just like in GUI, confirmation dialog shows up if it's possible to enable Auto TMM for any selected torrent. Right now it's not possible to properly test all cases in the WebUI because context menu completely hides TMM option when some torrents have it enabled and some not (no tri-state) - but that's something to add in another PR. PR #21378.
This commit is contained in:
parent
dc02a0fc56
commit
4ff0687b94
5 changed files with 95 additions and 17 deletions
|
@ -555,22 +555,36 @@ const initializeWindows = function() {
|
|||
|
||||
autoTorrentManagementFN = function() {
|
||||
const hashes = torrentsTable.selectedRowsIds();
|
||||
if (hashes.length) {
|
||||
let enable = false;
|
||||
hashes.each((hash, index) => {
|
||||
const row = torrentsTable.getRow(hash);
|
||||
if (!row.full_data.auto_tmm)
|
||||
enable = true;
|
||||
});
|
||||
new Request({
|
||||
url: "api/v2/torrents/setAutoManagement",
|
||||
method: "post",
|
||||
data: {
|
||||
hashes: hashes.join("|"),
|
||||
enable: enable
|
||||
}
|
||||
}).send();
|
||||
updateMainData();
|
||||
if (hashes.length > 0) {
|
||||
const enableAutoTMM = hashes.some((hash) => !(torrentsTable.getRow(hash).full_data.auto_tmm));
|
||||
if (enableAutoTMM) {
|
||||
new MochaUI.Modal({
|
||||
...window.qBittorrent.Dialog.baseModalOptions,
|
||||
id: "confirmAutoTMMDialog",
|
||||
title: "QBT_TR(Enable automatic torrent management)QBT_TR[CONTEXT=confirmAutoTMMDialog]",
|
||||
data: {
|
||||
hashes: hashes,
|
||||
enable: enableAutoTMM
|
||||
},
|
||||
contentURL: "views/confirmAutoTMM.html"
|
||||
});
|
||||
}
|
||||
else {
|
||||
new Request({
|
||||
url: "api/v2/torrents/setAutoManagement",
|
||||
method: "post",
|
||||
data: {
|
||||
hashes: hashes.join("|"),
|
||||
enable: enableAutoTMM
|
||||
},
|
||||
onSuccess: () => {
|
||||
updateMainData();
|
||||
},
|
||||
onFailure: () => {
|
||||
alert("QBT_TR(Unable to set Auto Torrent Management for the selected torrents.)QBT_TR[CONTEXT=HttpServer]");
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue