Skip to content

Commit

Permalink
Add interpretation for Pi-hole message type ADLIST
Browse files Browse the repository at this point in the history
Signed-off-by: Christian König <ckoenig@posteo.de>
  • Loading branch information
yubiuser committed Sep 1, 2022
1 parent 775a4e1 commit 1933028
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
25 changes: 25 additions & 0 deletions scripts/pi-hole/js/groups-adlists.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
var table;
var groups = [];
var token = $("#token").text();
var GETDict = {};

function getGroups() {
$.post(
Expand All @@ -24,6 +25,13 @@ function getGroups() {
}

$(function () {
window.location.search
.substr(1)
.split("&")
.forEach(function (item) {
GETDict[item.split("=")[0]] = item.split("=")[1];
});

$("#btnAdd").on("click", addAdlist);

utils.setBsSelectDefaults();
Expand Down Expand Up @@ -289,6 +297,11 @@ function initTable() {

var applyBtn = "#btn_apply_" + data.id;

// Highlight row (if url parameter "adlistid=" is used)
if ("adlistid" in GETDict && data.id === parseInt(GETDict.adlistid, 10)) {
$(row).find("td").addClass("highlight");
}

var button =
'<button type="button" class="btn btn-danger btn-xs" id="deleteAdlist_' +
data.id +
Expand Down Expand Up @@ -371,6 +384,18 @@ function initTable() {
// Apply loaded state to table
return data;
},
initComplete: function () {
if ("adlistid" in GETDict) {
var pos = table
.column(0, { order: "current" })
.data()
.indexOf(parseInt(GETDict.adlistid, 10));
if (pos >= 0) {
var page = Math.floor(pos / table.page.info().length);
table.page(page).draw(false);
}
}
},
});

table.on("init select deselect", function () {
Expand Down
13 changes: 13 additions & 0 deletions scripts/pi-hole/js/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ function renderMessage(data, type, row) {
"</pre>"
);

case "ADLIST":
return (
'<a href="groups-adlists.php?adlistid=' +
row.blob1 +
'">' +
"Adlist with ID " +
parseInt(row.blob1, 10) +
"</a> was inaccessible during last gravity run." +
"<pre>" +
utils.escapeHtml(row.message) +
"</pre>"
);

default:
return "Unknown message type<pre>" + JSON.stringify(row) + "</pre>";
}
Expand Down

0 comments on commit 1933028

Please sign in to comment.