diff --git a/static/juice.css b/static/juice.css index e42598b..510818c 100644 --- a/static/juice.css +++ b/static/juice.css @@ -1,10 +1,11 @@ body { - padding: 5%; font-family: Helvetica,sans-serif; background-color: lightblue; + margin: 0; } -#container { +#devices { + padding: 5%; display: flex; justify-content: center; } @@ -46,18 +47,6 @@ body { height: 5em; } -path { - cursor: pointer; -} - -.on { - stroke: red; -} - -.off { - stroke: black; -} - @font-face { font-family: FontAwesome; src: url("/static/fontawesome-webfont.woff2"); diff --git a/static/juice.js b/static/juice.js index 41995a9..e713584 100644 --- a/static/juice.js +++ b/static/juice.js @@ -1,5 +1,15 @@ +function get_object_from_svg(svg) { + var all_objects = document.getElementsByTagName("object"); + for (var i=0; i < all_objects.length; i++) { + if (svg === all_objects[i].getSVGDocument().firstElementChild) { + return all_objects[i]; + } + } + return null; +} + function toggle_outlet(svg) { - let sub_dev = svg.parentElement; + let sub_dev = get_object_from_svg(svg).parentElement; let params = { device_id: sub_dev.parentElement.parentElement.id, sub_dev_id: sub_dev.id diff --git a/static/outlet.svg b/static/outlet.svg index 314f598..8256067 100644 --- a/static/outlet.svg +++ b/static/outlet.svg @@ -1,20 +1,20 @@ - + - + + + + diff --git a/templates/index.html b/templates/index.html index 0ee729d..0b1efae 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,38 +1,35 @@ - - Juice - - - - -
- {% for dev_type, devices in network.items() %} - {% for device in devices %} -
-
{{ device.id }}
-
{{ device.description }}
-
{{ device.location }}
-
{{ device.ip_address }}
-
- {% for sub_dev_type, sub_devs in device.sub_devices.items() %} - {% for sub_dev in sub_devs %} -
-
{{ sub_dev.id }}
- - - - - - -
{{ sub_dev.description }}
+ + Juice + + + + +
+
+ {% for dev_type, devices in network.items() %} + {% for device in devices %} +
+
{{ device.id }}
+
{{ device.description }}
+
{{ device.location }}
+
{{ device.ip_address }}
+
+ {% for sub_dev_type, sub_devs in device.sub_devices.items() %} + {% for sub_dev in sub_devs %} +
+
{{ sub_dev.id }}
+ +
{{ sub_dev.description }}
+
+ {% endfor %} + {% endfor %} +
- {% endfor %} - {% endfor %} + {% endfor %} + {% endfor %}
-
- {% endfor %} - {% endfor %} -
- + +