Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interpretation for Pi-hole message type ADLIST #2320

Merged
merged 2 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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=' +
parseInt(row.blob1, 10) +
'">' +
"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