Added trigger page (incomplete). issue 6
This commit is contained in:
parent
1688a8b2e5
commit
5814b2537f
3 changed files with 216 additions and 0 deletions
161
resource/web/trigger.tmpl
Executable file
161
resource/web/trigger.tmpl
Executable file
|
|
@ -0,0 +1,161 @@
|
|||
<h1 class="page-header">
|
||||
Triggers
|
||||
|
||||
<form class="pull-right">
|
||||
<input type="hidden" name="action" value="create_flow" />
|
||||
<button type="submit" class="btn btn-default">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
</button>
|
||||
</form>
|
||||
</h1>
|
||||
|
||||
|
||||
{{#flows}}
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-default drop-shadow">
|
||||
<div class="panel-heading"></div>
|
||||
<div class="panel-body">
|
||||
<table class="table table-condensed">
|
||||
<thead class="row">
|
||||
<th class="col-md-5 text-center">
|
||||
Triggers
|
||||
<button class="btn btn-default btn-xs pull-right" data-toggle="modal"
|
||||
data-target="#triggerModal">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
</button>
|
||||
</th>
|
||||
<th></th>
|
||||
<th class="col-md-6 text-center">
|
||||
Actions
|
||||
<button class="btn btn-default btn-xs pull-right" data-toggle="modal"
|
||||
data-target="#actionModal">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
</button>
|
||||
</th>
|
||||
</thead>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<!-- TRIGGERS -->
|
||||
<table class="table table-hover table-condensed table-borderless">
|
||||
<tr><td>
|
||||
<div class="panel panel-default drop-shadow"><div class="panel-body">
|
||||
<span class="glyphicon glyphicon-time"></span>
|
||||
test trigger
|
||||
</div></div>
|
||||
</td></tr>
|
||||
<tr><td>
|
||||
<div class="panel panel-default drop-shadow"><div class="panel-body">
|
||||
<span class="glyphicon glyphicon-time"></span>
|
||||
test trigger
|
||||
</div></div>
|
||||
</td></tr>
|
||||
<tr><td>
|
||||
<div class="panel panel-default drop-shadow"><div class="panel-body">
|
||||
<span class="glyphicon glyphicon-time"></span>
|
||||
test trigger
|
||||
</div></div>
|
||||
</td></tr>
|
||||
</table>
|
||||
<!-- /TRIGGERS -->
|
||||
</td>
|
||||
<td class="text-center text-vert-middle">
|
||||
<span class="glyphicon glyphicon-arrow-right"></span><br />
|
||||
<span class="glyphicon glyphicon-arrow-right"></span>
|
||||
</td>
|
||||
<td>
|
||||
<!-- ACTIONS -->
|
||||
<table class="table table-hover table-condensed table-borderless">
|
||||
<tr><td>
|
||||
<div class="panel panel-default drop-shadow"><div class="panel-body">
|
||||
<span class="glyphicon glyphicon-play-circle"></span>
|
||||
test action
|
||||
</div></div>
|
||||
</td></tr>
|
||||
<tr><td>
|
||||
<div class="panel panel-default drop-shadow"><div class="panel-body">
|
||||
<span class="glyphicon glyphicon-play-circle"></span>
|
||||
test action
|
||||
</div></div>
|
||||
</td></tr>
|
||||
<tr><td>
|
||||
<div class="panel panel-default drop-shadow"><div class="panel-body">
|
||||
<span class="glyphicon glyphicon-play-circle"></span>
|
||||
test action
|
||||
</div></div>
|
||||
</td></tr>
|
||||
</table>
|
||||
<!-- /ACTIONS -->
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/flows}}
|
||||
|
||||
|
||||
|
||||
|
||||
<!-------------------------------- MODALS -------------------------------->
|
||||
|
||||
<div class="modal fade" id="triggerModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><span>×</span></button>
|
||||
<h4 class="modal-title">Trigger</h4>
|
||||
</div>
|
||||
<form method="POST">
|
||||
<div class="modal-body">
|
||||
<input type="hidden" id="action" name="action" value="">
|
||||
<input type="hidden" id="id" name="id">
|
||||
<div class="form-group">
|
||||
<label class="control-label">Type:</label>
|
||||
<select class="form-control" name="type">
|
||||
{{#availableTriggers}}
|
||||
<option>{{.getName()}}</option>
|
||||
{{/availableTriggers}}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="reset" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade" id="actionModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><span>×</span></button>
|
||||
<h4 class="modal-title">Action</h4>
|
||||
</div>
|
||||
<form method="POST">
|
||||
<div class="modal-body">
|
||||
<input type="hidden" id="action" name="action" value="">
|
||||
<input type="hidden" id="id" name="id">
|
||||
<div class="form-group">
|
||||
<label class="control-label">Type:</label>
|
||||
<select class="form-control" name="type">
|
||||
{{#availableActions}}
|
||||
<option>{{.getName()}}</option>
|
||||
{{/availableActions}}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="reset" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
54
src/se/hal/page/TriggerHttpPage.java
Executable file
54
src/se/hal/page/TriggerHttpPage.java
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
package se.hal.page;
|
||||
|
||||
import se.hal.ControllerManager;
|
||||
import se.hal.HalContext;
|
||||
import se.hal.TriggerManager;
|
||||
import se.hal.intf.HalHttpPage;
|
||||
import se.hal.struct.Event;
|
||||
import se.hal.struct.TriggerFlow;
|
||||
import se.hal.struct.devicedata.SwitchEventData;
|
||||
import se.hal.util.HistoryDataListSqlResult;
|
||||
import se.hal.util.HistoryDataListSqlResult.HistoryData;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.io.file.FileUtil;
|
||||
import zutil.parser.Templator;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TriggerHttpPage extends HalHttpPage {
|
||||
private static final String TEMPLATE = "resource/web/trigger.tmpl";
|
||||
|
||||
|
||||
public TriggerHttpPage(){
|
||||
super("trigger");
|
||||
super.getRootNav().createSubNav("Events").createSubNav(this.getId(), "Triggers");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Templator httpRespond(
|
||||
Map<String, Object> session,
|
||||
Map<String, String> cookie,
|
||||
Map<String, String> request)
|
||||
throws Exception{
|
||||
DBConnection db = HalContext.getDB();
|
||||
|
||||
if(request.containsKey("action")){
|
||||
switch(request.get("action")) {
|
||||
// Local Sensors
|
||||
case "create_flow":
|
||||
TriggerFlow flow = new TriggerFlow();
|
||||
flow.save(db);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Templator tmpl = new Templator(FileUtil.find(TEMPLATE));
|
||||
tmpl.set("availableTriggers", TriggerManager.getInstance().getAvailableTriggers());
|
||||
tmpl.set("availableActions", TriggerManager.getInstance().getAvailableActions());
|
||||
tmpl.set("flows", TriggerFlow.getTriggerFlows(db));
|
||||
return tmpl;
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
{"se.hal.intf.HalHttpPage": "se.hal.page.EventOverviewHttpPage"},
|
||||
{"se.hal.intf.HalHttpPage": "se.hal.page.EventConfigHttpPage"},
|
||||
{"se.hal.intf.HalHttpPage": "se.hal.page.TriggerHttpPage"},
|
||||
{"se.hal.intf.HalHttpPage": "se.hal.page.UserConfigHttpPage"}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue