[WebUI] Modify UI to display single incoming port

This commit is contained in:
Calum Lind 2016-10-20 15:02:27 +01:00
commit 72c588ad33
2 changed files with 23 additions and 34 deletions

View file

@ -53,7 +53,7 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
var fieldset = this.add({ var fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
title: _('Incoming Ports'), title: _('Incoming Port'),
style: 'margin-bottom: 5px; padding-bottom: 0px;', style: 'margin-bottom: 5px; padding-bottom: 0px;',
autoHeight: true, autoHeight: true,
labelWidth: 1, labelWidth: 1,
@ -62,48 +62,33 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
optMan.bind('random_port', fieldset.add({ optMan.bind('random_port', fieldset.add({
fieldLabel: '', fieldLabel: '',
labelSeparator: '', labelSeparator: '',
boxLabel: _('Use Random Ports'), boxLabel: _('Use Random Port'),
name: 'random_port', name: 'random_port',
height: 22, height: 22,
listeners: { listeners: {
'check': { 'check': {
fn: function(e, checked) { fn: function(e, checked) {
this.listenPorts.setDisabled(checked); this.listenPort.setDisabled(checked);
}, },
scope: this scope: this
} }
} }
})); }));
this.listenPorts = fieldset.add({
xtype: 'spinnergroup', this.listenPort = fieldset.add({
name: 'listen_ports', xtype: 'spinnerfield',
name: 'listen_port',
fieldLabel: '', fieldLabel: '',
labelSeparator: '', labelSeparator: '',
colCfg: { width: 75,
labelWidth: 40, strategy: {
style: 'margin-right: 10px;' xtype: 'number',
}, decimalPrecision: 0,
items: [{ minValue: 0,
fieldLabel: _('From:'), maxValue: 65535
labelSeparator: '', }
strategy: {
xtype: 'number',
decimalPrecision: 0,
minValue: -1,
maxValue: 99999
}
}, {
fieldLabel: _('To:'),
labelSeparator: '',
strategy: {
xtype: 'number',
decimalPrecision: 0,
minValue: -1,
maxValue: 99999
}
}]
}); });
optMan.bind('listen_ports', this.listenPorts); optMan.bind('listen_ports', this.listenPort);
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -144,8 +129,8 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
strategy: { strategy: {
xtype: 'number', xtype: 'number',
decimalPrecision: 0, decimalPrecision: 0,
minValue: -1, minValue: 0,
maxValue: 99999 maxValue: 65535
} }
}, { }, {
fieldLabel: _('To:'), fieldLabel: _('To:'),
@ -153,8 +138,8 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
strategy: { strategy: {
xtype: 'number', xtype: 'number',
decimalPrecision: 0, decimalPrecision: 0,
minValue: -1, minValue: 0,
maxValue: 99999 maxValue: 65535
} }
}] }]
}); });

View file

@ -108,6 +108,10 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
onApply: function(e) { onApply: function(e) {
var changed = this.optionsManager.getDirty(); var changed = this.optionsManager.getDirty();
if (!Ext.isObjectEmpty(changed)) { if (!Ext.isObjectEmpty(changed)) {
// Workaround for only displaying single listen port but still pass array to core.
if ('listen_ports' in changed) {
changed.listen_ports = [changed.listen_ports, changed.listen_ports]
}
deluge.client.core.set_config(changed, { deluge.client.core.set_config(changed, {
success: this.onSetConfig, success: this.onSetConfig,
scope: this scope: this