diff --git a/src/webui/webapplication.cpp b/src/webui/webapplication.cpp index 5f7a1c5df..3924cd973 100644 --- a/src/webui/webapplication.cpp +++ b/src/webui/webapplication.cpp @@ -116,6 +116,7 @@ QMap > WebApplication::initialize ADD_ACTION(command, recheck); ADD_ACTION(command, setCategory); ADD_ACTION(command, addCategory); + ADD_ACTION(command, removeCategory); ADD_ACTION(command, getSavePath); ADD_ACTION(version, api); ADD_ACTION(version, api_min); @@ -744,6 +745,15 @@ void WebApplication::action_command_addCategory() BitTorrent::Session::instance()->addCategory(category); } +void WebApplication::action_command_removeCategory() +{ + CHECK_URI(0); + CHECK_PARAMETERS("category"); + + QString category = request().posts["category"].trimmed(); + BitTorrent::Session::instance()->removeCategory(category); +} + void WebApplication::action_command_getSavePath() { CHECK_URI(0); diff --git a/src/webui/webapplication.h b/src/webui/webapplication.h index efa446531..248695de8 100644 --- a/src/webui/webapplication.h +++ b/src/webui/webapplication.h @@ -89,6 +89,7 @@ private: void action_command_recheck(); void action_command_setCategory(); void action_command_addCategory(); + void action_command_removeCategory(); void action_command_getSavePath(); void action_version_api(); void action_version_api_min(); diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html index 2f894f140..999b1fab9 100644 --- a/src/webui/www/private/index.html +++ b/src/webui/www/private/index.html @@ -127,6 +127,7 @@
diff --git a/src/webui/www/public/filters.html b/src/webui/www/public/filters.html index a1bba5e3d..295173332 100644 --- a/src/webui/www/public/filters.html +++ b/src/webui/www/public/filters.html @@ -22,6 +22,9 @@ actions : { CreateCategory : function (element, ref) { createCategoryFN(); + }, + DeleteCategory : function (element, ref) { + removeCategoryFN(element.id); } }, offsets : { diff --git a/src/webui/www/public/scripts/contextmenu.js b/src/webui/www/public/scripts/contextmenu.js index 717e4d5b5..cef6451e7 100644 --- a/src/webui/www/public/scripts/contextmenu.js +++ b/src/webui/www/public/scripts/contextmenu.js @@ -315,5 +315,12 @@ var TorrentsTableContextMenu = new Class({ }); var CategoriesFilterContextMenu = new Class({ - Extends: ContextMenu + Extends: ContextMenu, + updateMenuItems: function () { + var id = this.options.element.id; + if (id != CATEGORIES_ALL && id != CATEGORIES_UNCATEGORIZED) + this.showItem('DeleteCategory'); + else + this.hideItem('DeleteCategory'); + } }); diff --git a/src/webui/www/public/scripts/mocha-init.js b/src/webui/www/public/scripts/mocha-init.js index ae2e6a704..338e81ca7 100644 --- a/src/webui/www/public/scripts/mocha-init.js +++ b/src/webui/www/public/scripts/mocha-init.js @@ -357,6 +357,18 @@ initializeWindows = function() { updateMainData(); }; + removeCategoryFN = function (categoryHash) { + var categoryName = category_list[categoryHash].name; + new Request({ + url: 'command/removeCategory', + method: 'post', + data: { + category: categoryName + } + }).send(); + setCategoryFilter(CATEGORIES_ALL); + }; + ['pauseAll', 'resumeAll'].each(function(item) { addClickEvent(item, function(e) { new Event(e).stop();