Finish the only partially done renaming adlists -> lists on the dashboard. This fixes a few broken links such as "Manage lists" on the dashboard as well as the generated links from the Search Lists page to the Groups -> Lists page with enabled list row highlighting

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2023-10-15 14:11:32 +02:00
parent 191f89d58e
commit 7e879b29ae
5 changed files with 57 additions and 57 deletions

View File

@@ -34,15 +34,15 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r')
</div>
<div class="form-group col-md-6">
<label for="new_comment">Comment:</label>
<input id="new_comment" type="text" class="form-control" placeholder="Adlist description (optional)">
<input id="new_comment" type="text" class="form-control" placeholder="List description (optional)">
</div>
</div>
</div>
<div class="box-footer clearfix">
<strong>Hints:</strong>
<ol>
<li>Please run <code>pihole -g</code> or update your gravity list <a href="<?=webhome?>gravity">online</a> after modifying your adlists.</li>
<li>Multiple adlists can be added by separating each <i>unique</i> URL with a space</li>
<li>Please run <code>pihole -g</code> or update your gravity list <a href="<?=webhome?>gravity">online</a> after modifying your lists.</li>
<li>Multiple lists can be added by separating each <i>unique</i> URL with a space</li>
<li>Click on the icon in the first column to get additional information about your lists. The icons correspond to the health of the list.</li>
</ol>
<div class="btn-toolbar pull-right" role="toolbar" aria-label="Toolbar with buttons">
@@ -59,7 +59,7 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r')
</div>
<div class="row">
<div class="col-md-12">
<div class="box" id="adlists-list">
<div class="box" id="lists-list">
<div class="box-header with-border">
<h3 class="box-title">
List of subscribed lists
@@ -67,7 +67,7 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r')
</div>
<!-- /.box-header -->
<div class="box-body">
<table id="adlistsTable" class="table table-striped table-bordered" width="100%">
<table id="listsTable" class="table table-striped table-bordered" width="100%">
<thead>
<tr>
<th>ID</th>
@@ -92,6 +92,6 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r')
<script src="<?=pihole.fileversion('scripts/vendor/bootstrap-select.min.js')?>"></script>
<script src="<?=pihole.fileversion('scripts/vendor/bootstrap-toggle.min.js')?>"></script>
<script src="<?=pihole.fileversion('scripts/pi-hole/js/groups-common.js')?>"></script>
<script src="<?=pihole.fileversion('scripts/pi-hole/js/groups-adlists.js')?>"></script>
<script src="<?=pihole.fileversion('scripts/pi-hole/js/groups-lists.js')?>"></script>
<? mg.include('scripts/pi-hole/lua/footer.lp','r')?>

View File

@@ -64,14 +64,14 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r')
<!-- small box -->
<div class="small-box bg-green no-user-select">
<div class="inner">
<p>Domains on Adlists</p>
<p>Domains on Lists</p>
<h3 class="statistic"><span id="gravity_size">---</span></h3>
</div>
<div class="icon">
<i class="fas fa-list-alt"></i>
</div>
<a href="groups-adlists.lp" class="small-box-footer" title="">
Manage adlists <i class="fa fa-arrow-circle-right"></i>
<a href="groups-lists.lp" class="small-box-footer" title="">
Manage lists <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div>

View File

@@ -13,8 +13,8 @@ var GETDict = {};
$(function () {
GETDict = utils.parseQueryString();
$("#btnAddAllow").on("click", { type: "allow" }, addAdlist);
$("#btnAddBlock").on("click", { type: "block" }, addAdlist);
$("#btnAddAllow").on("click", { type: "allow" }, addList);
$("#btnAddBlock").on("click", { type: "block" }, addList);
utils.setBsSelectDefaults();
initTable();
@@ -99,7 +99,7 @@ function format(data) {
}
function initTable() {
table = $("#adlistsTable")
table = $("#listsTable")
.on("preXhr.dt", function () {
getGroups();
})
@@ -135,11 +135,11 @@ function initTable() {
},
],
drawCallback: function () {
// Hide buttons if all adlists were deleted
// Hide buttons if all lists were deleted
var hasRows = this.api().rows({ filter: "applied" }).data().length > 0;
$(".datatable-bt").css("visibility", hasRows ? "visible" : "hidden");
$('button[id^="deleteAdlist_"]').on("click", deleteAdlist);
$('button[id^="deleteList_"]').on("click", deleteList);
// Remove visible dropdown to prevent orphaning
$("body > .bootstrap-select.dropdown").remove();
},
@@ -225,12 +225,12 @@ function initTable() {
onstyle: "success",
width: "80px",
});
statusEl.on("change", editAdlist);
statusEl.on("change", editList);
$("td:eq(4)", row).html('<input id="comment_' + dataId + '" class="form-control">');
var commentEl = $("#comment_" + dataId, row);
commentEl.val(utils.unescapeHtml(data.comment));
commentEl.on("change", editAdlist);
commentEl.on("change", editList);
$("td:eq(5)", row).empty();
$("td:eq(5)", row).append(
@@ -275,7 +275,7 @@ function initTable() {
.addClass("btn-success")
.prop("disabled", false)
.on("click", function () {
editAdlist.call(selectEl);
editList.call(selectEl);
});
}
})
@@ -297,13 +297,13 @@ function initTable() {
var applyBtn = "#btn_apply_" + dataId;
// Highlight row (if url parameter "adlistid=" is used)
if ("adlistid" in GETDict && data.id === parseInt(GETDict.adlistid, 10)) {
// Highlight row (if url parameter "listid=" is used)
if ("listid" in GETDict && data.id === parseInt(GETDict.listid, 10)) {
$(row).find("td").addClass("highlight");
}
var button =
'<button type="button" class="btn btn-danger btn-xs" id="deleteAdlist_' +
'<button type="button" class="btn btn-danger btn-xs" id="deleteList_' +
dataId +
'" data-id="' +
dataId +
@@ -369,10 +369,10 @@ function initTable() {
stateSave: true,
stateDuration: 0,
stateSaveCallback: function (settings, data) {
utils.stateSaveCallback("groups-adlists-table", data);
utils.stateSaveCallback("groups-lists-table", data);
},
stateLoadCallback: function () {
var data = utils.stateLoadCallback("groups-adlists-table");
var data = utils.stateLoadCallback("groups-lists-table");
// Return if not available
if (data === null) {
@@ -385,11 +385,11 @@ function initTable() {
return data;
},
initComplete: function () {
if ("adlistid" in GETDict) {
if ("listid" in GETDict) {
var pos = table
.column(0, { order: "current" })
.data()
.indexOf(parseInt(GETDict.adlistid, 10));
.indexOf(parseInt(GETDict.listid, 10));
if (pos >= 0) {
var page = Math.floor(pos / table.page.info().length);
table.page(page).draw(false);
@@ -417,7 +417,7 @@ function initTable() {
});
// Add event listener for opening and closing details
$("#adlistsTable tbody").on("click", "td.details-control", function () {
$("#listsTable tbody").on("click", "td.details-control", function () {
var tr = $(this).closest("tr");
var row = table.row(tr);
@@ -445,7 +445,7 @@ function initTable() {
// Remove 'bnt-group' class from container, to avoid grouping
$.fn.dataTable.Buttons.defaults.dom.container.className = "dt-buttons";
function deleteAdlist() {
function deleteList() {
// Passes the button data-id attribute as ID
const ids = [$(this).attr("data-id")];
delItems(ids);
@@ -464,7 +464,7 @@ function delItems(ids) {
utils.disableAll();
const idstring = ids.join(", ");
utils.showAlert("info", "", "Deleting adlist(s) ...", "<ul>" + address + "</ul>");
utils.showAlert("info", "", "Deleting list(s) ...", "<ul>" + address + "</ul>");
$.ajax({
url: "/api/lists/" + encodeURIComponent(address),
@@ -497,7 +497,7 @@ function delItems(ids) {
});
}
function addAdlist(event) {
function addList(event) {
const type = event.data.type;
const address = utils.escapeHtml($("#new_address").val());
const comment = utils.escapeHtml($("#new_comment").val());
@@ -536,7 +536,7 @@ function addAdlist(event) {
});
}
function editAdlist() {
function editList() {
const elem = $(this).attr("id");
const tr = $(this).closest("tr");
const type = tr.attr("data-type");

View File

@@ -78,63 +78,63 @@ function eventsource(partial) {
// Group results in res.gravity by res.gravity[].address
var grouped = {};
for (const adlist of res.gravity) {
if (grouped[adlist.address] === undefined) {
grouped[adlist.address] = [];
for (const list of res.gravity) {
if (grouped[list.address] === undefined) {
grouped[list.address] = [];
}
grouped[adlist.address].push(adlist);
grouped[list.address].push(list);
}
const numAdlists = Object.keys(grouped).length;
const numLists = Object.keys(grouped).length;
result +=
"Found " +
numAdlists +
numLists +
" list" +
(numAdlists !== 1 ? "s" : "") +
(numLists !== 1 ? "s" : "") +
" <em>" +
verb +
"</em> matching '<strong class='text-blue'>" +
utils.escapeHtml(q) +
"</strong>'" +
(numAdlists > 0 ? ":" : ".") +
(numLists > 0 ? ":" : ".") +
"<br><br>";
for (const address of Object.keys(grouped)) {
const adlist = grouped[address][0];
const color = adlist.type === "block" ? "red" : "green";
const list = grouped[address][0];
const color = list.type === "block" ? "red" : "green";
result +=
" - <a href='groups-adlists.lp?adlistid=" +
adlist.id +
" - <a href='groups-lists.lp?listid=" +
list.id +
"' target='_blank'>" +
utils.escapeHtml(address) +
"</a><br> <strong class='text-" +
color +
"'>" +
adlist.type +
list.type +
" list</strong>" +
"<br> added: " +
utils.renderTimestamp(adlist.date_added, "display") +
utils.renderTimestamp(list.date_added, "display") +
"<br> last modified: " +
utils.renderTimestamp(adlist.date_modified, "display") +
utils.renderTimestamp(list.date_modified, "display") +
"<br> last updated: " +
utils.renderTimestamp(adlist.date_updated, "display") +
utils.renderTimestamp(list.date_updated, "display") +
" (" +
adlist.number.toLocaleString() +
list.number.toLocaleString() +
" domains)" +
"<br> " +
(adlist.enabled ? "enabled" : "disabled") +
(list.enabled ? "enabled" : "disabled") +
", used in " +
adlist.groups.length +
list.groups.length +
" group" +
(adlist.groups.length === 1 ? "" : "s") +
(adlist.comment !== null && adlist.comment.length > 0
? '<br> comment: "' + utils.escapeHtml(adlist.comment) + '"'
(list.groups.length === 1 ? "" : "s") +
(list.comment !== null && list.comment.length > 0
? '<br> comment: "' + utils.escapeHtml(list.comment) + '"'
: "<br> no comment") +
"<br> matching entries:<br>";
for (const adlists of grouped[address]) {
for (const lists of grouped[address]) {
result +=
" - <strong class='text-blue'>" + utils.escapeHtml(adlists.domain) + "</strong><br>";
" - <strong class='text-blue'>" + utils.escapeHtml(lists.domain) + "</strong><br>";
}
result += "<br>";

View File

@@ -1374,20 +1374,20 @@ table.dataTable thead .sorting_desc_disabled:after {
box-shadow: 0 0 10px rgba(0, 0, 0, 0.85);
}
#adlistsTable table td:first-child {
#listsTable table td:first-child {
font-weight: bold;
}
#adlistsTable table td:last-child {
#listsTable table td:last-child {
color: #fff;
font-weight: 100;
}
#adlistsTable table tr {
#listsTable table tr {
border-bottom: 1px solid #333 !important;
}
#adlistsTable table tr:last-child {
#listsTable table tr:last-child {
border: none !important;
}