From 0ec8e31aded7973d59878384fe13df1db220dc8a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Florian=20B=C3=BChrle?= Date: Sun, 19 May 2019 23:04:24 +0200 Subject: [PATCH] zoneconf: Switch rows/columns This change is necessary because the table can grow larger than the main container if a user has many NICs on their machine. Signed-off-by: Michael Tremer --- html/cgi-bin/zoneconf.cgi | 155 ++++++++++++++++++++------------------ 1 file changed, 80 insertions(+), 75 deletions(-) diff --git a/html/cgi-bin/zoneconf.cgi b/html/cgi-bin/zoneconf.cgi index 3712b92cde..9699b38087 100644 --- a/html/cgi-bin/zoneconf.cgi +++ b/html/cgi-bin/zoneconf.cgi @@ -30,14 +30,20 @@ my $css = < table { width: 100%; + border-collapse: collapse; + table-layout: fixed; } tr { height: 4em; } - td:first-child { - width: 1px; + tr.thin { + height: 3em; + } + + td.narrow { + width: 11em; } td { @@ -47,10 +53,6 @@ my $css = < END ; @@ -294,53 +295,30 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{"save"}) { ### START OF TABLE ### print < - - -
+
+ + + "; -} - -print ""; - +# Fill the table header with all activated zones foreach (@zones) { my $uc = uc $_; - my $dev_name = $ethsettings{"${uc}_DEV"}; - - if ($dev_name eq "") { # If the zone is not activated, don't show it - next; - } + my $dev_name = $ethsettings{"${uc}_DEV"}; - print ""; + if ($dev_name eq "") { # If the zone is not activated, don't show it + next; + } - if ($uc eq "RED") { + # If the zone is in PPP mode, don't show a mode dropdown + if ($uc eq "RED") { my $red_type = $ethsettings{"RED_TYPE"}; my $red_restricted = ($uc eq "RED" && ! ($red_type eq "STATIC" || $red_type eq "DHCP")); - # VLANs/Bridging is not possible if the RED interface is set to PPP, PPPoE, VDSL, ... if ($red_restricted) { - print ""; - - foreach (@nics) { - my $mac = $_->[0]; - my $checked = ""; + print ""; - if ($mac eq $ethsettings{"${uc}_MACADDR"}) { - $checked = "checked"; - } - - print ""; - } - - print ""; next; # We're done here } } @@ -357,7 +335,7 @@ foreach (@zones) { } print <$uc
+
END ; +} + +print ""; + +foreach (@nics) { + my $mac = $_->[0]; + my $nic = $_->[1]; + my $wlan = $_->[2]; + + print ""; + + # Iterate through all zones and check if the current NIC is assigned to it + foreach (@zones) { + my $uc = uc $_; + my $dev_name = $ethsettings{"${uc}_DEV"}; + + if ($dev_name eq "") { # Again, skip the zone if it is not activated + next; + } - # ZONE_PARENT_DEV is set if this zone accesses any interface via a VLAN - my $zone_parent_dev = $vlansettings{"${uc}_PARENT_DEV"}; + if ($uc eq "RED") { + my $red_type = $ethsettings{"RED_TYPE"}; + my $red_restricted = ($uc eq "RED" && ! ($red_type eq "STATIC" || $red_type eq "DHCP")); - # If ZONE_PARENT_DEV is set to a NICs name (e.g. green0 or eth0) instead of a MAC address, we have to find out this NICs MAC address - $zone_parent_dev = &Network::get_mac_by_name($zone_parent_dev); + # VLANs/Bridging is not possible if the RED interface is set to PPP, PPPoE, VDSL, ... + if ($red_restricted) { + my $checked = ""; - foreach (@nics) { # Check for all nics if they are assigned to the current zone - my %access_selected = (); - my $mac = $_->[0]; - my $wlan = $_->[2]; - my $field_disabled = "disabled"; # Only enable the VLAN ID input field if the current access mode is VLAN + if ($mac eq $ethsettings{"${uc}_MACADDR"}) { + $checked = "checked"; + } + + print ""; + next; # We're done here + } + } + + my %access_selected = (); + my $zone_mode = $ethsettings{"${uc}_MODE"}; + my $zone_parent_dev = $vlansettings{"${uc}_PARENT_DEV"}; # ZONE_PARENT_DEV is set if this zone accesses any interface via a VLAN + my $field_disabled = "disabled"; # Only enable the VLAN ID input field if the current access mode is VLAN my $zone_vlan_id = ""; - # If the current NIC is accessed by the current zone via a VLAN, the ZONE_PARENT_DEV option corresponds to the current NIC - if ($mac eq $zone_parent_dev) { + # If ZONE_PARENT_DEV is set to a NICs name (e.g. green0 or eth0) instead of a MAC address, we have to find out this NICs MAC address + $zone_parent_dev = &Network::get_mac_by_name($zone_parent_dev); + + # If the current NIC is accessed by the current zone via a VLAN, the ZONE_PARENT_DEV option corresponds to the current NIC + if ($mac eq $zone_parent_dev) { $access_selected{"VLAN"} = "selected"; $field_disabled = ""; $zone_vlan_id = $vlansettings{"${uc}_VLAN_ID"}; - } - - # If the current zone is in bridge mode, all corresponding NICs (Native as well as VLAN) are set via the ZONE_SLAVES option - if ($zone_mode eq "bridge") { + } elsif ($zone_mode eq "bridge") { # If the current zone is in bridge mode, all corresponding NICs (Native as well as VLAN) are set via the ZONE_SLAVES option my @slaves = split(/ /, $ethsettings{"${uc}_SLAVES"}); foreach (@slaves) { @@ -400,29 +407,27 @@ END last; } } - } else { # Native access via ZONE_MACADDR is only set if the zone does not access a NIC via a VLAN and the zone is not in bridge mode - if ($mac eq $ethsettings{"${uc}_MACADDR"}) { - $access_selected{"NATIVE"} = "selected"; - } + } elsif ($mac eq $ethsettings{"${uc}_MACADDR"}) { # Native access via ZONE_MACADDR is only set if the zone does not access a NIC via a VLAN and the zone is not in bridge mode + $access_selected{"NATIVE"} = "selected"; } - $access_selected{"NONE"} = ($access_selected{"NATIVE"} eq "") && ($access_selected{"VLAN"} eq "") ? "selected" : ""; + $access_selected{"NONE"} = ($access_selected{"NATIVE"} eq "") && ($access_selected{"VLAN"} eq "") ? "selected" : ""; my $vlan_disabled = ($wlan) ? "disabled" : ""; - print < - - - + print < + + + END ; + } - } - print ""; + print ""; } print <
END ; -# Fill the table header with all physical NICs -foreach (@nics) { - my $mac = $_->[0]; - my $nic = $_->[1]; - - print "$nic
$mac
$uc
($red_type)
$uc ($red_type)
$uc
$nic
$mac