Implemented UI for editing Triggers and Actions
This commit is contained in:
parent
5170a151c8
commit
1265c38d82
8 changed files with 77 additions and 24 deletions
|
|
@ -40,10 +40,35 @@
|
|||
<table class="table table-hover table-condensed table-borderless">
|
||||
{{#.getTriggers()}}
|
||||
<tr><td>
|
||||
<div class="panel panel-default drop-shadow"><div class="panel-body">
|
||||
<span class="glyphicon glyphicon-time"></span>
|
||||
{{.}}
|
||||
</div></div>
|
||||
<div class="panel panel-default drop-shadow {{#.evaluate()}}panel-success{{/.evaluate()}}">
|
||||
<div class="panel-heading" style="padding: 2px 15px;">
|
||||
<small>{{.getClass().getName()}}</small>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="action" value="remove_trigger">
|
||||
<input type="hidden" name="id" value="{{.getId()}}">
|
||||
|
||||
<div class="btn-toolbar pull-right">
|
||||
<button type="button" class="btn btn-default btn-xs" data-toggle="modal"
|
||||
data-target="#triggerModal"
|
||||
data-action="modify_trigger"
|
||||
data-trigger-id="{{.getId()}}"
|
||||
data-type="{{.getObjectClass()}}"
|
||||
{{#.getObjectConfigurator().getConfiguration()}}
|
||||
data-{{.getName()}}="{{.getString()}}"
|
||||
{{/.getObjectConfigurator().getConfiguration()}} >
|
||||
<span class="glyphicon glyphicon-pencil"></span>
|
||||
</button>
|
||||
<button type="submit" class="btn btn-danger btn-xs">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<span class="glyphicon glyphicon-time"></span>
|
||||
{{.}}
|
||||
</div>
|
||||
</div>
|
||||
</td></tr>
|
||||
{{/.getTriggers()}}
|
||||
</table>
|
||||
|
|
@ -58,10 +83,35 @@
|
|||
<table class="table table-hover table-condensed table-borderless">
|
||||
{{#.getActions()}}
|
||||
<tr><td>
|
||||
<div class="panel panel-default drop-shadow"><div class="panel-body">
|
||||
<span class="glyphicon glyphicon-play-circle"></span>
|
||||
{{.}}
|
||||
</div></div>
|
||||
<div class="panel panel-default drop-shadow">
|
||||
<div class="panel-heading" style="padding: 2px 15px;">
|
||||
<small>{{.getClass().getName()}}</small>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="action" value="remove_action">
|
||||
<input type="hidden" name="id" value="{{.getId()}}">
|
||||
|
||||
<div class="btn-toolbar pull-right">
|
||||
<button type="button" class="btn btn-default btn-xs" data-toggle="modal"
|
||||
data-target="#actionModal"
|
||||
data-action="modify_action"
|
||||
data-action-id="{{.getId()}}"
|
||||
data-type="{{.getObjectClass()}}"
|
||||
{{#.getObjectConfigurator().getConfiguration()}}
|
||||
data-{{.getName()}}="{{.getString()}}"
|
||||
{{/.getObjectConfigurator().getConfiguration()}} >
|
||||
<span class="glyphicon glyphicon-pencil"></span>
|
||||
</button>
|
||||
<button type="submit" class="btn btn-danger btn-xs">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<span class="glyphicon glyphicon-play-circle"></span>
|
||||
{{.}}
|
||||
</div>
|
||||
</div>
|
||||
</td></tr>
|
||||
{{/.getActions()}}
|
||||
</table>
|
||||
|
|
@ -166,8 +216,8 @@
|
|||
<form method="POST">
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="action" value="">
|
||||
<input type="hidden" name="flow_id">
|
||||
<input type="hidden" name="action_id">
|
||||
<input type="hidden" name="flow-id">
|
||||
<input type="hidden" name="action-id">
|
||||
<div class="form-group">
|
||||
<label class="control-label">Type:</label>
|
||||
<select class="form-control" name="type">
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class HalServer {
|
|||
TriggerManager.initialize(pluginManager);
|
||||
|
||||
|
||||
// Import sensors,events and controllers
|
||||
// Import sensors,events and triggers
|
||||
for(Sensor sensor : Sensor.getLocalSensors(db)){
|
||||
ControllerManager.getInstance().register(sensor);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,11 +75,12 @@ public class TriggerHttpPage extends HalHttpPage {
|
|||
}
|
||||
trigger = new Trigger();
|
||||
flow.addTrigger(trigger);
|
||||
flow.save(db);
|
||||
/* FALLTHROUGH */
|
||||
case "modify_trigger":
|
||||
trigger.setObjectClass(request.get("type"));
|
||||
trigger.getObjectConfigurator().setValues(request).applyConfiguration();
|
||||
flow.save(db); // will save all sub beans also
|
||||
trigger.save(db); // will save all sub beans also
|
||||
break;
|
||||
case "remove_trigger":
|
||||
flow.removeTrigger(trigger);
|
||||
|
|
@ -95,11 +96,12 @@ public class TriggerHttpPage extends HalHttpPage {
|
|||
}
|
||||
action = new Action();
|
||||
flow.addAction(action);
|
||||
flow.save(db);
|
||||
/* FALLTHROUGH */
|
||||
case "modify_action":
|
||||
action.setObjectClass(request.get("type"));
|
||||
action.getObjectConfigurator().setValues(request).applyConfiguration();
|
||||
flow.save(db); // will save all sub beans also
|
||||
action.save(db); // will save all sub beans also
|
||||
break;
|
||||
case "remove_action":
|
||||
flow.removeAction(action);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@
|
|||
|
||||
{"se.hal.intf.HalTrigger": "se.hal.trigger.DateTimeTrigger"},
|
||||
{"se.hal.intf.HalTrigger": "se.hal.trigger.TimerTrigger"},
|
||||
{"se.hal.intf.HalAction": "se.hal.trigger.action.SendEventAction"}
|
||||
{"se.hal.intf.HalAction": "se.hal.action.SendEventAction"}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,11 +22,6 @@ public class Action extends DBBeanObjectDSO<HalAction>{
|
|||
public static Action getAction(DBConnection db, long id) throws SQLException {
|
||||
return DBBean.load(db, Action.class, id);
|
||||
}
|
||||
public static List<Action> getActions(DBConnection db, TriggerFlow flow) throws SQLException {
|
||||
PreparedStatement stmt = db.getPreparedStatement( "SELECT * FROM action WHERE flow_id == ?" );
|
||||
stmt.setLong(1, flow.getId());
|
||||
return DBConnection.exec(stmt, DBBeanSQLResultHandler.createList(Action.class, db) );
|
||||
}
|
||||
|
||||
|
||||
public Action() { }
|
||||
|
|
|
|||
|
|
@ -23,11 +23,7 @@ public class Trigger extends DBBeanObjectDSO<HalTrigger>{
|
|||
public static Trigger getTrigger(DBConnection db, long id) throws SQLException {
|
||||
return DBBean.load(db, Trigger.class, id);
|
||||
}
|
||||
public static List<Trigger> getTriggers(DBConnection db, TriggerFlow flow) throws SQLException {
|
||||
PreparedStatement stmt = db.getPreparedStatement( "SELECT * FROM trigger WHERE flow_id == ?" );
|
||||
stmt.setLong(1, flow.getId());
|
||||
return DBConnection.exec(stmt, DBBeanSQLResultHandler.createList(Trigger.class, db) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Trigger() { }
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ public class TriggerFlow extends DBBean {
|
|||
public void addTrigger(Trigger trigger) {
|
||||
triggerList.add(trigger);
|
||||
}
|
||||
public List<Trigger> getTriggers() {
|
||||
return triggerList;
|
||||
}
|
||||
public void removeTrigger(Trigger trigger) {
|
||||
triggerList.remove(trigger);
|
||||
}
|
||||
|
|
@ -55,6 +58,9 @@ public class TriggerFlow extends DBBean {
|
|||
public void addAction(Action action) {
|
||||
actionList.add(action);
|
||||
}
|
||||
public List<Action> getActions() {
|
||||
return actionList;
|
||||
}
|
||||
public void removeAction(Action action) {
|
||||
actionList.remove(action);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,4 +23,8 @@ public class TimerTrigger implements HalTrigger {
|
|||
public void reset() {
|
||||
timer = new Timer(timerTime * 1000).start();
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "Timer: "+ timerTime +"s";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue