Add an option to choose between KiB, MiB, GiB and KB, MB, GB units

This commit is contained in:
Ilia Rostovtsev 2019-10-22 14:02:46 +03:00
parent eb412a1084
commit 1bf4b1e8ce
No known key found for this signature in database
GPG Key ID: 121E166DD9C821AB
4 changed files with 11 additions and 1 deletions

View File

@ -8691,10 +8691,14 @@ sub nice_size
{
my ($bytes, $minimal, $decimal) = @_;
&load_theme_library();
if ($gconfig{'nicesizenobinary'} eq '1' && !$decimal) {
$decimal = 1;
$_[2] = 1;
}
if (defined(&theme_nice_size) &&
$main::header_content_type eq "text/html" &&
$main::webmin_script_type eq "web") {
return &theme_nice_size(@_);
return &theme_nice_size($_[0], $_[1], $_[2]);
}
my ($decimal_units, $binary_units) = (1000, 1024);
my $bytes_initial = $bytes;

View File

@ -25,6 +25,7 @@ $in{'hostnamemode'} != 3 || $in{'hostnamedisplay'} =~ /^[a-z0-9\.\_\-]+$/i ||
$gconfig{'hostnamedisplay'} = $in{'hostnamedisplay'};
$gconfig{'feedback_to'} = $in{'feedback_def'} ? undef : $in{'feedback'};
$gconfig{'nofeedbackcc'} = $in{'nofeedbackcc'};
$gconfig{'nicesizenobinary'} = $in{'nicesizenobinary'};
$gconfig{'dateformat'} = $in{'dateformat'};
$in{'width_def'} || $in{'width'} =~ /^\d+$/ || &error($text{'ui_ewidth'});

View File

@ -41,6 +41,10 @@ print &ui_table_row($text{'ui_feedbackmode'},
[ [ 0, $text{'yes'} ], [ 1, $text{'ui_feednocc'} ],
[ 2, $text{'no'} ] ]), undef, [ "valign=middle","valign=middle" ]);
print &ui_table_row($text{'ui_nice_size_type'},
&ui_radio("nicesizenobinary", int($gconfig{'nicesizenobinary'}),
[ [ 0, $text{'yes'} ], [ 1, $text{'no'} ] ]), undef, [ "valign=middle","valign=middle" ]);
print &ui_table_row($text{'ui_dateformat'},
&ui_select("dateformat", $gconfig{'dateformat'} || "dd/mon/yyyy",
[ map { [ $_, $text{'ui_dateformat_'.$_} ] }

View File

@ -160,6 +160,7 @@ ui_err=Failed to save user interface options
ui_ergb=Invalid hexidecimal color value for '$1'
ui_feedback=Send feedback to
ui_feedbackmode=Allow sending of feedback?
ui_nice_size_type=Use binary units of measurement (KiB, MiB, GiB rather than KB, MB, GB)
ui_feednocc=Only to address above
ui_hostnamemode=Hostname to display in Webmin
ui_hnm0=Real hostname