From becbd719cde959c95fd3808f7ddea6e9066f3360 Mon Sep 17 00:00:00 2001 From: Eric Kao Date: Wed, 2 Aug 2017 15:25:00 -0700 Subject: [PATCH] Suppress 0s in monitoring pane rows Do not set value to 0 and do not add rows without non-zero value. Also fix javascript in template to avoid coloring 'No items to display.' With the following rules: $ openstack congress policy rule create action 'warning(x) :- blah(x)' $ openstack congress policy rule create classification 'blah(x) :- error(x)' Monitoring pane pre-patch shows rows of zero warning/error screenshot: https://imagebin.ca/v/3VXCVtZxXYUQ rows suppressed post-patch. screenshot: https://imagebin.ca/v/3VXX9g34QOGf Closes-Bug: 1708294 Change-Id: I56adc4da430e3e1e15bd31c42fe3f7bce996dcd0 --- congress_dashboard/datasources/utils.py | 6 ++++-- .../monitoring/templates/monitoring/index.html | 14 ++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/congress_dashboard/datasources/utils.py b/congress_dashboard/datasources/utils.py index 3a8f7d2..4ab1f9e 100644 --- a/congress_dashboard/datasources/utils.py +++ b/congress_dashboard/datasources/utils.py @@ -98,8 +98,10 @@ def get_policy_violations_data(request): row.set_policy_details(policy) for t in tables: rows = congress.policy_rows_list(request, policy['name'], t) - row.set_value(t, len(rows)) - violations_table.append(row) + if len(rows) > 0: + row.set_value(t, len(rows)) + if row.get('error') or row.get('warning'): + violations_table.append(row) return violations_table diff --git a/congress_dashboard/monitoring/templates/monitoring/index.html b/congress_dashboard/monitoring/templates/monitoring/index.html index 16b404d..149e3f5 100644 --- a/congress_dashboard/monitoring/templates/monitoring/index.html +++ b/congress_dashboard/monitoring/templates/monitoring/index.html @@ -31,16 +31,18 @@ {{ monitoring_table.render }}