Added scan button to controller section

This commit is contained in:
Ziver Koc 2021-06-09 20:53:10 +02:00
parent e662f7e29d
commit 6656882859
4 changed files with 34 additions and 13 deletions

View file

@ -19,8 +19,8 @@
<td>{{#.getDescription()}}{{.getDescription()}}{{/.getDescription()}}</td>
<td>
<form method="POST">
<input type="hidden" name="action" value="modify">
<input type="hidden" name="action_id" value="{{.getName()}}">
<input type="hidden" name="action" value="plugin_enable">
<input type="hidden" name="plugin_name" value="{{.getName()}}">
<div class="btn-toolbar pull-right">
<input class="toggle-switch" type="checkbox" name="enabled"
@ -44,10 +44,23 @@
<table class="table table-hover table-condensed">
<thead>
<th class="col-md-3">Name</th>
<th class="col-md-1 text-right">Actions</th>
</thead>
{{#controllers}}
<tr>
<td>{{.getClass().getName()}}</td>
<td>
<div class="btn-toolbar pull-right">
<form method="POST">
<input type="hidden" name="action" value="controller_scan">
<input type="hidden" name="controller" value="{{.getClass().getName()}}">
<button type="submit" class="btn btn-primary btn-xs" style="padding: 1px 20px;">
<span class="glyphicon glyphicon-search"></span>
</button>
</form>
</div>
</td>
</tr>
{{/controllers}}
</table>

View file

@ -92,7 +92,7 @@ public abstract class HalAbstractControllerManager<T extends HalAbstractControll
/**
* Registers a device configuration class type as usable by this manager
*/
protected void addAvailableDeviceConfig(Class<? extends C> deviceConfigClass) {
public void addAvailableDeviceConfig(Class<? extends C> deviceConfigClass) {
if (!availableDeviceConfigs.contains(deviceConfigClass))
availableDeviceConfigs.add(deviceConfigClass);
}

View file

@ -34,17 +34,25 @@ public class PluginConfigWebPage extends HalWebPage {
throws Exception{
if (request.containsKey("action")) {
String name = request.get("action_id");
switch (request.get("action")) {
case "plugin_enable":
String name = request.get("plugin_name");
if (!name.equals("Hal-Core")) {
HalServer.enablePlugin(name,
(request.containsKey("enabled") && "on".equals(request.get("enabled"))));
if (!name.equals("Hal-Core")) {
HalServer.enablePlugin(name,
(request.containsKey("enabled") && "on".equals(request.get("enabled"))));
HalAlertManager.getInstance().addAlert(new UserMessage(
MessageLevel.SUCCESS, "Successfully updated plugin " + name + ", change will take affect after restart.", MessageTTL.ONE_VIEW));
} else {
HalAlertManager.getInstance().addAlert(new UserMessage(
MessageLevel.ERROR, "Hal-Core cannot be disabled as it is critical component of Hal.", MessageTTL.ONE_VIEW));
HalAlertManager.getInstance().addAlert(new UserMessage(
MessageLevel.SUCCESS, "Successfully updated plugin " + name + ", change will take affect after restart.", MessageTTL.ONE_VIEW));
} else {
HalAlertManager.getInstance().addAlert(new UserMessage(
MessageLevel.ERROR, "Hal-Core cannot be disabled as it is critical component of Hal.", MessageTTL.ONE_VIEW));
}
break;
case "controller_scan":
String controllerName = request.get("controller");
break;
}
}

View file

@ -44,7 +44,7 @@ public class PluginConfig extends DBBean {
public static PluginConfig getPluginConfig(DBConnection db, String name) throws SQLException {
PreparedStatement stmt = db.getPreparedStatement( "SELECT plugin.* FROM plugin WHERE name == ?" );
stmt.setString(1, name);
return DBConnection.exec(stmt, DBBeanSQLResultHandler.create(PluginConfig.class, db) );
return DBConnection.exec(stmt, DBBeanSQLResultHandler.create(PluginConfig.class, db));
}