Added plugin page for viewing plugin information

This commit is contained in:
Ziver Koc 2020-06-22 22:16:50 +02:00
parent 4f7476bb84
commit fc11ae264f
10 changed files with 83 additions and 6 deletions

View file

@ -13,7 +13,10 @@
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-zigbee/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-zwave/test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-mqtt/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-nutups/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-mqtt/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-nutups/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-raspberry/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-tellstick/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-zigbee/build" />

View file

@ -1,6 +1,6 @@
{
"version": 1.1,
"name": "Raspberry Pi Sensors",
"name": "Hal-RaspberryPi Sensors",
"interfaces": [
{"se.hal.intf.HalSensorConfig": "se.hal.plugin.raspberry.RPiPowerConsumptionSensor"},
{"se.hal.intf.HalSensorConfig": "se.hal.plugin.raspberry.RPiTemperatureSensor"}

View file

@ -1,6 +1,6 @@
{
"version": 1.0,
"name": "Tellstick",
"name": "Hal-Tellstick",
"interfaces": [
{"se.hal.intf.HalAutoScannableController": "se.hal.plugin.tellstick.TellstickSerialComm"},

View file

@ -0,0 +1,6 @@
{
"version": 1.0,
"name": "Hal-ZWwave",
"interfaces": [
]
}

View file

@ -0,0 +1,22 @@
<h1 class="page-header">Plugins</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">Version</th>
</thead>
{{#plugins}}
<tr>
<td>{{.getName()}}</td>
<td>{{.getVersion()}}</td>
</tr>
{{/plugins}}
</table>
</div>
</div>
</div>

View file

@ -1,4 +1,4 @@
<h1 class="page-header">Event Overview</h1>
<h1 class="page-header">Hal Properties</h1>
<div class="col-md-12">
<div class="panel panel-default drop-shadow">

View file

@ -31,6 +31,8 @@ public class HalServer {
private static HttpServer http;
private static List<HalWebPage> pages = new ArrayList<>();
private static PluginManager pluginManager;
public static void main(String[] args) throws Exception {
@ -40,7 +42,7 @@ public class HalServer {
// init DB and other configurations
HalContext.initialize();
DBConnection db = HalContext.getDB();
PluginManager pluginManager = new PluginManager("./");
pluginManager = new PluginManager("./");
// init Managers
HalAlertManager.initialize();
@ -85,6 +87,10 @@ public class HalServer {
}
public static PluginManager getPluginManager() {
return pluginManager;
}
public static void registerDaemon(HalDaemon daemon){
daemons.add(daemon);
daemon.initiate(daemonExecutor);

View file

@ -0,0 +1,39 @@
package se.hal.page;
import se.hal.HalContext;
import se.hal.HalServer;
import se.hal.intf.HalWebPage;
import zutil.db.DBConnection;
import zutil.io.file.FileUtil;
import zutil.parser.Templator;
import zutil.plugin.PluginManager;
import java.util.HashMap;
import java.util.Map;
public class PluginConfigWebPage extends HalWebPage {
private static final String TEMPLATE = "resource/web/plugin_config.tmpl";
public PluginConfigWebPage(){
super("plugins");
super.getRootNav().createSubNav("Settings").createSubNav(this.getId(), "Plugins").setWeight(100);
}
@Override
public Templator httpRespond(
Map<String, Object> session,
Map<String, String> cookie,
Map<String, String> request)
throws Exception{
DBConnection db = HalContext.getDB();
PluginManager pluginManager = HalServer.getPluginManager();
Templator tmpl = new Templator(FileUtil.find(TEMPLATE));
tmpl.set("plugins", pluginManager.toArray());
return tmpl;
}
}

View file

@ -9,7 +9,7 @@ import zutil.parser.Templator;
import java.util.*;
public class PropertyConfigWebPage extends HalWebPage {
private static final String TEMPLATE = "resource/web/properties_config.tmpl";
private static final String TEMPLATE = "resource/web/property_config.tmpl";
public PropertyConfigWebPage(){

View file

@ -16,7 +16,8 @@
{"se.hal.intf.HalWebPage": "se.hal.page.EventConfigWebPage"},
{"se.hal.intf.HalWebPage": "se.hal.page.TriggerWebPage"},
{"se.hal.intf.HalWebPage": "se.hal.page.UserConfigWebPage"},
{"se.hal.intf.HalWebPage": "se.hal.page.PropertySettingsPage"},
{"se.hal.intf.HalWebPage": "se.hal.page.PropertyConfigWebPage"},
{"se.hal.intf.HalWebPage": "se.hal.page.PluginConfigWebPage"},
{"se.hal.intf.HalTrigger": "se.hal.trigger.DateTimeTrigger"},