Add support for displaying disk info on Dashboard

This commit is contained in:
Ilia Rostovtsev
2019-03-09 00:04:31 +03:00
parent e875c791fc
commit f2cbf0f001
5 changed files with 61 additions and 1 deletions

View File

@@ -33,7 +33,10 @@ print "<tr> <td><b>$text{'acl_browse'}</b></td>\n";
print "<td>",&ui_radio("browse", $_[0]->{'browse'},
[ [ 1, $text{'yes'} ], [ 0, $text{'no'} ] ]),"</td>\n";
print "</tr>\n";
print "<td><b>$text{'acl_sysinfo'}</b></td>\n";
print "<td>",&ui_radio("sysinfo", $_[0]->{'sysinfo'},
[ [ 1, $text{'yes'} ], [ 0, $text{'no'} ] ]),"</td> </tr>\n";
}
# acl_security_save(&options)
@@ -47,5 +50,6 @@ $_[0]->{'create'} = $in{'create'};
$_[0]->{'user'} = $in{'user'};
$_[0]->{'hide'} = $in{'hide'};
$_[0]->{'browse'} = $in{'browse'};
$_[0]->{'sysinfo'} = $in{'sysinfo'};
}

View File

@@ -5,6 +5,7 @@ long_fstypes=Show long filesystem type names,1,1-Yes,0-No
sort_mode=Sort filesystems by,1,2-Mount point,1-Type,0-Order in files
show_used=Show used disk space in filesystems list,1,1-Yes,0-No
delete_under=Delete directory when un-mounting if under,3,Never delete
sysinfo=Show available disk data on Dashboard?,1,1-Yes,0-No
line2=System configuration,11
fstab_file=File listing filesystems mounted at boot time,0
auto_file=NFS automounts file,3

View File

@@ -4,3 +4,4 @@ noconfig=0
user=0
hide=0
browse=1
sysinfo=1

View File

@@ -495,4 +495,8 @@ freebsd_edevfile=The device file '$1' does not exist
cswap_file=The swap file $1 does not exist.
cswap_size=Create and mount a swap file with size
acl_sysinfo=Show available disk data on Dashboard?
sysinfo_total=Total
sysinfo_dev=Device ID
__norefs=1

50
mount/system_info.pl Normal file
View File

@@ -0,0 +1,50 @@
do 'mount-lib.pl';
sub list_system_info
{
my $can = &foreign_available($module_name) && $access{'sysinfo'};
if ((length($config{'sysinfo'}) && !$config{'sysinfo'}) || !$can) {
return ();
}
my @disk_space = defined(&mount::local_disk_space) ? mount::local_disk_space() : ();
my $desc = ucwords($text{'edit_usage'});
my $html;
if (@disk_space) {
$html = ui_columns_start(
[ucwords($text{'index_dir'}), ucwords($text{'index_type'}),
ucwords($text{'edit_free'}), ucwords($text{'sysinfo_total'}),
ucwords($text{'sysinfo_dev'}),
]);
foreach my $disks (@disk_space) {
if (ref($disks)) {
foreach my $disk (@$disks) {
my $dev_id = $disk->{'device'};
my $dir = $disk->{'dir'};
my $type = $disk->{'type'};
my $total = $disk->{'total'};
my $total_nice = nice_size($disk->{'total'});
my $free = $disk->{'free'};
my $free_nice = nice_size($disk->{'free'});
my $free_percent = int(($total - $free) / $total * 100);
$html .= ui_columns_row([$dir, $type, $free_percent . "% ($free_nice)", $total_nice, $dev_id,]);
}
}
}
$html .= ui_columns_end();
}
return (
{ 'type' => 'html',
'desc' => $desc,
'open' => 1,
'id' => $module_name . '_disks_info',
'html' => $html
});
}
sub ucwords
{
$_[0] =~ s/(\w+)/\u$1/g;
return $_[0];
}