Home Information - Your home, your data, organized.
Python
Styling and layout still WIP.
Anthony Cassandra04c45aa7663d
diff --git a/src/hi/apps/attribute/templates/attribute/panes/attribute_form.html b/src/hi/apps/attribute/templates/attribute/panes/attribute_form.htmlindex 63ac6308..8fe4799c 100644--- a/src/hi/apps/attribute/templates/attribute/panes/attribute_form.html+++ b/src/hi/apps/attribute/templates/attribute/panes/attribute_form.html@@ -2,7 +2,7 @@{{ attribute_formset.management_form }}{% for attribute_form in attribute_formset %}- <div class="{{ DIVID.ATTRIBUTE_CONTAINER_CLASS }}">+ <div class="{{ DIVID.ATTRIBUTE_CONTAINER_CLASS }} my-2">{{ attribute_form.id }}{% if attribute_form.non_field_errors %}diff --git a/src/hi/apps/attribute/templates/attribute/panes/attribute_form_boolean.html b/src/hi/apps/attribute/templates/attribute/panes/attribute_form_boolean.htmlindex 14a96183..aac5eace 100644--- a/src/hi/apps/attribute/templates/attribute/panes/attribute_form_boolean.html+++ b/src/hi/apps/attribute/templates/attribute/panes/attribute_form_boolean.html@@ -2,11 +2,11 @@<input type="hidden" id="{{ attribute_form.name.id_for_label }}"name="{{ attribute_form.name.html_name }}"value="{{ attribute_form.instance.name }}" />-<div class="input-group" >+<div class="input-group align-items-center" ><input type="checkbox" name="{{ attribute_form.value.html_name }}"id="{{ attribute_form.value.id_for_label }}"{% if attribute_form.value.value %}checked="on"{% endif %} >- <label for="{{ attribute_form.value.id_for_label }}">{{ attribute_form.name.value }}</label>+ <label for="{{ attribute_form.value.id_for_label }}" class="pl-2 mb-0">{{ attribute_form.name.value }}</label></div>{% if attribute_form.show_as_editable and attribute_form.instance.is_editable and attribute_form.instance.attribute_type.can_delete %}diff --git a/src/hi/apps/attribute/templates/attribute/panes/attribute_form_new.html b/src/hi/apps/attribute/templates/attribute/panes/attribute_form_new.htmlindex e518c317..d3c170a7 100644--- a/src/hi/apps/attribute/templates/attribute/panes/attribute_form_new.html+++ b/src/hi/apps/attribute/templates/attribute/panes/attribute_form_new.html@@ -1,13 +1,13 @@-<div>+<div class="my-2"><a class="" data-toggle="collapse" href="#collapseExample"role="button" aria-expanded="false" aria-controls="collapseExample"><span class="plus-icon">+</span> Add New Attribute</a></div>-<div class="collapse" id="collapseExample">+<div class="collapse my-2" id="collapseExample"><div class="form-group" >- <label for="{{ attribute_form.name.id_for_label }}">New {{ attribute_form.name.label }}</label>+ <label for="{{ attribute_form.name.id_for_label }}"><em>New {{ attribute_form.name.label }}</em></label><input type="text"id="{{ attribute_form.name.id_for_label }}"class="form-control"@@ -16,7 +16,7 @@<div class="form-error text-danger" >{{ attribute_form.name.errors }}</div></div><div class="form-group">- <label for="{{ attribute_form.value.id_for_label }}">New {{ attribute_form.value.label }}</label>+ <label for="{{ attribute_form.value.id_for_label }}"><em>New {{ attribute_form.value.label }}</em></label><textarea rows="2" cols="40"id="{{ attribute_form.value.id_for_label }}"class="form-control"diff --git a/src/hi/apps/attribute/templates/attribute/panes/attribute_form_text.html b/src/hi/apps/attribute/templates/attribute/panes/attribute_form_text.htmlindex 03d80641..4e0f8481 100644--- a/src/hi/apps/attribute/templates/attribute/panes/attribute_form_text.html+++ b/src/hi/apps/attribute/templates/attribute/panes/attribute_form_text.html@@ -11,7 +11,7 @@{% if attribute_form.instance and not attribute_form.instance.is_editable %}disabled="true"{% endif %}name="{{ attribute_form.value.html_name }}"value="{{ attribute_form.value.value|default_if_none:'' }}">- <span>+ <span class="pl-2"><input type="checkbox" name="{{ attribute_form.value.html_name }}-show"id="{{ attribute_form.value.id_for_label }}-show"onclick="Hi.togglePasswordField( this );">diff --git a/src/hi/apps/config/templates/config/pages/config_base.html b/src/hi/apps/config/templates/config/pages/config_base.htmlindex 9dca74e5..7c1474da 100644--- a/src/hi/apps/config/templates/config/pages/config_base.html+++ b/src/hi/apps/config/templates/config/pages/config_base.html@@ -1,5 +1,5 @@-<div class="">- <h1>Administration</h1>+<div class="hi-administration-content">+ <div class="h1 text-primary py-1">Administration</div><ul id="hi-config-tab" class="nav nav-tabs" role="tablist">{% for config_page_type in request.config_page_type_list %}diff --git a/src/hi/apps/config/templates/config/panes/settings_form.html b/src/hi/apps/config/templates/config/panes/settings_form.htmlindex 6a61ba32..715b9ab5 100644--- a/src/hi/apps/config/templates/config/panes/settings_form.html+++ b/src/hi/apps/config/templates/config/panes/settings_form.html@@ -3,16 +3,29 @@<form action="{% url 'config_settings' %}" method="post"class="form" data-async="#hi-config-settings-form" data-mode="replace">{% csrf_token %}++ <div class="d-flex justify-content-start my-2">+ <div class="align-self-center h3">System Settings</div>+ <div class="align-self-center h3 ml-4">+ <button id="hi-config-setting-button" type="submit" class="btn btn-primary"+ name="action" value="update">+ UPDATE+ </button>+ </div>+ </div>{% for subsystem_attribute_formset in subsystem_attribute_formset_list %}- <h5>{{ subsystem_attribute_formset.instance.name }}</h5>+ <div class="h5">{{ subsystem_attribute_formset.instance.name }}</div>{% include "attribute/panes/attribute_form.html" with attribute_formset=subsystem_attribute_formset %}+ <hr />{% endfor %}- <button id="hi-config-setting-button" type="submit" class="btn btn-primary"- name="action" value="update">- UPDATE- </button>+ <div class="my-2">+ <button id="hi-config-setting-button" type="submit" class="btn btn-primary"+ name="action" value="update">+ UPDATE+ </button>+ </div></form></div></div>diff --git a/src/hi/apps/config/templates/config/panes/system_settings.html b/src/hi/apps/config/templates/config/panes/system_settings.htmlindex b94b0110..1fb393df 100644--- a/src/hi/apps/config/templates/config/panes/system_settings.html+++ b/src/hi/apps/config/templates/config/panes/system_settings.html@@ -1,2 +1 @@-<div class="h3">System</div>{% include "config/panes/settings_form.html" %}diff --git a/src/hi/apps/console/templates/console/panes/camera_controls.html b/src/hi/apps/console/templates/console/panes/camera_controls.htmlindex 2026ed67..1b89dc7d 100644--- a/src/hi/apps/console/templates/console/panes/camera_controls.html+++ b/src/hi/apps/console/templates/console/panes/camera_controls.html@@ -2,7 +2,7 @@<div class="h6 text-center">Cameras</div><div class="row">{% for video_stream_entity in video_stream_entity_list %}- <div class="col-6 my-1">+ <div class="w-50 pl-1 pb-1"><a href="{% url 'console_sensor_video_stream' sensor_id=video_stream_entity.sensor.id %}"class="btn btn-primary btn-control">{{ video_stream_entity.name }}diff --git a/src/hi/integrations/integration_manager.py b/src/hi/integrations/integration_manager.pyindex 09af6e3b..550c3cac 100644--- a/src/hi/integrations/integration_manager.py+++ b/src/hi/integrations/integration_manager.py@@ -222,7 +222,7 @@ class IntegrationManager( Singleton ):"""self._data_lock.acquire()try:- new_attribute_types = set()+ new_attribute_types = list()existing_attribute_integration_keys = set([ x.integration_keyfor x in integration.attributes.all() ])@@ -233,7 +233,7 @@ class IntegrationManager( Singleton ):integration_name = str(attribute_type),)if integration_key not in existing_attribute_integration_keys:- new_attribute_types.add( attribute_type )+ new_attribute_types.append( attribute_type )continueif new_attribute_types:diff --git a/src/hi/integrations/templates/integrations/modals/integrations_select.html b/src/hi/integrations/templates/integrations/modals/integrations_select.htmlindex e508dd80..116cffd6 100644--- a/src/hi/integrations/templates/integrations/modals/integrations_select.html+++ b/src/hi/integrations/templates/integrations/modals/integrations_select.html@@ -1,13 +1,13 @@{% extends "modals/action_done.html" %}{% block title_text %}-Manage Integrations+Select Integrations{% endblock %}{% block body %}{% for integration_data in integration_data_list %}-<div class="d-flex justify-content-between">+<div class="d-flex justify-content-between {% if not forloop.first %}border-top{% endif %} py-2 my-1"><div class="col-6">{{ integration_data.integration_metadata.label }}</div>diff --git a/src/hi/integrations/templates/integrations/pages/no_integrations.html b/src/hi/integrations/templates/integrations/pages/no_integrations.htmlindex 12757adf..f2287120 100644--- a/src/hi/integrations/templates/integrations/pages/no_integrations.html+++ b/src/hi/integrations/templates/integrations/pages/no_integrations.html@@ -1,10 +1,10 @@{% extends "config/pages/config_base.html" %}{% block config_content %}-<div class="alert alert-warning">+<div class="alert alert-warning m-4">There are no integrations currently registered.</div>-<div>- <a class="btn btn-primary" role="button"+<div class="m-4">+ <a class="btn btn-primary btn-lg" role="button"href="{% url 'integrations_select' %}"data-async="modal">ADD INTEGRATIONSdiff --git a/src/hi/services/zoneminder/enums.py b/src/hi/services/zoneminder/enums.pyindex 57c90070..9e2e9ab7 100644--- a/src/hi/services/zoneminder/enums.py+++ b/src/hi/services/zoneminder/enums.py@@ -1,5 +1,4 @@from hi.apps.attribute.enums import AttributeValueType-from hi.apps.common.enums import LabeledEnumfrom hi.integrations.enums import IntegrationAttributeTypediff --git a/src/hi/services/zoneminder/monitors.py b/src/hi/services/zoneminder/monitors.pyindex 2437c9b4..ab44b3c2 100644--- a/src/hi/services/zoneminder/monitors.py+++ b/src/hi/services/zoneminder/monitors.py@@ -58,8 +58,8 @@ class ZoneMinderMonitor( PeriodicMonitor, ZoneMinderMixin, SensorResponseMixin )sensor_response_map = dict()sensor_response_map.update( await self._process_events( ) )- sensor_response_map.update( self._process_monitors() )- sensor_response_map.update( self._process_states() )+ sensor_response_map.update( await self._process_monitors() )+ sensor_response_map.update( await self._process_states() )await self.sensor_response_manager().update_with_latest_sensor_responses(sensor_response_map = sensor_response_map,@@ -84,8 +84,8 @@ class ZoneMinderMonitor( PeriodicMonitor, ZoneMinderMixin, SensorResponseMixin )'from': tz_adjusted_poll_from_datetime.isoformat(), # "from" only looks at event start time'tz': self._zm_tzname,}- events = self.zm_manager().get_zm_events( options = options )- logger.debug( f'Found {len(events)} new ZM events' )+ zm_events = await sync_to_async( self.zm_manager().get_zm_events)( options = options )+ logger.debug( f'Found {len(zm_events)} new ZM events' )# Sensor readings and state value transitions are points in time,# but ZoneMinder events are intervals. Thus, one ZoneMinder event@@ -105,7 +105,7 @@ class ZoneMinderMonitor( PeriodicMonitor, ZoneMinderMixin, SensorResponseMixin )open_zm_event_list = list()closed_zm_event_list = list()zm_monitor_ids_seen = set()- for zm_api_event in events:+ for zm_api_event in zm_events:logger.debug( f'ZM Api Event: {zm_api_event.get()}' )zm_event = ZmEvent( zm_api_event = zm_api_event,zm_tzname = self._zm_tzname )@@ -142,7 +142,8 @@ class ZoneMinderMonitor( PeriodicMonitor, ZoneMinderMixin, SensorResponseMixin )# If there are no events for monitors/states, we still want to emit the# sensor response of it being idle.#- for zm_monitor in self.zm_manager().get_zm_monitors():+ zm_monitors = await sync_to_async( self.zm_manager().get_zm_monitors )()+ for zm_monitor in zm_monitors:if zm_monitor.id() not in zm_monitor_ids_seen:idle_sensor_response = self._create_idle_sensor_response(zm_monitor = zm_monitor,@@ -177,12 +178,14 @@ class ZoneMinderMonitor( PeriodicMonitor, ZoneMinderMixin, SensorResponseMixin )return sensor_response_map- def _process_monitors(self):+ async def _process_monitors(self):current_poll_datetime = datetimeproxy.now()sensor_response_map = dict()- for zm_monitor in self.zm_manager().get_zm_monitors( force_load = self.CACHING_DISABLED ):-+ zm_monitors = await sync_to_async( self.zm_manager().get_zm_monitors )(+ force_load = self.CACHING_DISABLED,+ )+ for zm_monitor in zm_monitors:video_stream_sensor_response = self._create_video_stream_sensor_response(zm_monitor = zm_monitor,timestamp = current_poll_datetime,@@ -198,12 +201,15 @@ class ZoneMinderMonitor( PeriodicMonitor, ZoneMinderMixin, SensorResponseMixin )return sensor_response_map- def _process_states(self):+ async def _process_states(self):current_poll_datetime = datetimeproxy.now()sensor_response_map = dict()active_run_state_name = None- for zm_state in self.zm_manager().get_zm_states( force_load = self.CACHING_DISABLED ):+ zm_states = await sync_to_async( self.zm_manager().get_zm_states )(+ force_load = self.CACHING_DISABLED,+ )+ for zm_state in zm_states:if zm_state.active():active_run_state_name = zm_state.name()breakdiff --git a/src/hi/static/css/main.css b/src/hi/static/css/main.cssindex ec28fce5..a96860e5 100644--- a/src/hi/static/css/main.css+++ b/src/hi/static/css/main.css@@ -3,11 +3,11 @@All Rights Reserved.*/:root {- --white-color: #fdfdfd;+ --white: #fdfdfd;--black: #020204;--primary-color: #177072;--on-primary-color: #ffffff;- --primary-highlight-color: #26BFD1;+ --primary-highlight-color: #115354;--secondary-color: #F45F36;--on-secondary-color: #ffffff;--secondary-highlight-color: #F8AD98;@@ -62,7 +62,7 @@ html, body {padding: 0;height: 100%;color: #222233;- background-color: var(--white-color);+ background-color: var(--white);}a { color: var(--primary-color); }@@ -91,7 +91,7 @@ a.underline:visited {color: var(--on-primary-color) !important;}.text-white {- color: var(--white-color) !important;+ color: var(--white) !important;}.text-black {color: var(--black);@@ -214,7 +214,7 @@ a.underline:visited {#hi-top-content,#hi-bottom-content,.hi-screen {- background: var(--white-color);+ background: var(--white);}#hi-top-content[hi-edit="True"] {@@ -230,7 +230,6 @@ a.underline:visited {background: var(--edit-side-bg-color);}-.hi-screen {max-height: 100vh;}@@ -276,7 +275,19 @@ a.underline:visited {}.form-group label {- color: var(--muted-color) !important;+ color: #060606 !important;+}+.input-group-text {+ color: var(--black);+ background-color: #f0f0f0;+}+select,+textarea,+input[type="text"],+input[type="password"],+.dropdown-menu {+ color: var(--black) !important;+ background-color: #f8f8f8 !important;}.hi-custom-select .input-group-text {height: calc(1.5em + 0.75rem + 2px);