Map view uses sensor and event objects

This commit is contained in:
Ziver Koc 2016-06-29 17:14:05 +02:00
parent 87badd45bc
commit 866e776b19
3 changed files with 38 additions and 4 deletions

22
resource/web/img/lightbulb.svg Executable file
View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="iso-8859-1"?><!-- Generator: Adobe Illustrator 19.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) --><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 40 40" style="enable-background:new 0 0 40 40;" xml:space="preserve" width="50" height="50">
<g>
<path style="fill:#FFEEA3;" d="M14.5,29.833V28c0-1.914-1.168-3.76-2.52-5.897C10.349,19.525,8.5,16.603,8.5,13 C8.5,6.659,13.659,1.5,20,1.5S31.5,6.659,31.5,13c0,3.603-1.849,6.525-3.48,9.103C26.668,24.24,25.5,26.086,25.5,28v1.833H14.5z"/>
<path style="fill:#BA9B48;" d="M20,2c6.065,0,11,4.935,11,11c0,3.458-1.808,6.315-3.402,8.835C26.262,23.947,25,25.941,25,28v1.333 h-5h-5V28c0-2.059-1.262-4.053-2.598-6.165C10.808,19.315,9,16.458,9,13C9,6.935,13.935,2,20,2 M20,1C13.373,1,8,6.373,8,13 c0,6.667,6,10.958,6,15v2.333h6h6V28c0-4.042,6-8.333,6-15C32,6.373,26.627,1,20,1L20,1z"/>
</g>
<g>
<path style="fill:#FFFFFF;" d="M22.714,11.335c0.502,0,0.974,0.195,1.329,0.55c0.733,0.733,0.733,1.925,0,2.657l-1.75,1.75 L22,16.586V17v12h-4V17v-0.414l-0.293-0.293l-1.75-1.75c-0.733-0.733-0.733-1.925,0-2.657c0.355-0.355,0.827-0.55,1.329-0.55 c0.502,0,0.974,0.195,1.329,0.55l0.679,0.679L20,13.271l0.707-0.707l0.679-0.679C21.741,11.531,22.212,11.335,22.714,11.335 M22.714,10.335c-0.737,0-1.474,0.281-2.036,0.843L20,11.857l-0.679-0.679c-0.562-0.562-1.299-0.843-2.036-0.843 c-0.737,0-1.474,0.281-2.036,0.843c-1.124,1.124-1.124,2.947,0,4.071L17,17v13h6V17l1.75-1.75c1.124-1.124,1.124-2.947,0-4.071 C24.188,10.616,23.451,10.335,22.714,10.335L22.714,10.335z"/>
</g>
<circle style="fill:#8B75A1;" cx="20" cy="35" r="4"/>
<g>
<path style="fill:#DCD5F2;" d="M17,36.5c-1.378,0-2.5-1.122-2.5-2.5v-5.5h11V34c0,1.378-1.122,2.5-2.5,2.5H17z"/>
<g>
<path style="fill:#8B75A1;" d="M25,29v5c0,1.103-0.897,2-2,2h-6c-1.103,0-2-0.897-2-2v-5H25 M26,28H14v6c0,1.657,1.343,3,3,3h6 c1.657,0,3-1.343,3-3V28L26,28z"/>
</g>
</g>
<rect x="19" y="34" style="fill:#8B75A1;" width="6.488" height="1"/>
<rect x="14.56" y="34" style="fill:#8B75A1;" width="2.44" height="1"/>
<rect x="19" y="32" style="fill:#8B75A1;" width="7" height="1"/>
<rect x="14" y="32" style="fill:#8B75A1;" width="3" height="1"/>
<rect x="19" y="30" style="fill:#8B75A1;" width="7" height="1"/>
<rect x="14" y="30" style="fill:#8B75A1;" width="3" height="1"/>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -7,11 +7,14 @@
<rect width="100%" height="100%" style="fill-opacity:0;stroke-width:5;stroke:rgb(0,0,0)" />
<!-- Sensor devices-->
<image class="draggable" x="0" y="0" width="46" height="46" xlink:href="/img/temperature.png" />
{{#sensors}}
<image id="sensor{{.getId()}}" class="draggable sensor" x="0" y="0" width="46" height="46" xlink:href="/img/temperature.png" />
{{/sensors}}
<!-- Event devices -->
<image class="draggable" x="0" y="0" width="46" height="46" xlink:href="/img/lightbulb_01.svg" />
<image class="draggable" x="0" y="0" width="46" height="46" xlink:href="/img/lightbulb_02.svg" />
{{#events}}
<image id="event{{.getId()}}" class="draggable event" x="0" y="0" width="46" height="46" xlink:href="/img/lightbulb.svg" />
{{/events}}
</svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Before After
Before After

View file

@ -1,6 +1,10 @@
package se.hal.page;
import se.hal.HalContext;
import se.hal.intf.HalHttpPage;
import se.hal.struct.Event;
import se.hal.struct.Sensor;
import zutil.db.DBConnection;
import zutil.io.file.FileUtil;
import zutil.parser.Templator;
@ -21,6 +25,11 @@ public class MapHttpPage extends HalHttpPage {
@Override
public Templator httpRespond(Map<String, Object> session, Map<String, String> cookie, Map<String, String> request) throws Exception {
return new Templator(FileUtil.find(TEMPLATE));
DBConnection db = HalContext.getDB();
Templator tmpl = new Templator(FileUtil.find(TEMPLATE));
tmpl.set("sensors", Sensor.getLocalSensors(db));
tmpl.set("events", Event.getLocalEvents(db));
return tmpl;
}
}