-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
5 changed files
with
95 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<div id="confirmAutoTMMDialog"> | ||
<div class="genericConfirmGrid"> | ||
<span class="confirmGridItem confirmWarning"></span> | ||
<span class="confirmGridItem dialogMessage" id="confirmAutoTmmMessage"></span> | ||
</div> | ||
</div> | ||
<div> | ||
<input type="button" value="QBT_TR(Yes)QBT_TR[CONTEXT=MainWindow]" id="confirmAutoTmmButton"> | ||
<input type="button" value="QBT_TR(No)QBT_TR[CONTEXT=MainWindow]" id="cancelAutoTmmButton"> | ||
</div> | ||
|
||
<script> | ||
"use strict"; | ||
|
||
(() => { | ||
const confirmButton = document.getElementById("confirmAutoTmmButton"); | ||
const cancelButton = document.getElementById("cancelAutoTmmButton"); | ||
const confirmText = document.getElementById("confirmAutoTmmMessage"); | ||
|
||
const { | ||
options: { data: { hashes, enable }, id }, | ||
windowEl | ||
} = window.MUI.Windows.instances["confirmAutoTMMDialog"]; | ||
|
||
confirmText.textContent = "QBT_TR(Are you sure you want to enable Automatic Torrent Management for the selected torrent(s)? They may be relocated.)QBT_TR[CONTEXT=confirmAutoTMMDialog]"; | ||
|
||
cancelButton.addEventListener("click", (e) => { window.qBittorrent.Client.closeWindow(id); }); | ||
confirmButton.addEventListener("click", (e) => { | ||
new Request({ | ||
url: "api/v2/torrents/setAutoManagement", | ||
method: "post", | ||
data: { | ||
hashes: hashes.join("|"), | ||
enable: enable | ||
}, | ||
onSuccess: () => { | ||
updateMainData(); | ||
window.qBittorrent.Client.closeWindow(id); | ||
}, | ||
onFailure: () => { | ||
alert("QBT_TR(Unable to set Auto Torrent Management for the selected torrents.)QBT_TR[CONTEXT=HttpServer]"); | ||
} | ||
}).send(); | ||
}); | ||
|
||
// set tabindex so window element receives keydown events | ||
windowEl.setAttribute("tabindex", "-1"); | ||
windowEl.focus(); | ||
windowEl.addEventListener("keydown", (e) => { | ||
switch (e.key) { | ||
case "Enter": | ||
confirmButton.click(); | ||
break; | ||
case "Escape": | ||
window.qBittorrent.Client.closeWindow(id); | ||
break; | ||
} | ||
}); | ||
})(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters