Some bugfixes
This commit is contained in:
parent
fc37d158c5
commit
7f22b2dee2
5 changed files with 18 additions and 17 deletions
|
|
@ -10,7 +10,7 @@
|
|||
<th class="col-md-3">Name</th>
|
||||
<th class="col-md-1">Version</th>
|
||||
<th class="col-md-7">Description</th>
|
||||
<th class="col-md-1 text-right">Actions</th>
|
||||
<th class="col-md-1 text-right">Enable</th>
|
||||
</thead>
|
||||
{{#plugins}}
|
||||
<tr>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import zutil.net.http.page.HttpRedirectPage;
|
|||
import zutil.plugin.PluginData;
|
||||
import zutil.plugin.PluginManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Executors;
|
||||
|
|
@ -42,7 +41,7 @@ public class HalServer {
|
|||
|
||||
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
// init logging
|
||||
LogUtil.readConfiguration("logging.properties");
|
||||
|
|
@ -61,10 +60,10 @@ public class HalServer {
|
|||
pluginManager = new PluginManager();
|
||||
|
||||
// Disable plugins based on settings
|
||||
for (PluginData plugin : getPlugins()) {
|
||||
for (PluginData plugin : getAllPlugins()) {
|
||||
PluginConfig pluginConfig = PluginConfig.getPluginConfig(db, plugin.getName());
|
||||
|
||||
if (pluginConfig != null && !pluginConfig.isEnabled()) {
|
||||
if (pluginConfig != null && !pluginConfig.isEnabled() && !plugin.getName().equals("Hal-Core")) {
|
||||
logger.info("Disabling plugin '" + plugin.getName() + "'.");
|
||||
plugin.setEnabled(false);
|
||||
}
|
||||
|
|
@ -138,7 +137,10 @@ public class HalServer {
|
|||
}
|
||||
|
||||
|
||||
public static void setPluginEnabled(String name, boolean enabled) throws SQLException {
|
||||
public static void enablePlugin(String name, boolean enabled) throws SQLException {
|
||||
if (name.equals("Hal-Core"))
|
||||
throw new IllegalArgumentException("Hal-Core cannot be disabled as it is critical component of Hal.");
|
||||
|
||||
DBConnection db = HalContext.getDB();
|
||||
PluginConfig pluginConfig = PluginConfig.getPluginConfig(db, name);
|
||||
|
||||
|
|
@ -152,10 +154,14 @@ public class HalServer {
|
|||
pluginConfig.save(db);
|
||||
}
|
||||
|
||||
public static List<PluginData> getPlugins() {
|
||||
public static List<PluginData> getEnabledPlugins() {
|
||||
return pluginManager.toArray();
|
||||
}
|
||||
|
||||
public static List<PluginData> getAllPlugins() {
|
||||
return pluginManager.toArrayAll();
|
||||
}
|
||||
|
||||
|
||||
public static void registerDaemon(HalDaemon daemon){
|
||||
daemons.add(daemon);
|
||||
|
|
|
|||
|
|
@ -7,14 +7,9 @@ import se.hal.intf.HalWebPage;
|
|||
import se.hal.page.HalAlertManager.AlertLevel;
|
||||
import se.hal.page.HalAlertManager.AlertTTL;
|
||||
import se.hal.page.HalAlertManager.HalAlert;
|
||||
import se.hal.struct.devicedata.SwitchEventData;
|
||||
import zutil.ObjectUtil;
|
||||
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 {
|
||||
|
|
@ -35,7 +30,7 @@ public class PluginConfigWebPage extends HalWebPage {
|
|||
|
||||
if (request.containsKey("action")) {
|
||||
String name = request.get("action_id");
|
||||
HalServer.setPluginEnabled(name,
|
||||
HalServer.enablePlugin(name,
|
||||
(request.containsKey("enabled") && "on".equals(request.get("enabled"))));
|
||||
|
||||
HalAlertManager.getInstance().addAlert(new HalAlert(
|
||||
|
|
@ -43,7 +38,7 @@ public class PluginConfigWebPage extends HalWebPage {
|
|||
}
|
||||
|
||||
Templator tmpl = new Templator(FileUtil.find(TEMPLATE));
|
||||
tmpl.set("plugins", HalServer.getPlugins());
|
||||
tmpl.set("plugins", HalServer.getAllPlugins());
|
||||
tmpl.set("controllers", ControllerManager.getInstance().getControllers());
|
||||
return tmpl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"version": 1.0,
|
||||
"name": "Hal Core",
|
||||
"name": "Hal-Core",
|
||||
"description": "Plugin contains core logic for running Hal.",
|
||||
"interfaces": [
|
||||
{"se.hal.intf.HalDaemon": "se.hal.daemon.SensorDataAggregatorDaemon"},
|
||||
{"se.hal.intf.HalDaemon": "se.hal.daemon.SensorDataCleanupDaemon"},
|
||||
|
||||
|
||||
{"se.hal.intf.HalJsonPage": "se.hal.page.MapJsonPage"},
|
||||
{"se.hal.intf.HalJsonPage": "se.hal.page.SensorJsonPage"},
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,6 @@ public class TemperatureSensorData extends HalSensorData {
|
|||
|
||||
@Override
|
||||
public String toString(){
|
||||
return temperature+" \u00b0C";
|
||||
return temperature + " C";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue