From c15bbca109cf11b4dac00e6cd482221bf17eea88 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Tue, 23 Jul 2024 21:52:24 -0700 Subject: [PATCH] Separate comment column https://github.com/webmin/webmin/issues/2221 --- dhcpd/index.cgi | 27 +++++++++++++++++++++++++-- dhcpd/lang/en | 1 + 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/dhcpd/index.cgi b/dhcpd/index.cgi index 7f1179368..8c2943104 100755 --- a/dhcpd/index.cgi +++ b/dhcpd/index.cgi @@ -597,7 +597,13 @@ sub host_table { local ($i, $h, $parent); local @tds = ( "width=5" ); -print &ui_columns_start([ "", $text{'index_hostgroup'}, +my $hascmt; +for ($i = $_[1]; $i < $_[2]; $i++) { + $hascmt++ if ($_[4]->[$i] =~ /\(.*\)/); + } +print &ui_columns_start([ "", + $text{'index_hostgroup'}, + $hascmt ? ( $text{'index_comment'} ) : ( ), $text{'index_parent'}, $text{'index_hardware'}, $text{'index_nameip'} ], 100, 0, \@tds); for ($i = $_[1]; $i < $_[2]; $i++) { @@ -613,6 +619,10 @@ for ($i = $_[1]; $i < $_[2]; $i++) { $firstcol .= $text{'index_group'}." "; $sp = "\ \ "; } + my $cmt; + if ($_[4]->[$i] =~ s/\s+\((.*)\)//) { + $cmt = $1; + } if ($_[3]->[$i]) { $firstcol .= &ui_link($_[3]->[$i], $_[4]->[$i]); } @@ -620,6 +630,7 @@ for ($i = $_[1]; $i < $_[2]; $i++) { $firstcol .= $_[4]->[$i]; } push(@cols, $firstcol); + push(@cols, $cmt) if ($hascmt); if ($par{$h}->{'name'} eq "group") { $par_type = $text{'index_togroup'}; @@ -648,7 +659,14 @@ sub net_table { local ($i, $n); local @tds = ( "width=5" ); -print &ui_columns_start([ "", $text{'index_net'}, $text{'index_netmask'}, +my $hascmt; +for ($i = $_[1]; $i < $_[2]; $i++) { + $hascmt++ if ($_[4]->[$i] =~ /\(.*\)/); + } +print &ui_columns_start([ "", + $text{'index_net'}, + $hascmt ? ( $text{'index_comment'} ) : ( ), + $text{'index_netmask'}, $text{'index_desc'}, $text{'index_parent'} ], 100, 0, \@tds); for ($i = $_[1]; $i < $_[2]; $i++) { @@ -661,6 +679,10 @@ for ($i = $_[1]; $i < $_[2]; $i++) { else { $sp = "\ \ "; } + my $cmt; + if ($_[4]->[$i] =~ s/\s+\((.*)\)//) { + $cmt = $1; + } if ($_[3]->[$i]) { $first .= &ui_link($_[3]->[$i],$_[4]->[$i]); } @@ -668,6 +690,7 @@ for ($i = $_[1]; $i < $_[2]; $i++) { $first .= $_[4]->[$i]; } push(@cols, $first); + push(@cols, $cmt) if ($hascmt); push(@cols, $_[3]->[$i] ? &netmask($n) : ""); push(@cols, $n->{'comment'}); push(@cols, $par{$n} ? diff --git a/dhcpd/lang/en b/dhcpd/lang/en index 51a888995..64a602cc4 100755 --- a/dhcpd/lang/en +++ b/dhcpd/lang/en @@ -14,6 +14,7 @@ index_memb=$1 members index_hst=Hosts and Host Groups index_nohst=No hosts or groups have been defined. index_hostgroup=Host/Group +index_comment=Description index_parent=Parent index_hardware=Hardware Address index_group=Group: