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>{{#.getDescription()}}{{.getDescription()}}{{/.getDescription()}}</td>
<td> <td>
<form method="POST"> <form method="POST">
<input type="hidden" name="action" value="modify"> <input type="hidden" name="action" value="plugin_enable">
<input type="hidden" name="action_id" value="{{.getName()}}"> <input type="hidden" name="plugin_name" value="{{.getName()}}">
<div class="btn-toolbar pull-right"> <div class="btn-toolbar pull-right">
<input class="toggle-switch" type="checkbox" name="enabled" <input class="toggle-switch" type="checkbox" name="enabled"
@ -44,10 +44,23 @@
<table class="table table-hover table-condensed"> <table class="table table-hover table-condensed">
<thead> <thead>
<th class="col-md-3">Name</th> <th class="col-md-3">Name</th>
<th class="col-md-1 text-right">Actions</th>
</thead> </thead>
{{#controllers}} {{#controllers}}
<tr> <tr>
<td>{{.getClass().getName()}}</td> <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> </tr>
{{/controllers}} {{/controllers}}
</table> </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 * 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)) if (!availableDeviceConfigs.contains(deviceConfigClass))
availableDeviceConfigs.add(deviceConfigClass); availableDeviceConfigs.add(deviceConfigClass);
} }

View file

@ -34,7 +34,9 @@ public class PluginConfigWebPage extends HalWebPage {
throws Exception{ throws Exception{
if (request.containsKey("action")) { 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")) { if (!name.equals("Hal-Core")) {
HalServer.enablePlugin(name, HalServer.enablePlugin(name,
@ -46,6 +48,12 @@ public class PluginConfigWebPage extends HalWebPage {
HalAlertManager.getInstance().addAlert(new UserMessage( HalAlertManager.getInstance().addAlert(new UserMessage(
MessageLevel.ERROR, "Hal-Core cannot be disabled as it is critical component of Hal.", MessageTTL.ONE_VIEW)); 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;
}
} }
List<HalAbstractController> controllers = new LinkedList<>(); List<HalAbstractController> controllers = new LinkedList<>();

View file

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