Completed ui-lib conversion
authorJamie Cameron <jcameron@webmin.com>
Thu, 10 Jan 2008 23:55:43 +0000 (23:55 +0000)
committerJamie Cameron <jcameron@webmin.com>
Thu, 10 Jan 2008 23:55:43 +0000 (23:55 +0000)
fdisk/CHANGELOG
fdisk/edit_disk.cgi
fdisk/fdisk-lib.pl
fdisk/fsck.cgi
fdisk/fsck_form.cgi
fdisk/index.cgi
fdisk/lang/en
fdisk/tunefs_form.cgi

index c045487..c28145f 100644 (file)
@@ -20,3 +20,4 @@ Link to SMART module for SCSI disks too, and IDE params page for SATA disks pret
 Changed the IDE standby timeout to use a slider, thanks to Jean-Christophe Dubois.
 ---- Changes since 1.390 ----
 Changed the module's main page so that it only lists disks, with links to a separate page for showing the partitions.
+Re-wrote all code to use the new Webmin user interface library, for a more consistent look.
index 1e8f0dd..eba4906 100644 (file)
@@ -132,7 +132,21 @@ else {
        print "<b>$text{'disk_none'}</b><p>\n";
        }
 print &ui_links_row(\@edlinks);
-print "<p>\n";
+
+# Buttons for IDE params and SMART
+print "<hr>\n";
+print &ui_buttons_start();
+if (&supports_hdparm($d)) {
+       print &ui_buttons_row("edit_hdparm.cgi", $text{'index_hdparm'},
+                             $text{'index_hdparmdesc'},
+                             &ui_hidden("disk", $d->{'index'}));
+       }
+if (&supports_smart($d)) {
+       print &ui_buttons_row("../smart-status/index.cgi", $text{'index_smart'},
+                             $text{'index_smartdesc'},
+                             &ui_hidden("drive", $d->{'device'}));
+       }
+print &ui_buttons_end();
 
 &ui_print_footer("", $text{'index_return'});
 
index 5aa4ce5..c8b7443 100644 (file)
@@ -731,38 +731,36 @@ return $_[0] eq "ext2" || $_[0] eq "ext3";
 sub tunefs_options
 {
 if ($_[0] eq "ext2" || $_[0] eq "ext3") {
+       # Gaps between checks
        &opt_input("tunefs_c", "", 1);
 
-       print "<td align=right><b>$text{'tunefs_e'}</b></td> <td>\n";
-       print "<input type=radio name=tunefs_e_def value=1 checked> ",
-             "$text{'opt_default'}\n";
-       print "&nbsp; <input type=radio name=tunefs_e_def value=0>\n";
-       print "<select name=tunefs_e>\n";
-       print "<option value=continue> $text{'tunefs_continue'}\n";
-       print "<option value=remount-ro> $text{'tunefs_remount'}\n";
-       print "<option value=panic> $text{'tunefs_panic'}\n";
-       print "</select></td> </tr>\n";
+       # Action on error
+       print &ui_table_row($text{'tunefs_e'},
+               &ui_radio("tunefs_e_def", 1,
+                       [ [ 1, $text{'opt_default'} ],
+                         [ 0, &ui_select("tunefs_e", undef,
+                               [ [ "continue", $text{'tunefs_continue'} ],
+                                 [ "remount-ro", $text{'tunefs_remount'} ],
+                                 [ "panic", $text{'tunefs_panic'} ] ]) ] ]));
 
-       print "<tr> <td align=right><b>$text{'tunefs_u'}</b></td> <td>\n";
-       print "<input type=radio name=tunefs_u_def value=1 checked> ",
-             "$text{'opt_default'}\n";
-       print "&nbsp; <input type=radio name=tunefs_u_def value=0>\n";
-       print "<input name=tunefs_u size=8> ",
-             &user_chooser_button("tunefs_u", 0),"</td>\n";
+       # Reserved user
+       print &ui_table_row($text{'tunefs_u'},
+               &ui_opt_textbox("tunefs_u", undef, 13, $text{'opt_default'})." ".
+               &user_chooser_button("tunefs_u", 0));
 
-       print "<td align=right><b>$text{'tunefs_g'}</b></td> <td>\n";
-       print "<input type=radio name=tunefs_g_def value=1 checked> ",
-             "$text{'opt_default'}\n";
-       print "&nbsp; <input type=radio name=tunefs_g_def value=0>\n";
-       print "<input name=tunefs_g size=8> ",
-             &group_chooser_button("tunefs_g", 0),"</td> </tr>\n";
+       # Reserved group
+       print &ui_table_row($text{'tunefs_g'},
+               &ui_opt_textbox("tunefs_g", undef, 13, $text{'opt_default'})." ".
+               &group_chooser_button("tunefs_g", 0));
 
+       # Reserved blocks
        &opt_input("tunefs_m", "%", 1);
-       $tsel = "<select name=tunefs_i_unit>\n".
-               "<option value=d> $text{'tunefs_days'}\n".
-               "<option value=w> $text{'tunefs_weeks'}\n".
-               "<option value=m> $text{'tunefs_months'}\n".
-               "</select>\n";
+
+       # Time between checks
+       $tsel = &ui_select("tunefs_i_unit", undef,
+                          [ [ "d", $text{'tunefs_days'} ],
+                            [ "w", $text{'tunefs_weeks'} ],
+                            [ "m", $text{'tunefs_months'} ] ]);
        &opt_input("tunefs_i", $tsel, 0);
        }
 }
@@ -1203,3 +1201,18 @@ if ($has_xfs_db && ($_[2] eq "xfs" || !$_[2])) {
        }
 return 0;
 }
+
+# supports_hdparm(&disk)
+sub supports_hdparm
+{
+local ($d) = @_;
+return $d->{'type'} eq 'ide' || $d->{'type'} eq 'scsi' && $d->{'model'} =~ /ATA/;
+}
+
+# supports_smart(&disk)
+sub supports_smart
+{
+return &foreign_installed("smart-status") &&
+       &foreign_available("smart-status");
+}
+
index 6b2bd7e..1d54ee5 100755 (executable)
@@ -7,10 +7,11 @@ require './fdisk-lib.pl';
 &can_edit_disk($in{'dev'}) || &error($text{'fsck_ecannot'});
 &ui_print_unbuffered_header(undef, $text{'fsck_title'}, "");
 
+$cmd = &fsck_command($in{'type'}, $in{'dev'});
 print "<b>",&text('fsck_exec', "<tt>$cmd</tt>"),"</b>\n";
 print "<pre>\n";
 &foreign_call("proc", "safe_process_exec_logged",
-             $in{'cmd'}, 0, 0, STDOUT, undef, 1);
+             $cmd, 0, 0, STDOUT, undef, 1);
 print "</pre>\n";
 print "<b>... ",&fsck_error($?/256),"</b><p>\n"; 
 &webmin_log("fsck", undef, $in{'dev'}, \%in);
index 185efef..cac3cdd 100755 (executable)
@@ -13,12 +13,10 @@ print &text('fsck_desc1', &fstype_name($stat[1]), "<tt>$in{dev}</tt>",
 $cmd = &fsck_command($stat[1], $in{dev});
 print &text('fsck_desc2', "<tt>$cmd</tt>", "<tt>fsck</tt>"),"<p>\n";
 
-print "<form action=fsck.cgi>\n";
-print "<input type=hidden name=cmd value=\"$cmd\">\n";
-print "<input type=hidden name=dev value=\"$in{'dev'}\">\n";
-print "<input type=hidden name=type value=\"$in{'type'}\">\n";
-print "<center><input type=submit value=\"$text{'fsck_repair'}\"></center>\n";
-print "</form>\n";
+print &ui_form_start("fsck.cgi");
+print &ui_hidden("dev", $in{'dev'});
+print &ui_hidden("type", $stat[1]);
+print &ui_form_end([ [ undef, $text{'fsck_repair'} ] ]);
 
 &ui_print_footer("", $text{'index_return'});
 
index 98f0690..c57017e 100755 (executable)
@@ -5,15 +5,21 @@
 require './fdisk-lib.pl';
 &error_setup($text{'index_err'});
 &check_fdisk();
+
+# Work out which disks are accessible
+@disks = &list_disks_partitions();
+@disks = grep { $access{'view'} || &can_edit_disk($_->{'device'}) } @disks;
+if (@disks == 1 && &can_edit_disk($disks[0]->{'device'})) {
+       # Just one .. go direct to it's page
+       &redirect("edit_disk.cgi?device=$disks[0]->{'device'}");
+       edit;
+       }
+
 &ui_print_header(undef, $module_info{'desc'}, "", undef, 0, 1, 0,
        &help_search_link("fdisk", "man", "doc", "howto"));
 $extwidth = 250;
 
 # Show a table of just disks
-$smart = &foreign_installed("smart-status") &&
-        &foreign_available("smart-status");
-@disks = &list_disks_partitions();
-@disks = grep { $access{'view'} || &can_edit_disk($_->{'device'}) } @disks;
 @disks = sort { $a->{'device'} cmp $b->{'device'} } @disks;
 if (@disks) {
        ($hasctrl) = grep { defined($d->{'scsiid'}) ||
@@ -27,6 +33,7 @@ if (@disks) {
                                  $text{'index_dacts'} ]);
        foreach $d (@disks) {
                $ed = &can_edit_disk($d->{'device'});
+               $smart = &supports_smart($d);
                @links = ( );
                @ctrl = ( );
                if (defined($d->{'scsiid'}) && defined($d->{'controller'})) {
@@ -36,13 +43,12 @@ if (@disks) {
                if ($d->{'raid'}) {
                        push(@ctrl, &text('index_draid', $d->{'raid'}));
                        }
-               if (($d->{'type'} eq 'ide' ||
-                   $d->{'type'} eq 'scsi' && $d->{'model'} =~ /ATA/) && $ed) {
+               if ($ed && &supports_hdparm($d)) {
                        # Display link to IDE params form
                        push(@links, "<a href='edit_hdparm.cgi?".
                             "disk=$d->{'index'}'>$text{'index_dhdparm'}</a>");
                        }
-               if ($smart) {
+               if (&supports_smart($d)) {
                        # Display link to smart module
                        push(@links, "<a href='../smart-status/index.cgi?".
                             "drive=$d->{'device'}'>$text{'index_dsmart'}</a>");
index 47a30bc..7f4b771 100644 (file)
@@ -18,8 +18,10 @@ index_end=End
 index_addpri=Add primary partition.
 index_addlog=Add logical partition.
 index_addext=Add extended partition.
-index_hdparm=Edit IDE parameters.
-index_smart=Show SMART status.
+index_hdparm=Edit IDE parameters
+index_hdparmdesc=Change settings for an IDE drive, such as the DMA mode, standby timeout and number of sectors read.
+index_smart=Show SMART status
+index_smartdesc=Displays the status reported by this drive, including temperature and error rates.
 index_use=Use
 index_free=Free
 index_return=disk list
index c45611c..bcb3787 100755 (executable)
@@ -7,21 +7,17 @@ require './fdisk-lib.pl';
 &ui_print_header(undef, $text{'tunefs_title'}, "");
 &ReadParse();
 
-print "<form action=tunefs.cgi>\n";
-print "<input type=hidden name=dev value=\"$in{dev}\">\n";
-print "<input type=hidden name=type value=\"$in{type}\">\n";
-
 @stat = &device_status($in{dev});
 print &text('tunefs_desc', &fstype_name($in{type}), "<tt>$in{dev}</tt>",
            "<tt>$stat[1]</tt>"),"<p>\n";
 
-print "<table border>\n";
-print "<tr $tb><td><b>$text{'tunefs_params'}</b></td> </tr>\n";
-print "<tr $cb><td><table cellpadding=5>\n";
+print &ui_form_start("tunefs.cgi");
+print &ui_hidden("dev", $in{'dev'});
+print &ui_hidden("type", $in{'type'});
+print &ui_table_start($text{'tunefs_params'}, "width=100%", 4);
 &tunefs_options($in{type});
-print "</table></td></tr></table><br>\n";
-
-print "<input type=submit value=\"$text{'tunefs_tune'}\"></form>\n";
+print &ui_table_end();
+print &ui_form_end([ [ undef, $text{'tunefs_tune'} ] ]);
 
 &ui_print_footer("", $text{'index_return'});