From 4af02914703f036496e7e20523a139ac503f431c Mon Sep 17 00:00:00 2001 From: calzoneman Date: Wed, 7 Aug 2013 10:30:16 -0400 Subject: [PATCH] Add channel list search to ACP --- acp.js | 29 ++++++++++++++++++++++++++++ www/acp.html | 21 +++++++++++++++++++++ www/assets/js/acp.js | 45 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) diff --git a/acp.js b/acp.js index e5993ab6..b69138fd 100644 --- a/acp.js +++ b/acp.js @@ -60,6 +60,35 @@ module.exports = function (Server) { user.socket.emit("acp-userdata", rows); }); + user.socket.on("acp-lookup-channel", function (data) { + var db = Server.db.getConnection(); + if(!db) { + return; + } + + var query; + if(data.field === "owner") { + query = Server.db.createQuery( + "SELECT * FROM channels WHERE owner LIKE ?", + ["%" + data.value + "%"] + ); + } else if (data.field === "name") { + query = Server.db.createQuery( + "SELECT * FROM channels WHERE name LIKE ?", + ["%" + data.value + "%"] + ); + } else { + return; + } + + var results = db.querySync(query); + if(!results) + return; + + var rows = results.fetchAllSync(); + user.socket.emit("acp-channeldata", rows); + }); + user.socket.on("acp-reset-password", function(data) { if(Auth.getGlobalRank(data.name) >= user.global_rank) return; diff --git a/www/acp.html b/www/acp.html index ff72d796..d362197f 100644 --- a/www/acp.html +++ b/www/acp.html @@ -42,6 +42,7 @@
  • Announcement Manager
  • Global Bans
  • Users
  • +
  • Channels
  • Loaded Channels
  • Action Log
  • Server Stats
  • @@ -163,6 +164,26 @@ +
    +

    Channels

    +
    + + + +
    + + + + + + + + +
    IDNameOwner
    +

    Loaded Channels

    diff --git a/www/assets/js/acp.js b/www/assets/js/acp.js index 81846af1..babc69eb 100644 --- a/www/assets/js/acp.js +++ b/www/assets/js/acp.js @@ -80,6 +80,17 @@ $("#userlookup_email").click(function() { tableResort($("#userlookup table"), "email"); }); +menuHandler("#show_chanlookup", "#chanlookup"); +$("#chanlookup_id").click(function() { + tableResort($("#chanlookup table"), "id"); +}); +$("#chanlookup_name").click(function() { + tableResort($("#chanlookup table"), "name"); +}); +$("#chanlookup_owner").click(function() { + tableResort($("#chanlookup table"), "owner"); +}); + menuHandler("#show_chanloaded", "#channellist"); $("#show_chanloaded").click(function() { socket.emit("acp-list-loaded"); @@ -240,6 +251,13 @@ $("#userlookup_submit").click(function() { socket.emit("acp-lookup-user", $("#userlookup_name").val()); }); +$("#chanlookup_submit").click(function () { + socket.emit("acp-lookup-channel", { + field: $("#chanlookup_field").val(), + value: $("#chanlookup_value").val() + }); +}); + function setupCallbacks() { socket.on("connect", function() { if(NAME && SESSION) { @@ -384,6 +402,33 @@ function setupCallbacks() { alert("Password reset successful. Reset hash: " + data.hash); }); + socket.on("acp-channeldata", function(data) { + var tbl = $("#chanlookup table"); + var p = tbl.data("paginator"); + if(p) { + p.items = data; + } + else { + var opts = { + preLoadPage: function () { + tbl.find("tbody").remove(); + }, + generator: function (u, page, index) { + var tr = $("").appendTo(tbl); + $("").text(u.id).appendTo(tr); + $("").text(u.name).appendTo(tr); + $("").text(u.owner).appendTo(tr); + } + }; + p = Paginate(data, opts); + p.paginator.insertBefore(tbl); + tbl.data("paginator", p); + } + tbl.data("sortby", "id"); + tbl.data("sort_desc", false); + tableResort(tbl); + }); + socket.on("acp-list-loaded", function(data) { $("#channellist tbody").remove(); data.sort(function(a, b) {