Closes #8232: Add color show full 100% utilization

This commit is contained in:
tranthang2404 2022-03-07 22:13:07 +07:00
parent a5603c9953
commit d434c3d7e5
2 changed files with 11 additions and 1 deletions

View File

@ -9,8 +9,13 @@
aria-valuemin="0" aria-valuemin="0"
aria-valuemax="100" aria-valuemax="100"
aria-valuenow="{{ utilization }}" aria-valuenow="{{ utilization }}"
{% if is_full_danger %}
class="progress-bar"
style="width: {{ utilization }}%; background-color: #800080;"
{% else %}
class="progress-bar {{ bar_class }}" class="progress-bar {{ bar_class }}"
style="width: {{ utilization }}%;" style="width: {{ utilization }}%;"
{% endif %}
> >
{% if utilization >= 25 %}{{ utilization }}%{% endif %} {% if utilization >= 25 %}{{ utilization }}%{% endif %}
</div> </div>

View File

@ -389,6 +389,9 @@ def utilization_graph(utilization, warning_threshold=75, danger_threshold=90):
""" """
Display a horizontal bar graph indicating a percentage of utilization. Display a horizontal bar graph indicating a percentage of utilization.
""" """
is_full_danger = False
if utilization == 100:
is_full_danger = True
if danger_threshold and utilization >= danger_threshold: if danger_threshold and utilization >= danger_threshold:
bar_class = 'bg-danger' bar_class = 'bg-danger'
elif warning_threshold and utilization >= warning_threshold: elif warning_threshold and utilization >= warning_threshold:
@ -397,9 +400,11 @@ def utilization_graph(utilization, warning_threshold=75, danger_threshold=90):
bar_class = 'bg-success' bar_class = 'bg-success'
else: else:
bar_class = 'bg-gray' bar_class = 'bg-gray'
is_full_danger = False
return { return {
'utilization': utilization, 'utilization': utilization,
'bar_class': bar_class, 'bar_class': bar_class,
'is_full_danger': is_full_danger,
} }