Skip to content

Conversation

@tranthang2404
Copy link
Contributor

@tranthang2404 tranthang2404 commented Mar 7, 2022

Fixes: #8232

{% endif %}
</div>
{% endif %}
{% endif %}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a newline

aria-valuenow="{{ utilization }}"
{% if is_full_danger %}
class="progress-bar"
style="width: {{ utilization }}%; background-color: #800080;"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any demo image for this? Including all four colors in light mode and dark mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I choose constants color for 100% utilization

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darkmode:
image
Lightmode:
image

Comment on lines 392 to 394
is_full_danger = False
if utilization == 100:
is_full_danger = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic can be cleaned up considerably. There should be no need to store a variable indicating whether the utilization value is 100: we can just reference utilization directly.

Copy link
Contributor Author

@tranthang2404 tranthang2404 Mar 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, I misunderstand something

utilization = int(float(child_ips.size) / prefix_size * 100)
utilization = float(child_ips.size) / prefix_size * 100

return min(utilization, 100)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call to min() is needed to address instances where utilization is reported to be greater than 100%.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot that context

utilization = int(float(child_prefixes.size) / self.prefix.size * 100)
utilization = float(child_prefixes.size) / self.prefix.size * 100

return min(utilization, 100)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below

aria-valuenow="{{ utilization }}"
{% if utilization == 100 %}
class="progress-bar"
style="width: {{ utilization }}%; background-color: #800080;"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bar color needs to be changed by modifying the bar_class context var inside the utilization_graph template tag. (bg-secondary seems like a good choice.) Please avoid hard-coding color values directly in the HTML.

@jeremystretch
Copy link
Member

Thanks for your work on this @tranthang2404!

@jeremystretch jeremystretch merged commit 1278429 into netbox-community:develop Mar 25, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show full 100% utilization bar in a different color from 99.9%

3 participants