TT#66754 Use a hash to map the ngcp status into the different structures

Change-Id: Ifc021feeca693b626e37e32d3c23cc272f3032e8
changes/86/34786/3
Guillem Jover 7 years ago
parent 34d8db19ce
commit 284f3b0c1c

@ -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;

Loading…
Cancel
Save