Browse Source

WebUI: Implement removing categories

adaptive-webui-19844
buinsky 9 years ago
parent
commit
50f2437ac3
  1. 10
      src/webui/webapplication.cpp
  2. 1
      src/webui/webapplication.h
  3. 1
      src/webui/www/private/index.html
  4. 3
      src/webui/www/public/filters.html
  5. 9
      src/webui/www/public/scripts/contextmenu.js
  6. 12
      src/webui/www/public/scripts/mocha-init.js

10
src/webui/webapplication.cpp

@ -116,6 +116,7 @@ QMap<QString, QMap<QString, WebApplication::Action> > WebApplication::initialize @@ -116,6 +116,7 @@ QMap<QString, QMap<QString, WebApplication::Action> > 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() @@ -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);

1
src/webui/webapplication.h

@ -89,6 +89,7 @@ private: @@ -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();

1
src/webui/www/private/index.html

@ -127,6 +127,7 @@ @@ -127,6 +127,7 @@
</ul>
<ul id="categoriesFilterMenu" class="contextMenu">
<li><a href="#CreateCategory"><img src="theme/list-add" alt="QBT_TR(Add category...)QBT_TR"/> QBT_TR(Add category...)QBT_TR</a></li>
<li><a href="#DeleteCategory"><img src="theme/list-remove" alt="QBT_TR(Remove category)QBT_TR"/> QBT_TR(Remove category)QBT_TR</a></li>
</ul>
<div id="desktopFooterWrapper">
<div id="desktopFooter">

3
src/webui/www/public/filters.html

@ -22,6 +22,9 @@ @@ -22,6 +22,9 @@
actions : {
CreateCategory : function (element, ref) {
createCategoryFN();
},
DeleteCategory : function (element, ref) {
removeCategoryFN(element.id);
}
},
offsets : {

9
src/webui/www/public/scripts/contextmenu.js

@ -315,5 +315,12 @@ var TorrentsTableContextMenu = new Class({ @@ -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');
}
});

12
src/webui/www/public/scripts/mocha-init.js

@ -357,6 +357,18 @@ initializeWindows = function() { @@ -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();

Loading…
Cancel
Save