Banlist and recent login history

This commit is contained in:
Calvin Montgomery 2013-06-17 23:57:29 -04:00
parent 32af68a68e
commit 449d01180a
7 changed files with 222 additions and 126 deletions

View file

@ -250,26 +250,60 @@ Callbacks = {
banlist: function(entries) {
var tbl = $("#banlist table");
// dumb hack because of jquery UI
// sortable turns tables and lists into a mess of race conditions
if(!tbl.hasClass("table")) {
setTimeout(function() {
Callbacks.banlist(entries);
}, 100);
return;
}
if(tbl.children().length > 1) {
$(tbl.children()[1]).remove();
}
for(var i = 0; i < entries.length; i++) {
var tr = $("<tr/>").appendTo(tbl);
var tr = document.createElement("tr");
var remove = $("<button/>").addClass("btn btn-mini btn-danger")
.appendTo($("<td/>").appendTo(tr));
$("<i/>").addClass("icon-remove-circle").appendTo(remove);
var ip = $("<td/>").text(entries[i].ip).appendTo(tr);
var ip = $("<td/>").text(entries[i].ip_displayed).appendTo(tr);
var name = $("<td/>").text(entries[i].name).appendTo(tr);
var aliases = $("<td/>").text(entries[i].aliases).appendTo(tr);
var aliases = $("<td/>").text(entries[i].aliases.join(", ")).appendTo(tr);
var banner = $("<td/>").text(entries[i].banner).appendTo(tr);
var callback = (function(id, name) { return function() {
var callback = (function(ip, name) { return function() {
socket.emit("unban", {
id: id,
ip: ip,
name: name
});
} })(entries[i].id, entries[i].name);
} })(entries[i].ip_hidden, entries[i].name);
remove.click(callback);
$(tr).appendTo(tbl);
}
},
recentLogins: function(entries) {
var tbl = $("#loginhistory table");
// dumb hack because of jquery UI
// sortable turns tables and lists into a mess of race conditions
if(!tbl.hasClass("table")) {
setTimeout(function() {
Callbacks.recentLogins(entries);
}, 100);
return;
}
if(tbl.children().length > 1) {
$(tbl.children()[1]).remove();
}
for(var i = 0; i < entries.length; i++) {
var tr = document.createElement("tr");
var name = $("<td/>").text(entries[i].name).appendTo(tr);
var aliases = $("<td/>").text(entries[i].aliases.join(", ")).appendTo(tr);
var time = new Date(entries[i].time).toTimeString();
$("<td/>").text(time).appendTo(tr);
$(tr).appendTo(tbl);
}
},

View file

@ -20,6 +20,11 @@
clickHandler("#show_filteredit", "#filteredit");
clickHandler("#show_cssedit", "#cssedit");
clickHandler("#show_jsedit", "#jsedit");
clickHandler("#show_banlist", "#banlist");
clickHandler("#show_loginhistory", "#loginhistory");
$("#show_loginhistory").click(function() {
socket.emit("requestLoginHistory");
});
genPermissionsEditor();

View file

@ -12,7 +12,7 @@
<li id="cssedit_tab"><a href="javascript:void(0);" id="show_cssedit">CSS Editor</a></li>
<li id="jsedit_tab"><a href="javascript:void(0);" id="show_jsedit">JS Editor</a></li>
<li id="banlist_tab"><a href="javascript:void(0);" id="show_banlist">Ban List</a></li>
<li id="recentconn_tab"><a href="javascript:void(0);" id="show_recentconn">Recent Connections</a></li>
<li id="loginhistory_tab"><a href="javascript:void(0);" id="show_loginhistory">Recent Connections</a></li>
</ul>
</div>
<hr>
@ -102,3 +102,27 @@ Filters Here
<textarea rows="10" id="jstext"></textarea>
<button class="btn btn-primary" id="save_js">Save</button>
</div>
<div id="banlist" class="span12">
<table class="table table-striped">
<thead>
<tr>
<th>Unban</th>
<th>IP</th>
<th>Name</th>
<th>Aliases</th>
<th>Banned By</th>
</tr>
</thead>
</table>
</div>
<div id="loginhistory" class="span12">
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Aliases</th>
<th>Time</th>
</tr>
</thead>
</table>
</div>