diff --git a/src/webui/api/synccontroller.cpp b/src/webui/api/synccontroller.cpp
index dac4fb316..cb8a038c0 100644
--- a/src/webui/api/synccontroller.cpp
+++ b/src/webui/api/synccontroller.cpp
@@ -445,6 +445,12 @@ void SyncController::maindataAction()
data["categories"] = categories;
+ QVariantList tags;
+ for (const QString &tag : asConst(session->tags()))
+ tags << tag;
+
+ data["tags"] = tags;
+
QVariantMap serverState = getTranserInfo();
serverState[KEY_TRANSFER_FREESPACEONDISK] = getFreeDiskSpace();
serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled();
diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp
index 35561b10e..0a965bf28 100644
--- a/src/webui/api/torrentscontroller.cpp
+++ b/src/webui/api/torrentscontroller.cpp
@@ -1041,3 +1041,67 @@ void TorrentsController::categoriesAction()
setResult(categories);
}
+
+void TorrentsController::addTagsAction()
+{
+ checkParams({"hashes", "tags"});
+
+ const QStringList hashes {params()["hashes"].split('|')};
+ const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
+
+ for (const QString &tag : tags) {
+ const QString tagTrimmed {tag.trimmed()};
+ applyToTorrents(hashes, [&tagTrimmed](BitTorrent::TorrentHandle *const torrent)
+ {
+ torrent->addTag(tagTrimmed);
+ });
+ }
+}
+
+void TorrentsController::removeTagsAction()
+{
+ checkParams({"hashes"});
+
+ const QStringList hashes {params()["hashes"].split('|')};
+ const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
+
+ for (const QString &tag : tags) {
+ const QString tagTrimmed {tag.trimmed()};
+ applyToTorrents(hashes, [&tagTrimmed](BitTorrent::TorrentHandle *const torrent)
+ {
+ torrent->removeTag(tagTrimmed);
+ });
+ }
+
+ if (tags.isEmpty()) {
+ applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent)
+ {
+ torrent->removeAllTags();
+ });
+ }
+}
+
+void TorrentsController::createTagsAction()
+{
+ checkParams({"tags"});
+
+ const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
+
+ for (const QString &tag : tags)
+ BitTorrent::Session::instance()->addTag(tag.trimmed());
+}
+
+void TorrentsController::deleteTagsAction()
+{
+ checkParams({"tags"});
+
+ const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
+ for (const QString &tag : tags)
+ BitTorrent::Session::instance()->removeTag(tag.trimmed());
+}
+
+void TorrentsController::tagsAction()
+{
+ const QStringList tags = BitTorrent::Session::instance()->tags().toList();
+ setResult(QJsonArray::fromStringList(tags));
+}
diff --git a/src/webui/api/torrentscontroller.h b/src/webui/api/torrentscontroller.h
index 2f467a22e..61bf4e14f 100644
--- a/src/webui/api/torrentscontroller.h
+++ b/src/webui/api/torrentscontroller.h
@@ -56,6 +56,11 @@ private slots:
void editCategoryAction();
void removeCategoriesAction();
void categoriesAction();
+ void addTagsAction();
+ void removeTagsAction();
+ void createTagsAction();
+ void deleteTagsAction();
+ void tagsAction();
void addAction();
void deleteAction();
void addTrackersAction();
diff --git a/src/webui/www/private/addtrackers.html b/src/webui/www/private/addtrackers.html
index 10b77dc1f..a482f3464 100644
--- a/src/webui/www/private/addtrackers.html
+++ b/src/webui/www/private/addtrackers.html
@@ -32,7 +32,7 @@
$('trackersUrls').focus();
$('addTrackersButton').addEvent('click', function(e) {
new Event(e).stop();
- var hash = new URI().getData('hash');
+ const hash = new URI().getData('hash');
new Request({
url: 'api/v2/torrents/addTrackers',
method: 'post',
diff --git a/src/webui/www/private/confirmdeletion.html b/src/webui/www/private/confirmdeletion.html
index f078ccb47..34334ebd4 100644
--- a/src/webui/www/private/confirmdeletion.html
+++ b/src/webui/www/private/confirmdeletion.html
@@ -10,8 +10,8 @@
diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html
index 0fd0e8076..89fc2c68e 100644
--- a/src/webui/www/private/index.html
+++ b/src/webui/www/private/index.html
@@ -132,6 +132,10 @@
QBT_TR(Category)QBT_TR[CONTEXT=TransferListWidget]
QBT_TR(Comma-separated tags:)QBT_TR[CONTEXT=TransferListWidget]
+ +