From 284f3b0c1cd086be78edfbbb30a0bdc872db4a7f Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 29 Oct 2019 23:07:01 +0100 Subject: [PATCH] TT#66754 Use a hash to map the ngcp status into the different structures Change-Id: Ifc021feeca693b626e37e32d3c23cc272f3032e8 --- .../Widget/Dashboard/AdminSystemOverview.pm | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/NGCP/Panel/Widget/Dashboard/AdminSystemOverview.pm b/lib/NGCP/Panel/Widget/Dashboard/AdminSystemOverview.pm index 2c84e64f07..e73bccf227 100644 --- a/lib/NGCP/Panel/Widget/Dashboard/AdminSystemOverview.pm +++ b/lib/NGCP/Panel/Widget/Dashboard/AdminSystemOverview.pm @@ -41,10 +41,26 @@ sub emergency_mode { sub overall_status { my ($self, $c) = @_; - my $ngcp_status = decode_json(NGCP::Panel::Utils::Statistics::get_ngcp_status()); - return { class => "ngcp-red-error", text => $c->loc("Errors"), data => $ngcp_status->{data} } if ( $ngcp_status->{system_status} eq 'ERRORS' ); - return { class => "ngcp-orange-warning", text => $c->loc("Warnings"), , data => $ngcp_status->{data} } if ( $ngcp_status->{system_status} eq 'WARNINGS' ); - return { class => "ngcp-green-ok", text => $c->loc("All services running") }; + my $report = decode_json(NGCP::Panel::Utils::Statistics::get_ngcp_status()); + + my %status_map = ( + ERRORS => { + class => 'ngcp-red-error', + text => $c->loc('Errors'), + }, + WARNINGS => { + class => 'ngcp-orange-warning', + text => $c->loc('Warnings'), + }, + OK => { + class => 'ngcp-green-ok', + text => $c->loc('All services running'), + }, + ); + my $status = $status_map{$report->{system_status}}; + $status->{data} = $report->{data} if $report->{system_status} ne 'OK'; + + return $status; } 1;