Home Information - Your home, your data, organized.
Python
Started refactoring the config/integration page views/flows. WIP
Anthony Cassandra3c902323c6c4
diff --git a/src/hi/apps/collection/views.py b/src/hi/apps/collection/views.pyindex 5ab3681c..6cd3ee6c 100644--- a/src/hi/apps/collection/views.py+++ b/src/hi/apps/collection/views.py@@ -1,7 +1,7 @@import loggingfrom django.core.exceptions import BadRequest-from django.http import HttpResponseRedirect, Http404+from django.http import HttpResponseRedirectfrom django.urls import reversefrom django.views.generic import Viewdiff --git a/src/hi/apps/config/async_views.py b/src/hi/apps/config/async_views.pydeleted file mode 100644index 08a78653..00000000--- a/src/hi/apps/config/async_views.py+++ /dev/null@@ -1,16 +0,0 @@-from hi.integrations.core.views import IntegrationViewMixin--from hi.constants import DIVID-from hi.hi_async_view import HiAsyncView---class ConfigTabPaneView( HiAsyncView, IntegrationViewMixin ):-- def get_target_div_id( self ) -> str:- return DIVID['INTEGRATION_TAB']-- def get_template_name( self ) -> str:- return 'core/panes/integration_config_tab.html'-- def get_template_context( self, request, *args, **kwargs ):- return self.get_integration_config_tab_context()diff --git a/src/hi/apps/config/enums.py b/src/hi/apps/config/enums.pynew file mode 100644index 00000000..994c5bf3--- /dev/null+++ b/src/hi/apps/config/enums.py@@ -0,0 +1,21 @@+from hi.apps.common.enums import LabeledEnum+++class ConfigPageType(LabeledEnum):+ # Defines those features that appear on the main config (admin) home+ # page and links to their content.++ def __init__( self,+ label : str,+ description : str,+ url_name : str ):+ super().__init__( label, description )+ self.url_name = url_name+ return++ SETTINGS = ('Settings' , '' , 'config_settings' )+ INTEGRATIONS = ('Integrations' , '' , 'integrations_home' )++ def default(self):+ return ConfigPageType.SETTINGS+diff --git a/src/hi/apps/config/templates/config/pages/config_base.html b/src/hi/apps/config/templates/config/pages/config_base.htmlnew file mode 100644index 00000000..9dca74e5--- /dev/null+++ b/src/hi/apps/config/templates/config/pages/config_base.html@@ -0,0 +1,20 @@+<div class="">+ <h1>Administration</h1>++ <ul id="hi-config-tab" class="nav nav-tabs" role="tablist">+ {% for config_page_type in request.config_page_type_list %}+ <li class="nav-item">+ <a id="hi-config-tab-{{ config_page_type }}" role="tab"+ class="nav-link {% if request.current_config_page_type == config_page_type %}active{% endif %}"+ href="{% url config_page_type.url_name %}"+ data-async="true">{{ config_page_type.label }}</a>+ </li>+ {% endfor %}+ </ul>++ <div class="tab-content" id="hi-config-tab-content">+ {% block config_content %}+ {% endblock %}+ </div>++</div>diff --git a/src/hi/apps/config/templates/config/panes/home.html b/src/hi/apps/config/templates/config/panes/home.htmldeleted file mode 100644index caaf4594..00000000--- a/src/hi/apps/config/templates/config/panes/home.html+++ /dev/null@@ -1,91 +0,0 @@-<div class="">- <h1>Administration</h1>-- <ul class="nav nav-tabs" id="hi-config-tab" role="tablist">- <li class="nav-item">- <a class="nav-link active" id="hi-settings-tab" data-toggle="tab" href="#hi-settings" role="tab"- aria-controls="hi-settings" aria-selected="true">Settings</a>- </li>- <li class="nav-item">- <a class="nav-link" id="hi-integrations-tab" data-toggle="tab" href="#hi-integrations" role="tab"- aria-controls="hi-integrations" aria-selected="false">Integrations</a>- </li>- <li class="nav-item">- <a class="nav-link" id="hi-other-tab" data-toggle="tab" href="#hi-other" role="tab"- aria-controls="hi-other" aria-selected="false">Other</a>- </li>- </ul>-- <div class="tab-content" id="hi-config-tab-content">- <div class="tab-pane fade show active" id="hi-settings" role="tabpanel"- aria-labelledby="hi-settings-tab">- TBD for Settings- </div>- <div class="tab-pane fade" id="hi-integrations" role="tabpanel"- aria-labelledby="hi-integrations-tab">- <div id="{{ DIVID.INTEGRATION_TAB }}">- {% include "core/panes/integration_config_tab.html" with integration_data_list=integration_data_list %}- </div>- </div>-- <div class="tab-pane fade" id="hi-other" role="tabpanel"- aria-labelledby="hi-other-tab">- TBD for Other- </div>- </div>--</div>-<script>- let gHiPreviousTabId = ''; // Track the previously active tab- let gHiIgnorePushState = false; // Flag to ignore pushState when triggered by popstate-- $(document).ready(function () {-- $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {- let tabId = $(e.target).attr('href');-- if ( gHiIgnorePushState ) {- if ( Hi.DEBUG ) { console.log( `Ignoring Tab change: ${tabId}` ); }- gHiIgnorePushState = false;- return;- }--- if ( Hi.DEBUG ) { console.log( `Tab change event: ${tabId} [prev=${gHiPreviousTabId}]` ); }-- if (tabId === gHiPreviousTabId) {- return;- }- gHiPreviousTabId = tabId;-- let newUrl = window.location.protocol + "//" + window.location.hostname;- if (window.location.port) {- newUrl += ':' + window.location.port;- }- newUrl += window.location.pathname + tabId;- window.history.pushState(null, null, newUrl);-- if ( Hi.DEBUG ) { console.log( `Pushed URL: ${newUrl}` ); }-- });-- // On page load, show the correct tab based on the URL hash- let hash = window.location.hash;- if (hash) {- $('.nav-tabs a[href="' + hash + '"]').tab('show');- }- });--- window.addEventListener('popstate', function() {- let hash = window.location.hash;- if ( Hi.DEBUG ) { console.log( `Pop State: ${hash}` ); }- gHiIgnorePushState = true;- if (hash) {- $('.nav-tabs a[href="' + hash + '"]').tab('show');- } else {- // Fallback if no hash exists- $('.nav-tabs a:first').tab('show');- }- });-</script>diff --git a/src/hi/apps/config/templates/config/panes/settings.html b/src/hi/apps/config/templates/config/panes/settings.htmlnew file mode 100644index 00000000..308a9e64--- /dev/null+++ b/src/hi/apps/config/templates/config/panes/settings.html@@ -0,0 +1,9 @@+{% extends "config/pages/config_base.html" %}++{% block config_content %}+<div class="h3">Settings</div>++<div>+ TBD+</div>+{% endblock %}diff --git a/src/hi/apps/config/urls.py b/src/hi/apps/config/urls.pyindex ed13b28f..b8271eda 100644--- a/src/hi/apps/config/urls.py+++ b/src/hi/apps/config/urls.py@@ -1,17 +1,12 @@from django.urls import re_path-from . import async_viewsfrom . import viewsurlpatterns = [- re_path( r'^$',- views.ConfigHomePaneView.as_view(),- name='config_home_pane' ),-- re_path( r'^tab$',- async_views.ConfigTabPaneView.as_view(),- name='config_tab_pane' ),+ re_path( r'^settings$',+ views.ConfigSettingsView.as_view(),+ name='config_settings' ),]diff --git a/src/hi/apps/config/views.py b/src/hi/apps/config/views.pyindex ed156932..cd564056 100644--- a/src/hi/apps/config/views.py+++ b/src/hi/apps/config/views.py@@ -1,28 +1,75 @@-from django.urls import reverse-+import hi.apps.common.antinode as antinodefrom hi.apps.common.utils import is_ajax-from hi.integrations.core.views import IntegrationViewMixin-from hi.enums import ViewMode, ViewType-from hi.exceptions import ForceRedirectExceptionfrom hi.hi_grid_view import HiGridView+from .enums import ConfigPageType-class ConfigHomePaneView( HiGridView, IntegrationViewMixin ):- def get_main_template_name( self ) -> str:- return 'config/panes/home.html'+class ConfigPageView( HiGridView ):+ """+ The app's config/admin page is shown as a tabbed pane with one tab for+ each separate configuration concern. We want them to share some+ standard state tracking and consistent page rendering. However, we+ also want the different config areas to remain somewhat independent.- def get_template_context( self, request, *args, **kwargs ):+ We do this with these:++ - ConfigPageType (enum) - An entry for each configuration concenr,+ coupled only by the URL name for its mian/entry page.++ - ConfigPageView (this view) - Each section (tab) of the+ configuration/admin view should subclass. It contains some state+ management and common needs for rendering itself in the overall+ HiGridView view paradigm.++ - config/pages/config_base.html (template) - The companion template+ for the main/entry view that ensure the config pages are visually+ consistent (appearing as a tabbed pane) with navigation between+ config concerns.++ """++ def dispatch( self, request, *args, **kwargs ):+ """+ Override Django dispatch() method to handle dispatching to ensure+ states and views are consistent for all config tab/pages.+ """view_type_changed = bool( request.view_parameters.view_type != ViewType.CONFIGURATION )request.view_parameters.view_type = ViewType.CONFIGURATIONrequest.view_parameters.view_mode = ViewMode.MONITORrequest.view_parameters.to_session( request )+ # Especially for editing mode, where it may have editing context in+ # many page sections, we should not asynchronously load the config+ # content without refreshing all areas first.+ #if view_type_changed and is_ajax( request ):- redirect_url = reverse('config_home_pane')- raise ForceRedirectException( url = redirect_url )+ redirect_url = request.get_full_path()+ raise antinode.redirect_response( redirect_url )++ request.config_page_type_list = list( ConfigPageType )+ request.current_config_page_type = self.config_page_type++ return super().dispatch( request, *args, **kwargs )++ @property+ def config_page_type(self) -> ConfigPageType:+ raise NotImplementedError('Subclasses must override this method.')+++class ConfigSettingsView( ConfigPageView ):++ @property+ def config_page_type(self) -> ConfigPageType:+ return ConfigPageType.SETTINGS++ def get_main_template_name( self ) -> str:+ return 'config/panes/settings.html'++ def get_template_context( self, request, *args, **kwargs ):- return self.get_integration_config_tab_context()+ return {+ }diff --git a/src/hi/integrations/core/forms.py b/src/hi/integrations/core/forms.pyindex b8fcae12..edcdcce3 100644--- a/src/hi/integrations/core/forms.py+++ b/src/hi/integrations/core/forms.py@@ -8,8 +8,8 @@ from .models import Integration, IntegrationAttributeclass IntegrationAttributeForm( AttributeForm ):class Meta( AttributeForm.Meta ):model = IntegrationAttribute-+IntegrationAttributeFormSet = forms.inlineformset_factory(Integration,IntegrationAttribute,diff --git a/src/hi/integrations/core/integration_factory.py b/src/hi/integrations/core/integration_factory.pyindex 196a04ba..f4ed150d 100644--- a/src/hi/integrations/core/integration_factory.py+++ b/src/hi/integrations/core/integration_factory.py@@ -16,9 +16,14 @@ class IntegrationFactory( Singleton ):self._integration_gateway_map = dict()return+ def get_integration_gateway_list( self ):+ integration_gateway_list = list( self._integration_gateway_map.values() )+ integration_gateway_list.sort( key = lambda gateway : gateway.get_meta_data().label )+ return integration_gateway_list+def get_integration_data_list( self ) -> List[ IntegrationData ]:integration_data_list = list()- for integration_gateway in self._integration_gateway_map.values():+ for integration_gateway in self.get_integration_gateway_list():integration_metadata = integration_gateway.get_meta_data()integration = self.get_integration( integration_id = integration_metadata.integration_id )integration_data = IntegrationData(@@ -45,6 +50,12 @@ class IntegrationFactory( Singleton ):return self._integration_gateway_map[integration_id]raise KeyError( f'Unknown integration id "{integration_id}".' )+ def get_default_integration_gateway( self ):+ integration_gateway_list = self.get_integration_gateway_list()+ if not integration_gateway_list:+ return None+ return integration_gateway_list[0]+def register( self, integration_gateway : IntegrationGateway ):integration_metadata = integration_gateway.get_meta_data()integration_id = integration_metadata.integration_id@@ -54,3 +65,4 @@ class IntegrationFactory( Singleton ):logger.debug( f'Registering integration: {integration_metadata.label}' )self._integration_gateway_map[integration_id] = integration_gatewayreturn+diff --git a/src/hi/integrations/core/integration_gateway.py b/src/hi/integrations/core/integration_gateway.pyindex 6c52e8a6..985d0a5f 100644--- a/src/hi/integrations/core/integration_gateway.py+++ b/src/hi/integrations/core/integration_gateway.py@@ -22,3 +22,4 @@ class IntegrationGateway:def manage_pane_view( self, request : HttpRequest, *args, **kwargs ) -> HttpResponse:# Should return HTML fragment for the management pane of the integration.raise NotImplementedError('Subclasses must override this method')+diff --git a/src/hi/integrations/core/templates/core/modals/integrations_manage.html b/src/hi/integrations/core/templates/core/modals/integrations_manage.htmlnew file mode 100644index 00000000..88f5f538--- /dev/null+++ b/src/hi/integrations/core/templates/core/modals/integrations_manage.html@@ -0,0 +1,36 @@+{% extends "modals/action_done.html" %}++{% block title_text %}+Manage Integrations+{% endblock %}++{% block body %}++{% for integration_data in integration_data_list %}++<div>+ {{ integration_data.integration_metadata.label }}+</div>++<div class="col-2">+ {% if integration_data.integration.is_enabled %}+ <span class="text-success">ENABLED</span>+ {% else %}+ <span class="text-danger">DISABLED</span>+ {% endif %}+</div>++<div>+ {% if integration_data.integration.is_enabled %}+ <a href="{% url 'integrations_action' integration_id=integration_data.integration.integration_id action='disable' %}"+ role="button" class="btn btn-danger btn-control" data-async="modal">DISABLE</a>++ {% else %}+ <a href="{% url 'integrations_action' integration_id=integration_data.integration.integration_id action='enable' %}"+ class="btn btn-success btn-control" role="button" data-async="modal">ENABLE</a>+ {% endif %}+</div>++{% endfor %}++{% endblock %}diff --git a/src/hi/integrations/core/templates/core/pages/integration_base.html b/src/hi/integrations/core/templates/core/pages/integration_base.htmlnew file mode 100644index 00000000..386ef236--- /dev/null+++ b/src/hi/integrations/core/templates/core/pages/integration_base.html@@ -0,0 +1,51 @@+{% extends "config/pages/config_base.html" %}++{% block config_content %}+<div class="row">+ <nav class="nav flex-column">+ {% for integration_data in request.integration_data_list %}+ <a class="nav-link {% if request.current_integration_metadata == integration_data.integration_metadata %}active{% endif %}"+ href="{% url integration_data.integration_metadata.manage_url_name %}">+ {{ integration_data.integration_metadata.label }}+ </a>+ {% endfor %}+ </nav>+ <div class=" flex-colum flex-grow-1">+ <div class="tab-content">+ <div class="d-flex justify-content-between">+ <div class="h3">{{ request.current_integration_metadata.label }}</div>+ <div>+ <a class="btn btn-info" role="button"+ href="{% url 'integrations_manage' %}"+ data-async="modal">+ ADD INTEGRATIONS+ </a>+ </div>+ </div>++ {% if error_message %}+ <div class="alert alert-danger">+ <b>Error</b>: {{ error_message }}+ </div>+ {% endif %}++ {% if info_message %}+ <div class="alert alert-info">+ {{ info_message }}+ </div>+ {% endif %}++ {% if processing_result %}+ {% include "common/processing_result.html" with processing_result=processing_result %}+ {% endif %}++++++ {% block integration_content %}+ {% endblock %}+ </div>+ </div>+</div>+{% endblock %}diff --git a/src/hi/integrations/core/templates/core/pages/no_integrations.html b/src/hi/integrations/core/templates/core/pages/no_integrations.htmlnew file mode 100644index 00000000..377c3dd9--- /dev/null+++ b/src/hi/integrations/core/templates/core/pages/no_integrations.html@@ -0,0 +1,6 @@+{% extends "config/pages/config_base.html" %}+{% block config_content %}+<div class="alert alert-warning">+ There are no integrations currently registered.+</div>+{% endblock %}diff --git a/src/hi/integrations/core/templates/core/panes/integration_config_tab.html b/src/hi/integrations/core/templates/core/panes/integration_config_tab.htmldeleted file mode 100644index 860674fe..00000000--- a/src/hi/integrations/core/templates/core/panes/integration_config_tab.html+++ /dev/null@@ -1,46 +0,0 @@-<div class="m-2" >- {% if error_message %}- <div class="alert alert-danger">- <b>Error</b>: {{ error_message }}- </div>- {% endif %}-- {% if info_message %}- <div class="alert alert-info">- {{ info_message }}- </div>- {% endif %}-- {% for integration_data in integration_data_list %}- <div class="row hi-config-integration">- <div class="col-3">- {{ integration_data.integration_metadata.label }}- </div>- <div class="col-2">- {% if integration_data.integration.is_enabled %}- <span class="text-success">ENABLED</span>- {% else %}- <span class="text-danger">DISABLED</span>- {% endif %}- </div>- <div class="col-2">- {% if integration_data.integration.is_enabled %}- <a href="{% url 'integration_action' integration_id=integration_data.integration.integration_id action='disable' %}"- role="button" class="btn btn-danger btn-control" data-async="modal">DISABLE</a>-- {% else %}- <a href="{% url 'integration_action' integration_id=integration_data.integration.integration_id action='enable' %}"- class="btn btn-success btn-control" role="button" data-async="modal">ENABLE</a>- {% endif %}- </div>- <div class="col-2">- {% if integration_data.integration.is_enabled %}- <a href="{% url 'integration_action' integration_id=integration_data.integration.integration_id action='manage' %}"- class="btn btn-info btn-control" role="button" data-async="#{{ DIVID.INTEGRATION_TAB }}">MANAGE</a>- {% else %}- - {% endif %}- </div>- </div>- {% endfor %}-</div>diff --git a/src/hi/integrations/core/transient_models.py b/src/hi/integrations/core/transient_models.pyindex 577340ac..b46c8af4 100644--- a/src/hi/integrations/core/transient_models.py+++ b/src/hi/integrations/core/transient_models.py@@ -8,6 +8,7 @@ from .models import Integrationclass IntegrationMetaData:integration_id : str # An identifier that must be unique across all integrations+ manage_url_name : str # URL for main page for managing the integrationlabel : str # For human-friendly displayingattribute_type : IntegrationAttributeTypeallow_entity_deletion : booldiff --git a/src/hi/integrations/core/urls.py b/src/hi/integrations/core/urls.pyindex 9966c1a0..b6fd3fa4 100644--- a/src/hi/integrations/core/urls.py+++ b/src/hi/integrations/core/urls.py@@ -6,9 +6,17 @@ from . import viewsurlpatterns = [+ re_path( r'^$',+ views.IntegrationsHomeView.as_view(),+ name='integrations_home' ),++ re_path( r'^manage$',+ views.IntegrationsManageView.as_view(),+ name='integrations_manage' ),+re_path( r'^action/(?P<integration_id>[\w\-]+)/(?P<action>[\w\-]+)$',views.IntegrationActionView.as_view(),- name='integration_action' ),+ name='integrations_action' ),re_path( r'^zm/', include('hi.integrations.zoneminder.urls' )),diff --git a/src/hi/integrations/core/views.py b/src/hi/integrations/core/views.pyindex 8c86240d..8cefe1eb 100644--- a/src/hi/integrations/core/views.py+++ b/src/hi/integrations/core/views.py@@ -1,19 +1,87 @@import loggingfrom django.core.exceptions import BadRequest+from django.urls import reversefrom django.views.generic import View+from hi.apps.config.enums import ConfigPageType+from hi.apps.config.views import ConfigPageView++from hi.exceptions import ForceRedirectException+from hi.hi_async_view import HiModalView+from .integration_factory import IntegrationFactory+from .transient_models import IntegrationDatalogger = logging.getLogger(__name__)-class IntegrationViewMixin:+class IntegrationPageView( ConfigPageView ):+ """+ The integrations page is shown as a vertically tabbed pane with one tab+ for each separate integration. We want them to share some standard+ state tracking and consistent page rendering. However, we also want+ the different integrations to remain somewhat independent.++ We do this with these:++ - IntegrationMetaData - Integrations register this with the+ IntegrationFactory to define their exisatence and common+ properties.++ - IntegrationPageView (this view) - Each integration should subclass+ this for their main default view. It contains some state management+ and common needs for rendering itself in the overall+ IntegrationPageView, ConfigPageView and HiGridView view paradigms.++ - core/pages/integration_base.html (template) - The companion+ template for the main/entry view that ensure the integration pages+ are visually consistent (appearing as a tabbed pane) with+ navigation between integrations (and config sections).++ """++ def dispatch( self, request, *args, **kwargs ):+ request.integration_data_list = IntegrationFactory().get_integration_data_list()+ request.current_integration_metadata = self.integration_metadata+ return super().dispatch( request, *args, **kwargs )++ @property+ def integration_metadata(self) -> IntegrationData:+ raise NotImplementedError('Subclasses must override this method.')++ def config_page_type(self) -> ConfigPageType:+ return ConfigPageType.INTEGRATIONS+++class IntegrationsHomeView( ConfigPageView ):++ def config_page_type(self) -> ConfigPageType:+ return ConfigPageType.INTEGRATIONS++ def get_main_template_name( self ) -> str:+ return 'core/pages/no_integrations.html'++ def get_template_context( self, request, *args, **kwargs ):++ integration_gateway = IntegrationFactory().get_default_integration_gateway()+ if not integration_gateway:+ return dict()++ redirect_url = reverse( integration_gateway.get_meta_data().manage_url_name )+ raise ForceRedirectException( redirect_url )+++class IntegrationsManageView( HiModalView ):++ def get_template_name( self ) -> str:+ return 'core/modals/integrations_manage.html'- def get_integration_config_tab_context(self):- return {+ def get( self, request, *args, **kwargs ):+ context = {'integration_data_list': IntegrationFactory().get_integration_data_list(),}+ return self.modal_response( request, context )class IntegrationActionView( View ):diff --git a/src/hi/integrations/hass/hass_metadata.py b/src/hi/integrations/hass/hass_metadata.pyindex e5ac947a..d642d5dd 100644--- a/src/hi/integrations/hass/hass_metadata.py+++ b/src/hi/integrations/hass/hass_metadata.py@@ -5,6 +5,7 @@ from .enums import HassAttributeTypeHassMetaData = IntegrationMetaData(integration_id = 'hass',+ manage_url_name = 'hass_manage',label = 'Home Assistant',attribute_type = HassAttributeType,allow_entity_deletion = False,diff --git a/src/hi/integrations/hass/templates/hass/panes/manage.html b/src/hi/integrations/hass/templates/hass/panes/manage.htmlindex 169da461..ba804919 100644--- a/src/hi/integrations/hass/templates/hass/panes/manage.html+++ b/src/hi/integrations/hass/templates/hass/panes/manage.html@@ -1,22 +1,10 @@-<div class="d-flex justify-content-between">- <div cLASS="h3">HAss Integration</div>- <div>- <a href="{% url 'config_tab_pane' %}"- class="btn btn-tertiary btn-control" role="button" data-async="#{{ DIVID.INTEGRATION_TAB }}">- BACK- </a>- </div>-</div>--{% if processing_result %}-{% include "common/processing_result.html" with processing_result=processing_result %}-{% endif %}-+{% extends "core/pages/integration_base.html" %}+{% block integration_content %}<div class="col-2"><form action="{% url 'hass_sync' %}"method="POST" role="form" data-async="#{{ DIVID.INTEGRATION_TAB }}">{% csrf_token %}- <button type="submit" class="btn btn-primary btn-control" role="button"+ <button type="submit" class="btn btn-primary" role="button"name="action" value="sync" >SYNC</button></form></div>@@ -24,3 +12,4 @@<div id="{{ DIVID.INTEGRATION_SETTINGS_PANE }}">{% include "hass/panes/hass_settings.html" %}</div>+{% endblock %}diff --git a/src/hi/integrations/hass/views.py b/src/hi/integrations/hass/views.pyindex 74c3f8d9..619d6618 100644--- a/src/hi/integrations/hass/views.py+++ b/src/hi/integrations/hass/views.py@@ -9,6 +9,7 @@ import hi.apps.common.antinode as antinodefrom hi.integrations.core.forms import IntegrationAttributeFormSetfrom hi.integrations.core.helpers import IntegrationHelperMixin+from hi.integrations.core.views import IntegrationPageViewfrom hi.constants import DIVID@@ -90,9 +91,16 @@ class HassDisableView( View ):return render( request, 'hass/modals/hass_disable.html', context )-class HassManageView( View, IntegrationHelperMixin ):+class HassManageView( IntegrationPageView, IntegrationHelperMixin ):- def get(self, request, *args, **kwargs):+ @property+ def integration_metadata(self):+ return HassMetaData++ def get_main_template_name( self ) -> str:+ return 'hass/panes/manage.html'++ def get_template_context( self, request, *args, **kwargs ):integration = self.get_or_create_integration(integration_metadata = HassMetaData,@@ -107,11 +115,10 @@ class HassManageView( View, IntegrationHelperMixin ):'show_as_editable': True,},)- context = {+ return {'integration_metadata': HassMetaData,'integration_attribute_formset': integration_attribute_formset,}- return render( request, 'hass/panes/manage.html', context )class HassSettingsView( View, IntegrationHelperMixin ):@@ -122,7 +129,7 @@ class HassSettingsView( View, IntegrationHelperMixin ):integration_metadata = HassMetaData,)if not integration.is_enabled:- raise BadRequest( 'HAss not is enabled' )+ raise BadRequest( 'HAss is not enabled' )integration_attribute_formset = IntegrationAttributeFormSet(request.POST,diff --git a/src/hi/integrations/zoneminder/templates/zoneminder/panes/manage.html b/src/hi/integrations/zoneminder/templates/zoneminder/panes/manage.htmlindex bea8809c..74571957 100644--- a/src/hi/integrations/zoneminder/templates/zoneminder/panes/manage.html+++ b/src/hi/integrations/zoneminder/templates/zoneminder/panes/manage.html@@ -1,17 +1,5 @@-<div class="d-flex justify-content-between">- <div cLASS="h3">ZoneMinder Integration</div>- <div>- <a href="{% url 'config_tab_pane' %}"- class="btn btn-tertiary btn-control" role="button" data-async="#{{ DIVID.INTEGRATION_TAB }}">- BACK- </a>- </div>-</div>--{% if processing_result %}-{% include "common/processing_result.html" with processing_result=processing_result %}-{% endif %}-+{% extends "core/pages/integration_base.html" %}+{% block integration_content %}<div class="col-2"><form action="{% url 'zm_sync' %}"method="POST" role="form" data-async="#{{ DIVID.INTEGRATION_TAB }}">@@ -24,3 +12,4 @@<div id="{{ DIVID.INTEGRATION_SETTINGS_PANE }}">{% include "zoneminder/panes/zm_settings.html" %}</div>+{% endblock %}diff --git a/src/hi/integrations/zoneminder/views.py b/src/hi/integrations/zoneminder/views.pyindex 8b4e0b29..7dde2d07 100644--- a/src/hi/integrations/zoneminder/views.py+++ b/src/hi/integrations/zoneminder/views.py@@ -9,6 +9,7 @@ import hi.apps.common.antinode as antinodefrom hi.integrations.core.forms import IntegrationAttributeFormSetfrom hi.integrations.core.helpers import IntegrationHelperMixin+from hi.integrations.core.views import IntegrationPageViewfrom hi.constants import DIVID@@ -90,9 +91,16 @@ class ZmDisableView( View ):return render( request, 'zoneminder/modals/zm_disable.html', context )-class ZmManageView( View, IntegrationHelperMixin ):+class ZmManageView( IntegrationPageView, IntegrationHelperMixin ):- def get(self, request, *args, **kwargs):+ @property+ def integration_metadata(self):+ return ZmMetaData++ def get_main_template_name( self ) -> str:+ return 'zoneminder/panes/manage.html'++ def get_template_context( self, request, *args, **kwargs ):integration = self.get_or_create_integration(integration_metadata = ZmMetaData,@@ -107,11 +115,10 @@ class ZmManageView( View, IntegrationHelperMixin ):'show_as_editable': True,},)- context = {+ return {'integration_metadata': ZmMetaData,'integration_attribute_formset': integration_attribute_formset,}- return render( request, 'zoneminder/panes/manage.html', context )class ZmSettingsView( View, IntegrationHelperMixin ):diff --git a/src/hi/integrations/zoneminder/zm_metadata.py b/src/hi/integrations/zoneminder/zm_metadata.pyindex 3cbe1e71..c267f6ba 100644--- a/src/hi/integrations/zoneminder/zm_metadata.py+++ b/src/hi/integrations/zoneminder/zm_metadata.py@@ -5,6 +5,7 @@ from .enums import ZmAttributeTypeZmMetaData = IntegrationMetaData(integration_id = 'zm',+ manage_url_name = 'zm_manage',label = 'ZoneMinder',attribute_type = ZmAttributeType,allow_entity_deletion = False,diff --git a/src/hi/templates/panes/bottom_buttons.html b/src/hi/templates/panes/bottom_buttons.htmlindex 0c0e1772..d476bcad 100644--- a/src/hi/templates/panes/bottom_buttons.html+++ b/src/hi/templates/panes/bottom_buttons.html@@ -2,7 +2,7 @@<div class="d-flex justify-content-between">{% include "collection/collection_buttons.html" %}<div>- <a href="{% url 'config_home_pane' %}"+ <a href="{% url 'config_settings' %}"class="btn btn-tertiary btn-control" role="button"data-async="true" >ADMIN