1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #8232: Add color show full 100% utilization (#8816)

* Closes #8232: Add color show full 100% utilization

* change rounding

* change rounding

* fix hard code html

* format
This commit is contained in:
tranthang2404
2022-03-25 20:52:13 +07:00
committed by GitHub
parent 421f5a03aa
commit 1278429518
4 changed files with 9 additions and 7 deletions

View File

@@ -12,10 +12,10 @@
class="progress-bar {{ bar_class }}"
style="width: {{ utilization }}%;"
>
{% if utilization >= 25 %}{{ utilization }}%{% endif %}
{% if utilization >= 25 %}{{ utilization|floatformat:-2 }}%{% endif %}
</div>
{% if utilization < 25 %}
<span class="ps-1">{{ utilization }}%</span>
<span class="ps-1">{{ utilization|floatformat:-2 }}%</span>
{% endif %}
</div>
{% endif %}

View File

@@ -389,7 +389,9 @@ def utilization_graph(utilization, warning_threshold=75, danger_threshold=90):
"""
Display a horizontal bar graph indicating a percentage of utilization.
"""
if danger_threshold and utilization >= danger_threshold:
if utilization == 100:
bar_class = 'bg-secondary'
elif danger_threshold and utilization >= danger_threshold:
bar_class = 'bg-danger'
elif warning_threshold and utilization >= warning_threshold:
bar_class = 'bg-warning'