From 515d041560e709820f301bf2543ce216f82171e2 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 27 Aug 2024 09:30:15 -0400 Subject: [PATCH] Fixes #17230: Ensure consistent rendering for all dashboard widget colors --- netbox/extras/dashboard/widgets.py | 16 ------ netbox/templates/extras/dashboard/widget.html | 54 ++++++++++--------- 2 files changed, 29 insertions(+), 41 deletions(-) diff --git a/netbox/extras/dashboard/widgets.py b/netbox/extras/dashboard/widgets.py index c5e0f5fc3..df41cd34b 100644 --- a/netbox/extras/dashboard/widgets.py +++ b/netbox/extras/dashboard/widgets.py @@ -131,22 +131,6 @@ class DashboardWidget: def name(self): return f'{self.__class__.__module__.split(".")[0]}.{self.__class__.__name__}' - @property - def fg_color(self): - """ - Return the appropriate foreground (text) color for the widget's color. - """ - if self.color in ( - ButtonColorChoices.CYAN, - ButtonColorChoices.GRAY, - ButtonColorChoices.GREY, - ButtonColorChoices.TEAL, - ButtonColorChoices.WHITE, - ButtonColorChoices.YELLOW, - ): - return ButtonColorChoices.BLACK - return ButtonColorChoices.WHITE - @property def form_data(self): return { diff --git a/netbox/templates/extras/dashboard/widget.html b/netbox/templates/extras/dashboard/widget.html index 39be16145..18be2cc92 100644 --- a/netbox/templates/extras/dashboard/widget.html +++ b/netbox/templates/extras/dashboard/widget.html @@ -9,31 +9,35 @@ gs-id="{{ widget.id }}" >
-
- - - -
- {% if widget.title %} - {{ widget.title }} - {% endif %} + {% with bg_color=widget.color|default:"secondary" %} +
+ + + +
+ {% if widget.title %} + {{ widget.title }} + {% endif %} +
+ + +
- - - -
-
- {% render_widget widget %} -
+
+ {% render_widget widget %} +
+ {% endwith %}