From 4ff0687b944a4b293ebf20d70a22b29ff4de8f24 Mon Sep 17 00:00:00 2001 From: skomerko <168652295+skomerko@users.noreply.github.com> Date: Fri, 4 Oct 2024 16:39:08 +0200 Subject: [PATCH] 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. --- src/webui/www/private/css/Window.css | 3 + src/webui/www/private/index.html | 2 +- src/webui/www/private/scripts/mocha-init.js | 46 +++++++++----- .../www/private/views/confirmAutoTMM.html | 60 +++++++++++++++++++ src/webui/www/webui.qrc | 1 + 5 files changed, 95 insertions(+), 17 deletions(-) create mode 100644 src/webui/www/private/views/confirmAutoTMM.html diff --git a/src/webui/www/private/css/Window.css b/src/webui/www/private/css/Window.css index 9a71df8e3..008e760a1 100644 --- a/src/webui/www/private/css/Window.css +++ b/src/webui/www/private/css/Window.css @@ -57,7 +57,10 @@ Required by: font-weight: bold; line-height: 15px; margin: 0; + overflow: hidden; padding: 5px 10px 4px 12px; + text-overflow: ellipsis; + white-space: nowrap; } .mochaToolbarWrapper { diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html index 868521497..86e92eb51 100644 --- a/src/webui/www/private/index.html +++ b/src/webui/www/private/index.html @@ -174,7 +174,7 @@ QBT_TR(Tags)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Tags)QBT_TR[CONTEXT=TransferListWidget] -
  • +
  • QBT_TR(Automatic Torrent Management)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Automatic Torrent Management)QBT_TR[CONTEXT=TransferListWidget]
  • QBT_TR(Limit download rate...)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Limit download rate...)QBT_TR[CONTEXT=TransferListWidget]
  • diff --git a/src/webui/www/private/scripts/mocha-init.js b/src/webui/www/private/scripts/mocha-init.js index b404c59cc..d9edc22c5 100644 --- a/src/webui/www/private/scripts/mocha-init.js +++ b/src/webui/www/private/scripts/mocha-init.js @@ -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(); + } } }; diff --git a/src/webui/www/private/views/confirmAutoTMM.html b/src/webui/www/private/views/confirmAutoTMM.html new file mode 100644 index 000000000..14ae0a87e --- /dev/null +++ b/src/webui/www/private/views/confirmAutoTMM.html @@ -0,0 +1,60 @@ +
    +
    + + +
    +
    +
    + + +
    + + diff --git a/src/webui/www/webui.qrc b/src/webui/www/webui.qrc index bd11d9a0a..ae1ddfeee 100644 --- a/src/webui/www/webui.qrc +++ b/src/webui/www/webui.qrc @@ -423,6 +423,7 @@ private/uploadlimit.html private/views/about.html private/views/aboutToolbar.html + private/views/confirmAutoTMM.html private/views/confirmdeletion.html private/views/confirmRecheck.html private/views/cookies.html