Clear individual rows from action log

This commit is contained in:
calzoneman 2013-07-13 13:23:32 -04:00
parent 5df30cb8a9
commit 8d9d2b6433
4 changed files with 34 additions and 0 deletions

5
acp.js
View File

@ -152,5 +152,10 @@ module.exports = {
ActionLog.clear(data);
ActionLog.record(user.ip, user.name, "acp-actionlog-clear", data);
});
user.socket.on("acp-actionlog-clear-one", function(data) {
ActionLog.clearOne(data);
ActionLog.record(user.ip, user.name, "acp-actionlog-clear-one", data);
});
}
}

View File

@ -65,6 +65,24 @@ exports.clear = function(actions) {
return result;
}
exports.clearOne = function(e) {
var db = Database.getConnection();
if(!db)
return false;
var query = Database.createQuery(
"DELETE FROM actionlog WHERE ip=? AND time=?",
[e.ip, e.time]
);
var result = db.querySync(query);
if(!result) {
Logger.errlog.log("! Failed to clear action log");
}
return result;
}
exports.tooManyRegistrations = function (ip) {
var db = Database.getConnection();
if(!db)

View File

@ -187,6 +187,7 @@
<table class="table table-bordered table-striped table-compact">
<thead>
<tr>
<th id="actionlog_rem">Remove</th>
<th id="actionlog_ip">IP Address</th>
<th id="actionlog_name">Name</th>
<th id="actionlog_action">Action</th>

View File

@ -157,6 +157,16 @@ function getActionLog() {
tbl.data("allentries", entries);
tbl.data("generator", function(e) {
var tr = $("<tr/>").appendTo($("#actionlog table"));
var rem = $("<td/>").appendTo(tr);
$("<button/>").addClass("btn btn-mini btn-danger")
.html("<i class='icon-trash'></i>")
.appendTo(rem)
.click(function () {
socket.emit("acp-actionlog-clear-one", e);
tr.hide("blind", function () {
tr.remove();
});
});
$("<td/>").text(e.ip).appendTo(tr);
$("<td/>").text(e.name).appendTo(tr);
$("<td/>").text(e.action).appendTo(tr);