Skip to content

Home Information - Your home, your data, organized.

Python

Added better styling for entity paths.

Anthony Cassandra586726940851
diff --git a/src/hi/apps/entity/enums.py b/src/hi/apps/entity/enums.py
index d452102c..fc645488 100644
--- a/src/hi/apps/entity/enums.py
+++ b/src/hi/apps/entity/enums.py
@@ -42,7 +42,7 @@ class EntityType(LabeledEnum):
OPEN_CLOSE_SENSOR = ( 'Open/Close Sensor', '' )
OTHER = ( 'Other', '' ) # Will use generic visual element
PRESENCE_SENSOR = ( 'Presence Sensor', '' )
- SEWER_LINE = ( 'Sewer Wire', '' )
+ SEWER_LINE = ( 'Sewer Line', '' )
SHOWER = ( 'Shower', '' )
SINK = ( 'Sink', '' )
SERVICE = ( 'Service' , '' )
@@ -60,7 +60,6 @@ class EntityType(LabeledEnum):
TOOL = ( 'Tool', '' )
VIDEO_PLAYER = ( 'Video Player', '' )
WALL_SWITCH = ( 'Wall Switch', '' )
- WASTE_PIPE = ( 'Waste Pipe', '' )
WATER_HEATER = ( 'Water Heater', '' )
WATER_LINE = ( 'Water Line', '' )
WATER_METER = ( 'Water Meter', '' )
diff --git a/src/hi/apps/location/edit/views.py b/src/hi/apps/location/edit/views.py
index c9220e52..6e245894 100644
--- a/src/hi/apps/location/edit/views.py
+++ b/src/hi/apps/location/edit/views.py
@@ -455,6 +455,7 @@ class LocationViewEntityToggleView( View, LocationViewMixin ):
include_status_display_data = bool( not request.view_parameters.is_editing ),
)
context = {
+ 'location_view': location_view,
'location_view_data': location_view_data,
}
template = get_template( self.LOCATION_VIEW_TEMPLATE_NAME )
diff --git a/src/hi/apps/location/location_view_data.py b/src/hi/apps/location/location_view_data.py
index e2cd2698..5db08c00 100644
--- a/src/hi/apps/location/location_view_data.py
+++ b/src/hi/apps/location/location_view_data.py
@@ -82,7 +82,7 @@ class LocationViewData:
svg_status_style = status_display_data.svg_status_style
else:
svg_status_style = None
-
+
svg_path_item = self._svg_item_factory.create_svg_path_item(
item = entity_path.entity,
path = entity_path,
diff --git a/src/hi/apps/location/svg_item_factory.py b/src/hi/apps/location/svg_item_factory.py
index 2ff856e8..615fd6df 100644
--- a/src/hi/apps/location/svg_item_factory.py
+++ b/src/hi/apps/location/svg_item_factory.py
@@ -46,6 +46,20 @@ class SvgItemFactory( Singleton ):
path : LocationItemPathModel,
css_class : str,
svg_status_style : SvgStatusStyle = None ) -> SvgPathItem:
+ if isinstance( item, Entity ):
+ entity_type = item.entity_type
+ if entity_type == EntityType.WATER_LINE:
+ svg_status_style = StatusStyle.WaterLine
+ elif entity_type == EntityType.ELECTRIC_WIRE:
+ svg_status_style = StatusStyle.ElectricWire
+ elif entity_type == EntityType.TELECOM_WIRE:
+ svg_status_style = StatusStyle.TelecomWire
+ elif entity_type == EntityType.SEWER_LINE:
+ svg_status_style = StatusStyle.SewerLine
+ elif entity_type in [ EntityType.CONTROL_WIRE,
+ EntityType.SPRINKLER_WIRE ]:
+ svg_status_style = StatusStyle.ControlWire
+
if not svg_status_style:
svg_status_style = StatusStyle.default()
@@ -69,7 +83,6 @@ class SvgItemFactory( Singleton ):
EntityType.SEWER_LINE,
EntityType.SPRINKLER_WIRE,
EntityType.TELECOM_WIRE,
- EntityType.WASTE_PIPE,
EntityType.WATER_LINE, ]:
return SvgItemType.OPEN_PATH
diff --git a/src/hi/apps/location/templates/location/panes/svg_path_item.html b/src/hi/apps/location/templates/location/panes/svg_path_item.html
index 7fef9b8e..09e002a4 100644
--- a/src/hi/apps/location/templates/location/panes/svg_path_item.html
+++ b/src/hi/apps/location/templates/location/panes/svg_path_item.html
@@ -1,13 +1,7 @@
<g id="{{ svg_path_item.html_id }}" class="selectable" data-type="svg-path">
- <path class="{{ svg_path_item.css_class }}"
- fill="{{ svg_path_item.fill_color }}"
- fill-opacity="{{ svg_path_item.fill_opacity }}"
- stroke="{{ svg_path_item.stroke_color }}"
- stroke-width="{{ svg_path_item.stroke_width }}"
- stroke-dasharray="{{ svg_path_item.stroke_dasharray_value }}"
- vector-effect="non-scaling-stroke"
- {% if not svg_path_item.is_closed %}style="pointer-events: stroke;"{% endif %}
- onmouseover="this.style.strokeWidth='3';"
- onmouseout="this.style.strokeWidth='{{ svg_path_item.stroke_width }}';"
- d="{{ svg_path_item.svg_path }}"></path>
+ {% if svg_path_item.is_closed %}
+ {% include "location/panes/svg_path_item_closed.html" %}
+ {% else %}
+ {% include "location/panes/svg_path_item_open.html" %}
+ {% endif %}
</g>
diff --git a/src/hi/apps/location/templates/location/panes/svg_path_item_closed.html b/src/hi/apps/location/templates/location/panes/svg_path_item_closed.html
new file mode 100644
index 00000000..7aa1dd0e
--- /dev/null
+++ b/src/hi/apps/location/templates/location/panes/svg_path_item_closed.html
@@ -0,0 +1,11 @@
+<path class="{{ svg_path_item.css_class }} hi-path-closed"
+ fill="{{ svg_path_item.fill_color }}"
+ fill-opacity="{{ svg_path_item.fill_opacity }}"
+ stroke="{{ svg_path_item.stroke_color }}"
+ stroke-width="{{ svg_path_item.stroke_width }}"
+ {% if svg_path_item.stroke_dasharray_value %}stroke-dasharray="{{ svg_path_item.stroke_dasharray_value }}"{% endif %}
+ vector-effect="non-scaling-stroke"
+ onmouseover="this.setAttribute('hover','true');"
+ onmouseout="this.removeAttribute('hover');"
+ d="{{ svg_path_item.svg_path }}"></path>
+</g>
diff --git a/src/hi/apps/location/templates/location/panes/svg_path_item_open.html b/src/hi/apps/location/templates/location/panes/svg_path_item_open.html
new file mode 100644
index 00000000..322ed276
--- /dev/null
+++ b/src/hi/apps/location/templates/location/panes/svg_path_item_open.html
@@ -0,0 +1,14 @@
+<path class="hover-target" style="pointer-events: stroke;"
+ onmouseover="this.setAttribute('hover','true');"
+ onmouseout="this.removeAttribute('hover');"
+ d="{{ svg_path_item.svg_path }}"></path>
+<path class="{{ svg_path_item.css_class }} hi-path-open"
+ fill="{{ svg_path_item.fill_color }}"
+ fill-opacity="{{ svg_path_item.fill_opacity }}"
+ stroke="{{ svg_path_item.stroke_color }}"
+ stroke-width="{{ svg_path_item.stroke_width }}"
+ {% if svg_path_item.stroke_dasharray_value %}stroke-dasharray="{{ svg_path_item.stroke_dasharray_value }}"{% endif %}
+ vector-effect="non-scaling-stroke"
+ style="pointer-events: none;"
+ d="{{ svg_path_item.svg_path }}"></path>
+</g>
diff --git a/src/hi/apps/monitor/status_display_data.py b/src/hi/apps/monitor/status_display_data.py
index 3669411f..bb9cc236 100644
--- a/src/hi/apps/monitor/status_display_data.py
+++ b/src/hi/apps/monitor/status_display_data.py
@@ -10,8 +10,8 @@ class StatusStyle:
DEFAULT_STATUS_VALUE = ''
DEFAULT_STROKE_COLOR = '#a0a0a0'
- DEFAULT_STROKE_WIDTH = 1.0
- DEFAULT_STROKE_DASHARRAY = [ 3, 6 ]
+ DEFAULT_STROKE_WIDTH = 4.0
+ DEFAULT_STROKE_DASHARRAY = []
DEFAULT_FILL_COLOR = 'white'
DEFAULT_FILL_OPACITY = 0.0
@@ -135,6 +135,46 @@ class StatusStyle:
fill_color = STATUS_BAD_COLOR,
fill_opacity = 0.5,
)
+ WaterLine = SvgStatusStyle(
+ status_value = '',
+ stroke_color = '#0000FF',
+ stroke_width = 3,
+ stroke_dasharray = [ 4, 2 ],
+ fill_color = None,
+ fill_opacity = 0.0,
+ )
+ ElectricWire = SvgStatusStyle(
+ status_value = '',
+ stroke_color = '#FF0000',
+ stroke_width = 3,
+ stroke_dasharray = [ 2, 2 ],
+ fill_color = None,
+ fill_opacity = 0.0,
+ )
+ SewerLine = SvgStatusStyle(
+ status_value = '',
+ stroke_color = '#008000',
+ stroke_width = 3,
+ stroke_dasharray = [ 8, 4, 2, 4 ],
+ fill_color = None,
+ fill_opacity = 0.0,
+ )
+ TelecomWire = SvgStatusStyle(
+ status_value = '',
+ stroke_color = '#FFA500',
+ stroke_width = 3,
+ stroke_dasharray = [ 6, 2 ],
+ fill_color = None,
+ fill_opacity = 0.0,
+ )
+ ControlWire = SvgStatusStyle(
+ status_value = '',
+ stroke_color = '#800080',
+ stroke_width = 3,
+ stroke_dasharray = [ 3, 6 ],
+ fill_color = None,
+ fill_opacity = 0.0,
+ )
@classmethod
def default( cls, status_value : str = DEFAULT_STATUS_VALUE ):
diff --git a/src/hi/simulator/enums.py b/src/hi/simulator/enums.py
index 41e54df5..608ff1e9 100644
--- a/src/hi/simulator/enums.py
+++ b/src/hi/simulator/enums.py
@@ -94,7 +94,6 @@ class SimEntityType(LabeledEnum):
TOOL = ( 'Tool', '' )
VIDEO_PLAYER = ( 'Video Player', '' )
WALL_SWITCH = ( 'Wall Switch', '' )
- WASTE_PIPE = ( 'Waste Pipe', '' )
WATER_HEATER = ( 'Water Heater', '' )
WATER_LINE = ( 'Water Line', '' )
WATER_METER = ( 'Water Meter', '' )
diff --git a/src/hi/static/css/main.css b/src/hi/static/css/main.css
index e73be234..15eae942 100644
--- a/src/hi/static/css/main.css
+++ b/src/hi/static/css/main.css
@@ -247,6 +247,24 @@ g[hover] {
outline: 2px solid var(--status-hover-color);
filter: drop-shadow(0 0 5px var(--status-hover-color));
}
+path.hi-path-closed[hover] {
+}
+path.hover-target {
+ stroke: none;
+ stroke-width: 10;
+ fill: none;
+ pointer-events: all;
+}
+path.hi-path-closed[hover] {
+ stroke: var(--status-hover-color);
+ stroke-width: 5;
+}
+path.hover-target[hover] + path.hi-path-open {
+ stroke: var(--status-hover-color);
+ stroke-width: 5;
+ filter: drop-shadow(0 0 5px var(--status-hover-color));
+}
+
g[status="active"] {
outline: 2px solid var(--status-active-color);
filter: drop-shadow(0 0 5px var(--status-active-color));