fixed config page post and added gitignore
This commit is contained in:
parent
6601f75f49
commit
2b1db8f9f2
3 changed files with 56 additions and 14 deletions
3
.gitignore
vendored
Executable file
3
.gitignore
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
/screenlog.0
|
||||
/webadmin.db*
|
||||
/build/
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
<th>{{.getNiceName()}}</th>
|
||||
{{/params}}
|
||||
<th>
|
||||
<button type="button" class="btn btn-default pull-left" data-toggle="modal" data-target="#configureModal">+</button>
|
||||
<button type="button" class="btn btn-default pull-left" data-toggle="modal" data-target="#configureModal" title="Create">+</button>
|
||||
</th>
|
||||
</tr></thead>
|
||||
{{#data}}
|
||||
|
|
@ -21,20 +21,26 @@
|
|||
{{^.isTypeBoolean()}}{{.getString()}}{{/.isTypeBoolean()}}
|
||||
</td>
|
||||
{{/.getConfiguration()}}
|
||||
<td class="text-right">
|
||||
<td>
|
||||
<div class="btn-toolbar pull-right">
|
||||
<button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#configureModal" title="Edit"
|
||||
data-id="{{.getId()}}" {{#.getConfiguration()}}data-{{.getName()}}="{{.getString()}}" {{/.getConfiguration()}}>
|
||||
<span class="glyphicon glyphicon-pencil"></span>
|
||||
</button>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="action" value="delete">
|
||||
<input type="hidden" name="id" value="{{.getId()}}">
|
||||
<button type="submit" class="btn btn-danger btn-xs" title="Delete">>
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<button type="button" class="btn btn-default btn-xs" title="Edit">
|
||||
<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span>
|
||||
</button>
|
||||
{{^.enabled}}
|
||||
<button type="button" class="btn btn-default btn-xs" title="Disable">
|
||||
<span class="glyphicon glyphicon-ban-circle" aria-hidden="true"></span>
|
||||
</button>
|
||||
{{/.enabled}}
|
||||
{{#.enabled}}
|
||||
<button type="button" class="btn btn-default btn-xs" title="Activate">
|
||||
<span class="glyphicon glyphicon-ok-circle" aria-hidden="true"></span>
|
||||
</button>
|
||||
{{/.enabled}}
|
||||
<button type="button" class="btn btn-default btn-xs" title="Remove">
|
||||
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
|
||||
</button>
|
||||
|
|
@ -49,6 +55,35 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
$("#configureModal").on('show.bs.modal', function (event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var modal = $(this);
|
||||
modal.find("input[type=text]").val(""); // Reset all inputs
|
||||
if(button.data("id") >= 0){ // edit
|
||||
modal.find("input[name=action]").val("modify");
|
||||
modal.find("input[name=id]").val(button.data("id"));
|
||||
|
||||
// Fill in inputs
|
||||
$.each(button.attr(), function(fieldName, value) {
|
||||
if(fieldName.startsWith("data-")) {
|
||||
fieldName = fieldName.substring(5);
|
||||
modal.find("input").filter(function() { // case insensitive search
|
||||
return this.name.toLowerCase() == fieldName;
|
||||
}).val(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
else{ // create
|
||||
modal.find("input[name=action]").val("create");
|
||||
modal.find("input[name=id]").val(-1);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="configureModal" tabindex="-1" role="dialog" aria-labelledby="configureModalLabel">
|
||||
<div class="modal-dialog" role="document">
|
||||
|
|
@ -59,6 +94,8 @@
|
|||
</div>
|
||||
<form class="form-horizontal">
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="action">
|
||||
<input type="hidden" name="id">
|
||||
{{#params}}
|
||||
<div class="form-group">
|
||||
<label for="{{.getName()}}" class="control-label col-xs-2">{{.getNiceName()}}</label>
|
||||
|
|
|
|||
|
|
@ -47,14 +47,16 @@ public abstract class WAConfigObject extends DBBean{
|
|||
PreparedStatement stmt = db.getPreparedStatement( "SELECT * FROM "+DB_TABLE+" WHERE id == ?" );
|
||||
stmt.setInt(1, id);
|
||||
WAConfigObject obj = DBConnection.exec(stmt, DBBeanSQLResultHandler.create(clazz, db) );
|
||||
obj.configureObj();
|
||||
if (obj != null)
|
||||
obj.configureObj();
|
||||
return obj;
|
||||
}
|
||||
public static List<WAConfigObject> getAllConfigObjs(DBConnection db, Class<? extends WAConfigObject> clazz) throws SQLException {
|
||||
List<WAConfigObject> list =
|
||||
(List<WAConfigObject>) db.exec("SELECT * FROM "+DB_TABLE, DBBeanSQLResultHandler.createList(clazz, db) );
|
||||
for (WAConfigObject obj : list)
|
||||
obj.configureObj();
|
||||
if (obj != null)
|
||||
obj.configureObj();
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue