Skip to content
Browse files

Use new UI for samba networking page

  • Loading branch information...
1 parent a06b2b7 commit 2fa3c71cc307f6e811d938b4737ffef89fed374f @jcameron jcameron committed Mar 13, 2012
Showing with 54 additions and 82 deletions.
  1. +53 −82 samba/conf_net.cgi
  2. +1 −0 samba/lang/en
View
135 samba/conf_net.cgi
@@ -13,111 +13,82 @@ require './samba-lib.pl';
&get_share("global");
-print "<form action=save_net.cgi>\n";
-print "<table border width=100%>\n";
-print "<tr $tb> <td><b>$text{'net_title'}</b></td> </tr>\n";
-print "<tr $cb> <td><table width=100%>\n";
-print "<tr> <td><b>$text{'net_idle'}</b></td>\n";
-printf "<td><input type=radio name=dead_time_def value=1 %s> $text{'config_never'}\n",
- &getval("deadtime") eq "" ? "checked" : "";
-printf "<input type=radio name=dead_time_def value=0 %s>\n",
- &getval("deadtime") eq "" ? "" : "checked";
-printf "<input name=dead_time size=5 value=\"%s\"> $text{'config_mins'}</td> </tr>\n",
- &getval("deadtime");
-
-print "<tr> <td><b>$text{'net_trustlist'}</b></td>\n";
-printf "<td><input type=radio name=hosts_equiv_def value=1 %s> $text{'config_none'}\n",
- &getval("hosts equiv") eq "" ? "checked" : "";
-printf "<input type=radio name=hosts_equiv_def value=0 %s>",
- &getval("hosts equiv") eq "" ? "" : "checked";
-printf "<input name=hosts_equiv size=20 value=\"%s\">\n",
- &getval("hosts equiv");
-print &file_chooser_button("hosts_equiv", 0);
-print "</td> </tr>\n";
-
-print "<tr> <td valign=top><b>$text{'net_netinterface'}</b></td>\n";
-print "<td>\n";
-printf "<input type=radio name=interfaces_def value=1 %s> $text{'net_auto'}&nbsp;\n",
- &getval("interfaces") ? "" : "checked";
-printf "<input type=radio name=interfaces_def value=0 %s> $text{'net_uselist'}<br>\n",
- &getval("interfaces") ? "checked" : "";
-print "<table border>\n";
-print "<tr> <td><b>$text{'net_interface'}</b></td> <td><b>$text{'net_netmask'}</b></td> </tr>\n";
-@iflist = split(/\s+/, &getval("interfaces"));
+print &ui_form_start("save_net.cgi", "post");
+print &ui_table_start($text{'net_title'}, undef, 2);
+
+print &ui_table_row($text{'net_idle'},
+ &ui_opt_textbox("dead_time", &getval("deadtime"), 5,
+ $text{'config_never'})." ".$text{'config_mins'});
+
+print &ui_table_row($text{'net_trustlist'},
+ &ui_opt_textbox("hosts_equiv", &getval("hosts equiv"), 40,
+ $text{'config_none'})." ".
+ &file_chooser_button("hosts_equiv", 0));
+
+$ifaces = &getval("interfaces");
+$itable = &ui_columns_start([ $text{'net_interface'}, $text{'net_netmask'} ]);
+@iflist = split(/\s+/, $ifaces);
$len = @iflist ? @iflist+1 : 2;
for($i=0; $i<$len; $i++) {
- print "<tr>\n";
+ my ($ip, $nm);
if ($iflist[$i] =~ /^([0-9\.]+)\/([0-9]+)$/) {
+ $ip = $1;
for($j=0; $j<$2; $j++) { $pw += 2**(31-$j); }
- $n = sprintf "%u.%u.%u.%u",
+ $nm = sprintf "%u.%u.%u.%u",
($pw>>24)&0xff, ($pw>>16)&0xff,
($pw>>8)&0xff, ($pw)&0xff;
- print "<td><input name=interface_ip$i value=$1 size=15></td>\n";
- print "<td><input name=interface_nm$i value=$n size=15></td>\n";
}
elsif ($iflist[$i] =~ /^([0-9\.]+)\/([0-9\.]+)$/) {
- print "<td><input name=interface_ip$i value=$1 size=15></td>\n";
- print "<td><input name=interface_nm$i value=$2 size=15></td>\n";
+ $ip = $1;
+ $nm = $2;
}
elsif ($iflist[$i] =~ /^(\S+)$/) {
- print "<td><input name=interface_ip$i value=$1 size=15></td>\n";
- print "<td><input name=interface_nm$i size=15></td>\n";
- }
- else {
- print "<td><input name=interface_ip$i size=15></td>\n";
- print "<td><input name=interface_nm$i size=15></td>\n";
+ $ip = $1;
+ $nm = "";
}
- print "</tr>\n";
+ $itable .= &ui_columns_row([
+ &ui_textbox("interface_ip$i", $ip, 15),
+ &ui_textbox("interface_nm$i", $nm, 15),
+ ]);
}
-print "</table></td> </tr>\n";
-
-print "<tr> <td><b>$text{'net_keepalive'}</b></td>\n";
-printf "<td><input type=radio name=keepalive_def value=1 %s> $text{'net_notsend'}\n",
- &getval("keepalive") eq "" ? "checked" : "";
-printf "<input type=radio name=keepalive_def value=0 %s>\n",
- &getval("keepalive") eq "" ? "" : "checked";
-print "$text{'net_every'}\n";
-printf "<input name=keepalive size=5 value=\"%s\">$text{'config_secs'}</td> </tr>\n",
- &getval("keepalive");
-
-print "<tr> <td><b>$text{'net_maxpacket'}</b></td>\n";
-printf "<td><input type=radio name=max_xmit_def value=1 %s> $text{'default'}\n",
- &getval("max xmit") eq "" ? "checked" : "";
-printf "<input type=radio name=max_xmit_def value=0 %s>\n",
- &getval("max xmit") eq "" ? "" : "checked";
-printf "<input name=max_xmit size=5 value=\"%s\"> $text{'config_bytes'}</td> </tr>\n",
- &getval("max xmit");
-
-print "<tr> <td><b>$text{'net_listen'}</b></td>\n";
-printf "<td><input type=radio name=socket_address_def value=1 %s> $text{'config_all'}\n",
- &getval("socket address") eq "" ? "checked" : "";
-printf "<input type=radio name=socket_address_def value=0 %s>\n",
- &getval("socket address") eq "" ? "" : "checked";
-printf "<input name=socket_address size=15 value=\"%s\"></td> </tr>\n",
- &getval("socket address");
-
-print "<tr> <td valign=top><b>$text{'net_socket'}</b></td>\n";
-print "<td><table>\n";
+$itable .= &ui_columns_end();
+print &ui_table_row($text{'net_netinterface'},
+ &ui_radio("interfaces_def", $ifaces ? 0 : 1,
+ [ [ 1, $text{'net_auto'} ],
+ [ 0, $text{'net_uselist'} ] ])."<br>\n".
+ $itable);
+
+print &ui_table_row($text{'net_keepalive'},
+ &ui_opt_textbox("keepalive", &getval("keepalive"), 5,
+ $text{'net_notsend'})." ".$text{'config_secs'});
+
+print &ui_table_row($text{'net_maxpacket'},
+ &ui_opt_textbox("max_xmit", &getval("max xmit"), 5,
+ $text{'default'})." ".$text{'config_bytes'});
+
+print &ui_table_row($text{'net_listen'},
+ &ui_opt_textbox("socket_address", &getval("socket address"), 15,
+ $text{'config_all'}, $text{'net_ip'}));
+
foreach (split(/\s+/, &getval("socket options"))) {
if (/^([A-Z\_]+)=(.*)/) { $sopts{$1} = $2; }
else { $sopts{$_} = ""; }
}
+@grid = ( );
for($i=0; $i<@sock_opts; $i++) {
$sock_opts[$i] =~ /^([A-Z\_]+)(.*)$/;
- if ($i%2 == 0) { print "<tr>\n"; }
- printf "<td><input type=checkbox name=$1 value=1 %s> $1\n",
- defined($sopts{$1}) ? "checked" : "";
+ $f = &ui_checkbox("$1", 1, "$1", defined($sopts{$1}));
if ($2 eq "*") {
- printf "<input size=5 name=\"$1_val\" value=\"%s\">\n",
- $sopts{$1};
+ $f .= " ".&ui_textbox("${1}_val", $sopts{$1}, 5);
}
+ push(@grid, $f);
print "</td>\n";
- if ($i%2 == 1) { print "<tr>\n"; }
}
-print "</table></td> </tr>\n";
+print &ui_table_row($text{'net_socket'},
+ &ui_grid_table(\@grid, 2));
-print "</table></td></tr></table><p>\n";
-print "<input type=submit value=$text{'save'}></form>\n";
+print &ui_table_end();
+print &ui_form_end([ [ undef, $text{'save'} ] ]);
&ui_print_footer("", $text{'index_sharelist'});
View
1 samba/lang/en
@@ -120,6 +120,7 @@ net_notsend=Don't send any
net_every=Send every
net_maxpacket=Maximum packet size
net_listen=Listen on address
+net_ip=IP address
net_socket=Socket options
passwd_title=Password Options

0 comments on commit 2fa3c71

Please sign in to comment.
Something went wrong with that request. Please try again.