adds BANNER_MAINTENANCE config #12554

This commit is contained in:
Abhimanyu Saharan 2023-05-11 02:35:19 +05:30
parent b7f028fba3
commit eedf8a1068
4 changed files with 22 additions and 3 deletions

View File

@ -121,6 +121,15 @@ Default: False
Setting this to True will display a "maintenance mode" banner at the top of every page. Additionally, NetBox will no longer update a user's "last active" time upon login. This is to allow new logins when the database is in a read-only state. Recording of login times will resume when maintenance mode is disabled.
## BANNER_MAINTENANCE
!!! tip "Dynamic Configuration Parameter"
!!! note
This parameter was added in NetBox v3.5.
This adds a banner to the top of every page when maintenance mode is enabled. HTML is allowed.
---
## MAPS_URL

View File

@ -39,7 +39,10 @@ class ConfigRevisionAdmin(admin.ModelAdmin):
'fields': ('DEFAULT_USER_PREFERENCES',),
}),
('Miscellaneous', {
'fields': ('MAINTENANCE_MODE', 'GRAPHQL_ENABLED', 'CHANGELOG_RETENTION', 'JOB_RETENTION', 'MAPS_URL'),
'fields': (
'MAINTENANCE_MODE', 'BANNER_MAINTENANCE', 'GRAPHQL_ENABLED', 'CHANGELOG_RETENTION', 'JOB_RETENTION',
'MAPS_URL'
),
}),
('Config Revision', {
'fields': ('comment',),

View File

@ -199,6 +199,13 @@ PARAMS = (
description=_("Enable maintenance mode"),
field=forms.BooleanField
),
ConfigParam(
name='BANNER_MAINTENANCE',
label=_('Maintenance banner'),
default=None,
description=_('Additional content to display when in maintenance mode'),
field=forms.CharField,
),
ConfigParam(
name='GRAPHQL_ENABLED',
label=_('GraphQL enabled'),

View File

@ -77,10 +77,10 @@ Blocks:
</div>
{% endif %}
{% if config.MAINTENANCE_MODE %}
{% if config.MAINTENANCE_MODE and config.BANNER_MAINTENANCE %}
<div class="alert alert-warning text-center mx-3" role="alert">
<h5><i class="mdi mdi-alert"></i> Maintenance Mode</h5>
NetBox is currently in maintenance mode. Functionality may be limited.
{{ config.BANNER_MAINTENANCE|escape }}
</div>
{% endif %}