More ui-lib conversion

This commit is contained in:
Jamie Cameron
2008-01-10 22:52:13 +00:00
parent 36382a3bfa
commit beb6207bef
7 changed files with 121 additions and 201 deletions
+4 -8
View File
@@ -28,14 +28,10 @@ if( $in{ 'action' } eq $text{ 'hdparm_apply' } )
( $_, $buffered ) = split( /=/, $buffered );
( $_, $buffer_cache ) = split( /=/, $buffer_cache );
print "<p><table border cellpadding=2>\n";
print "<tr $tb> <td colspan=2>",
"<b>$text{'hdparm_speedres'}</b></td> </tr>\n";
print "<tr $cb> <td><b>$text{'hdparm_buf1'}</b></td> ",
"<td>$buffered</td> </tr>\n";
print "<tr $cb> <td><b>$text{'hdparm_buf2'}</b></td> ",
"<td>$buffer_cache</td> </tr>\n";
print "</table><p>\n";
print &ui_table_start($text{'hdparm_speedres'}, undef, 2,[ "width=30%" ]);
print &ui_table_row($text{'hdparm_buf1'}, $buffered);
print &ui_table_row($text{'hdparm_buf2'}, $buffer_cache);
print &ui_table_end();
}
&ui_print_footer( "", $text{ 'index_return' } );
+49 -83
View File
@@ -9,7 +9,7 @@ $d = $dlist[$in{'disk'}];
&can_edit_disk($d->{'device'}) ||
&error($text{'edit_ecannot'});
&ui_print_header(undef, $text{'hdparm_title'}, "");
&ui_print_header($d->{'desc'}, $text{'hdparm_title'}, "");
if ( ! &has_command( "hdparm" ) ) {
print "<p>$text{ 'edit_ehdparm' }<p>\n";
&ui_print_footer( "", $text{ 'index_return' } );
@@ -30,37 +30,58 @@ foreach $argument ( 'a', 'd', 'r', 'k', 'u', 'm', 'c' )
#( $hdparm{ $argument } ) = split( / /, $line );
}
# Javascript for slider
print(
"<script type=\"text/javascript\" src=\"range.js\"></script>
<script type=\"text/javascript\" src=\"timer.js\"></script>
<script type=\"text/javascript\" src=\"slider.js\"></script>
<link type=\"text/css\" rel=\"StyleSheet\" href=\"winclassic.css\" />");
# Form header
print &ui_form_start("apply_hdparm.cgi");
print &ui_hidden("drive", $d->{'device'});
print &ui_table_start($text{'hdparm_label'}, "width=100%", 4);
print(
"<form action=apply_hdparm.cgi><table border cols=1 width=\"100%\"><input type=hidden name=drive value=", $d -> { 'device' }, ">",
"<tr ", $tb, ">",
"<td><b>", $d->{'desc'}," (",$d->{'device'}.") : ",$text{ 'hdparm_label' }, "</b></td>",
"</tr><tr ", $cb, "><td>",
"<table width=\"100%\">",
"<tr>",
"<td>", &hlink( "<b>". $text{ 'hdparm_conf_X' }. "</b>", 'X' ), &p_select_wdl( "X", $hdparm{ 'X' }, ( "0", $text{ 'hdparm_conf_X_defaut' }, "1", $text{ 'hdparm_conf_X_disable' }, "9", "PIO mode 1", "10", "PIO mode 2", "11", "PIO mode 3", "12", "PIO mode 4", "32", "Multimode DMA 0", "33", "Multimode DMA 1", "34", "Multimode DMA 2", "64", "Ultra DMA 0", "65", "Ultra DMA 1", "66", "Ultra DMA 2" ) ), "</td>",
"<td>", &l_radio( $text{ 'hdparm_conf_d' }, 'd', @yesno ), "</td>",
"</tr><tr>",
"<td>", &hlink( "<b>". $text{ 'hdparm_conf_a' }. "</b>", "a" ), " ", &p_entry( "a", 2, $hdparm{ 'a' } ), "</td>",
"<td>", &l_radio( $text{ 'hdparm_conf_A' }, 'A', @yesno ), "</td>",
"</tr><tr>",
"<td>", &l_radio( $text{ 'hdparm_conf_W' }, 'W', @yesno ), "</td>",
"<td>", &l_radio( $text{ 'hdparm_conf_u' }, 'u', @yesno ), "</td>",
"</tr><tr>",
"<td>", &l_radio( $text{ 'hdparm_conf_k' }, 'k', @yesno ), "</td>",
"<td>", &l_radio( $text{ 'hdparm_conf_K' }, 'K', @yesno ), "</td>",
"</tr><tr>",
"<td>", &l_radio( $text{ 'hdparm_conf_r' }, 'r', @yesno ), "</td>",
"<td>", &l_radio( $text{ 'hdparm_conf_P' }, 'P', @yesno ), "</td>",
"</tr><tr>",
"<td>", &hlink( "<b>". $text{ 'hdparm_conf_S' }. "</b>", "S" ), "</td>", "<td>", &p_slider( "S", 0, 251, 0),
"<script type=\"text/javascript\">
# Transfer mode
print &ui_table_row(&hlink($text{'hdparm_conf_X'}, 'X'),
&ui_select("X", $hdparm{'X'},
[ [ "0", $text{ 'hdparm_conf_X_defaut' } ], [ "1", $text{ 'hdparm_conf_X_disable' } ], [ "9", "PIO mode 1", ], [ "10", "PIO mode 2" ], [ "11", "PIO mode 3" ], [ "12", "PIO mode 4" ], [ "32", "Multimode DMA 0" ], [ "33", "Multimode DMA 1" ], [ "34", "Multimode DMA 2" ], [ "64", "Ultra DMA 0" ], [ "65", "Ultra DMA 1" ], [ "66", "Ultra DMA 2" ] ], 1, 0, 1));
# Sector count
print &ui_table_row(&hlink($text{'hdparm_conf_a'},"a"),
&ui_textbox("a", $hdparm{'a'}, 2));
# Other yes/no options
foreach $o ('d', 'A', 'W', 'u', 'k', 'K', 'r', 'P') {
print &ui_table_row(&hlink($text{'hdparm_conf_'.$o}, $o),
&ui_yesno_radio($o, $hdparm{$o}));
}
# Standby timeout (slider)
print &ui_table_row(&hlink($text{'hdparm_conf_S'}, 'S'),
&p_slider( "S", 0, 251, 0), 3);
# 32-bit I/O support
print &ui_table_row(&hlink($text{'hdparm_conf_c'}, 'c'),
&ui_radio('c', $hdparm{'c'},
[ [ 0, $text{'hdparm_disable'} ],
[ 1, $text{'hdparm_enable'} ],
[ 3, $text{'hdparm_enable_special'} ] ]), 3);
# Sector count for multiple sector I/O
print &ui_table_row(&hlink($text{'hdparm_conf_m'}, 'm'),
&ui_radio('m', $hdparm{'m'},
[ [ 0, $text{'hdparm_disable'} ],
[ 2 ], [ 4 ], [ 8 ], [ 16 ], [ 32 ] ]), 3);
print &ui_table_end();
print &ui_form_end([ [ 'action', $text{'hdparm_apply'} ],
[ 'action', $text{'hdparm_speed'} ] ]);
&ui_print_footer( "", $text{ 'index_return' } );
# Javascript for slider
print "<script type=\"text/javascript\">
var sliderEl = document.getElementById ?
document.getElementById(\"S-slider\") : null;
@@ -103,44 +124,9 @@ s.setValue(0);
s.setMinimum(0);
s.setMaximum(251);
</script></td>",
"</tr>",
"</table><table>",
"<tr><td>", &l_radio( $text{ 'hdparm_conf_c' }, 'c', ( "0", $text{ 'hdparm_disable' }, "1", $text{ 'hdparm_enable' }, "3", $text{ 'hdparm_enable_special' } ) ), "</td></tr>",
"<tr><td>", &l_radio( $text{ 'hdparm_conf_m' }, 'm', ( "0", $text{ 'hdparm_disable' }, "2", "2", "4", "4", "8", "8", "16", "16", "32", "32" ) ), "<td><tr>",
"</table></td>",
"</tr>",
"</table><table cols=3 width=\"100%\" nosave>",
"<tr>",
"<td align=left><input type=submit name=action value=\"", $text{ 'hdparm_apply' }, "\"></td>",
"<td align=right><input type=submit name=action value=\"", $text{ 'hdparm_speed' }, "\"></td>",
"</tr>",
"</table></form>" );
&ui_print_footer( "", $text{ 'index_return' } );
sub l_radio
{
my ( $label, $flag, @items ) = @_;
return &hlink( "<b>".$label."</b>", $flag )."</td> <td>".
&p_radio( $flag, $hdparm{ $flag }, @items );
}
sub p_radio
{
my ( $name, $checked, @list ) = @_;
local $out, $size = @list, $i = 0;
do
{
$out .= " <input type=radio name=".$name." value=".$list[$i];
$out .= " checked" if( $checked eq $list[$i++] );
$out .="> ".$list[$i++];
} while( $i < $size );
return $out;
}
</script>";
# Returns a slider
sub p_slider
{
my ( $name, $min, $max, $default ) = @_;
@@ -148,30 +134,10 @@ sub p_slider
$out .= "<div class=\"slider\" id=\"". $name ."-slider\" tabIndex=\"1\">";
$out .= "<input class=\"slider-input\" id=\"".$name."-slider-input\"";
$out .= " name=\"".$name."\"/></div></td><td>";
$out .= " name=\"".$name."\"/></div>";
$out .= "<input type=text name=\"".$name."-text\" id=\"".$name."-text-id\" readonly value=\"This field is not used\" >";
return $out;
}
sub p_entry
{
my ( $name, $size, $value ) = @_;
$size ? return "</td> <td><input name=\"". $name. "\" id=\"". $name. "-id\" size=". $size." value=\"". $value."\">" : return "</td> <td><input name=\"". $name. "\" id=\"". $name. "-id\" value=\"". $value."\">";
}
sub p_select_wdl
{
my ( $name, $selected, @list ) = @_;
local $size = @list, $i = 0, $out = "</td> <td><select name=".$name.">";
do
{
$out .= "<option name=".$name." value=".$list[$i];
$out .= " selected" if( $selected eq $list[$i++] );
$out .= ">".$list[$i++];
} while( $i < $size );
$out .= "</select>";
return $out;
}
+28 -46
View File
@@ -128,7 +128,7 @@ if ($in{'new'}) {
else {
$ext = "$pinfo->{'start'} - $pinfo->{'end'}";
}
$ext .= " ".$text{'edit_of'}." $dinfo->{'cylinders'};
$ext .= " ".$text{'edit_of'}." ".$dinfo->{'cylinders'};
print &ui_table_row($text{'edit_extent'}, $ext);
# Current status
@@ -207,83 +207,65 @@ else {
if (!$in{'new'} && !$pinfo->{'extended'}) {
print "<hr>\n";
print &ui_buttons_start();
if (!@stat || $stat[2] == 0) {
# Show form for creating filesystem
print "<hr><table width=100%>\n" if (!$donehead++);
print "<tr> <form action=mkfs_form.cgi>\n";
print "<input type=hidden name=dev value=$dev>\n";
print "<td nowrap><input type=submit value='$text{'edit_mkfs2'}'>\n";
print "<select name=type>\n";
local $rt = @stat ? $stat[1] : &conv_type($pinfo->{'type'});
foreach $f (&supported_filesystems()) {
printf "<option value=%s %s>%s (%s)\n",
$f, $rt eq $f ? "selected" : "",
$text{"fs_$f"}, $f;
}
print "</select></td>\n";
print "<td>$text{'edit_mkfsmsg2'}</td> </form></tr>\n";
print &ui_buttons_row("mkfs_form.cgi",
$text{'edit_mkfs2'}, $text{'edit_mkfsmsg2'},
&ui_hidden("dev", $dev),
&ui_select("type", $rt,
[ map { [ $_, $text{"fs_$_"} ] }
&supported_filesystems() ]));
}
if (!$in{'new'} && @stat && $stat[2] == 0 && &can_fsck($stat[1])) {
# Show form to fsck filesystem
print "<hr><table width=100%>\n" if (!$donehead++);
print "<tr> <form action=fsck_form.cgi>\n";
print "<td valign=top>\n";
print "<input type=hidden name=dev value=$dev>\n";
print "<input type=hidden name=type value=$stat[1]>\n";
print "<input type=submit value=\"$text{'edit_fsck'}\"></td>\n";
print "<td>",&text('edit_fsckmsg', "<tt>fsck</tt>"),"</td>\n";
print "</form> </tr>\n";
print &ui_buttons_row("fsck_form.cgi",
$text{'edit_fsck'},&text('edit_fsckmsg', "<tt>fsck</tt>"),
&ui_hidden("dev", $dev)." ".
&ui_hidden("type", $stat[1]));
}
if (!$in{'new'} && @stat && $stat[2] == 0 && &can_tune($stat[1])) {
# Show form to tune filesystem
print "<hr><table width=100%>\n" if (!$donehead++);
print "<tr> <form action=tunefs_form.cgi>\n";
print "<td valign=top>\n";
print "<input type=hidden name=dev value=$dev>\n";
print "<input type=hidden name=type value=$stat[1]>\n";
print "<input type=submit value=\"", $text{'edit_tune'}, "\"></td>\n";
print "<td>$text{'edit_tunemsg'}</td> </tr>\n";
print "</form> </tr>\n";
print &ui_buttons_row("tunefs_form.cgi",
$text{'edit_tune'}, $text{'edit_tunemsg'},
&ui_hidden("dev", $dev)." ".
&ui_hidden("type", $stat[1]));
}
@types = &conv_type($pinfo->{'type'});
if (!$in{'new'} && !@stat && @types) {
# Show form to mount filesystem
print "<hr><table width=100%>\n" if (!$donehead++);
print "<tr> <form action=../mount/edit_mount.cgi>\n";
print "<input type=hidden name=newdev value=$dev>\n";
print "<td valign=top>\n";
if ($types[0] eq "swap") {
# Swap partition
print "<input type=submit value=\"$text{'edit_newmount2'}\">\n";
print "</td>\n";
print &ui_hidden("type", $types[0]);
print "<td>$text{'edit_mountmsg2'}</td> </tr>\n";
print &ui_buttons_row("../mount/edit_mount.cgi",
$text{'edit_newmount2'}, $text{'edit_mountmsg2'},
&ui_hidden("type", $types[0]));
}
else {
# For some filesystem
print "<input type=submit value=\"$text{'edit_newmount'}\">\n";
print "<input name=newdir size=20>\n";
$dirsel = &ui_textbox("newdir", undef, 20);
if (@types > 1) {
print "$text{'edit_mountas'} <select name=type>\n";
foreach $t (@types) {
print "<option>$t\n";
}
print "</select>\n";
$dirsel .= $text{'edit_mountas'}." ".
&ui_select("type", undef, \@types);
}
else {
print &ui_hidden("type", $types[0]);
$dirsel .= &ui_hidden("type", $types[0]);
}
print "</td>\n";
print "<td>$text{'edit_mountmsg'}</td> </tr>\n";
print &ui_buttons_row("../mount/edit_mount.cgi",
$text{'edit_newmount'}, $text{'edit_mountmsg'},
undef, $dirsel);
}
print "</form> </tr>\n";
}
print "</table><p>\n" if ($donehead);
print &ui_buttons_end();
print "<p>\n";
}
&ui_print_footer("", $text{'index_return'});
+25 -47
View File
@@ -567,49 +567,39 @@ if ($_[0] eq "ext2") {
&opt_input("ext2_i", "", 1);
&opt_input("ext2_m", "%", 0);
&opt_input("ext2_g", "", 1);
print "<td align=right><b>$text{'ext2_c'}</b></td>\n";
print "<td><input type=radio name=ext2_c value=1> $text{'yes'}\n";
print "<input type=radio name=ext2_c value=0 checked> $text{'no'}",
"</td> </tr>\n";
print &ui_table_row($text{'ext2_c'},
&ui_yesno_radio("ext2_c", 0));
}
elsif ($_[0] eq "msdos" || $_[0] eq "vfat") {
&opt_input("msdos_ff", "", 1);
print "<td align=right><b>$text{'msdos_F'}</b></td>\n";
print "<td>",&ui_select("msdos_F", undef,
print &ui_table_row($text{'msdos_F'},
&ui_select("msdos_F", undef,
[ [ undef, $text{'default'} ],
[ 12 ], [ 16 ], [ 32 ],
[ "*", $text{'msdos_F_other'} ] ])," ",
&ui_textbox("msdos_F_other", undef, 4),"</td> </tr>\n";
[ "*", $text{'msdos_F_other'} ] ])." ".
&ui_textbox("msdos_F_other", undef, 4));
&opt_input("msdos_i", "", 1);
&opt_input("msdos_n", "", 0);
&opt_input("msdos_r", "", 1);
&opt_input("msdos_s", "sectors", 0);
print "<tr> <td align=right><b>$text{'msdos_c'}</b></td>\n";
print "<td><input type=radio name=msdos_c value=1> $text{'yes'}\n";
print "<input type=radio name=msdos_c value=0 checked> $text{'no'}",
"</td> </tr>\n";
print &ui_table_row($text{'msdos_c'},
&ui_yesno_radio("msdos_c", 0));
}
elsif ($_[0] eq "minix") {
&opt_input("minix_n", "", 1);
&opt_input("minix_i", "", 0);
&opt_input("minix_b", "", 1);
print "<td align=right><b>$text{'minix_c'}</b></td>\n";
print "<td><input type=radio name=msdos_c value=1> $text{'yes'}\n";
print "<input type=radio name=msdos_c value=0 checked> $text{'no'}",
"</td> </tr>\n";
print &ui_table_row($text{'minix_c'},
&ui_yesno_radio("minix_c", 0));
}
elsif ($_[0] eq "reiserfs") {
print "<tr> <td><b>$text{'reiserfs_force'}</b></td>\n";
print "<td><input type=radio name=reiserfs_f value=1> $text{'yes'}\n";
print "<input type=radio name=reiserfs_f value=0 checked> ",
"$text{'no'}</td>\n";
print &ui_table_row($text{'reiserfs_force'},
&ui_yesno_radio("reiserfs_f", 0));
print "<td><b>$text{'reiserfs_hash'}</b></td>\n";
print "<td><select name=reiserfs_h>\n";
print "<option value='' checked>$text{'default'}\n";
print "<option>rupasov\n";
print "<option>tea\n";
print "</select></td> </tr>\n";
print &ui_table_row($text{'reiserfs_hash'},
&ui_select("reiserfs_h", "",
[ [ "", $text{'default'} ],
[ "rupasov", "tea" ] ]));
}
elsif ($_[0] eq "ext3") {
&opt_input("ext2_b", $text{'bytes'}, 1);
@@ -617,29 +607,22 @@ elsif ($_[0] eq "ext3") {
&opt_input("ext2_i", "", 1);
&opt_input("ext2_m", "%", 0);
&opt_input("ext3_j", "MB", 1);
print "<td align=right><b>$text{'ext2_c'}</b></td>\n";
print "<td><input type=radio name=ext2_c value=1> $text{'yes'}\n";
print "<input type=radio name=ext2_c value=0 checked> $text{'no'}",
"</td> </tr>\n";
print &ui_table_row($text{'ext2_c'},
&ui_yesno_radio("ext2_c", 0));
}
elsif ($_[0] eq "xfs") {
print "<tr> <td><b>$text{'xfs_force'}</b></td>\n";
print "<td><input type=radio name=xfs_f value=1> $text{'yes'}\n";
print "<input type=radio name=xfs_f value=0 checked> ",
"$text{'no'}</td>\n";
print &ui_table_row($text{'xfs_force'},
&ui_yesno_radio("xfs_f", 0));
&opt_input("xfs_b", $text{'bytes'}, 0);
}
elsif ($_[0] eq "jfs") {
&opt_input("jfs_s", $text{'megabytes'}, 1);
print "<td align=right><b>$text{'jfs_c'}</b></td>\n";
print "<td><input type=radio name=jfs_c value=1> $text{'yes'}\n";
print "<input type=radio name=jfs_c value=0 checked> $text{'no'}",
"</td> </tr>\n";
print &ui_table_row($text{'jfs_c'},
&ui_yesno_radio("jfs_c", 0));
}
elsif ($_[0] eq "fatx") {
# Has no options!
print "<tr> <td colspan=4>$text{'fatx_none'}</td> </tr>\n";
print &ui_table_row(undef, $text{'fatx_none'}, 4);
}
}
@@ -1024,13 +1007,8 @@ syswrite($fh, $_[0], length($_[0]));
sub opt_input
{
print $_[2] ? "<tr>" : "";
print "<td align=right><b>$text{$_[0]}</b></td>\n";
print "<td nowrap><input type=radio name=$_[0]_def value=1 checked> ",
$text{'opt_default'},"\n";
print "&nbsp; <input type=radio name=$_[0]_def value=0>\n";
print "<input name=$_[0] size=6> $_[1]</td>";
print $_[2] ? "\n" : "</tr>\n";
print &ui_table_row($text{$_[0]},
&ui_opt_textbox($_[0], undef, 6, $text{'opt_default'})." ".$_[1]);
}
sub opt_check
+1 -1
View File
@@ -9,8 +9,8 @@ require './fdisk-lib.pl';
&can_edit_disk($in{'dev'}) || &error($text{'mkfs_ecannot'});
&error_setup($text{'mkfs_err'});
$cmd = &mkfs_parse($in{type}, $in{dev});
&ui_print_unbuffered_header(undef, $text{'mkfs_title'}, "");
&ui_print_unbuffered_header(undef, $text{'mkfs_title'}, "");
$label = &get_label($in{'dev'});
print &text('mkfs_exec', "<tt>$cmd</tt>"),"<p>\n";
+6 -9
View File
@@ -7,9 +7,9 @@ require './fdisk-lib.pl';
&can_edit_disk($in{'dev'}) || &error($text{'mkfs_ecannot'});
&ui_print_header(undef, $text{'mkfs_title'}, "");
print "<form action=mkfs.cgi>\n";
print "<input type=hidden name=dev value=\"$in{dev}\">\n";
print "<input type=hidden name=type value=\"$in{type}\">\n";
print &ui_form_start("mkfs.cgi");
print &ui_hidden("dev", $in{'dev'});
print &ui_hidden("type", $in{'type'});
print &text('mkfs_desc1', "<b>".&fstype_name($in{type})."</b>",
"<b><tt>$in{dev}</tt></b>"),"<p>\n";
@@ -19,13 +19,10 @@ if ((@stat = &device_status($in{dev})) && $stat[1] ne "swap") {
&fstype_name($in{type})),"<p>\n";
}
print "<table border>\n";
print "<tr $tb><td><b>$text{'mkfs_options'}</b></td> </tr>\n";
print "<tr $cb><td><table cellpadding=5>\n";
print &ui_table_start($text{'mkfs_options'}, undef, 4);
&mkfs_options($in{type});
print "</table></td></tr></table>\n";
print "<input type=submit value=\"$text{'mkfs_create'}\"></form>\n";
print &ui_table_end();
print &ui_form_end([ [ undef, $text{'mkfs_create'} ] ]);
&ui_print_footer("", $text{'index_return'});
+8 -7
View File
@@ -83,8 +83,12 @@ else {
}
&webmin_log("create", "part", $dinfo->{'device'}, \%in);
}
if (&need_reboot($dinfo)) { &ask_reboot($dinfo); }
else { &redirect(""); }
if (&need_reboot($dinfo)) {
&ask_reboot($dinfo);
}
else {
&redirect("edit_disk.cgi?device=$dinfo->{'device'}");
}
}
# ask_reboot(disk)
@@ -92,15 +96,12 @@ else {
sub ask_reboot
{
&ui_print_header(undef, $text{'reboot_title'}, "");
print "<hr>\n";
local $what = &text('select_device', uc($_[0]->{'type'}),
uc(substr($_[0]->{'device'}, -1)));
print "<b>",&text('reboot_why', $what),"</b> <p>\n";
print "<form action=reboot.cgi>\n";
print "<center><input type=submit value=\"$text{'reboot_ok'}\"></center>\n";
print "</form>\n";
print &ui_form_start("reboot.cgi");
print &ui_form_end([ [ undef, $text{'reboot_ok'} ] ]);
print "<hr>\n";
&ui_print_footer("", $text{'index_return'});
}