mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 12:48:29 +00:00
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:
@@ -34,15 +34,15 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r')
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="new_comment">Comment:</label>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-footer clearfix">
|
<div class="box-footer clearfix">
|
||||||
<strong>Hints:</strong>
|
<strong>Hints:</strong>
|
||||||
<ol>
|
<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>Please run <code>pihole -g</code> or update your gravity list <a href="<?=webhome?>gravity">online</a> after modifying your lists.</li>
|
||||||
<li>Multiple adlists can be added by separating each <i>unique</i> URL with a space</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>
|
<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>
|
</ol>
|
||||||
<div class="btn-toolbar pull-right" role="toolbar" aria-label="Toolbar with buttons">
|
<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>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="box" id="adlists-list">
|
<div class="box" id="lists-list">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title">
|
<h3 class="box-title">
|
||||||
List of subscribed lists
|
List of subscribed lists
|
||||||
@@ -67,7 +67,7 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r')
|
|||||||
</div>
|
</div>
|
||||||
<!-- /.box-header -->
|
<!-- /.box-header -->
|
||||||
<div class="box-body">
|
<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>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<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-select.min.js')?>"></script>
|
||||||
<script src="<?=pihole.fileversion('scripts/vendor/bootstrap-toggle.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-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')?>
|
<? mg.include('scripts/pi-hole/lua/footer.lp','r')?>
|
||||||
|
|||||||
6
index.lp
6
index.lp
@@ -64,14 +64,14 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r')
|
|||||||
<!-- small box -->
|
<!-- small box -->
|
||||||
<div class="small-box bg-green no-user-select">
|
<div class="small-box bg-green no-user-select">
|
||||||
<div class="inner">
|
<div class="inner">
|
||||||
<p>Domains on Adlists</p>
|
<p>Domains on Lists</p>
|
||||||
<h3 class="statistic"><span id="gravity_size">---</span></h3>
|
<h3 class="statistic"><span id="gravity_size">---</span></h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<i class="fas fa-list-alt"></i>
|
<i class="fas fa-list-alt"></i>
|
||||||
</div>
|
</div>
|
||||||
<a href="groups-adlists.lp" class="small-box-footer" title="">
|
<a href="groups-lists.lp" class="small-box-footer" title="">
|
||||||
Manage adlists <i class="fa fa-arrow-circle-right"></i>
|
Manage lists <i class="fa fa-arrow-circle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ var GETDict = {};
|
|||||||
$(function () {
|
$(function () {
|
||||||
GETDict = utils.parseQueryString();
|
GETDict = utils.parseQueryString();
|
||||||
|
|
||||||
$("#btnAddAllow").on("click", { type: "allow" }, addAdlist);
|
$("#btnAddAllow").on("click", { type: "allow" }, addList);
|
||||||
$("#btnAddBlock").on("click", { type: "block" }, addAdlist);
|
$("#btnAddBlock").on("click", { type: "block" }, addList);
|
||||||
|
|
||||||
utils.setBsSelectDefaults();
|
utils.setBsSelectDefaults();
|
||||||
initTable();
|
initTable();
|
||||||
@@ -99,7 +99,7 @@ function format(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initTable() {
|
function initTable() {
|
||||||
table = $("#adlistsTable")
|
table = $("#listsTable")
|
||||||
.on("preXhr.dt", function () {
|
.on("preXhr.dt", function () {
|
||||||
getGroups();
|
getGroups();
|
||||||
})
|
})
|
||||||
@@ -135,11 +135,11 @@ function initTable() {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
drawCallback: function () {
|
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;
|
var hasRows = this.api().rows({ filter: "applied" }).data().length > 0;
|
||||||
$(".datatable-bt").css("visibility", hasRows ? "visible" : "hidden");
|
$(".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
|
// Remove visible dropdown to prevent orphaning
|
||||||
$("body > .bootstrap-select.dropdown").remove();
|
$("body > .bootstrap-select.dropdown").remove();
|
||||||
},
|
},
|
||||||
@@ -225,12 +225,12 @@ function initTable() {
|
|||||||
onstyle: "success",
|
onstyle: "success",
|
||||||
width: "80px",
|
width: "80px",
|
||||||
});
|
});
|
||||||
statusEl.on("change", editAdlist);
|
statusEl.on("change", editList);
|
||||||
|
|
||||||
$("td:eq(4)", row).html('<input id="comment_' + dataId + '" class="form-control">');
|
$("td:eq(4)", row).html('<input id="comment_' + dataId + '" class="form-control">');
|
||||||
var commentEl = $("#comment_" + dataId, row);
|
var commentEl = $("#comment_" + dataId, row);
|
||||||
commentEl.val(utils.unescapeHtml(data.comment));
|
commentEl.val(utils.unescapeHtml(data.comment));
|
||||||
commentEl.on("change", editAdlist);
|
commentEl.on("change", editList);
|
||||||
|
|
||||||
$("td:eq(5)", row).empty();
|
$("td:eq(5)", row).empty();
|
||||||
$("td:eq(5)", row).append(
|
$("td:eq(5)", row).append(
|
||||||
@@ -275,7 +275,7 @@ function initTable() {
|
|||||||
.addClass("btn-success")
|
.addClass("btn-success")
|
||||||
.prop("disabled", false)
|
.prop("disabled", false)
|
||||||
.on("click", function () {
|
.on("click", function () {
|
||||||
editAdlist.call(selectEl);
|
editList.call(selectEl);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -297,13 +297,13 @@ function initTable() {
|
|||||||
|
|
||||||
var applyBtn = "#btn_apply_" + dataId;
|
var applyBtn = "#btn_apply_" + dataId;
|
||||||
|
|
||||||
// Highlight row (if url parameter "adlistid=" is used)
|
// Highlight row (if url parameter "listid=" is used)
|
||||||
if ("adlistid" in GETDict && data.id === parseInt(GETDict.adlistid, 10)) {
|
if ("listid" in GETDict && data.id === parseInt(GETDict.listid, 10)) {
|
||||||
$(row).find("td").addClass("highlight");
|
$(row).find("td").addClass("highlight");
|
||||||
}
|
}
|
||||||
|
|
||||||
var button =
|
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 +
|
dataId +
|
||||||
'" data-id="' +
|
'" data-id="' +
|
||||||
dataId +
|
dataId +
|
||||||
@@ -369,10 +369,10 @@ function initTable() {
|
|||||||
stateSave: true,
|
stateSave: true,
|
||||||
stateDuration: 0,
|
stateDuration: 0,
|
||||||
stateSaveCallback: function (settings, data) {
|
stateSaveCallback: function (settings, data) {
|
||||||
utils.stateSaveCallback("groups-adlists-table", data);
|
utils.stateSaveCallback("groups-lists-table", data);
|
||||||
},
|
},
|
||||||
stateLoadCallback: function () {
|
stateLoadCallback: function () {
|
||||||
var data = utils.stateLoadCallback("groups-adlists-table");
|
var data = utils.stateLoadCallback("groups-lists-table");
|
||||||
|
|
||||||
// Return if not available
|
// Return if not available
|
||||||
if (data === null) {
|
if (data === null) {
|
||||||
@@ -385,11 +385,11 @@ function initTable() {
|
|||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
initComplete: function () {
|
initComplete: function () {
|
||||||
if ("adlistid" in GETDict) {
|
if ("listid" in GETDict) {
|
||||||
var pos = table
|
var pos = table
|
||||||
.column(0, { order: "current" })
|
.column(0, { order: "current" })
|
||||||
.data()
|
.data()
|
||||||
.indexOf(parseInt(GETDict.adlistid, 10));
|
.indexOf(parseInt(GETDict.listid, 10));
|
||||||
if (pos >= 0) {
|
if (pos >= 0) {
|
||||||
var page = Math.floor(pos / table.page.info().length);
|
var page = Math.floor(pos / table.page.info().length);
|
||||||
table.page(page).draw(false);
|
table.page(page).draw(false);
|
||||||
@@ -417,7 +417,7 @@ function initTable() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Add event listener for opening and closing details
|
// 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 tr = $(this).closest("tr");
|
||||||
var row = table.row(tr);
|
var row = table.row(tr);
|
||||||
|
|
||||||
@@ -445,7 +445,7 @@ function initTable() {
|
|||||||
// Remove 'bnt-group' class from container, to avoid grouping
|
// Remove 'bnt-group' class from container, to avoid grouping
|
||||||
$.fn.dataTable.Buttons.defaults.dom.container.className = "dt-buttons";
|
$.fn.dataTable.Buttons.defaults.dom.container.className = "dt-buttons";
|
||||||
|
|
||||||
function deleteAdlist() {
|
function deleteList() {
|
||||||
// Passes the button data-id attribute as ID
|
// Passes the button data-id attribute as ID
|
||||||
const ids = [$(this).attr("data-id")];
|
const ids = [$(this).attr("data-id")];
|
||||||
delItems(ids);
|
delItems(ids);
|
||||||
@@ -464,7 +464,7 @@ function delItems(ids) {
|
|||||||
|
|
||||||
utils.disableAll();
|
utils.disableAll();
|
||||||
const idstring = ids.join(", ");
|
const idstring = ids.join(", ");
|
||||||
utils.showAlert("info", "", "Deleting adlist(s) ...", "<ul>" + address + "</ul>");
|
utils.showAlert("info", "", "Deleting list(s) ...", "<ul>" + address + "</ul>");
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/api/lists/" + encodeURIComponent(address),
|
url: "/api/lists/" + encodeURIComponent(address),
|
||||||
@@ -497,7 +497,7 @@ function delItems(ids) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addAdlist(event) {
|
function addList(event) {
|
||||||
const type = event.data.type;
|
const type = event.data.type;
|
||||||
const address = utils.escapeHtml($("#new_address").val());
|
const address = utils.escapeHtml($("#new_address").val());
|
||||||
const comment = utils.escapeHtml($("#new_comment").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 elem = $(this).attr("id");
|
||||||
const tr = $(this).closest("tr");
|
const tr = $(this).closest("tr");
|
||||||
const type = tr.attr("data-type");
|
const type = tr.attr("data-type");
|
||||||
@@ -78,63 +78,63 @@ function eventsource(partial) {
|
|||||||
|
|
||||||
// Group results in res.gravity by res.gravity[].address
|
// Group results in res.gravity by res.gravity[].address
|
||||||
var grouped = {};
|
var grouped = {};
|
||||||
for (const adlist of res.gravity) {
|
for (const list of res.gravity) {
|
||||||
if (grouped[adlist.address] === undefined) {
|
if (grouped[list.address] === undefined) {
|
||||||
grouped[adlist.address] = [];
|
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 +=
|
result +=
|
||||||
"Found " +
|
"Found " +
|
||||||
numAdlists +
|
numLists +
|
||||||
" list" +
|
" list" +
|
||||||
(numAdlists !== 1 ? "s" : "") +
|
(numLists !== 1 ? "s" : "") +
|
||||||
" <em>" +
|
" <em>" +
|
||||||
verb +
|
verb +
|
||||||
"</em> matching '<strong class='text-blue'>" +
|
"</em> matching '<strong class='text-blue'>" +
|
||||||
utils.escapeHtml(q) +
|
utils.escapeHtml(q) +
|
||||||
"</strong>'" +
|
"</strong>'" +
|
||||||
(numAdlists > 0 ? ":" : ".") +
|
(numLists > 0 ? ":" : ".") +
|
||||||
"<br><br>";
|
"<br><br>";
|
||||||
for (const address of Object.keys(grouped)) {
|
for (const address of Object.keys(grouped)) {
|
||||||
const adlist = grouped[address][0];
|
const list = grouped[address][0];
|
||||||
const color = adlist.type === "block" ? "red" : "green";
|
const color = list.type === "block" ? "red" : "green";
|
||||||
result +=
|
result +=
|
||||||
" - <a href='groups-adlists.lp?adlistid=" +
|
" - <a href='groups-lists.lp?listid=" +
|
||||||
adlist.id +
|
list.id +
|
||||||
"' target='_blank'>" +
|
"' target='_blank'>" +
|
||||||
utils.escapeHtml(address) +
|
utils.escapeHtml(address) +
|
||||||
"</a><br> <strong class='text-" +
|
"</a><br> <strong class='text-" +
|
||||||
color +
|
color +
|
||||||
"'>" +
|
"'>" +
|
||||||
adlist.type +
|
list.type +
|
||||||
" list</strong>" +
|
" list</strong>" +
|
||||||
"<br> added: " +
|
"<br> added: " +
|
||||||
utils.renderTimestamp(adlist.date_added, "display") +
|
utils.renderTimestamp(list.date_added, "display") +
|
||||||
"<br> last modified: " +
|
"<br> last modified: " +
|
||||||
utils.renderTimestamp(adlist.date_modified, "display") +
|
utils.renderTimestamp(list.date_modified, "display") +
|
||||||
"<br> last updated: " +
|
"<br> last updated: " +
|
||||||
utils.renderTimestamp(adlist.date_updated, "display") +
|
utils.renderTimestamp(list.date_updated, "display") +
|
||||||
" (" +
|
" (" +
|
||||||
adlist.number.toLocaleString() +
|
list.number.toLocaleString() +
|
||||||
" domains)" +
|
" domains)" +
|
||||||
"<br> " +
|
"<br> " +
|
||||||
(adlist.enabled ? "enabled" : "disabled") +
|
(list.enabled ? "enabled" : "disabled") +
|
||||||
", used in " +
|
", used in " +
|
||||||
adlist.groups.length +
|
list.groups.length +
|
||||||
" group" +
|
" group" +
|
||||||
(adlist.groups.length === 1 ? "" : "s") +
|
(list.groups.length === 1 ? "" : "s") +
|
||||||
(adlist.comment !== null && adlist.comment.length > 0
|
(list.comment !== null && list.comment.length > 0
|
||||||
? '<br> comment: "' + utils.escapeHtml(adlist.comment) + '"'
|
? '<br> comment: "' + utils.escapeHtml(list.comment) + '"'
|
||||||
: "<br> no comment") +
|
: "<br> no comment") +
|
||||||
"<br> matching entries:<br>";
|
"<br> matching entries:<br>";
|
||||||
for (const adlists of grouped[address]) {
|
for (const lists of grouped[address]) {
|
||||||
result +=
|
result +=
|
||||||
" - <strong class='text-blue'>" + utils.escapeHtml(adlists.domain) + "</strong><br>";
|
" - <strong class='text-blue'>" + utils.escapeHtml(lists.domain) + "</strong><br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
result += "<br>";
|
result += "<br>";
|
||||||
|
|||||||
@@ -1374,20 +1374,20 @@ table.dataTable thead .sorting_desc_disabled:after {
|
|||||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.85);
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.85);
|
||||||
}
|
}
|
||||||
|
|
||||||
#adlistsTable table td:first-child {
|
#listsTable table td:first-child {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
#adlistsTable table td:last-child {
|
#listsTable table td:last-child {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-weight: 100;
|
font-weight: 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
#adlistsTable table tr {
|
#listsTable table tr {
|
||||||
border-bottom: 1px solid #333 !important;
|
border-bottom: 1px solid #333 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
#adlistsTable table tr:last-child {
|
#listsTable table tr:last-child {
|
||||||
border: none !important;
|
border: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user