[Execute] Tabs to spaces
This commit is contained in:
parent
21691c5cc1
commit
7c22135bb4
|
@ -33,106 +33,106 @@ Copyright:
|
||||||
Ext.ns('Deluge.ux');
|
Ext.ns('Deluge.ux');
|
||||||
Deluge.ux.ExecuteWindowBase = Ext.extend(Ext.Window, {
|
Deluge.ux.ExecuteWindowBase = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
width: 400,
|
width: 400,
|
||||||
height: 130,
|
height: 130,
|
||||||
closeAction: 'hide',
|
closeAction: 'hide',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.ux.ExecuteWindowBase.superclass.initComponent.call(this);
|
Deluge.ux.ExecuteWindowBase.superclass.initComponent.call(this);
|
||||||
this.addButton(_('Cancel'), this.onCancelClick, this);
|
this.addButton(_('Cancel'), this.onCancelClick, this);
|
||||||
|
|
||||||
this.form = this.add({
|
this.form = this.add({
|
||||||
xtype: 'form',
|
xtype: 'form',
|
||||||
baseCls: 'x-plain',
|
baseCls: 'x-plain',
|
||||||
bodyStyle: 'padding: 5px',
|
bodyStyle: 'padding: 5px',
|
||||||
items: [{
|
items: [{
|
||||||
xtype: 'combo',
|
xtype: 'combo',
|
||||||
width: 270,
|
width: 270,
|
||||||
fieldLabel: _('Event'),
|
fieldLabel: _('Event'),
|
||||||
store: new Ext.data.ArrayStore({
|
store: new Ext.data.ArrayStore({
|
||||||
fields: ['id', 'text'],
|
fields: ['id', 'text'],
|
||||||
data: [
|
data: [
|
||||||
['complete', _('Torrent Complete')],
|
['complete', _('Torrent Complete')],
|
||||||
['added', _('Torrent Added')]
|
['added', _('Torrent Added')]
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
name: 'event',
|
name: 'event',
|
||||||
mode: 'local',
|
mode: 'local',
|
||||||
editable: false,
|
editable: false,
|
||||||
triggerAction: 'all',
|
triggerAction: 'all',
|
||||||
valueField: 'id',
|
valueField: 'id',
|
||||||
displayField: 'text'
|
displayField: 'text'
|
||||||
}, {
|
}, {
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
fieldLabel: _('Command'),
|
fieldLabel: _('Command'),
|
||||||
name: 'command',
|
name: 'command',
|
||||||
width: 270
|
width: 270
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancelClick: function() {
|
onCancelClick: function() {
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Deluge.ux.EditExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, {
|
Deluge.ux.EditExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, {
|
||||||
|
|
||||||
title: _('Edit Command'),
|
title: _('Edit Command'),
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.ux.EditExecuteCommandWindow.superclass.initComponent.call(this);
|
Deluge.ux.EditExecuteCommandWindow.superclass.initComponent.call(this);
|
||||||
this.addButton(_('Save'), this.onSaveClick, this);
|
this.addButton(_('Save'), this.onSaveClick, this);
|
||||||
this.addEvents({
|
this.addEvents({
|
||||||
'commandedit': true
|
'commandedit': true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function(command) {
|
show: function(command) {
|
||||||
Deluge.ux.EditExecuteCommandWindow.superclass.show.call(this);
|
Deluge.ux.EditExecuteCommandWindow.superclass.show.call(this);
|
||||||
this.command = command;
|
this.command = command;
|
||||||
this.form.getForm().setValues({
|
this.form.getForm().setValues({
|
||||||
event: command.get('event'),
|
event: command.get('event'),
|
||||||
command: command.get('name')
|
command: command.get('name')
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onSaveClick: function() {
|
onSaveClick: function() {
|
||||||
var values = this.form.getForm().getFieldValues();
|
var values = this.form.getForm().getFieldValues();
|
||||||
deluge.client.execute.save_command(this.command.id, values.event, values.command, {
|
deluge.client.execute.save_command(this.command.id, values.event, values.command, {
|
||||||
success: function() {
|
success: function() {
|
||||||
this.fireEvent('commandedit', this, values.event, values.command);
|
this.fireEvent('commandedit', this, values.event, values.command);
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Deluge.ux.AddExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, {
|
Deluge.ux.AddExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, {
|
||||||
|
|
||||||
title: _('Add Command'),
|
title: _('Add Command'),
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.ux.AddExecuteCommandWindow.superclass.initComponent.call(this);
|
Deluge.ux.AddExecuteCommandWindow.superclass.initComponent.call(this);
|
||||||
this.addButton(_('Add'), this.onAddClick, this);
|
this.addButton(_('Add'), this.onAddClick, this);
|
||||||
this.addEvents({
|
this.addEvents({
|
||||||
'commandadd': true
|
'commandadd': true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onAddClick: function() {
|
onAddClick: function() {
|
||||||
var values = this.form.getForm().getFieldValues();
|
var values = this.form.getForm().getFieldValues();
|
||||||
deluge.client.execute.add_command(values.event, values.command, {
|
deluge.client.execute.add_command(values.event, values.command, {
|
||||||
success: function() {
|
success: function() {
|
||||||
this.fireEvent('commandadd', this, values.event, values.command);
|
this.fireEvent('commandadd', this, values.event, values.command);
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -144,144 +144,144 @@ Ext.ns('Deluge.ux.preferences');
|
||||||
*/
|
*/
|
||||||
Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
|
Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
|
||||||
|
|
||||||
title: _('Execute'),
|
title: _('Execute'),
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
border: false,
|
border: false,
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.ux.preferences.ExecutePage.superclass.initComponent.call(this);
|
Deluge.ux.preferences.ExecutePage.superclass.initComponent.call(this);
|
||||||
var event_map = this.event_map = {
|
var event_map = this.event_map = {
|
||||||
'complete': _('Torrent Complete'),
|
'complete': _('Torrent Complete'),
|
||||||
'added': _('Torrent Added')
|
'added': _('Torrent Added')
|
||||||
}
|
}
|
||||||
|
|
||||||
this.list = new Ext.list.ListView({
|
this.list = new Ext.list.ListView({
|
||||||
store: new Ext.data.SimpleStore({
|
store: new Ext.data.SimpleStore({
|
||||||
fields: [
|
fields: [
|
||||||
{name: 'event', mapping: 1},
|
{name: 'event', mapping: 1},
|
||||||
{name: 'name', mapping: 2}
|
{name: 'name', mapping: 2}
|
||||||
],
|
],
|
||||||
id: 0
|
id: 0
|
||||||
}),
|
}),
|
||||||
columns: [{
|
columns: [{
|
||||||
width: .3,
|
width: .3,
|
||||||
header: _('Event'),
|
header: _('Event'),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
dataIndex: 'event',
|
dataIndex: 'event',
|
||||||
tpl: new Ext.XTemplate('{[this.getEvent(values.event)]}', {
|
tpl: new Ext.XTemplate('{[this.getEvent(values.event)]}', {
|
||||||
getEvent: function(e) {
|
getEvent: function(e) {
|
||||||
return (event_map[e]) ? event_map[e] : e;
|
return (event_map[e]) ? event_map[e] : e;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, {
|
}, {
|
||||||
id: 'name',
|
id: 'name',
|
||||||
header: _('Command'),
|
header: _('Command'),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
dataIndex: 'name'
|
dataIndex: 'name'
|
||||||
}],
|
}],
|
||||||
singleSelect: true,
|
singleSelect: true,
|
||||||
autoExpandColumn: 'name'
|
autoExpandColumn: 'name'
|
||||||
});
|
});
|
||||||
this.list.on('selectionchange', this.onSelectionChange, this);
|
this.list.on('selectionchange', this.onSelectionChange, this);
|
||||||
|
|
||||||
this.panel = this.add({
|
this.panel = this.add({
|
||||||
items: [this.list],
|
items: [this.list],
|
||||||
bbar: {
|
bbar: {
|
||||||
items: [{
|
items: [{
|
||||||
text: _('Add'),
|
text: _('Add'),
|
||||||
iconCls: 'icon-add',
|
iconCls: 'icon-add',
|
||||||
handler: this.onAddClick,
|
handler: this.onAddClick,
|
||||||
scope: this
|
scope: this
|
||||||
}, {
|
}, {
|
||||||
text: _('Edit'),
|
text: _('Edit'),
|
||||||
iconCls: 'icon-edit',
|
iconCls: 'icon-edit',
|
||||||
handler: this.onEditClick,
|
handler: this.onEditClick,
|
||||||
scope: this,
|
scope: this,
|
||||||
disabled: true
|
disabled: true
|
||||||
}, '->', {
|
}, '->', {
|
||||||
text: _('Remove'),
|
text: _('Remove'),
|
||||||
iconCls: 'icon-remove',
|
iconCls: 'icon-remove',
|
||||||
handler: this.onRemoveClick,
|
handler: this.onRemoveClick,
|
||||||
scope: this,
|
scope: this,
|
||||||
disabled: true
|
disabled: true
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
deluge.preferences.on('show', this.onPreferencesShow, this);
|
deluge.preferences.on('show', this.onPreferencesShow, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateCommands: function() {
|
updateCommands: function() {
|
||||||
deluge.client.execute.get_commands({
|
deluge.client.execute.get_commands({
|
||||||
success: function(commands) {
|
success: function(commands) {
|
||||||
this.list.getStore().loadData(commands);
|
this.list.getStore().loadData(commands);
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onAddClick: function() {
|
onAddClick: function() {
|
||||||
if (!this.addWin) {
|
if (!this.addWin) {
|
||||||
this.addWin = new Deluge.ux.AddExecuteCommandWindow();
|
this.addWin = new Deluge.ux.AddExecuteCommandWindow();
|
||||||
this.addWin.on('commandadd', function() {
|
this.addWin.on('commandadd', function() {
|
||||||
this.updateCommands();
|
this.updateCommands();
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
this.addWin.show();
|
this.addWin.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
onCommandAdded: function(win, evt, cmd) {
|
onCommandAdded: function(win, evt, cmd) {
|
||||||
var record = new this.list.getStore().recordType({
|
var record = new this.list.getStore().recordType({
|
||||||
event: evt,
|
event: evt,
|
||||||
command: cmd
|
command: cmd
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onEditClick: function() {
|
onEditClick: function() {
|
||||||
if (!this.editWin) {
|
if (!this.editWin) {
|
||||||
this.editWin = new Deluge.ux.EditExecuteCommandWindow();
|
this.editWin = new Deluge.ux.EditExecuteCommandWindow();
|
||||||
this.editWin.on('commandedit', function() {
|
this.editWin.on('commandedit', function() {
|
||||||
this.updateCommands();
|
this.updateCommands();
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
this.editWin.show(this.list.getSelectedRecords()[0]);
|
this.editWin.show(this.list.getSelectedRecords()[0]);
|
||||||
},
|
},
|
||||||
|
|
||||||
onPreferencesShow: function() {
|
onPreferencesShow: function() {
|
||||||
this.updateCommands();
|
this.updateCommands();
|
||||||
},
|
},
|
||||||
|
|
||||||
onRemoveClick: function() {
|
onRemoveClick: function() {
|
||||||
var record = this.list.getSelectedRecords()[0];
|
var record = this.list.getSelectedRecords()[0];
|
||||||
deluge.client.execute.remove_command(record.id, {
|
deluge.client.execute.remove_command(record.id, {
|
||||||
success: function() {
|
success: function() {
|
||||||
this.updateCommands();
|
this.updateCommands();
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onSelectionChange: function(dv, selections) {
|
onSelectionChange: function(dv, selections) {
|
||||||
if (selections.length) {
|
if (selections.length) {
|
||||||
this.panel.getBottomToolbar().items.get(1).enable();
|
this.panel.getBottomToolbar().items.get(1).enable();
|
||||||
this.panel.getBottomToolbar().items.get(3).enable();
|
this.panel.getBottomToolbar().items.get(3).enable();
|
||||||
} else {
|
} else {
|
||||||
this.panel.getBottomToolbar().items.get(1).disable();
|
this.panel.getBottomToolbar().items.get(1).disable();
|
||||||
this.panel.getBottomToolbar().items.get(3).disable();
|
this.panel.getBottomToolbar().items.get(3).disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Deluge.plugins.ExecutePlugin = Ext.extend(Deluge.Plugin, {
|
Deluge.plugins.ExecutePlugin = Ext.extend(Deluge.Plugin, {
|
||||||
|
|
||||||
name: 'Execute',
|
name: 'Execute',
|
||||||
|
|
||||||
onDisable: function() {
|
onDisable: function() {
|
||||||
deluge.preferences.removePage(this.prefsPage);
|
deluge.preferences.removePage(this.prefsPage);
|
||||||
},
|
},
|
||||||
|
|
||||||
onEnable: function() {
|
onEnable: function() {
|
||||||
this.prefsPage = deluge.preferences.addPage(new Deluge.ux.preferences.ExecutePage());
|
this.prefsPage = deluge.preferences.addPage(new Deluge.ux.preferences.ExecutePage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Deluge.registerPlugin('Execute', Deluge.plugins.ExecutePlugin);
|
Deluge.registerPlugin('Execute', Deluge.plugins.ExecutePlugin);
|
||||||
|
|
Loading…
Reference in New Issue