mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-16 20:48:17 -06:00
fix hard code html
This commit is contained in:
parent
bf83e223ab
commit
e5b23e5219
@ -250,7 +250,7 @@ class Aggregate(GetAvailablePrefixesMixin, PrimaryModel):
|
||||
child_prefixes = netaddr.IPSet([p.prefix for p in queryset])
|
||||
utilization = float(child_prefixes.size) / self.prefix.size * 100
|
||||
|
||||
return utilization
|
||||
return min(utilization, 100)
|
||||
|
||||
|
||||
@extras_features('custom_fields', 'custom_links', 'export_templates', 'tags', 'webhooks')
|
||||
@ -560,7 +560,7 @@ class Prefix(GetAvailablePrefixesMixin, PrimaryModel):
|
||||
prefix_size -= 2
|
||||
utilization = float(child_ips.size) / prefix_size * 100
|
||||
|
||||
return utilization
|
||||
return min(utilization, 100)
|
||||
|
||||
|
||||
@extras_features('custom_fields', 'custom_links', 'export_templates', 'tags', 'webhooks')
|
||||
|
@ -9,15 +9,10 @@
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="100"
|
||||
aria-valuenow="{{ utilization }}"
|
||||
{% if utilization == 100 %}
|
||||
class="progress-bar"
|
||||
style="width: {{ utilization }}%; background-color: #800080;"
|
||||
{% else %}
|
||||
class="progress-bar {{ bar_class }}"
|
||||
style="width: {{ utilization }}%;"
|
||||
{% endif %}
|
||||
>
|
||||
{% if utilization >= 25 %}{{ utilization|floatformat:-2 }}%{% endif %}
|
||||
{% if utilization >= 25 %}{{ utilization|floatformat:-2 }}%{% endif %}
|
||||
</div>
|
||||
{% if utilization < 25 %}
|
||||
<span class="ps-1">{{ utilization|floatformat:-2 }}%</span>
|
||||
|
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user