Merge pull request #1684 from RaspAP/fix/fallback-static-enabled

Add event listener to chkfallback, enable/disable static IP fields
This commit is contained in:
Bill Zimmerman 2024-10-28 17:32:47 +01:00 committed by GitHub
commit 9e52cda593
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -242,16 +242,13 @@ function loadInterfaceDHCPSelect() {
$('#txtmetric').val(jsonData.Metric); $('#txtmetric').val(jsonData.Metric);
if (jsonData.StaticIP !== null && jsonData.StaticIP !== '' && !jsonData.FallbackEnabled) { if (jsonData.StaticIP !== null && jsonData.StaticIP !== '' && !jsonData.FallbackEnabled) {
$('#chkstatic').closest('.btn').button('toggle'); $('#chkstatic').prop('checked', true).closest('.btn').addClass('active');
$('#chkstatic').closest('.btn').button('toggle').blur(); $('#chkdhcp').prop('checked', false).closest('.btn').removeClass('active');
$('#chkstatic').blur();
$('#chkfallback').prop('disabled', true); $('#chkfallback').prop('disabled', true);
$('#dhcp-iface').removeAttr('disabled'); $('#dhcp-iface').removeAttr('disabled');
} else { } else {
$('#chkdhcp').closest('.btn').button('toggle'); $('#chkdhcp').closest('.btn').addClass('active');
$('#chkdhcp').closest('.btn').button('toggle').blur(); $('#chkdhcp').closest('.btn').button.blur();
$('#chkdhcp').blur();
$('#chkfallback').prop('disabled', false);
} }
if (jsonData.FallbackEnabled || $('#chkdhcp').is(':checked')) { if (jsonData.FallbackEnabled || $('#chkdhcp').is(':checked')) {
$('#dhcp-iface').prop('disabled', true); $('#dhcp-iface').prop('disabled', true);
@ -272,6 +269,14 @@ function setDHCPToggles(state) {
$('#dhcp-iface').prop('disabled', !state); $('#dhcp-iface').prop('disabled', !state);
} }
$('#chkfallback').change(function() {
if ($('#chkfallback').is(':checked')) {
setStaticFieldsEnabled();
} else {
setStaticFieldsDisabled();
}
});
$('#debugModal').on('shown.bs.modal', function (e) { $('#debugModal').on('shown.bs.modal', function (e) {
var csrfToken = $('meta[name=csrf_token]').attr('content'); var csrfToken = $('meta[name=csrf_token]').attr('content');
$.post('ajax/system/sys_debug.php',{'csrf_token': csrfToken},function(data){ $.post('ajax/system/sys_debug.php',{'csrf_token': csrfToken},function(data){