Added page for viewing properties.
This commit is contained in:
parent
584760b6ba
commit
cf3c922fa2
6 changed files with 83 additions and 7 deletions
24
resource/web/properties_config.tmpl
Normal file
24
resource/web/properties_config.tmpl
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<h1 class="page-header">Event Overview</h1>
|
||||||
|
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="panel panel-default drop-shadow">
|
||||||
|
<div class="panel-heading">Local Events</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
|
||||||
|
<table class="table table-hover table-condensed">
|
||||||
|
<thead>
|
||||||
|
<th class="col-md-2">Name</th>
|
||||||
|
<th class="col-md-8">Value</th>
|
||||||
|
<th class="col-md-4">Description</th>
|
||||||
|
</thead>
|
||||||
|
{{#properties}}
|
||||||
|
<tr>
|
||||||
|
<td>{{.getKey()}}:</td>
|
||||||
|
<td><input name="{{.getKey()}}" value="{{.getValue()}}" disabled style="width: 100%"></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
{{/properties}}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
@ -10,11 +10,8 @@ import zutil.log.LogUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.*;
|
||||||
import java.sql.ResultSet;
|
import java.util.*;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class HalContext {
|
public class HalContext {
|
||||||
|
|
@ -171,6 +168,14 @@ public class HalContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static HashMap<String,String> getProperties() {
|
||||||
|
HashMap map = new HashMap();
|
||||||
|
map.putAll(fileConf);
|
||||||
|
map.putAll(dbConf);
|
||||||
|
return map;
|
||||||
|
|
||||||
|
}
|
||||||
public static String getStringProperty(String key){
|
public static String getStringProperty(String key){
|
||||||
String value = null;
|
String value = null;
|
||||||
if (fileConf != null)
|
if (fileConf != null)
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public class EventConfigHttpPage extends HalHttpPage {
|
||||||
|
|
||||||
public EventConfigHttpPage() {
|
public EventConfigHttpPage() {
|
||||||
super("event_config");
|
super("event_config");
|
||||||
super.getRootNav().createSubNav("Events").createSubNav(this.getId(), "Configuration").setWeight(100);
|
super.getRootNav().createSubNav("Settings").createSubNav(this.getId(), "Event Settings").setWeight(100);
|
||||||
|
|
||||||
eventConfigurations = new ArrayList<>();
|
eventConfigurations = new ArrayList<>();
|
||||||
for(Class c : ControllerManager.getInstance().getAvailableEvents())
|
for(Class c : ControllerManager.getInstance().getAvailableEvents())
|
||||||
|
|
|
||||||
46
src/se/hal/page/PropertySettingsPage.java
Normal file
46
src/se/hal/page/PropertySettingsPage.java
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
package se.hal.page;
|
||||||
|
|
||||||
|
import se.hal.ControllerManager;
|
||||||
|
import se.hal.HalContext;
|
||||||
|
import se.hal.intf.HalHttpPage;
|
||||||
|
import se.hal.struct.Event;
|
||||||
|
import se.hal.struct.devicedata.SwitchEventData;
|
||||||
|
import se.hal.util.DeviceNameComparator;
|
||||||
|
import se.hal.util.HistoryDataListSqlResult;
|
||||||
|
import se.hal.util.HistoryDataListSqlResult.HistoryData;
|
||||||
|
import zutil.ObjectUtil;
|
||||||
|
import zutil.db.DBConnection;
|
||||||
|
import zutil.io.file.FileUtil;
|
||||||
|
import zutil.log.LogUtil;
|
||||||
|
import zutil.parser.Templator;
|
||||||
|
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class PropertySettingsPage extends HalHttpPage {
|
||||||
|
private static final String TEMPLATE = "resource/web/properties_config.tmpl";
|
||||||
|
|
||||||
|
|
||||||
|
public PropertySettingsPage(){
|
||||||
|
super("properties");
|
||||||
|
super.getRootNav().createSubNav("Settings").setWeight(100).createSubNav(this.getId(), "Properties");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Templator httpRespond(
|
||||||
|
Map<String, Object> session,
|
||||||
|
Map<String, String> cookie,
|
||||||
|
Map<String, String> request)
|
||||||
|
throws Exception{
|
||||||
|
|
||||||
|
DBConnection db = HalContext.getDB();
|
||||||
|
|
||||||
|
HashMap properties = HalContext.getProperties();
|
||||||
|
|
||||||
|
Templator tmpl = new Templator(FileUtil.find(TEMPLATE));
|
||||||
|
tmpl.set("properties", properties.entrySet());
|
||||||
|
return tmpl;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -28,7 +28,7 @@ public class SensorConfigHttpPage extends HalHttpPage {
|
||||||
|
|
||||||
public SensorConfigHttpPage() {
|
public SensorConfigHttpPage() {
|
||||||
super("sensor_config");
|
super("sensor_config");
|
||||||
super.getRootNav().createSubNav("Sensors").createSubNav(this.getId(), "Configuration").setWeight(100);
|
super.getRootNav().createSubNav("Settings").createSubNav(this.getId(), "Sensor Settings").setWeight(100);
|
||||||
|
|
||||||
sensorConfigurations = new ArrayList<>();
|
sensorConfigurations = new ArrayList<>();
|
||||||
for(Class c : ControllerManager.getInstance().getAvailableSensors())
|
for(Class c : ControllerManager.getInstance().getAvailableSensors())
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
{"se.hal.intf.HalHttpPage": "se.hal.page.EventConfigHttpPage"},
|
{"se.hal.intf.HalHttpPage": "se.hal.page.EventConfigHttpPage"},
|
||||||
{"se.hal.intf.HalHttpPage": "se.hal.page.TriggerHttpPage"},
|
{"se.hal.intf.HalHttpPage": "se.hal.page.TriggerHttpPage"},
|
||||||
{"se.hal.intf.HalHttpPage": "se.hal.page.UserConfigHttpPage"},
|
{"se.hal.intf.HalHttpPage": "se.hal.page.UserConfigHttpPage"},
|
||||||
|
{"se.hal.intf.HalHttpPage": "se.hal.page.PropertySettingsPage"},
|
||||||
|
|
||||||
|
|
||||||
{"se.hal.intf.HalTrigger": "se.hal.trigger.DateTimeTrigger"},
|
{"se.hal.intf.HalTrigger": "se.hal.trigger.DateTimeTrigger"},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue