From a929d773ca0ef8566c99fc6093cd559bcd7fd09f Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sun, 6 Jan 2008 02:02:33 +0000 Subject: [PATCH] Front page ui-lib-ification and re-design --- lvm/CHANGELOG | 2 + lvm/config | 1 + lvm/config.info | 1 + lvm/index.cgi | 233 +++++++++++++++++++++++++++++++++++------------- lvm/lang/en | 24 ++++- lvm/lvm-lib.pl | 2 + 6 files changed, 200 insertions(+), 63 deletions(-) create mode 100644 lvm/config create mode 100644 lvm/config.info diff --git a/lvm/CHANGELOG b/lvm/CHANGELOG index 78e2c0c97..f108c44f9 100644 --- a/lvm/CHANGELOG +++ b/lvm/CHANGELOG @@ -6,3 +6,5 @@ Added support for LVM2, as used in the new 2.6 Linux kernel. When viewing a physical volume, the space used by each logical volume on it is displayed. Similarly, when viewing a logical volume, the amount of space contributed by each physical volume is displayed. ---- Changes since 1.290 ---- Fixed display of space used on each physical volume by a logical volume for LVM version 2. +---- Changes since 1.390 ---- +Re-designed the module's main page to use tabs, and added an option to show volumes and groups in tables (with more information) instead of using icons. diff --git a/lvm/config b/lvm/config new file mode 100644 index 000000000..926b8764f --- /dev/null +++ b/lvm/config @@ -0,0 +1 @@ +show_table=0 diff --git a/lvm/config.info b/lvm/config.info new file mode 100644 index 000000000..7f5338255 --- /dev/null +++ b/lvm/config.info @@ -0,0 +1 @@ +show_table=Show volumes and groups as,1,1-Table,0-Icons diff --git a/lvm/index.cgi b/lvm/index.cgi index 32b16030a..86a895dee 100755 --- a/lvm/index.cgi +++ b/lvm/index.cgi @@ -3,10 +3,11 @@ # Display a table of all volumne groups and their physical and logical volumes. require './lvm-lib.pl'; +&ReadParse(); if (!&has_command("vgdisplay")) { &lvm_header(); - print "

",&text('index_ecommands', "vgdisplay"),"

\n"; + print &text('index_ecommands', "vgdisplay"),"

\n"; &ui_print_footer("/", $text{'index'}); exit; } @@ -18,7 +19,7 @@ if ($lvm_version && $lvm_version < 2) { } if (!-d $lvm_proc) { &lvm_header(); - print "

",&text('index_emodule', "$lvm_proc", + print &text('index_emodule', "$lvm_proc", "lvm-mod"),"

\n"; &ui_print_footer("/", $text{'index'}); exit; @@ -26,76 +27,184 @@ if ($lvm_version && $lvm_version < 2) { } if (!$lvm_version) { &lvm_header(); - print "

",&text('index_eversion', "vgdisplay --version", + print &text('index_eversion', "vgdisplay --version", "

$out
"),"

\n"; &ui_print_footer("/", $text{'index'}); exit; } &lvm_header(); -# Show table of volume groups @vgs = &list_volume_groups(); if (@vgs) { - print "\n"; - print " ", - " ", - "\n"; - foreach $v (sort { $a->{'number'} <=> $b->{'number'} } @vgs) { - # Show volume group icon - print "\n"; + print &ui_columns_end(); } - print "
$text{'index_vgs'}$text{'index_pvs'}$text{'index_lvs'}
\n"; - &icons_table( [ "edit_vg.cgi?vg=".&urlize($v->{'name'}) ], - [ &html_escape($v->{'name'}). - "
".&nice_size($v->{'size'}*1024) ], - [ "images/vg.gif" ], 1); - print &ui_links_row([ - "$text{'index_add'}" ]); - print "
\n"; + # Start tabs for volume groups, physical volumes and logical volumes + @tabs = ( [ 'vgs', $text{'index_vgs'}, 'index.cgi?mode=vgs' ], + [ 'pvs', $text{'index_pvs'}, 'index.cgi?mode=pvs' ], + [ 'lvs', $text{'index_lvs'}, 'index.cgi?mode=lvs' ] ); + print &ui_tabs_start(\@tabs, "mode", $in{'mode'} || 'vgs', 1); - # Show physical volume icons - local @pvs = sort { $a->{'number'} <=> $b->{'number'} } - &list_physical_volumes($v->{'name'}); - if (@pvs) { - local (@icons, @titles, @links); - @icons = map { "images/pv.gif" } @pvs; - @titles = map { &html_escape($_->{'device'}). - "
".&nice_size($_->{'size'}*1024) } @pvs; - @links = map { "edit_pv.cgi?vg=".&urlize($v->{'name'}). - "&pv=".&urlize($_->{'name'}) } @pvs; - &icons_table(\@links, \@titles, \@icons, 3); + # Show volume groups + print &ui_tabs_start_tab("mode", "vgs"); + print $text{'index_vgsdesc'},"

\n"; + @vgs = sort { $a->{'number'} <=> $b->{'number'} } @vgs; + @links = ( "$text{'index_add'}" ); + if ($config{'show_table'}) { + # As table + print &ui_links_row(\@links); + print &ui_columns_start([ $text{'index_vgname'}, + $text{'index_vgsize'}, + $text{'index_vgtotal'}, + $text{'index_vgtotal2'} ], 100); + foreach $v (@vgs) { + print &ui_columns_row([ + "". + &html_escape($v->{'name'})."", + &nice_size($v->{'size'}*1024), + &text('lv_petotals', $v->{'pe_alloc'}, + $v->{'pe_total'}), + &text('lv_petotals', + &nice_size($v->{'pe_alloc'}*$v->{'pe_size'}*1024), + &nice_size($v->{'pe_total'}*$v->{'pe_size'}*1024)) + ]); } - else { - print "$text{'index_nopvs'}

\n"; - } - print &ui_links_row([ - "$text{'index_addpv'}" ]); - - # Show logical volume icons - print "

\n"; - local @lvs = sort { $a->{'number'} <=> $b->{'number'} } - &list_logical_volumes($v->{'name'}); - if (@lvs) { - @icons = map { $_->{'is_snap'} ? "images/snap.gif" - : "images/lv.gif" } @lvs; - @titles = map { &html_escape($_->{'name'}). - "
".&nice_size($_->{'size'}*1024) } @lvs; - @links = map { "edit_lv.cgi?vg=".&urlize($v->{'name'}). - "&lv=".&urlize($_->{'name'}) } @lvs; - &icons_table(\@links, \@titles, \@icons, 3); - } - else { - print "$text{'index_nolvs'}

\n"; - } - print &ui_links_row([ - "$text{'index_addlv'}", - @lvs ? ( - "$text{'index_addsnap'}" ) : ( ) - ]); - print "

\n"; + else { + # As icons + print &ui_links_row(\@links); + foreach $v (@vgs) { + push(@vgicons, "edit_vg.cgi?vg=".&urlize($v->{'name'})); + push(@vgtitles, &html_escape($v->{'name'}). + "
".&nice_size($v->{'size'}*1024)); + push(@vglinks, "images/vg.gif"); + } + &icons_table(\@vgicons, \@vgtitles, \@vglinks); + } + print &ui_links_row(\@links); + print &ui_tabs_end_tab(); + + # Show physical volumes + print &ui_tabs_start_tab("mode", "pvs"); + print $text{'index_pvsdesc'},"

\n"; + foreach $v (@vgs) { + push(@allpvs, &list_physical_volumes($v->{'name'})); + } + @allpvs = sort { $a->{'name'} cmp $b->{'name'} } @allpvs; + @links = ( ); + foreach $v (@vgs) { + push(@links, "".&text('index_addpv2', $v->{'name'}).""); + } + if (!@allpvs) { + # None yet + print "$text{'index_nopvs2'}

\n"; + } + elsif ($config{'show_table'}) { + # Show table of PVs + print &ui_links_row(\@links); + print &ui_columns_start([ $text{'index_pvname'}, + $text{'index_pvvg'}, + $text{'index_pvsize'}, + $text{'index_pvtotal'}, + $text{'index_pvtotal2'} ], 100); + foreach $p (@allpvs) { + ($v) = grep { $_->{'name'} eq $p->{'vg'} } @vgs; + print &ui_columns_row([ + "$p->{'name'}", + $v->{'name'}, + &nice_size($p->{'size'}*1024), + &text('lv_petotals', $p->{'pe_alloc'}, + $p->{'pe_total'}), + &text('lv_petotals', + &nice_size($p->{'pe_alloc'}*$p->{'pe_size'}*1024), + &nice_size($p->{'pe_total'}*$p->{'pe_size'}*1024)), + ]); + } + print &ui_columns_end(); + } + else { + # Show PV icons + print &ui_links_row(\@links); + foreach $p (@allpvs) { + ($v) = grep { $_->{'name'} eq $p->{'vg'} } @vgs; + push(@pvicons, "edit_pv.cgi?vg=".&urlize($v->{'name'}). + "&pv=".&urlize($p->{'name'})); + push(@pvtitles, &html_escape($p->{'name'}). + "
".&nice_size($p->{'size'}*1024)); + push(@pvlinks, "images/vg.gif"); + } + &icons_table(\@pvicons, \@pvtitles, \@pvlinks); + } + print &ui_links_row(\@links); + print &ui_tabs_end_tab(); + + # Show logical volumes + print &ui_tabs_start_tab("mode", "lvs"); + print $text{'index_lvsdesc'},"

\n"; + foreach $v (@vgs) { + push(@alllvs, &list_logical_volumes($v->{'name'})); + } + @alllvs = sort { $a->{'name'} cmp $b->{'name'} } @alllvs; + @links = ( ); + foreach $v (@vgs) { + push(@links, "".&text('index_addlv2', $v->{'name'}).""); + push(@links, "".&text('index_addlv2s', $v->{'name'}).""); + } + if (!@alllvs) { + # None yet + print "$text{'index_nolvs2'}

\n"; + } + elsif ($config{'show_table'}) { + # Show table of LVs + print &ui_links_row(\@links); + print &ui_columns_start([ $text{'index_lvname'}, + $text{'index_lvvg'}, + $text{'index_lvsize'}, + $text{'index_lvuse'} ], 100); + foreach $l (@alllvs) { + ($v) = grep { $_->{'name'} eq $l->{'vg'} } @vgs; + if ($lv->{'is_snap'}) { + ($snapof) = grep { + $_->{'size'} == $l->{'size'} && + $_->{'vg'} eq $l->{'vg'} && + $_->{'has_snap'} } @alllvs; + } + else { + $snapof = undef; + } + @stat = &device_status($l->{'device'}); + print &ui_columns_row([ + "$l->{'name'}", + $v->{'name'}, + &nice_size($l->{'size'}*1024), + (@stat ? &device_message(@stat) : undef). + ($snap ? " ".&text('index_snapof', $snap->{'name'}) + : ""), + ]); + } + print &ui_columns_end(); + } + else { + # Show PV icons + print &ui_links_row(\@links); + foreach $l (@alllvs) { + ($v) = grep { $_->{'name'} eq $l->{'vg'} } @vgs; + push(@lvicons, "edit_lv.cgi?vg=".&urlize($v->{'name'}). + "&lv=".&urlize($l->{'name'})); + push(@lvtitles, &html_escape($l->{'name'}). + "
".&nice_size($l->{'size'}*1024)); + push(@lvlinks, "images/lv.gif"); + } + &icons_table(\@lvicons, \@lvtitles, \@lvlinks); + } + print &ui_links_row(\@links); + print &ui_tabs_end_tab(); + + print &ui_tabs_end(1); } else { print "$text{'index_none'}

\n"; @@ -112,7 +221,7 @@ else { sub lvm_header { -&ui_print_header(undef, $text{'index_title'}, "", undef, 0, 1, 0, +&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, &help_search_link("lvm", "man", "doc", "google"), undef, undef, $lvm_version ? &text('index_version', $lvm_version) : undef); } diff --git a/lvm/lang/en b/lvm/lang/en index 5a5e11bc6..cf2d38e81 100644 --- a/lvm/lang/en +++ b/lvm/lang/en @@ -8,13 +8,35 @@ index_none=No volume groups were found on your system. index_add=Add a new volume group. index_nolvs=This volume group has
no logical volumes yet. index_nopvs=This volume group has
no physical volumes yet. -index_addpv=Add a physical volume to the group. +i2ndex_addpv=Add a physical volume to the group. +index_addpv2=Add a physical volume to $1. +index_addlv2=Create a logical volume in $1. +index_addlv2s=Create a snapshot in $1. index_addlv=Create a new logical volume. index_addsnap=Create a new snapshot. index_return=volume groups index_init=This may be because LVM has not been activated yet. Activate it now to view all volume groups. index_eversion=Webmin only supports LVM versions 1.0 and above. The output from $1 on your system was : $2 index_version=LVM version $1 +index_vgname=Volume group name +index_vgsize=Total size +index_vgtotal=Blocks used +index_vgtotal2=Size used +index_nopvs2=No physical volumes have been added to any volume groups yet. +index_nolvs2=No logical volumes have been created from any volume groups yet. +index_pvname=Physical volume device +index_pvvg=In volume group +index_pvsize=Device size +index_pvtotal=Blocks used +index_pvtotal2=Size used +index_vgsdesc=A volume group is a set of disks that can be allocated to one or more logical volumes. Most systems will have only one. +index_pvsdesc=A physical volume is a disk partition or RAID device that is part of a volume group. Its disk space can then be used by one or more logical volumes. +index_lvsdesc=A logical volume is a virtual partition created from the combined disk space of a volume group. Each can have a filesystem which is then mounted to store files. +index_lvname=Logical volume +index_lvvg=Volume group +index_lvsize=Size +index_lvuse=Used for +index_snapof=(Snapshot of $1) lv_edit=Edit Logical Volume lv_edit_snap=Edit Snapshot diff --git a/lvm/lvm-lib.pl b/lvm/lvm-lib.pl index 819b560fc..debae614a 100644 --- a/lvm/lvm-lib.pl +++ b/lvm/lvm-lib.pl @@ -42,6 +42,7 @@ if (-d $lvm_proc) { else { # Use pvdisplay command local $pv; + local $_; open(DISPLAY, "pvdisplay |"); while() { s/\r|\n//g; @@ -258,6 +259,7 @@ if (-d $lvm_proc) { else { # Use the lvdisplay command local $lv; + local $_; open(DISPLAY, "lvdisplay |"); while() { s/\r|\n//g;