Skip to content

Commit

Permalink
Display the compliance alert in tab_inventory #3
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed Dec 19, 2023
1 parent 374f163 commit 3bcaf2e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,19 @@
<div class="d-flex justify-content-center">
{% include 'pagination/object_list_pagination.html' %}
</div>
{% endspaceless %}
{% endspaceless %}

{% if compliance_errors %}
<script>
const tabInventoryLabel = document.getElementById('tab_inventory-tab');
if (tabInventoryLabel) {
var iconElement = document.createElement('i');
iconElement.className = 'fas fa-exclamation-circle text-danger';
iconElement.setAttribute('data-bs-toggle', 'tooltip');
iconElement.setAttribute('title', 'Compliance errors');
tabInventoryLabel.insertBefore(iconElement, tabInventoryLabel.firstChild);
// Initialize the tooltip
new bootstrap.Tooltip(iconElement, { container: 'body' });
}
</script>
{% endif %}
22 changes: 9 additions & 13 deletions product_portfolio/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,19 +662,15 @@ def get_context_data(self, **kwargs):
self.inject_scan_data(scancodeio, objects_by_feature, dataspace.uuid)

# 5. Display the compliance alert based on license policies
# if self.show_licenses_policy:
# compliance_alerts = set(
# alert
# for inventory_item in filtered_inventory_items
# for alert in inventory_item.compliance_alerts
# )
#
# if "error" in compliance_alerts:
# label = (
# f'<i class="fas fa-exclamation-circle text-danger" '
# f' data-bs-toggle="tooltip" '
# f' title="Compliance errors"></i> {label}'
# )
if self.show_licenses_policy:
context["show_licenses_policy"] = True
compliance_alerts = set(
alert
for inventory_item in filtered_inventory_items
for alert in inventory_item.compliance_alerts
)
if "error" in compliance_alerts:
context["compliance_errors"] = True

# 6. Add vulnerability data
vulnerablecode = VulnerableCode(user)
Expand Down

0 comments on commit 3bcaf2e

Please sign in to comment.