From 6d50571d208d7578a46e7e7a0fea2156aa1d23d8 Mon Sep 17 00:00:00 2001 From: Flaviu Mates Date: Thu, 26 Sep 2019 00:04:01 +0300 Subject: [PATCH] TT#66754 - Implement panel statistics * Retrieve statistics details from ngcp-collective-check * Restore statistics widget to display either "All services running", "Errors" or "Warnings" according to collective- check result * Create pop-up modal to display ngcp- collective-check results Change-Id: I094a51ad1905d2bf968775dd43480c94a7a440b8 --- lib/NGCP/Panel/Utils/Statistics.pm | 5 ++ .../Widget/Dashboard/AdminSystemOverview.pm | 21 ++++---- share/static/css/main.css | 8 ++++ share/templates/dashboard.tt | 2 +- .../widgets/admin_system_overview.tt | 48 +++++++++++-------- 5 files changed, 49 insertions(+), 35 deletions(-) diff --git a/lib/NGCP/Panel/Utils/Statistics.pm b/lib/NGCP/Panel/Utils/Statistics.pm index 6936c18e0a..a00dfab044 100644 --- a/lib/NGCP/Panel/Utils/Statistics.pm +++ b/lib/NGCP/Panel/Utils/Statistics.pm @@ -86,6 +86,11 @@ sub get_dpkg_support_status { } } +sub get_ngcp_status { + my ($self) = @_; + return `/usr/sbin/ngcp-collective-check json`; +} + 1; # vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Widget/Dashboard/AdminSystemOverview.pm b/lib/NGCP/Panel/Widget/Dashboard/AdminSystemOverview.pm index 75d6a2f4c1..a8684d9d92 100644 --- a/lib/NGCP/Panel/Widget/Dashboard/AdminSystemOverview.pm +++ b/lib/NGCP/Panel/Widget/Dashboard/AdminSystemOverview.pm @@ -4,11 +4,12 @@ use warnings; use strict; use NGCP::Panel::Utils::Preferences; +use NGCP::Panel::Utils::Statistics; +use JSON qw(decode_json); sub template { - # disabled - #return 'widgets/admin_system_overview.tt'; - return; + return unless ( -e '/usr/sbin/ngcp-collective-check' ); + return 'widgets/admin_system_overview.tt'; } sub filter { @@ -37,18 +38,12 @@ sub emergency_mode { return $em_count.''; } -sub system_status { - my ($self, $c) = @_; - return { color => "#000000", text => $c->loc("OK") }; -} - -sub hardware { - my ($self, $c) = @_; - return { color => "#000000", text => $c->loc("OK") }; -} - 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") }; } diff --git a/share/static/css/main.css b/share/static/css/main.css index 5ab995050b..f1152ee49b 100644 --- a/share/static/css/main.css +++ b/share/static/css/main.css @@ -503,6 +503,14 @@ div.ngcp-modal .control-group.error .dataTables_wrapper input[type="text"] { color:#0f0; } +.plan .ngcp-orange-warning { + color:#ff6700; +} + +.plan .ngcp-red-error { + color:#ff0000; +} + .ngcp-quickform div.form-actions { padding-left: 0px; } diff --git a/share/templates/dashboard.tt b/share/templates/dashboard.tt index e18ef04482..96b6a5287d 100644 --- a/share/templates/dashboard.tt +++ b/share/templates/dashboard.tt @@ -29,7 +29,7 @@ $(document).ready(function () { [% enabled_widgets.push(w) -%] [% END -%] [% END -%] -[% wcount = enabled_widgets.size() > 3 ? 3 : enabled_widgets.size() -%] +[% wcount = enabled_widgets.size() > 4 ? 4 : enabled_widgets.size() -%]
diff --git a/share/templates/widgets/admin_system_overview.tt b/share/templates/widgets/admin_system_overview.tt index ced829ebd2..9ae048f09f 100644 --- a/share/templates/widgets/admin_system_overview.tt +++ b/share/templates/widgets/admin_system_overview.tt @@ -8,37 +8,31 @@ enqueLists.push([{ var col = (data.widget_data > 0 ? "#FFC200" : "#000"); $("#admin_system_overview_lazy_items_list").prepend('
  • [% c.loc('Applications') %] ' + txt + '
  • '); } -},{ - res: 'system_status', - widgetName: "AdminSystemOverview", - cb: function(data) { - //console.log(data); - var txt = data.widget_data.text; - var col = data.widget_data.color; - $("#admin_system_overview_lazy_items_list").append('
  • [% c.escape_js(c.loc('System')) %] ' + txt + '
  • '); - } -},{ - res: 'hardware', - widgetName: "AdminSystemOverview", - cb: function(data) { - //console.log(data); - var txt = data.widget_data.text; - var col = data.widget_data.color; - $("#admin_system_overview_lazy_items_list").append('
  • [% c.escape_js(c.loc('Hardware')) %] ' + txt + '
  • '); - } -},{ +}, +{ res: 'overall_status', widgetName: "AdminSystemOverview", cb: function(data) { //console.log(data); var txt = data.widget_data.text; var cls = data.widget_data.class; + var ngcp_status = data.widget_data.data; $("#admin_system_overview_lazy_loading").remove(); $("#admin_system_overview_lazy_items_header").append( '
    ' + '' + - '' + txt + '' + + '' + '
    '); + $("#admin_system_overview_lazy_items_list").prepend( + '
  • [% c.loc('Status') %]: ' + txt + ' ' + + '(details)
  • ' + ); + $.each( ngcp_status, function( i, val ) { + $("#statistics_modal_content").append( "

    " + val.title + "

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

    " + message + "

    " ); + }); + }); } }]); @@ -54,8 +48,20 @@ enqueLists.push([{
    + + [% # vim: set tabstop=4 syntax=html expandtab: -%]