1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes : Introduce a DEFAULT_DASHBOARD config parameter

This commit is contained in:
jeremystretch
2023-04-05 08:32:18 -04:00
parent 1b5f926e17
commit 29fbe6e4ee
3 changed files with 51 additions and 1 deletions
docs/configuration
netbox
extras/dashboard
netbox

@ -1,5 +1,50 @@
# Default Value Parameters
## DEFAULT_DASHBOARD
This parameter controls the content and layout of user's default dashboard. Once the dashboard has been created, the user is free to customize it as they please by adding, removing, and reconfiguring widgets.
This parameter must specify an iterable of dictionaries, each representing a discrete dashboard widget and its configuration. The follow widget attributes are supported:
* `widget`: Dotted path to the Python class (required)
* `width`: Default widget width (between 1 and 12, inclusive)
* `height`: Default widget height, in rows
* `title`: Widget title
* `color`: Color of the widget's title bar, specified by name
* `config`: Dictionary mapping of any widget configuration parameters
A brief example configuration is provided below.
```python
DEFAULT_DASHBOARD = [
{
'widget': 'extras.ObjectCountsWidget',
'width': 4,
'height': 2,
'title': 'Organization',
'config': {
'models': [
'dcim.site',
'tenancy.tenant',
'tenancy.contact',
]
}
},
{
'widget': 'extras.ObjectCountsWidget',
'title': 'IPAM',
'color': 'blue',
'config': {
'models': [
'ipam.prefix',
'ipam.iprange',
'ipam.ipaddress',
]
}
},
]
```
## DEFAULT_USER_PREFERENCES
!!! tip "Dynamic Configuration Parameter"

@ -1,5 +1,6 @@
import uuid
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from netbox.registry import registry
@ -54,8 +55,11 @@ def get_dashboard(user):
def get_default_dashboard():
from extras.models import Dashboard
dashboard = Dashboard()
for widget in DEFAULT_DASHBOARD:
default_config = settings.DEFAULT_DASHBOARD or DEFAULT_DASHBOARD
for widget in default_config:
id = str(uuid.uuid4())
dashboard.layout.append({
'id': id,

@ -86,6 +86,7 @@ CSRF_TRUSTED_ORIGINS = getattr(configuration, 'CSRF_TRUSTED_ORIGINS', [])
DATE_FORMAT = getattr(configuration, 'DATE_FORMAT', 'N j, Y')
DATETIME_FORMAT = getattr(configuration, 'DATETIME_FORMAT', 'N j, Y g:i a')
DEBUG = getattr(configuration, 'DEBUG', False)
DEFAULT_DASHBOARD = getattr(configuration, 'DEFAULT_DASHBOARD', None)
DEVELOPER = getattr(configuration, 'DEVELOPER', False)
DOCS_ROOT = getattr(configuration, 'DOCS_ROOT', os.path.join(os.path.dirname(BASE_DIR), 'docs'))
EMAIL = getattr(configuration, 'EMAIL', {})