diff --git a/gray-theme/right.cgi b/gray-theme/right.cgi index fcbe6e36d..30ab3a283 100755 --- a/gray-theme/right.cgi +++ b/gray-theme/right.cgi @@ -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 "

\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 = "
".$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 = "
".$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 "

\n"; } - print &ui_table_end(); } print "\n"; diff --git a/ui-lib.pl b/ui-lib.pl index e6e354c87..88d222484 100755 --- a/ui-lib.pl +++ b/ui-lib.pl @@ -2386,7 +2386,7 @@ Type of alert: =item info - blue -=item warning - yellow +=item warn - yellow =item danger - red diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl index c75ffd8d8..9a5e3e9d8 100755 --- a/web-lib-funcs.pl +++ b/web-lib-funcs.pl @@ -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; }