-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filter for category in region card Before: After: Reviewed-by: Vladimir Hasko <[email protected]>
- Loading branch information
1 parent
c606677
commit 5ea648a
Showing
1 changed file
with
28 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
<div class="container row row-cols-1 row-cols-md-3 g-4"> | ||
{% set categories = component_attributes.get_unique_values("category") %} | ||
{% for cat in categories|sort %} | ||
<div class="col"> | ||
<div class="card"> | ||
<h5 class="card-header"> | ||
{{ cat }} | ||
</h2> | ||
{# Filtering components for category #} | ||
{% set filtered_components = [] %} | ||
{% for component in all_components_with_incidents %} | ||
{% with attrs = component.get_attributes_as_dict() %} | ||
{% if 'region' in attrs and attrs['region'] == region and 'category' in attrs and attrs['category'] == cat %} | ||
{% set _ = filtered_components.append(component) %} | ||
{% endif %} | ||
{% endwith %} | ||
{% endfor %} | ||
|
||
<ul class="list-group list-group-flush"> | ||
{% for component in all_components_with_incidents %} | ||
{% with attrs = component.get_attributes_as_dict() %} | ||
{% if 'region' in attrs and attrs['region'] == region and 'category' in attrs and attrs['category'] == cat %} | ||
<li class="list-group-item d-flex justify-content-between | ||
align-items-center"> | ||
{{ component.name }} | ||
{{ component_status_widget(component) }} | ||
</li> | ||
{% endif %} | ||
{% endwith %} | ||
{% endfor %} | ||
</ul> | ||
{# Display card only if there are components for the current category and region #} | ||
{% if filtered_components %} | ||
<div class="col"> | ||
<div class="card"> | ||
<h5 class="card-header"> | ||
{{ cat }} | ||
</h5> | ||
|
||
<ul class="list-group list-group-flush"> | ||
{% for component in filtered_components %} | ||
<li class="list-group-item d-flex justify-content-between align-items-center"> | ||
{{ component.name }} | ||
{{ component_status_widget(component) }} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
{% endif %} | ||
{% endfor %} | ||
</div> | ||
</div> |