mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
* Replace masonry with gridstack * Initial work on dashboard widgets * Implement function to save dashboard layout * Define a default dashboard * Clean up widgets * Implement widget configuration views & forms * Permit merging dict value with existing dict in user config * Add widget deletion view * Enable HTMX for widget configuration * Implement view to add dashboard widgets * ObjectCountsWidget: Identify models by app_label & name * Add color customization to dashboard widgets * Introduce Dashboard model to store user dashboard layout & config * Clean up utility functions * Remove hard-coded API URL * Use fixed grid cell height * Add modal close button * Clean up dashboard views * Rebuild JS
This commit is contained in:
38
netbox/extras/dashboard/forms.py
Normal file
38
netbox/extras/dashboard/forms.py
Normal file
@ -0,0 +1,38 @@
|
||||
from django import forms
|
||||
from django.urls import reverse_lazy
|
||||
|
||||
from netbox.registry import registry
|
||||
from utilities.forms import BootstrapMixin, add_blank_choice
|
||||
from utilities.choices import ButtonColorChoices
|
||||
|
||||
__all__ = (
|
||||
'DashboardWidgetAddForm',
|
||||
'DashboardWidgetForm',
|
||||
)
|
||||
|
||||
|
||||
def get_widget_choices():
|
||||
return registry['widgets'].items()
|
||||
|
||||
|
||||
class DashboardWidgetForm(BootstrapMixin, forms.Form):
|
||||
title = forms.CharField(
|
||||
required=False
|
||||
)
|
||||
color = forms.ChoiceField(
|
||||
choices=add_blank_choice(ButtonColorChoices),
|
||||
required=False,
|
||||
)
|
||||
|
||||
|
||||
class DashboardWidgetAddForm(DashboardWidgetForm):
|
||||
widget_class = forms.ChoiceField(
|
||||
choices=get_widget_choices,
|
||||
widget=forms.Select(
|
||||
attrs={
|
||||
'hx-get': reverse_lazy('extras:dashboardwidget_add'),
|
||||
'hx-target': '#widget_add_form',
|
||||
}
|
||||
)
|
||||
)
|
||||
field_order = ('widget_class', 'title', 'color')
|
Reference in New Issue
Block a user