diff --git a/netbox/netbox/preferences.py b/netbox/netbox/preferences.py index 4fdb7e31f..31e99824e 100644 --- a/netbox/netbox/preferences.py +++ b/netbox/netbox/preferences.py @@ -54,6 +54,14 @@ PREFERENCES = { default='bottom', description=_('Where the paginator controls will be displayed relative to a table') ), + 'ui.tables.striping': UserPreference( + label=_('Striped table rows'), + choices=( + ('', _('Disabled')), + ('true', _('Enabled')), + ), + description=_('Render table rows with alternating colors to increase readability'), + ), # Miscellaneous 'data_format': UserPreference( diff --git a/netbox/netbox/tables/tables.py b/netbox/netbox/tables/tables.py index d9170aa3d..63fd0ea0e 100644 --- a/netbox/netbox/tables/tables.py +++ b/netbox/netbox/tables/tables.py @@ -166,6 +166,8 @@ class BaseTable(tables.Table): columns = userconfig.get(f"tables.{self.name}.columns") if ordering is None: ordering = userconfig.get(f"tables.{self.name}.ordering") + if userconfig.get("ui.tables.striping"): + self.attrs['class'] += ' table-striped' # Fall back to the default columns & ordering if columns is None and hasattr(settings, 'DEFAULT_USER_PREFERENCES'): diff --git a/netbox/users/forms/model_forms.py b/netbox/users/forms/model_forms.py index 42c3b15f0..d8773feb4 100644 --- a/netbox/users/forms/model_forms.py +++ b/netbox/users/forms/model_forms.py @@ -59,6 +59,7 @@ class UserConfigForm(forms.ModelForm, metaclass=UserConfigFormMetaclass): fieldsets = ( FieldSet( 'locale.language', 'pagination.per_page', 'pagination.placement', 'ui.htmx_navigation', + 'ui.tables.striping', name=_('User Interface') ), FieldSet('data_format', name=_('Miscellaneous')),