Complete support for showing warnings on right frame

This commit is contained in:
Jamie Cameron
2014-12-17 14:54:09 -08:00
parent 5eb9821920
commit dc4ea2a94d
3 changed files with 60 additions and 25 deletions

View File

@@ -10,6 +10,14 @@ our ($current_theme);
our %text = &load_language($current_theme);
my $bar_width = 300;
# Get system info to show
my @info = &list_combined_system_info();
my ($redir) = grep { $_->{'type'} eq 'redirect' } @info;
if ($redir) {
&redirect($redir->{'url'});
return;
}
my $prehead = defined(&WebminCore::theme_prehead) ?
&capture_function_output(\&WebminCore::theme_prehead) : "";
&popup_header(undef, $prehead);
@@ -20,36 +28,50 @@ if (&get_product_name() eq 'webmin') {
print "<a href=http://www.webmin.com/ target=_new><img src=images/webmin-blue.png border=0></a><p>\n";
}
# Get system info to show
my @info = &list_combined_system_info();
# Show notifications first
@info = sort { ($b->{'type'} eq 'warning') <=> ($a->{'type'} eq 'warning') }
@info;
foreach my $info (@info) {
print &ui_table_start($info->{'desc'}, "width=600", 2);
if ($info->{'type'} eq 'table') {
# A table of various labels and values
foreach my $t (@{$info->{'table'}}) {
my $chart = "";
if ($t->{'chart'}) {
my $chart = &make_bar_chart($t->{'chart'});
$chart = "<br>".$chart;
if ($info->{'type'} eq 'warning') {
print &ui_alert_box($info->{'warning'},
$info->{'level'} || 'warn');
}
else {
print &ui_table_start($info->{'desc'}, "width=600", 2);
if ($info->{'type'} eq 'table') {
# A table of various labels and values
foreach my $t (@{$info->{'table'}}) {
my $chart = "";
if ($t->{'chart'}) {
my $chart = &make_bar_chart(
$t->{'chart'});
$chart = "<br>".$chart;
}
print &ui_table_row($t->{'desc'},
$t->{'value'}.$chart);
}
print &ui_table_row($t->{'desc'}, $t->{'value'}.$chart);
}
}
elsif ($info->{'type'} eq 'chart') {
# A table of graphs
my $ctable = &ui_columns_start($info->{'titles'});
foreach my $t (@{$info->{'chart'}}) {
$ctable .= &ui_columns_row([
$t->{'desc'},
&make_bar_chart($t->{'chart'}),
$t->{'value'},
]);
elsif ($info->{'type'} eq 'chart') {
# A table of graphs
my $ctable = &ui_columns_start($info->{'titles'});
foreach my $t (@{$info->{'chart'}}) {
$ctable .= &ui_columns_row([
$t->{'desc'},
&make_bar_chart($t->{'chart'}),
$t->{'value'},
]);
}
$ctable .= &ui_columns_end();
print &ui_table_row(undef, $ctable, 2);
}
$ctable .= &ui_columns_end();
print &ui_table_row(undef, $ctable, 2);
elsif ($info->{'type'} eq 'html') {
# A chunk of HTML
print &ui_table_row(undef, $info->{'html'}, 2);
}
print &ui_table_end();
print "<p>\n";
}
print &ui_table_end();
}
print "</center>\n";

View File

@@ -2386,7 +2386,7 @@ Type of alert:
=item info - blue
=item warning - yellow
=item warn - yellow
=item danger - red

View File

@@ -10131,6 +10131,9 @@ to display. Each is a hash ref with the following keys :
=item warning - In "warning" mode, the HTML warning message
=item level - In "warning" mode, can be one of "success", "info", "warn" or
"danger"
For "table" mode, the keys in each hash ref are :
=item desc - Label for this item
@@ -10173,6 +10176,16 @@ foreach my $m (&get_available_module_infos()) {
push(@rv, $i);
}
}
if (&foreign_available("webmin")) {
# Merge in old-style notification API
&foreign_require("webmin");
foreach my $n (&webmin::get_webmin_notifications()) {
push(@rv, { 'type' => 'warning',
'level' => 'info',
'module' => 'webmin',
'warning' => $n });
}
}
return sort { ($b->{'priority'} || 0) <=> ($a->{'priority'} || 0) } @rv;
}