Added page for viewing properties.

This commit is contained in:
Ziver Koc 2020-06-22 21:55:04 +02:00
parent 584760b6ba
commit cf3c922fa2
6 changed files with 83 additions and 7 deletions

View 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>

View file

@ -10,11 +10,8 @@ import zutil.log.LogUtil;
import java.io.File;
import java.io.FileReader;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import java.sql.*;
import java.util.*;
import java.util.logging.Logger;
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){
String value = null;
if (fileConf != null)

View file

@ -28,7 +28,7 @@ public class EventConfigHttpPage extends HalHttpPage {
public EventConfigHttpPage() {
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<>();
for(Class c : ControllerManager.getInstance().getAvailableEvents())

View 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;
}
}

View file

@ -28,7 +28,7 @@ public class SensorConfigHttpPage extends HalHttpPage {
public SensorConfigHttpPage() {
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<>();
for(Class c : ControllerManager.getInstance().getAvailableSensors())

View file

@ -17,6 +17,7 @@
{"se.hal.intf.HalHttpPage": "se.hal.page.EventConfigHttpPage"},
{"se.hal.intf.HalHttpPage": "se.hal.page.TriggerHttpPage"},
{"se.hal.intf.HalHttpPage": "se.hal.page.UserConfigHttpPage"},
{"se.hal.intf.HalHttpPage": "se.hal.page.PropertySettingsPage"},
{"se.hal.intf.HalTrigger": "se.hal.trigger.DateTimeTrigger"},