mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 21:03:30 -07:00
Support specifying tags when adding torrent in WebUI
Signed-off-by: Thomas Piccirello <thomas@piccirello.com>
This commit is contained in:
parent
4790c8b023
commit
772fe9999e
2 changed files with 60 additions and 0 deletions
|
@ -7,8 +7,10 @@
|
|||
<link rel="stylesheet" type="text/css" href="css/dynamicTable.css?v=${CACHEID}">
|
||||
<link rel="stylesheet" href="css/style.css?v=${CACHEID}" type="text/css">
|
||||
<link rel="stylesheet" href="css/Window.css?v=${CACHEID}" type="text/css">
|
||||
<link rel="stylesheet" href="css/vanillaSelectBox.css" type="text/css">
|
||||
<script defer src="scripts/lib/MooTools-Core-1.6.0-compat-compressed.js"></script>
|
||||
<script defer src="scripts/lib/MooTools-More-1.6.0-compat-compressed.js"></script>
|
||||
<script defer src="scripts/lib/vanillaSelectBox.js"></script>
|
||||
<script defer src="scripts/localpreferences.js?v=${CACHEID}"></script>
|
||||
<script defer src="scripts/color-scheme.js?v=${CACHEID}"></script>
|
||||
<script defer src="scripts/addtorrent.js?locale=${LANG}&v=${CACHEID}"></script>
|
||||
|
@ -84,6 +86,13 @@
|
|||
window.qBittorrent.AddTorrent.loadMetadata(source);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
#btn-group-tagsSelect button {
|
||||
background-color: initial;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -166,6 +175,17 @@
|
|||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label id="tagsLabel" for="tagsSelect">QBT_TR(Tags:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<input type="hidden" id="tags" name="tags">
|
||||
<select id="tagsSelect" name="tagsSelect" multiple></select>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="startTorrent">QBT_TR(Start torrent)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||
|
|
|
@ -37,6 +37,7 @@ window.qBittorrent.AddTorrent ??= (() => {
|
|||
};
|
||||
|
||||
let categories = {};
|
||||
let tags = [];
|
||||
let defaultSavePath = "";
|
||||
let windowId = "";
|
||||
let source;
|
||||
|
@ -66,6 +67,38 @@ window.qBittorrent.AddTorrent ??= (() => {
|
|||
});
|
||||
};
|
||||
|
||||
const getTags = () => {
|
||||
fetch("api/v2/torrents/tags", {
|
||||
method: "GET",
|
||||
cache: "no-store"
|
||||
})
|
||||
.then(async (response) => {
|
||||
if (!response.ok)
|
||||
return;
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
tags = data;
|
||||
const tagsSelect = document.getElementById("tagsSelect");
|
||||
for (const tag of tags) {
|
||||
const option = document.createElement("option");
|
||||
option.value = tag;
|
||||
option.textContent = tag;
|
||||
tagsSelect.appendChild(option);
|
||||
}
|
||||
|
||||
new vanillaSelectBox("#tagsSelect", {
|
||||
maxHeight: 200,
|
||||
search: false,
|
||||
disableSelectAll: true,
|
||||
translations: {
|
||||
all: tags.length === 0 ? "" : "QBT_TR(All)QBT_TR[CONTEXT=AddNewTorrentDialog]",
|
||||
},
|
||||
keepInlineStyles: false
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const getPreferences = () => {
|
||||
const pref = window.parent.qBittorrent.Cache.preferences.get();
|
||||
|
||||
|
@ -122,6 +155,11 @@ window.qBittorrent.AddTorrent ??= (() => {
|
|||
}
|
||||
};
|
||||
|
||||
const changeTagsSelect = (element) => {
|
||||
const tags = [...element.options].filter(opt => opt.selected).map(opt => opt.value);
|
||||
document.getElementById("tags").value = tags.join(",");
|
||||
};
|
||||
|
||||
const changeTMM = (item) => {
|
||||
const savepath = document.getElementById("savepath");
|
||||
const useDownloadPath = document.getElementById("useDownloadPath");
|
||||
|
@ -240,10 +278,12 @@ window.qBittorrent.AddTorrent ??= (() => {
|
|||
|
||||
getPreferences();
|
||||
getCategories();
|
||||
getTags();
|
||||
});
|
||||
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
document.getElementById("useDownloadPath").addEventListener("change", (e) => changeUseDownloadPath(e.target));
|
||||
document.getElementById("tagsSelect").addEventListener("change", (e) => changeTagsSelect(e.target));
|
||||
});
|
||||
|
||||
return exports();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue