mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-13 16:28:06 +00:00
WebUI: Implement adding categories
This commit is contained in:
parent
a939fca4ac
commit
a4dca52617
@ -115,6 +115,7 @@ QMap<QString, QMap<QString, WebApplication::Action> > WebApplication::initialize
|
|||||||
ADD_ACTION(command, bottomPrio);
|
ADD_ACTION(command, bottomPrio);
|
||||||
ADD_ACTION(command, recheck);
|
ADD_ACTION(command, recheck);
|
||||||
ADD_ACTION(command, setCategory);
|
ADD_ACTION(command, setCategory);
|
||||||
|
ADD_ACTION(command, addCategory);
|
||||||
ADD_ACTION(command, getSavePath);
|
ADD_ACTION(command, getSavePath);
|
||||||
ADD_ACTION(version, api);
|
ADD_ACTION(version, api);
|
||||||
ADD_ACTION(version, api_min);
|
ADD_ACTION(version, api_min);
|
||||||
@ -728,6 +729,21 @@ void WebApplication::action_command_setCategory()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebApplication::action_command_addCategory()
|
||||||
|
{
|
||||||
|
CHECK_URI(0);
|
||||||
|
CHECK_PARAMETERS("category");
|
||||||
|
|
||||||
|
QString category = request().posts["category"].trimmed();
|
||||||
|
|
||||||
|
if (!BitTorrent::Session::isValidCategoryName(category) && !category.isEmpty()) {
|
||||||
|
status(400, tr("Incorrect category name"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BitTorrent::Session::instance()->addCategory(category);
|
||||||
|
}
|
||||||
|
|
||||||
void WebApplication::action_command_getSavePath()
|
void WebApplication::action_command_getSavePath()
|
||||||
{
|
{
|
||||||
CHECK_URI(0);
|
CHECK_URI(0);
|
||||||
|
@ -88,6 +88,7 @@ private:
|
|||||||
void action_command_bottomPrio();
|
void action_command_bottomPrio();
|
||||||
void action_command_recheck();
|
void action_command_recheck();
|
||||||
void action_command_setCategory();
|
void action_command_setCategory();
|
||||||
|
void action_command_addCategory();
|
||||||
void action_command_getSavePath();
|
void action_command_getSavePath();
|
||||||
void action_version_api();
|
void action_version_api();
|
||||||
void action_version_api_min();
|
void action_version_api_min();
|
||||||
|
@ -126,6 +126,7 @@
|
|||||||
<li class="separator"><a href="#ForceRecheck"><img src="theme/document-edit-verify" alt="QBT_TR(Force recheck)QBT_TR"/> QBT_TR(Force recheck)QBT_TR</a></li>
|
<li class="separator"><a href="#ForceRecheck"><img src="theme/document-edit-verify" alt="QBT_TR(Force recheck)QBT_TR"/> QBT_TR(Force recheck)QBT_TR</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul id="categoriesFilterMenu" class="contextMenu">
|
<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>
|
||||||
</ul>
|
</ul>
|
||||||
<div id="desktopFooterWrapper">
|
<div id="desktopFooterWrapper">
|
||||||
<div id="desktopFooter">
|
<div id="desktopFooter">
|
||||||
|
@ -19,6 +19,11 @@
|
|||||||
var categoriesFilterContextMenu = new CategoriesFilterContextMenu({
|
var categoriesFilterContextMenu = new CategoriesFilterContextMenu({
|
||||||
targets : '.categoriesFilterContextMenuTarget',
|
targets : '.categoriesFilterContextMenuTarget',
|
||||||
menu : 'categoriesFilterMenu',
|
menu : 'categoriesFilterMenu',
|
||||||
|
actions : {
|
||||||
|
CreateCategory : function (element, ref) {
|
||||||
|
createCategoryFN();
|
||||||
|
}
|
||||||
|
},
|
||||||
offsets : {
|
offsets : {
|
||||||
x : -15,
|
x : -15,
|
||||||
y : 2
|
y : 2
|
||||||
|
@ -31,6 +31,20 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var hashesList = new URI().getData('hashes');
|
var hashesList = new URI().getData('hashes');
|
||||||
|
if (!hashesList) {
|
||||||
|
new Request({
|
||||||
|
url: 'command/addCategory',
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
category: categoryName
|
||||||
|
},
|
||||||
|
onComplete: function () {
|
||||||
|
window.parent.closeWindows();
|
||||||
|
}
|
||||||
|
}).send();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
new Request({
|
new Request({
|
||||||
url: 'command/setCategory',
|
url: 'command/setCategory',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@ -42,6 +56,7 @@
|
|||||||
window.parent.closeWindows();
|
window.parent.closeWindows();
|
||||||
}
|
}
|
||||||
}).send();
|
}).send();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -292,8 +292,8 @@ var TorrentsTableContextMenu = new Class({
|
|||||||
updateCategoriesSubMenu : function (category_list) {
|
updateCategoriesSubMenu : function (category_list) {
|
||||||
var categoryList = $('contextCategoryList');
|
var categoryList = $('contextCategoryList');
|
||||||
categoryList.empty();
|
categoryList.empty();
|
||||||
categoryList.appendChild(new Element('li', {html: '<a href="javascript:newCategoryFN();"><img src="theme/list-add" alt="QBT_TR(New...)QBT_TR"/> QBT_TR(New...)QBT_TR</a>'}));
|
categoryList.appendChild(new Element('li', {html: '<a href="javascript:torrentNewCategoryFN();"><img src="theme/list-add" alt="QBT_TR(New...)QBT_TR"/> QBT_TR(New...)QBT_TR</a>'}));
|
||||||
categoryList.appendChild(new Element('li', {html: '<a href="javascript:setCategoryFN(0);"><img src="theme/edit-clear" alt="QBT_TR(Reset)QBT_TR"/> QBT_TR(Reset)QBT_TR</a>'}));
|
categoryList.appendChild(new Element('li', {html: '<a href="javascript:torrentSetCategoryFN(0);"><img src="theme/edit-clear" alt="QBT_TR(Reset)QBT_TR"/> QBT_TR(Reset)QBT_TR</a>'}));
|
||||||
|
|
||||||
var sortedCategories = []
|
var sortedCategories = []
|
||||||
Object.each(category_list, function (category) {
|
Object.each(category_list, function (category) {
|
||||||
@ -304,7 +304,7 @@ var TorrentsTableContextMenu = new Class({
|
|||||||
var first = true;
|
var first = true;
|
||||||
Object.each(sortedCategories, function (categoryName) {
|
Object.each(sortedCategories, function (categoryName) {
|
||||||
var categoryHash = genHash(categoryName);
|
var categoryHash = genHash(categoryName);
|
||||||
var el = new Element('li', {html: '<a href="javascript:setCategoryFN(\'' + categoryHash + '\');"><img src="theme/inode-directory"/> ' + escapeHtml(categoryName) + '</a>'});
|
var el = new Element('li', {html: '<a href="javascript:torrentSetCategoryFN(\'' + categoryHash + '\');"><img src="theme/inode-directory"/> ' + escapeHtml(categoryName) + '</a>'});
|
||||||
if (first) {
|
if (first) {
|
||||||
el.addClass('separator');
|
el.addClass('separator');
|
||||||
first = false;
|
first = false;
|
||||||
|
@ -304,7 +304,7 @@ initializeWindows = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
newCategoryFN = function () {
|
torrentNewCategoryFN = function () {
|
||||||
var h = torrentsTable.selectedRowsIds();
|
var h = torrentsTable.selectedRowsIds();
|
||||||
if (h.length) {
|
if (h.length) {
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
@ -323,7 +323,7 @@ initializeWindows = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
setCategoryFN = function (categoryHash) {
|
torrentSetCategoryFN = function (categoryHash) {
|
||||||
var categoryName = '';
|
var categoryName = '';
|
||||||
if (categoryHash != 0)
|
if (categoryHash != 0)
|
||||||
var categoryName = category_list[categoryHash].name;
|
var categoryName = category_list[categoryHash].name;
|
||||||
@ -340,6 +340,23 @@ initializeWindows = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
createCategoryFN = function () {
|
||||||
|
new MochaUI.Window({
|
||||||
|
id: 'newCategoryPage',
|
||||||
|
title: "QBT_TR(New Category)QBT_TR",
|
||||||
|
loadMethod: 'iframe',
|
||||||
|
contentURL: 'newcategory.html',
|
||||||
|
scrollbars: false,
|
||||||
|
resizable: false,
|
||||||
|
maximizable: false,
|
||||||
|
paddingVertical: 0,
|
||||||
|
paddingHorizontal: 0,
|
||||||
|
width: 250,
|
||||||
|
height: 100
|
||||||
|
});
|
||||||
|
updateMainData();
|
||||||
|
};
|
||||||
|
|
||||||
['pauseAll', 'resumeAll'].each(function(item) {
|
['pauseAll', 'resumeAll'].each(function(item) {
|
||||||
addClickEvent(item, function(e) {
|
addClickEvent(item, function(e) {
|
||||||
new Event(e).stop();
|
new Event(e).stop();
|
||||||
|
Loading…
Reference in New Issue
Block a user