diff --git a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/common.py b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/common.py
index b47f85d0b..16b41e643 100644
--- a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/common.py
+++ b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/common.py
@@ -19,5 +19,6 @@ import os.path
from pkg_resources import resource_filename
-def get_resource(filename):
- return resource_filename('deluge.plugins.autoadd', os.path.join('data', filename))
+def get_resource(filename, subdir=False):
+ folder = os.path.join('data', 'autoadd_options') if subdir else 'data'
+ return resource_filename('deluge.plugins.autoadd', os.path.join(folder, filename))
diff --git a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py
index 0d87cfd22..d23f94aae 100644
--- a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py
+++ b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py
@@ -90,6 +90,7 @@ class Core(CorePluginBase):
self.config.save()
self.watchdirs = self.config['watchdirs']
+ self.rpcserver = component.get('RPCServer')
component.get('EventManager').register_event_handler(
'PreTorrentRemovedEvent', self.__on_pre_torrent_removed,
)
@@ -393,9 +394,8 @@ class Core(CorePluginBase):
@export
def get_watchdirs(self):
- rpcserver = component.get('RPCServer')
- session_user = rpcserver.get_session_user()
- session_auth_level = rpcserver.get_session_auth_level()
+ session_user = self.rpcserver.get_session_user()
+ session_auth_level = self.rpcserver.get_session_auth_level()
if session_auth_level == AUTH_LEVEL_ADMIN:
log.debug(
'Current logged in user %s is an ADMIN, send all '
@@ -496,3 +496,11 @@ class Core(CorePluginBase):
'Failed to removed torrent file "%s" from "%s": %s',
torrent_fname, copy_torrent_path, ex,
)
+
+ @export
+ def is_admin_level(self):
+ return self.rpcserver.get_session_auth_level() == deluge.common.AUTH_LEVEL_ADMIN
+
+ @export
+ def get_auth_user(self):
+ return self.rpcserver.get_session_user()
diff --git a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/data/autoadd.js b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/data/autoadd.js
index e7ee476b6..1bb73ebb4 100644
--- a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/data/autoadd.js
+++ b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/data/autoadd.js
@@ -9,6 +9,9 @@
* See LICENSE for more details.
*/
+Ext.ns('Deluge.ux.AutoAdd');
+Deluge.ux.AutoAdd.onClickFunctions = {};
+
Ext.ns('Deluge.ux.preferences');
/**
@@ -18,39 +21,180 @@ Ext.ns('Deluge.ux.preferences');
Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, {
title: _('AutoAdd'),
+ header: false,
layout: 'fit',
border: false,
+ watchdirs: {},
initComponent: function() {
Deluge.ux.preferences.AutoAddPage.superclass.initComponent.call(this);
- fieldset = this.add({
- xtype: 'fieldset',
- border: false,
- title: _('AutoAdd Preferences'),
- autoHeight: true,
- labelWidth: 1,
- defaultType: 'panel'
+
+ var autoAdd = this;
+
+ this.list = new Ext.list.ListView({
+ store: new Ext.data.JsonStore({
+ fields: [
+ 'id',
+ 'enabled',
+ 'owner',
+ 'path'
+ ]
+ }),
+ columns: [{
+ id: 'enabled',
+ header: _('Active'),
+ sortable: true,
+ dataIndex: 'enabled',
+ tpl: new Ext.XTemplate('{enabled:this.getCheckbox}', {
+ getCheckbox: function(checked, selected) {
+ Deluge.ux.AutoAdd.onClickFunctions[selected.id] = function () {
+ if (selected.enabled) {
+ deluge.client.autoadd.disable_watchdir(selected.id);
+ checked = false;
+ }
+ else {
+ deluge.client.autoadd.enable_watchdir(selected.id);
+ checked = true;
+ }
+ autoAdd.updateWatchDirs();
+ };
+ return ''
+ }
+ }),
+ width: .15
+ }, {
+ id: 'owner',
+ header: _('Owner'),
+ sortable: true,
+ dataIndex: 'owner',
+ width: .2
+ }, {
+ id: 'path',
+ header: _('Path'),
+ sortable: true,
+ dataIndex: 'path'
+ }],
+ singleSelect: true,
+ autoExpandColumn: 'path'
});
- fieldset.add({
- border: false,
- bodyCfg: {
- html: _('
The AutoAdd plugin is enabled however there is no WebUI ' +
- 'preferences page implemented yet for this plugin.
' +
- 'In the meantime please use GtkUI preference page to configure this plugin.
')
+ this.list.on('selectionchange', this.onSelectionChange, this);
+
+ this.panel = this.add({
+ items: [this.list],
+ bbar: {
+ items: [{
+ text: _('Add'),
+ iconCls: 'icon-add',
+ handler: this.onAddClick,
+ scope: this
+ }, {
+ text: _('Edit'),
+ iconCls: 'icon-edit',
+ handler: this.onEditClick,
+ scope: this,
+ disabled: true
+ }, '->', {
+ text: _('Remove'),
+ iconCls: 'icon-remove',
+ handler: this.onRemoveClick,
+ scope: this,
+ disabled: true
+ }]
}
});
+
+ this.on('show', this.onPreferencesShow, this);
+ },
+
+ updateWatchDirs: function() {
+ deluge.client.autoadd.get_watchdirs({
+ success: function(watchdirs) {
+ this.watchdirs = watchdirs;
+ var watchdirsArray = [];
+ for (var id in watchdirs) {
+ if (watchdirs.hasOwnProperty(id)) {
+ var watchdir = {};
+ watchdir['id'] = id;
+ watchdir['enabled'] = watchdirs[id].enabled;
+ watchdir['owner'] = watchdirs[id].owner || 'localclient';
+ watchdir['path'] = watchdirs[id].path;
+
+ watchdirsArray.push(watchdir);
+ }
+ }
+ this.list.getStore().loadData(watchdirsArray);
+ },
+ scope: this
+ });
+ },
+
+ onAddClick: function() {
+ if (!this.addWin) {
+ this.addWin = new Deluge.ux.AutoAdd.AddAutoAddCommandWindow();
+ this.addWin.on('watchdiradd', function() {
+ this.updateWatchDirs();
+ }, this);
+ }
+ this.addWin.show();
+ },
+
+ onEditClick: function() {
+ if (!this.editWin) {
+ this.editWin = new Deluge.ux.AutoAdd.EditAutoAddCommandWindow();
+ this.editWin.on('watchdiredit', function() {
+ this.updateWatchDirs();
+ }, this);
+ }
+ var id = this.list.getSelectedRecords()[0].id;
+ this.editWin.show(id, this.watchdirs[id]);
+ },
+
+ onPreferencesShow: function() {
+ this.updateWatchDirs();
+ },
+
+ onRemoveClick: function() {
+ var record = this.list.getSelectedRecords()[0];
+ deluge.client.autoadd.remove(record.id, {
+ success: function() {
+ this.updateWatchDirs();
+ },
+ scope: this
+ });
+ },
+
+ onSelectionChange: function(dv, selections) {
+ if (selections.length) {
+ this.panel.getBottomToolbar().items.get(1).enable();
+ this.panel.getBottomToolbar().items.get(3).enable();
+ } else {
+ this.panel.getBottomToolbar().items.get(1).disable();
+ this.panel.getBottomToolbar().items.get(3).disable();
+ }
}
});
Deluge.plugins.AutoAddPlugin = Ext.extend(Deluge.Plugin, {
name: 'AutoAdd',
+ static: {
+ prefsPage: null
+ },
+
onDisable: function() {
- deluge.preferences.removePage(this.prefsPage);
+ deluge.preferences.removePage(Deluge.plugins.AutoAddPlugin.prefsPage);
+ Deluge.plugins.AutoAddPlugin.prefsPage = null;
},
onEnable: function() {
- this.prefsPage = deluge.preferences.addPage(new Deluge.ux.preferences.AutoAddPage());
+ /*
+ * Called for each of the JavaScript files.
+ * This will prevent adding unnecessary tabs to the preferences window.
+ */
+ if (!Deluge.plugins.AutoAddPlugin.prefsPage) {
+ Deluge.plugins.AutoAddPlugin.prefsPage = deluge.preferences.addPage(new Deluge.ux.preferences.AutoAddPage());
+ }
}
});
diff --git a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/data/autoadd_options.js b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/data/autoadd_options.js
new file mode 100644
index 000000000..186e52b5b
--- /dev/null
+++ b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/data/autoadd_options.js
@@ -0,0 +1,398 @@
+/*!
+ * Script: autoadd.js
+ * The client-side javascript code for the AutoAdd plugin.
+ *
+ * Copyright (C) 2009 GazpachoKing
+ *
+ * This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
+ * the additional special exception to link portions of this program with the OpenSSL library.
+ * See LICENSE for more details.
+ */
+
+Ext.ns('Deluge.ux.AutoAdd');
+
+/**
+ * @class Deluge.ux.AutoAdd.AutoAddWindowBase
+ * @extends Ext.Window
+ */
+Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
+
+ width: 350,
+ autoHeight: true,
+ closeAction: 'hide',
+
+ spin_ids: ['max_download_speed', 'max_upload_speed', 'stop_ratio'],
+ spin_int_ids: ['max_upload_slots', 'max_connections'],
+ chk_ids: ['stop_at_ratio', 'remove_at_ratio', 'move_completed',
+ 'add_paused', 'auto_managed', 'queue_to_top'],
+ toggle_ids: ['append_extension_toggle', 'download_location_toggle',
+ 'label_toggle', 'copy_torrent_toggle',
+ 'delete_copy_torrent_toggle', 'seed_mode'],
+
+ accounts: new Ext.data.ArrayStore({
+ storeId: 'accountStore',
+ id: 0,
+ fields: [{
+ name: 'displayText',
+ type: 'string'
+ }]
+ }),
+ labels: new Ext.data.ArrayStore({
+ storeId: 'labelStore',
+ id: 0,
+ fields: [{
+ name: 'displayText',
+ type: 'string'
+ }]
+ }),
+
+ initComponent: function() {
+ Deluge.ux.AutoAdd.AutoAddWindowBase.superclass.initComponent.call(this);
+ this.addButton(_('Cancel'), this.onCancelClick, this);
+
+ this.MainTab = new Deluge.ux.AutoAdd.AutoAddMainPanel();
+ this.OptionsTab = new Deluge.ux.AutoAdd.AutoAddOptionsPanel();
+
+ this.form = this.add({
+ xtype: 'form',
+ baseCls: 'x-plain',
+ bodyStyle: 'padding: 5px',
+ items: [{
+ xtype: 'tabpanel',
+ activeTab: 0,
+ items: [
+ this.MainTab,
+ this.OptionsTab
+ ]
+ }]
+ });
+ },
+
+ onCancelClick: function() {
+ this.hide();
+ },
+
+ getOptions: function () {
+ var options = {};
+
+ options['enabled'] = Ext.getCmp('enabled').getValue();
+ options['path'] = Ext.getCmp('path').getValue();
+ options['download_location'] = Ext.getCmp('download_location').getValue();
+ options['move_completed_path'] = Ext.getCmp('move_completed_path').getValue();
+ options['copy_torrent'] = Ext.getCmp('copy_torrent').getValue();
+
+ options['label'] = Ext.getCmp('label').getValue();
+ options['append_extension'] = Ext.getCmp('append_extension').getValue();
+ options['owner'] = Ext.getCmp('owner').getValue();
+
+ this.toggle_ids.forEach(function(toggle_id) {
+ options[toggle_id] = Ext.getCmp(toggle_id).getValue();
+ });
+ this.spin_ids.forEach(function(spin_id) {
+ options[spin_id] = Ext.getCmp(spin_id).getValue();
+ options[spin_id + '_toggle'] = Ext.getCmp(spin_id + '_toggle').getValue();
+ });
+ this.spin_int_ids.forEach(function(spin_int_id) {
+ options[spin_int_id] = Ext.getCmp(spin_int_id).getValue();
+ options[spin_int_id + '_toggle'] = Ext.getCmp(spin_int_id + '_toggle').getValue();
+ });
+ this.chk_ids.forEach(function(chk_id) {
+ options[chk_id] = Ext.getCmp(chk_id).getValue();
+ options[chk_id + '_toggle'] = Ext.getCmp(chk_id + '_toggle').getValue();
+ });
+
+ if (options['copy_torrent_toggle'] && options['path'] === options['copy_torrent']) {
+ throw _('"Watch Folder" directory and "Copy of .torrent' +
+ ' files to" directory cannot be the same!');
+ }
+
+ return options;
+ },
+
+ loadOptions: function (options) {
+ /*
+ * Populate all available options data to the UI
+ */
+ var value;
+
+ if (options === undefined) {
+ options = {};
+ }
+ Ext.getCmp('enabled').setValue(
+ options['enabled'] !== undefined ? options['enabled'] : true
+ );
+ Ext.getCmp('isnt_append_extension').setValue(true);
+ Ext.getCmp('append_extension_toggle').setValue(
+ options['append_extension_toggle'] !== undefined ? options['append_extension_toggle'] : false
+ );
+ Ext.getCmp('append_extension').setValue(
+ options['append_extension'] !== undefined ? options['append_extension'] : '.added'
+ );
+ Ext.getCmp('download_location_toggle').setValue(
+ options['download_location_toggle'] !== undefined ? options['download_location_toggle'] : false
+ );
+ Ext.getCmp('copy_torrent_toggle').setValue(
+ options['copy_torrent_toggle'] !== undefined ? options['copy_torrent_toggle'] : false
+ );
+ Ext.getCmp('delete_copy_torrent_toggle').setValue(
+ options['delete_copy_torrent_toggle'] !== undefined ? options['delete_copy_torrent_toggle'] : false
+ );
+
+ value = options['seed_mode'] !== undefined ? options['seed_mode'] : false;
+ Ext.getCmp('seed_mode').setValue(value);
+
+ this.accounts.removeAll(true);
+ this.labels.removeAll(true);
+ Ext.getCmp('owner').store = this.accounts;
+ Ext.getCmp('label').store = this.labels;
+ Ext.getCmp('label').setValue(
+ options['label'] !== undefined ? options['label'] : ''
+ );
+ Ext.getCmp('label_toggle').setValue(
+ options['label_toggle'] !== undefined ? options['label_toggle'] : false
+ );
+
+ this.spin_ids.forEach(function(spin_id) {
+ Ext.getCmp(spin_id).setValue(
+ options[spin_id] !== undefined ? options[spin_id] : 0
+ );
+ Ext.getCmp(spin_id + '_toggle').setValue(
+ options[spin_id + '_toggle'] !== undefined ? options[spin_id + '_toggle'] : false
+ );
+ });
+ this.chk_ids.forEach(function(chk_id) {
+ Ext.getCmp(chk_id).setValue(
+ options[chk_id] !== undefined ? options[chk_id] : true
+ );
+ Ext.getCmp(chk_id + '_toggle').setValue(
+ options[chk_id + '_toggle'] !== undefined ? options[chk_id + '_toggle'] : false
+ );
+ });
+ value = options['add_paused'] !== undefined ? options['add_paused'] : true;
+ if (!value) {
+ Ext.getCmp('not_add_paused').setValue(true);
+ }
+ value = options['queue_to_top'] !== undefined ? options['queue_to_top'] : true;
+ if (!value) {
+ Ext.getCmp('not_queue_to_top').setValue(true);
+ }
+ value = options['auto_managed'] !== undefined ? options['auto_managed'] : true;
+ if (!value) {
+ Ext.getCmp('not_auto_managed').setValue(true)
+ }
+ ['move_completed_path', 'path', 'download_location',
+ 'copy_torrent'].forEach(function(field) {
+ value = options[field] !== undefined ? options[field] : '';
+ Ext.getCmp(field).setValue(value);
+ });
+
+ if (Object.keys(options).length === 0) {
+ deluge.client.core.get_config({
+ success: function(config) {
+ var value;
+ Ext.getCmp('download_location').setValue(
+ options['download_location'] !== undefined ?
+ options['download_location'] :
+ config['download_location']
+ );
+ value = options['move_completed_toggle'] !== undefined ?
+ options['move_completed_toggle'] :
+ config['move_completed'];
+ if (value) {
+ Ext.getCmp('move_completed_toggle').setValue(
+ options['move_completed_toggle'] !== undefined ?
+ options['move_completed_toggle'] :
+ false
+ );
+ Ext.getCmp('move_completed_path').setValue(
+ options['move_completed_path'] !== undefined ?
+ options['move_completed_path'] :
+ config['move_completed_path']
+ );
+ }
+ value = options['copy_torrent_toggle'] !== undefined ?
+ options['copy_torrent_toggle'] :
+ config['copy_torrent_file'];
+ if (value) {
+ Ext.getCmp('copy_torrent_toggle').setValue(true);
+ Ext.getCmp('copy_torrent').setValue(
+ options['copy_torrent'] !== undefined ?
+ options['copy_torrent'] :
+ config['torrentfiles_location']
+ );
+ }
+ value = options['delete_copy_torrent_toggle'] !== undefined ?
+ options['copy_torrent_toggle'] :
+ config['del_copy_torrent_file'];
+ if (value) {
+ Ext.getCmp('delete_copy_torrent_toggle').setValue(true)
+ }
+ }
+ })
+ }
+
+ deluge.client.core.get_enabled_plugins({
+ success: function (plugins) {
+ if (plugins !== undefined && plugins.indexOf('Label') > -1) {
+ this.MainTab.LabelFset.setVisible(true);
+ deluge.client.label.get_labels({
+ success: function(labels) {
+ for (var index = 0; index < labels.length; index++) {
+ labels[index] = [labels[index]];
+ }
+ this.labels.loadData(labels, false);
+ },
+ failure: function(failure) {
+ console.error(failure);
+ },
+ scope: this
+ });
+ }
+ else {
+ this.MainTab.LabelFset.setVisible(false);
+ }
+ },
+ scope: this
+ });
+
+ var me = this;
+
+ function on_accounts(accounts, owner) {
+ for (var index = 0; index < accounts.length; index++) {
+ accounts[index] = [accounts[index]['username']];
+ }
+ me.accounts.loadData(accounts, false);
+ Ext.getCmp('owner').setValue(owner).enable();
+ }
+
+ function on_accounts_failure(failure){
+ deluge.client.autoadd.get_auth_user({
+ success: function (user) {
+ me.accounts.loadData([[user]], false);
+ Ext.getCmp('owner').setValue(user).disable(true);
+ },
+ scope: this
+ });
+ }
+
+ deluge.client.autoadd.is_admin_level({
+ success: function (is_admin) {
+ if (is_admin) {
+ deluge.client.core.get_known_accounts({
+ success: function (accounts) {
+ deluge.client.autoadd.get_auth_user({
+ success: function(user) {
+ on_accounts(accounts,
+ options['owner'] !== undefined ? options['owner'] : user
+ );
+ },
+ scope: this
+ });
+ },
+ failure: on_accounts_failure,
+ scope: this
+ })
+ }
+ else {
+ on_accounts_failure(null);
+ }
+ },
+ scope: this
+ });
+ }
+});
+
+/**
+ * @class Deluge.ux.AutoAdd.EditAutoAddCommandWindow
+ * @extends Deluge.ux.AutoAdd.AutoAddWindowBase
+ */
+Deluge.ux.AutoAdd.EditAutoAddCommandWindow = Ext.extend(Deluge.ux.AutoAdd.AutoAddWindowBase, {
+
+ title: _('Edit Watch Folder'),
+
+ initComponent: function() {
+ Deluge.ux.AutoAdd.EditAutoAddCommandWindow.superclass.initComponent.call(this);
+ this.addButton(_('Save'), this.onSaveClick, this);
+ this.addEvents({
+ 'watchdiredit': true
+ });
+ },
+
+ show: function(watchdir_id, options) {
+ Deluge.ux.AutoAdd.EditAutoAddCommandWindow.superclass.show.call(this);
+ this.watchdir_id = watchdir_id;
+ this.loadOptions(options);
+ },
+
+ onSaveClick: function() {
+ try {
+ var options = this.getOptions();
+ deluge.client.autoadd.set_options(this.watchdir_id, options, {
+ success: function() {
+ this.fireEvent('watchdiredit', this, options);
+ },
+ scope: this
+ });
+ }
+ catch(err) {
+ Ext.Msg.show({
+ title: _('Incompatible Option'),
+ msg: err,
+ buttons: Ext.Msg.OK,
+ scope: this
+ });
+ }
+
+ this.hide();
+ }
+
+});
+
+/**
+ * @class Deluge.ux.AutoAdd.AddAutoAddCommandWindow
+ * @extends Deluge.ux.AutoAdd.AutoAddWindowBase
+ */
+Deluge.ux.AutoAdd.AddAutoAddCommandWindow = Ext.extend(Deluge.ux.AutoAdd.AutoAddWindowBase, {
+
+ title: _('Add Watch Folder'),
+
+ initComponent: function() {
+ Deluge.ux.AutoAdd.AddAutoAddCommandWindow.superclass.initComponent.call(this);
+ this.addButton(_('Add'), this.onAddClick, this);
+ this.addEvents({
+ 'watchdiradd': true
+ });
+ },
+
+ show: function() {
+ Deluge.ux.AutoAdd.AddAutoAddCommandWindow.superclass.show.call(this);
+ this.loadOptions();
+ },
+
+ onAddClick: function() {
+ var options = this.getOptions();
+ deluge.client.autoadd.add(options, {
+ success: function() {
+ this.fireEvent('watchdiradd', this, options);
+ this.hide();
+ },
+ failure: function(err) {
+ const regex = /: (.*\n)\n?\]/m;
+ var error;
+ if ((error = regex.exec(err.error.message)) !== null) {
+ error = error[1];
+ }
+ else {
+ error = err.error.message;
+ }
+ Ext.Msg.show({
+ title: _('Incompatible Option'),
+ msg: error,
+ buttons: Ext.Msg.OK,
+ scope: this
+ });
+ },
+ scope: this
+ });
+ }
+});
diff --git a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/data/autoadd_options/main_tab.js b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/data/autoadd_options/main_tab.js
new file mode 100644
index 000000000..113b4ef23
--- /dev/null
+++ b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/data/autoadd_options/main_tab.js
@@ -0,0 +1,243 @@
+/*!
+ * Script: main_tab.js
+ * The client-side javascript code for the AutoAdd plugin.
+ *
+ * Copyright (C) 2009 GazpachoKing
+ *
+ * This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
+ * the additional special exception to link portions of this program with the OpenSSL library.
+ * See LICENSE for more details.
+ */
+
+Ext.ns('Deluge.ux.AutoAdd');
+
+/**
+ * @class Deluge.ux.AutoAdd.AutoAddMainPanel
+ * @extends Ext.Panel
+ */
+Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, {
+ id: 'main_tab_panel',
+ title: _('Main'),
+
+ initComponent: function() {
+ Deluge.ux.AutoAdd.AutoAddMainPanel.superclass.initComponent.call(this);
+ this.watchFolderFset = new Ext.form.FieldSet({
+ xtype: 'fieldset',
+ border: false,
+ title: _('Watch Folder'),
+ defaultType: 'textfield',
+ style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
+ width: '85%',
+ labelWidth: 1,
+ items: [{
+ xtype: 'textfield',
+ id: 'path',
+ hideLabel: true,
+ width: 304
+ }, {
+ hideLabel: true,
+ id: 'enabled',
+ xtype: 'checkbox',
+ boxLabel: _('Enable this watch folder'),
+ checked: true
+ }]
+ });
+
+ this.torrentActionFset = new Ext.form.FieldSet({
+ xtype: 'fieldset',
+ border: false,
+ title: _('Torrent File Action'),
+ style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
+ width: '85%',
+ labelWidth: 1,
+ defaults: {
+ style: 'margin-bottom: 2px'
+ },
+ items: [{
+ xtype: 'radiogroup',
+ columns: 1,
+ items: [{
+ xtype: 'radio',
+ name: 'torrent_action',
+ id: 'isnt_append_extension',
+ boxLabel: _('Delete .torrent after adding'),
+ checked: true,
+ hideLabel: true,
+ listeners: {
+ check: function (cb, newValue) {
+ if (newValue) {
+ Ext.getCmp('append_extension').setDisabled(newValue);
+ Ext.getCmp('copy_torrent').setDisabled(newValue);
+ Ext.getCmp('delete_copy_torrent_toggle').setDisabled(newValue);
+ }
+ }
+ }
+ }, {
+ xtype: 'container',
+ layout: 'hbox',
+ hideLabel: true,
+ items: [{
+ xtype: 'radio',
+ name: 'torrent_action',
+ id: 'append_extension_toggle',
+ boxLabel: _('Append extension after adding:'),
+ hideLabel: true,
+ listeners: {
+ check: function (cb, newValue) {
+ if (newValue) {
+ Ext.getCmp('append_extension').setDisabled(!newValue);
+ Ext.getCmp('copy_torrent').setDisabled(newValue);
+ Ext.getCmp('delete_copy_torrent_toggle').setDisabled(newValue);
+ }
+ }
+ }
+ }, {
+ xtype: 'textfield',
+ id: 'append_extension',
+ hideLabel: true,
+ disabled: true,
+ style: 'margin-left: 2px',
+ width: 112
+ }]
+ }, {
+ xtype: 'container',
+ hideLabel: true,
+ items: [{
+ xtype: 'container',
+ layout: 'hbox',
+ hideLabel: true,
+ items: [{
+ xtype: 'radio',
+ name: 'torrent_action',
+ id: 'copy_torrent_toggle',
+ boxLabel: _('Copy of .torrent files to:'),
+ hideLabel: true,
+ listeners: {
+ check: function (cb, newValue) {
+ if (newValue) {
+ Ext.getCmp('append_extension').setDisabled(newValue);
+ Ext.getCmp('copy_torrent').setDisabled(!newValue);
+ Ext.getCmp('delete_copy_torrent_toggle').setDisabled(!newValue);
+ }
+ }
+ }
+ }, {
+ xtype: 'textfield',
+ id: 'copy_torrent',
+ hideLabel: true,
+ disabled: true,
+ style: 'margin-left: 2px',
+ width: 152
+ }]
+ }, {
+ xtype: 'checkbox',
+ id: 'delete_copy_torrent_toggle',
+ boxLabel: _('Delete copy of torrent file on remove'),
+ style: 'margin-left: 10px',
+ disabled: true
+ }]
+ }]
+ }]
+ });
+
+ this.downloadFolderFset = new Ext.form.FieldSet({
+ xtype: 'fieldset',
+ border: false,
+ title: _('Download Folder'),
+ defaultType: 'textfield',
+ style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
+ width: '85%',
+ labelWidth: 1,
+ items: [{
+ hideLabel: true,
+ id: 'download_location_toggle',
+ xtype: 'checkbox',
+ boxLabel: _('Set download folder'),
+ listeners: {
+ check: function (cb, checked) {
+ Ext.getCmp('download_location').setDisabled(!checked);
+ }
+ }
+ }, {
+ xtype: 'textfield',
+ id: 'download_location',
+ hideLabel: true,
+ width: 304,
+ disabled: true
+ }]
+ });
+
+ this.moveCompletedFset = new Ext.form.FieldSet({
+ xtype: 'fieldset',
+ border: false,
+ title: _('Move Completed'),
+ defaultType: 'textfield',
+ style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
+ width: '85%',
+ labelWidth: 1,
+ items: [{
+ hideLabel: true,
+ id: 'move_completed_toggle',
+ xtype: 'checkbox',
+ boxLabel: _('Set move completed folder'),
+ listeners: {
+ check: function (cb, checked) {
+ Ext.getCmp('move_completed_path').setDisabled(!checked);
+ }
+ }
+ }, {
+ xtype: 'textfield',
+ id: 'move_completed_path',
+ hideLabel: true,
+ width: 304,
+ disabled: true
+ }]
+ });
+
+ this.LabelFset = new Ext.form.FieldSet({
+ xtype: 'fieldset',
+ border: false,
+ title: _('Label'),
+ defaultType: 'textfield',
+ style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 3px;',
+ //width: '85%',
+ labelWidth: 1,
+ //hidden: true,
+ items: [{
+ xtype: 'container',
+ layout: 'hbox',
+ hideLabel: true,
+ items: [{
+ hashLabel: false,
+ id: 'label_toggle',
+ xtype: 'checkbox',
+ boxLabel: _('Label:'),
+ listeners: {
+ check: function (cb, checked) {
+ Ext.getCmp('label').setDisabled(!checked);
+ }
+ }
+ }, {
+ xtype: 'combo',
+ id: 'label',
+ hideLabel: true,
+ //width: 220,
+ width: 254,
+ disabled: true,
+ style: 'margin-left: 2px',
+ mode: 'local',
+ valueField: 'displayText',
+ displayField: 'displayText'
+ }]
+ }]
+ });
+
+ this.add([
+ this.watchFolderFset,
+ this.torrentActionFset,
+ this.downloadFolderFset,
+ this.moveCompletedFset,
+ this.LabelFset
+ ])
+ }
+});
diff --git a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/data/autoadd_options/options_tab.js b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/data/autoadd_options/options_tab.js
new file mode 100644
index 000000000..674f0a410
--- /dev/null
+++ b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/data/autoadd_options/options_tab.js
@@ -0,0 +1,276 @@
+/*!
+ * Script: options_tab.js
+ * The client-side javascript code for the AutoAdd plugin.
+ *
+ * Copyright (C) 2009 GazpachoKing
+ *
+ * This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
+ * the additional special exception to link portions of this program with the OpenSSL library.
+ * See LICENSE for more details.
+ */
+
+Ext.ns('Deluge.ux.AutoAdd');
+
+/**
+ * @class Deluge.ux.AutoAdd.AutoAddOptionsPanel
+ * @extends Ext.Panel
+ */
+Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
+ id: 'options_tab_panel',
+ title: _('Options'),
+
+ initComponent: function() {
+ Deluge.ux.AutoAdd.AutoAddOptionsPanel.superclass.initComponent.call(this);
+ var maxDownload = {
+ idCheckbox: 'max_download_speed_toggle',
+ labelCheckbox: 'Max Download Speed (KiB/s):',
+ idSpinner: 'max_download_speed',
+ decimalPrecision: 1
+ };
+ var maxUploadSpeed = {
+ idCheckbox: 'max_upload_speed_toggle',
+ labelCheckbox: 'Max upload Speed (KiB/s):',
+ idSpinner: 'max_upload_speed',
+ decimalPrecision: 1
+ };
+ var maxConnections = {
+ idCheckbox: 'max_connections_toggle',
+ labelCheckbox: 'Max Connections::',
+ idSpinner: 'max_connections',
+ decimalPrecision: 0
+ };
+ var maxUploadSlots = {
+ idCheckbox: 'max_upload_slots_toggle',
+ labelCheckbox: 'Max Upload Slots:',
+ idSpinner: 'max_upload_slots',
+ decimalPrecision: 0
+ };
+ // queue data
+ var addPause = {
+ idCheckbox: 'add_paused_toggle',
+ labelCheckbox: 'Add Pause:',
+ nameRadio: 'add_paused',
+ labelRadio: {
+ yes: 'Yes',
+ no: 'No'
+ }
+ };
+ var queueTo = {
+ idCheckbox: 'queue_to_top_toggle',
+ labelCheckbox: 'Queue To:',
+ nameRadio: 'queue_to_top',
+ labelRadio: {
+ yes: 'Top',
+ no: 'Bottom'
+ }
+ };
+ var autoManaged = {
+ idCheckbox: 'auto_managed_toggle',
+ labelCheckbox: 'Auto Managed:',
+ nameRadio: 'auto_managed',
+ labelRadio: {
+ yes: 'Yes',
+ no: 'No'
+ }
+ };
+
+ this.ownerFset = new Ext.form.FieldSet({
+ xtype: 'fieldset',
+ border: false,
+ title: _('Owner'),
+ style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
+ //width: '85%',
+ labelWidth: 1,
+ items: [{
+ xtype: 'combo',
+ id: 'owner',
+ hideLabel: true,
+ width: 312,
+ mode: 'local',
+ valueField: 'displayText',
+ displayField: 'displayText'
+ }]
+ });
+
+ this.bandwidthFset = new Ext.form.FieldSet({
+ xtype: 'fieldset',
+ border: false,
+ title: _('Bandwidth'),
+ style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
+ //width: '85%',
+ labelWidth: 1,
+ defaults: {
+ style: 'margin-bottom: 5px'
+ }
+ });
+ this.bandwidthFset.add(this._getBandwidthContainer(maxDownload));
+ this.bandwidthFset.add(this._getBandwidthContainer(maxUploadSpeed));
+ this.bandwidthFset.add(this._getBandwidthContainer(maxConnections));
+ this.bandwidthFset.add(this._getBandwidthContainer(maxUploadSlots));
+
+ this.queueFset = new Ext.form.FieldSet({
+ xtype: 'fieldset',
+ border: false,
+ title: _('Queue'),
+ style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
+ //width: '85%',
+ labelWidth: 1,
+ defaults: {
+ style: 'margin-bottom: 5px'
+ },
+ items: [{
+ xtype: 'container',
+ layout: 'hbox',
+ hideLabel: true
+ }]
+ });
+ this.queueFset.add(this._getQueueContainer(addPause));
+ this.queueFset.add(this._getQueueContainer(queueTo));
+ this.queueFset.add(this._getQueueContainer(autoManaged));
+ this.queueFset.add({
+ xtype: 'container',
+ hideLabel: true,
+ items: [{
+ xtype: 'container',
+ layout: 'hbox',
+ hideLabel: true,
+ items: [{
+ xtype: 'checkbox',
+ id: 'stop_at_ratio_toggle',
+ boxLabel: _('Stop seed at ratio:'),
+ hideLabel: true,
+ width: 175,
+ listeners: {
+ check: function(cb, checked) {
+ Ext.getCmp('stop_ratio').setDisabled(!checked);
+ Ext.getCmp('remove_at_ratio').setDisabled(!checked);
+ }
+ }
+ }, {
+ xtype: 'spinnerfield',
+ id: 'stop_ratio',
+ hideLabel: true,
+ disabled: true,
+ value: 0.0,
+ minValue: 0.0,
+ maxValue: 100.0,
+ decimalPrecision: 1,
+ incrementValue: 0.1,
+ style: 'margin-left: 2px',
+ width: 100
+ }]
+ }, {
+ xtype: 'container',
+ layout: 'hbox',
+ hideLabel: true,
+ style: 'margin-left: 10px',
+ items: [{
+ xtype: 'checkbox',
+ id: 'remove_at_ratio',
+ boxLabel: _('Remove at ratio'),
+ disabled: true,
+ checked: true
+ }, {
+ xtype: 'checkbox',
+ id: 'remove_at_ratio_toggle',
+ disabled: true,
+ checked: true,
+ hidden: true
+ }, {
+ xtype: 'checkbox',
+ id: 'stop_ratio_toggle',
+ disabled: true,
+ checked: true,
+ hidden: true
+ }, {
+ xtype: 'checkbox',
+ id: 'stop_ratio_toggle',
+ disabled: true,
+ checked: true,
+ hidden: true
+ }]
+ }]
+ });
+ this.queueFset.add({
+ xtype: 'checkbox',
+ id: 'seed_mode',
+ boxLabel: _('Skip File Hash Check'),
+ hideLabel: true,
+ width: 175
+ });
+
+ this.add([
+ this.ownerFset,
+ this.bandwidthFset,
+ this.queueFset
+ ]);
+ },
+
+ _getBandwidthContainer: function(values) {
+ return new Ext.Container({
+ xtype: 'container',
+ layout: 'hbox',
+ hideLabel: true,
+ items: [{
+ xtype: 'checkbox',
+ hideLabel: true,
+ id: values.idCheckbox,
+ boxLabel: _(values.labelCheckbox),
+ width: 175,
+ listeners: {
+ check: function(cb, checked) {
+ Ext.getCmp(values.idSpinner).setDisabled(!checked);
+ }
+ }
+ }, {
+ xtype: 'spinnerfield',
+ id: values.idSpinner,
+ hideLabel: true,
+ disabled: true,
+ minValue: -1,
+ maxValue: 10000,
+ value: 0.0,
+ decimalPrecision: values.decimalPrecision,
+ style: 'margin-left: 2px',
+ width: 100
+ }]
+ });
+ },
+
+ _getQueueContainer: function (values) {
+ return new Ext.Container({
+ xtype: 'container',
+ layout: 'hbox',
+ hideLabel: true,
+ items: [{
+ xtype: 'checkbox',
+ hideLabel: true,
+ id: values.idCheckbox,
+ boxLabel: _(values.labelCheckbox),
+ width: 175,
+ listeners: {
+ check: function(cb, checked) {
+ Ext.getCmp(values.nameRadio).setDisabled(!checked);
+ Ext.getCmp('not_' + values.nameRadio).setDisabled(!checked);
+ }
+ }
+ }, {
+ xtype: 'radio',
+ name: values.nameRadio,
+ id: values.nameRadio,
+ boxLabel: _(values.labelRadio.yes),
+ hideLabel: true,
+ checked: true,
+ disabled: true,
+ width: 50
+ }, {
+ xtype: 'radio',
+ name: values.nameRadio,
+ id: 'not_' + values.nameRadio,
+ boxLabel: _(values.labelRadio.no),
+ hideLabel: true,
+ disabled: true
+ }]
+ });
+ }
+});
diff --git a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/webui.py b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/webui.py
index 47a37d7a3..ed4a71655 100644
--- a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/webui.py
+++ b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/webui.py
@@ -24,8 +24,12 @@ log = logging.getLogger(__name__)
class WebUI(WebPluginBase):
-
- scripts = [get_resource('autoadd.js')]
+ scripts = [
+ get_resource('autoadd.js'),
+ get_resource('autoadd_options.js'),
+ get_resource('main_tab.js', True),
+ get_resource('options_tab.js', True)
+ ]
def enable(self):
pass