mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
networks: Use radio buttons for network modes
Closes: #1974 BTW: Javascript IPV4/6 hide/show arrangements triggered on page load. Otherwise page loads form fields inconsistently. Signed-off-by: Fioddor Superconcentrado <fioddor@gmail.com> [sunil: Fix the use of RadioSelect widget] [sunil: Alter the wording of what each type means] [sunil: Drop the help text for radio group as it is mostly repetitive] [sunil: js: Make the entire jQuery code run on document ready] [sunil: js: Revert unneeded double call to change methods, change() is enough] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
99935a9696
commit
6e747f281e
@ -37,15 +37,20 @@ class ConnectionForm(forms.Form):
|
|||||||
'available over this interfaces. Select Internal only '
|
'available over this interfaces. Select Internal only '
|
||||||
'for trusted networks.'), choices=network.ZONES)
|
'for trusted networks.'), choices=network.ZONES)
|
||||||
ipv4_method = forms.ChoiceField(
|
ipv4_method = forms.ChoiceField(
|
||||||
label=_('IPv4 Addressing Method'), help_text=format_lazy(
|
label=_('IPv4 Addressing Method'), widget=forms.RadioSelect, choices=[
|
||||||
_('"Automatic" method will make {box_name} acquire '
|
('auto',
|
||||||
'configuration from this network making it a client. "Shared" '
|
_('Automatic (DHCP): Configure automatically, use Internet '
|
||||||
'method will make {box_name} act as a router, configure '
|
'connection from this network')),
|
||||||
'clients on this network and share its Internet connection.'),
|
('shared',
|
||||||
box_name=_(cfg.box_name)),
|
_('Shared: Act as a router, provide Internet connection to other '
|
||||||
choices=[('auto', _('Automatic (DHCP)')), ('shared', _('Shared')),
|
'devices on this network')),
|
||||||
('manual', pgettext_lazy('Not automatically', 'Manual')),
|
('manual',
|
||||||
('disabled', _('Disabled'))])
|
_('Manual: Use manually specified parameters, use Internet '
|
||||||
|
'connection from this network')),
|
||||||
|
('disabled',
|
||||||
|
_('Disabled: Do not configure this addressing method')),
|
||||||
|
], initial='auto')
|
||||||
|
|
||||||
ipv4_address = forms.CharField(
|
ipv4_address = forms.CharField(
|
||||||
label=_('Address'), validators=[validators.validate_ipv4_address],
|
label=_('Address'), validators=[validators.validate_ipv4_address],
|
||||||
required=False)
|
required=False)
|
||||||
@ -70,13 +75,18 @@ class ConnectionForm(forms.Form):
|
|||||||
'provided by a DHCP server will be ignored.'),
|
'provided by a DHCP server will be ignored.'),
|
||||||
validators=[validators.validate_ipv4_address], required=False)
|
validators=[validators.validate_ipv4_address], required=False)
|
||||||
ipv6_method = forms.ChoiceField(
|
ipv6_method = forms.ChoiceField(
|
||||||
label=_('IPv6 Addressing Method'), help_text=format_lazy(
|
label=_('IPv6 Addressing Method'), widget=forms.RadioSelect, choices=[
|
||||||
_('"Automatic" methods will make {box_name} acquire '
|
('auto',
|
||||||
'configuration from this network making it a client.'),
|
_('Automatic: Configure automatically, use Internet connection '
|
||||||
box_name=_(cfg.box_name)),
|
'from this network')),
|
||||||
choices=[('auto', _('Automatic')), ('dhcp', _('Automatic, DHCP only')),
|
('dhcp',
|
||||||
('manual', pgettext_lazy('Not automatically', 'Manual')),
|
_('Automatic (DHCP only): Configure automatically, use Internet '
|
||||||
('ignore', _('Ignore'))])
|
'connection from this network')),
|
||||||
|
('manual',
|
||||||
|
_('Manual: Use manually specified parameters, use Internet '
|
||||||
|
'connection from this network')),
|
||||||
|
('ignore', _('Ignore: Ignore this addressing method')),
|
||||||
|
])
|
||||||
ipv6_address = forms.CharField(
|
ipv6_address = forms.CharField(
|
||||||
label=_('Address'), validators=[validators.validate_ipv6_address],
|
label=_('Address'), validators=[validators.validate_ipv6_address],
|
||||||
required=False)
|
required=False)
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
* in this page.
|
* in this page.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function($) {
|
jQuery(function($) {
|
||||||
|
|
||||||
function ip_required(required, ip_version, fields) {
|
function ip_required(required, ip_version, fields) {
|
||||||
var prefix = '#id_' + ip_version + '_';
|
var prefix = '#id_' + ip_version + '_';
|
||||||
@ -43,16 +43,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function on_ipv4_method_change() {
|
function on_ipv4_method_change() {
|
||||||
if ($("#id_ipv4_method").prop("value") == "manual") {
|
var selected = $("input[name=ipv4_method]:checked");
|
||||||
|
if (selected.prop("value") == "manual") {
|
||||||
ip_required(true, 'ipv4', ['address']);
|
ip_required(true, 'ipv4', ['address']);
|
||||||
ip_readonly(false, 'ipv4', ['address', 'netmask', 'gateway',
|
ip_readonly(false, 'ipv4', ['address', 'netmask', 'gateway',
|
||||||
'dns', 'second_dns'
|
'dns', 'second_dns'
|
||||||
]);
|
]);
|
||||||
} else if ($("#id_ipv4_method").prop("value") == "shared") {
|
} else if (selected.prop("value") == "shared") {
|
||||||
ip_required(false, 'ipv4', ['address']);
|
ip_required(false, 'ipv4', ['address']);
|
||||||
ip_readonly(false, 'ipv4', ['address', 'netmask']);
|
ip_readonly(false, 'ipv4', ['address', 'netmask']);
|
||||||
ip_readonly(true, 'ipv4', ['gateway', 'dns', 'second_dns']);
|
ip_readonly(true, 'ipv4', ['gateway', 'dns', 'second_dns']);
|
||||||
} else if ($("#id_ipv4_method").prop("value") == "auto") {
|
} else if (selected.prop("value") == "auto") {
|
||||||
ip_readonly(true, 'ipv4', ['address', 'netmask', 'gateway']);
|
ip_readonly(true, 'ipv4', ['address', 'netmask', 'gateway']);
|
||||||
ip_readonly(false, 'ipv4', ['dns', 'second_dns']);
|
ip_readonly(false, 'ipv4', ['dns', 'second_dns']);
|
||||||
} else {
|
} else {
|
||||||
@ -63,12 +64,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function on_ipv6_method_change() {
|
function on_ipv6_method_change() {
|
||||||
if ($("#id_ipv6_method").prop("value") == "manual") {
|
var selected = $("input[name=ipv6_method]:checked");
|
||||||
|
if (selected.prop("value") == "manual") {
|
||||||
ip_required(true, 'ipv6', ['address', 'prefix']);
|
ip_required(true, 'ipv6', ['address', 'prefix']);
|
||||||
ip_readonly(false, 'ipv6', ['address', 'prefix', 'gateway',
|
ip_readonly(false, 'ipv6', ['address', 'prefix', 'gateway',
|
||||||
'dns', 'second_dns'
|
'dns', 'second_dns'
|
||||||
]);
|
]);
|
||||||
} else if ($("#id_ipv6_method").prop("value") == "auto" ||
|
} else if (selected.prop("value") == "auto" ||
|
||||||
$("#id_ipv6_method").prop("value") == "dhcp") {
|
$("#id_ipv6_method").prop("value") == "dhcp") {
|
||||||
ip_readonly(true, 'ipv6', ['address', 'prefix', 'gateway']);
|
ip_readonly(true, 'ipv6', ['address', 'prefix', 'gateway']);
|
||||||
ip_readonly(false, 'ipv6', ['dns', 'second_dns']);
|
ip_readonly(false, 'ipv6', ['dns', 'second_dns']);
|
||||||
@ -81,8 +83,8 @@
|
|||||||
|
|
||||||
$("#id_name").focus();
|
$("#id_name").focus();
|
||||||
|
|
||||||
$("#id_ipv4_method").change(on_ipv4_method_change).change();
|
$("input[name=ipv4_method]").change(on_ipv4_method_change).change();
|
||||||
$("#id_ipv6_method").change(on_ipv6_method_change).change();
|
$("input[name=ipv6_method]").change(on_ipv6_method_change).change();
|
||||||
|
|
||||||
$('#id_show_password').change(function() {
|
$('#id_show_password').change(function() {
|
||||||
// Changing type attribute from password to text is prevented by
|
// Changing type attribute from password to text is prevented by
|
||||||
@ -95,4 +97,4 @@
|
|||||||
$('#id_password').clone().attr('type', new_type));
|
$('#id_password').clone().attr('type', new_type));
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery);
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user