implement getting and saving label options

This commit is contained in:
Damien Churchill 2010-05-02 18:15:06 +01:00
parent 82a5b5262c
commit c2b4fad389
1 changed files with 34 additions and 8 deletions

View File

@ -131,6 +131,7 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
style: 'margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-bottom: 0px; padding-bottom: 0px;',
items: [{ items: [{
xtype: 'checkbox', xtype: 'checkbox',
name: 'apply_max',
fieldLabel: '', fieldLabel: '',
boxLabel: _('Apply per torrent max settings:'), boxLabel: _('Apply per torrent max settings:'),
listeners: { listeners: {
@ -144,28 +145,28 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
style: 'margin-top: 0px; padding-top: 0px;', style: 'margin-top: 0px; padding-top: 0px;',
items: [{ items: [{
fieldLabel: _('Download Speed'), fieldLabel: _('Download Speed'),
name: 'down_speed', name: 'max_download_speed',
width: 80, width: 80,
disabled: true, disabled: true,
value: -1, value: -1,
minValue: -1 minValue: -1
}, { }, {
fieldLabel: _('Upload Speed'), fieldLabel: _('Upload Speed'),
name: 'up_speed', name: 'max_upload_speed',
width: 80, width: 80,
disabled: true, disabled: true,
value: -1, value: -1,
minValue: -1 minValue: -1
}, { }, {
fieldLabel: _('Upload Slots'), fieldLabel: _('Upload Slots'),
name: 'upload_slots', name: 'max_upload_slots',
width: 80, width: 80,
disabled: true, disabled: true,
value: -1, value: -1,
minValue: -1 minValue: -1
}, { }, {
fieldLabel: _('Connections'), fieldLabel: _('Connections'),
name: 'connections', name: 'max_connections',
width: 80, width: 80,
disabled: true, disabled: true,
value: -1, value: -1,
@ -184,6 +185,7 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
style: 'margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-bottom: 0px; padding-bottom: 0px;',
items: [{ items: [{
xtype: 'checkbox', xtype: 'checkbox',
name: 'apply_queue',
fieldLabel: '', fieldLabel: '',
boxLabel: _('Apply queue settings:'), boxLabel: _('Apply queue settings:'),
listeners: { listeners: {
@ -201,15 +203,23 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
}, },
items: [{ items: [{
boxLabel: _('Auto Managed'), boxLabel: _('Auto Managed'),
name: 'auto_managed', name: 'is_auto_managed',
disabled: true disabled: true
}, { }, {
boxLabel: _('Stop seed at ratio:'), boxLabel: _('Stop seed at ratio:'),
name: 'up_speed', name: 'stop_at_ratio',
disabled: true
}, {
xtype: 'spinnerfield',
name: 'stop_ratio',
width: 60,
decimalPrecision: 2,
incrementValue: 0.1,
style: 'position: relative; left: 100px',
disabled: true disabled: true
}, { }, {
boxLabel: _('Remove at ratio'), boxLabel: _('Remove at ratio'),
name: 'upload_slots', name: 'remove_at_ratio',
disabled: true disabled: true
}] }]
}] }]
@ -225,6 +235,7 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
style: 'margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-bottom: 0px; padding-bottom: 0px;',
items: [{ items: [{
xtype: 'checkbox', xtype: 'checkbox',
name: 'apply_move_completed',
fieldLabel: '', fieldLabel: '',
boxLabel: _('Apply location settings:'), boxLabel: _('Apply location settings:'),
listeners: { listeners: {
@ -264,6 +275,7 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
style: 'margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-bottom: 0px; padding-bottom: 0px;',
items: [{ items: [{
xtype: 'checkbox', xtype: 'checkbox',
name: 'auto_add',
fieldLabel: '', fieldLabel: '',
boxLabel: _('Automatically apply label:'), boxLabel: _('Automatically apply label:'),
listeners: { listeners: {
@ -281,7 +293,7 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
defaultType: 'textarea', defaultType: 'textarea',
items: [{ items: [{
boxLabel: _('Move completed to:'), boxLabel: _('Move completed to:'),
name: 'trackers', name: 'auto_add_trackers',
width: 250, width: 250,
height: 100, height: 100,
disabled: true disabled: true
@ -292,11 +304,23 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
}); });
}, },
getLabelOptions: function() {
deluge.client.label.get_options(this.label, {
success: this.gotOptions,
scope: this
});
},
gotOptions: function(options) {
this.form.getForm().setValues(options);
},
show: function(label) { show: function(label) {
Deluge.ux.LabelOptionsWindow.superclass.show.call(this); Deluge.ux.LabelOptionsWindow.superclass.show.call(this);
this.label = label; this.label = label;
this.setTitle(_('Label Options') + ': ' + this.label); this.setTitle(_('Label Options') + ': ' + this.label);
this.tabs.setActiveTab(0); this.tabs.setActiveTab(0);
this.getLabelOptions();
}, },
onCancelClick: function() { onCancelClick: function() {
@ -304,6 +328,8 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
}, },
onOkClick: function() { onOkClick: function() {
var values = this.form.getForm().getFieldValues();
deluge.client.label.set_options(this.label, values);
this.hide(); this.hide();
}, },