diff --git a/src/se/hal/page/EventConfigHttpPage.java b/src/se/hal/page/EventConfigHttpPage.java index 302f0e34..8d4c53d4 100755 --- a/src/se/hal/page/EventConfigHttpPage.java +++ b/src/se/hal/page/EventConfigHttpPage.java @@ -86,7 +86,7 @@ public class EventConfigHttpPage extends HalHttpPage { // Output Templator tmpl = new Templator(FileUtil.find(TEMPLATE)); tmpl.set("user", localUser); - tmpl.set("localEvent", Event.getLocalEvents(db)); + tmpl.set("localEvents", Event.getLocalEvents(db)); tmpl.set("localEventConf", eventConfigurations); tmpl.set("detectedEvents", ControllerManager.getInstance().getDetectedEvents()); diff --git a/src/se/hal/struct/Event.java b/src/se/hal/struct/Event.java index 69765cc7..32e24ca6 100755 --- a/src/se/hal/struct/Event.java +++ b/src/se/hal/struct/Event.java @@ -15,7 +15,7 @@ import java.util.logging.Logger; /** * Created by Ziver on 2015-12-15. */ -@DBBean.DBTable("event") +@DBBean.DBTable(value="event", superBean=true) public class Event extends AbstractDevice{ private static final Logger logger = LogUtil.getLogger(); diff --git a/web-resource/css/main.css b/web-resource/css/hal.css similarity index 93% rename from web-resource/css/main.css rename to web-resource/css/hal.css index 8f982497..305aedee 100755 --- a/web-resource/css/main.css +++ b/web-resource/css/hal.css @@ -1,113 +1,113 @@ -/* - * Base structure - */ - -/* Move down content because we have a fixed navbar that is 50px tall */ -body { - padding-top: 50px; -} - - -/* - * Global add-ons - */ - -.sub-header { - padding-bottom: 10px; - border-bottom: 1px solid #eee; -} - -/* - * Top navigation - * Hide default border to remove 1px line. - */ -.navbar-fixed-top { - border: 0; -} - -/* - * Sidebar - */ - -/* Hide for mobile, show later */ -.sidebar { - display: none; -} -@media (min-width: 768px) { - .sidebar { - position: fixed; - top: 51px; - bottom: 0; - left: 0; - z-index: 1000; - display: block; - padding: 20px; - overflow-x: hidden; - overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ - background-color: #f5f5f5; - border-right: 1px solid #eee; - } -} - -/* Sidebar navigation */ -.nav-sidebar { - margin-right: -21px; /* 20px padding + 1px border */ - margin-bottom: 20px; - margin-left: -20px; -} -.nav-sidebar > li > a { - padding-right: 20px; - padding-left: 20px; -} -.nav-sidebar > .active > a, -.nav-sidebar > .active > a:hover, -.nav-sidebar > .active > a:focus { - color: #fff; - background-color: #428bca; -} - - -/* - * Main content - */ - -.main { - padding: 20px; -} -@media (min-width: 768px) { - .main { - padding-right: 40px; - padding-left: 40px; - } -} -.main .page-header { - margin-top: 0; -} - - -/* - * Placeholder dashboard ideas - */ - -.placeholders { - margin-bottom: 200px; - text-align: center; -} -.placeholders h4 { - margin-bottom: 0; -} -.placeholder { - margin-bottom: 20px; -} -.placeholder img { - display: inline-block; - border-radius: 50%; -} - -.panel{ - margin-bottom: 70px; -} - -.drop-shadow { - box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12) +/* + * Base structure + */ + +/* Move down content because we have a fixed navbar that is 50px tall */ +body { + padding-top: 50px; +} + + +/* + * Global add-ons + */ + +.sub-header { + padding-bottom: 10px; + border-bottom: 1px solid #eee; +} + +/* + * Top navigation + * Hide default border to remove 1px line. + */ +.navbar-fixed-top { + border: 0; +} + +/* + * Sidebar + */ + +/* Hide for mobile, show later */ +.sidebar { + display: none; +} +@media (min-width: 768px) { + .sidebar { + position: fixed; + top: 51px; + bottom: 0; + left: 0; + z-index: 1000; + display: block; + padding: 20px; + overflow-x: hidden; + overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ + background-color: #f5f5f5; + border-right: 1px solid #eee; + } +} + +/* Sidebar navigation */ +.nav-sidebar { + margin-right: -21px; /* 20px padding + 1px border */ + margin-bottom: 20px; + margin-left: -20px; +} +.nav-sidebar > li > a { + padding-right: 20px; + padding-left: 20px; +} +.nav-sidebar > .active > a, +.nav-sidebar > .active > a:hover, +.nav-sidebar > .active > a:focus { + color: #fff; + background-color: #428bca; +} + + +/* + * Main content + */ + +.main { + padding: 20px; +} +@media (min-width: 768px) { + .main { + padding-right: 40px; + padding-left: 40px; + } +} +.main .page-header { + margin-top: 0; +} + + +/* + * Placeholder dashboard ideas + */ + +.placeholders { + margin-bottom: 200px; + text-align: center; +} +.placeholders h4 { + margin-bottom: 0; +} +.placeholder { + margin-bottom: 20px; +} +.placeholder img { + display: inline-block; + border-radius: 50%; +} + +.panel{ + margin-bottom: 70px; +} + +.drop-shadow { + box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12) } \ No newline at end of file diff --git a/web-resource/event_config.tmpl b/web-resource/event_config.tmpl index cb303b16..58c3ddb7 100755 --- a/web-resource/event_config.tmpl +++ b/web-resource/event_config.tmpl @@ -22,7 +22,7 @@ {{.getName()}} {{.getType()}} - {{.getConfig()}} + {{.getDeviceData()}}
@@ -34,7 +34,10 @@ data-id="{{.getId()}}" data-name="{{.getName()}}" data-type="{{.getType()}}" - data-config="{{.getConfig()}}"> + {{#.getDeviceConfig().getConfiguration()}} + data-{{.getName()}}="{{.getString()}}" + {{/.getDeviceConfig().getConfiguration()}} + > @@ -64,7 +67,10 @@ @@ -96,18 +102,21 @@ var modal = $(this); modal.find("input[type=text]").val(""); // Reset all inputs if(button.data("id") >= 0){ // edit - modal.find("input[name=action]").val("modify_local_event"); - modal.find("input[name=id]").val(button.data("id")); - modal.find("input[name=name]").val(button.data("name")); modal.find("select[name=type]").val(button.data("type")); - modal.find("input[name=config]").val(button.data("config")); + modal.find("select[name=type]").change(); // Update dynamic inputs + $.each(button.attr(), function(name, value) { + if(name.startsWith("data-")) { + name = name.substring(5); + console.log(name, value); + modal.find("input[name="+name+"]").val(value); + } + }); + modal.find("input[name=action]").val("modify_local_event"); } else{ // create modal.find("input[name=action]").val("create_local_event"); modal.find("input[name=id]").val(-1); } - // Update dynamic inputs - modal.find("select[name=type]").change(); }); }); diff --git a/web-resource/index.tmpl b/web-resource/index.tmpl index 25bae537..c8ef2a7d 100755 --- a/web-resource/index.tmpl +++ b/web-resource/index.tmpl @@ -10,10 +10,12 @@ - + + + diff --git a/web-resource/js/hal.js b/web-resource/js/hal.js new file mode 100755 index 00000000..2e88427f --- /dev/null +++ b/web-resource/js/hal.js @@ -0,0 +1,19 @@ +(function(old) { + $.fn.attr = function() { + if(arguments.length === 0) { + if(this.length === 0) { + return null; + } + + var obj = {}; + $.each(this[0].attributes, function() { + if(this.specified) { + obj[this.name] = this.value; + } + }); + return obj; + } + + return old.apply(this, arguments); + }; +})($.fn.attr); \ No newline at end of file diff --git a/web-resource/sensor_config.tmpl b/web-resource/sensor_config.tmpl index 2954170c..2b7e0e30 100755 --- a/web-resource/sensor_config.tmpl +++ b/web-resource/sensor_config.tmpl @@ -24,7 +24,7 @@ {{.getName()}} {{.getType()}} {{.isSynced()}} - {{.getDeviceConfig()}} + {{.getDeviceData()}} @@ -37,7 +37,10 @@ data-name="{{.getName()}}" data-type="{{.getType()}}" data-sync="{{.isSynced()}}" - data-config="{{.getConfig()}}"> + {{#.getDeviceConfig().getConfiguration()}} + data-{{.getName()}}="{{.getString()}}" + {{/.getDeviceConfig().getConfiguration()}} + > @@ -67,7 +70,10 @@ @@ -148,7 +154,7 @@ {{.getName()}} {{.getType()}} - {{.getDeviceConfig()}} + {{.getDeviceData()}}
@@ -196,20 +202,23 @@ var modal = $(this); modal.find("input[type=text]").val(""); // Reset all inputs if(button.data("id") >= 0){ // edit - modal.find("input[name=action]").val("modify_local_sensor"); - modal.find("input[name=id]").val(button.data("id")); - modal.find("input[name=name]").val(button.data("name")); modal.find("select[name=type]").val(button.data("type")); + modal.find("select[name=type]").change(); // Update dynamic inputs + $.each(button.attr(), function(name, value) { + if(name.startsWith("data-")) { + name = name.substring(5); + console.log(name, value); + modal.find("input[name="+name+"]").val(value); + } + }); + modal.find("input[name=action]").val("modify_local_sensor"); modal.find("input[name=sync]").prop("checked", button.data("sync")); - modal.find("input[name=config]").val(button.data("config")); } else{ // create modal.find("input[name=action]").val("create_local_sensor"); modal.find("input[name=id]").val(-1); modal.find("input[name=sync]").prop("checked", "false"); } - // Update dynamic inputs - modal.find("select[name=type]").change(); });