From 194dc6a26f3dbba4ad0b7205677258fc71b7b003 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 21 Mar 2022 19:39:52 +0100 Subject: [PATCH] TT#167050 Switch system statistics dashboard status to new problems JSON The ngcp-collective-check now produces a more semantic JSON key. This should allow to produce more organized problems reporting on the panels, and will allow to remove the old messy keys. Change-Id: I302eb7927adf70e33a88ef231b477fc7111c4371 --- .../Widget/Dashboard/AdminSystemOverview.pm | 11 ++++++----- .../widgets/admin_system_overview.tt | 19 ++++++++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/NGCP/Panel/Widget/Dashboard/AdminSystemOverview.pm b/lib/NGCP/Panel/Widget/Dashboard/AdminSystemOverview.pm index 668a7880c4..90b32ea4d0 100644 --- a/lib/NGCP/Panel/Widget/Dashboard/AdminSystemOverview.pm +++ b/lib/NGCP/Panel/Widget/Dashboard/AdminSystemOverview.pm @@ -43,22 +43,23 @@ sub overall_status { my $report = decode_json(NGCP::Panel::Utils::Statistics::get_ngcp_status()); + my $status_level = lc $report->{system_status}; my %status_map = ( - ERRORS => { + errors => { class => 'ngcp-red-error', text => $c->loc('Errors'), }, - WARNINGS => { + warnings => { class => 'ngcp-orange-warning', text => $c->loc('Warnings'), }, - OK => { + ok => { class => 'ngcp-green-ok', text => $c->loc('All services running'), }, ); - my $status = $status_map{$report->{system_status}}; - $status->{data} = $report->{checks} if $report->{system_status} ne 'OK'; + my $status = $status_map{$status_level}; + $status->{problems} = $report->{problems} if $status_level ne 'ok'; return $status; } diff --git a/share/templates/widgets/admin_system_overview.tt b/share/templates/widgets/admin_system_overview.tt index ffe4ae1fb2..8c57bbbb0c 100644 --- a/share/templates/widgets/admin_system_overview.tt +++ b/share/templates/widgets/admin_system_overview.tt @@ -16,7 +16,7 @@ enqueLists.push([{ //console.log(data); var txt = data.widget_data.text; var cls = data.widget_data.class; - var ngcp_status = data.widget_data.data; + var problems = data.widget_data.problems; $("#admin_system_overview_lazy_loading").remove(); $("#admin_system_overview_lazy_items_header").append( '
' + @@ -26,7 +26,7 @@ enqueLists.push([{ $("#admin_system_overview_lazy_items_list").prepend( '
  • [% c.loc('Status') %]:
  • ' ); - if (ngcp_status) { + if (problems) { $("#status_text").append( '' + txt + '' ); @@ -34,12 +34,17 @@ enqueLists.push([{ else{ $("#status_text").append(txt); } - $.each( ngcp_status, function( i, val ) { - $("#statistics_modal_content").append( "

    " + val.title + "

    " ); - $.each( val.messages, function( i, message ) { - $("#statistics_modal_content").append( "

    " + message + "

    " ); + for (var type in problems) { + var last_host = "none"; + $("#statistics_modal_content").append( "

    " + type + " problems detected

    " ); + $.each( problems[type], function( i, problem ) { + if (type == "node" && last_host != problem.host) { + $("#statistics_modal_content").append( "

    node " + problem.host + " in cluster blade " + problem.blade + "

    " ); + last_host = problem.host; + } + $("#statistics_modal_content").append( "

    service " + problem.service + ": " + problem.error + "

    " ); }); - }); + } } }]);