Skip to content

Commit

Permalink
Finalize renaming adlists -> lists (#2756)
Browse files Browse the repository at this point in the history
  • Loading branch information
DL6ER authored Nov 4, 2023
2 parents abe4a9f + 04ffa50 commit c27bf73
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 58 deletions.
14 changes: 7 additions & 7 deletions groups-lists.lp
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -59,15 +59,15 @@ 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
Subscribed lists
</h3>
</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>
Expand All @@ -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')?>
6 changes: 3 additions & 3 deletions index.lp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -99,7 +99,7 @@ function format(data) {
}

function initTable() {
table = $("#adlistsTable")
table = $("#listsTable")
.on("preXhr.dt", function () {
getGroups();
})
Expand Down Expand Up @@ -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();
},
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -275,7 +275,7 @@ function initTable() {
.addClass("btn-success")
.prop("disabled", false)
.on("click", function () {
editAdlist.call(selectEl);
editList.call(selectEl);
});
}
})
Expand All @@ -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 +
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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),
Expand Down Expand Up @@ -497,7 +497,7 @@ function delItems(ids) {
});
}

function addAdlist(event) {
function addList(event) {
const type = event.data.type;
const comment = utils.escapeHtml($("#new_comment").val());

Expand Down Expand Up @@ -544,7 +544,7 @@ function addAdlist(event) {
});
}

function editAdlist() {
function editList() {
const elem = $(this).attr("id");
const tr = $(this).closest("tr");
const type = tr.attr("data-type");
Expand Down
48 changes: 24 additions & 24 deletions scripts/pi-hole/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>";
Expand Down
8 changes: 4 additions & 4 deletions style/themes/lcars.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit c27bf73

Please sign in to comment.