diff --git a/groups-adlists.lp b/groups-lists.lp similarity index 84% rename from groups-adlists.lp rename to groups-lists.lp index 953dedf4..8b212791 100644 --- a/groups-adlists.lp +++ b/groups-lists.lp @@ -12,7 +12,7 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r') @@ -22,7 +22,7 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r')

- Add a new adlist + Add a new subscribed list

@@ -45,7 +45,14 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r')
  • Multiple adlists can be added by separating each unique URL with a space
  • Click on the icon in the first column to get additional information about your lists. The icons correspond to the health of the list.
  • - + @@ -55,7 +62,7 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r')

    - List of adlists + List of subscribed lists

    diff --git a/scripts/pi-hole/js/groups-adlists.js b/scripts/pi-hole/js/groups-adlists.js index 8889d498..8bffae22 100644 --- a/scripts/pi-hole/js/groups-adlists.js +++ b/scripts/pi-hole/js/groups-adlists.js @@ -13,7 +13,8 @@ var GETDict = {}; $(function () { GETDict = utils.parseQueryString(); - $("#btnAdd").on("click", addAdlist); + $("#btnAddAllow").on("click", { type: "allow" }, addAdlist); + $("#btnAddBlock").on("click", { type: "block" }, addAdlist); utils.setBsSelectDefaults(); initTable(); @@ -59,7 +60,9 @@ function format(data) { // Compile extra info for displaying return ( "" + - '
    Health status of this list:' + + '
    Type of this list:' + + data.type + + 'list
    Health status of this list:' + statusText + '
    This list was added to Pi-hole  ' + utils.datetimeRelative(data.date_added) + @@ -170,9 +173,22 @@ function initTable() { break; } + // Add red minus sign icon if data["type"] is "block" + // Add green plus sign icon if data["type"] is "allow" + let status = + ""; + if (data.type === "block") { + status = ""; + } else if (data.type === "allow") { + status = ""; + } + $("td:eq(1)", row).addClass("list-status-" + statusCode); $("td:eq(1)", row).html( - "" + "" + + status ); if (data.address.startsWith("file://")) { @@ -480,17 +496,18 @@ function delItems(ids) { }); } -function addAdlist() { +function addAdlist(event) { + const type = event.data.type; const address = utils.escapeHtml($("#new_address").val()); const comment = utils.escapeHtml($("#new_comment").val()); utils.disableAll(); - utils.showAlert("info", "", "Adding adlist...", address); + utils.showAlert("info", "", "Adding subscribed " + type + "list...", address); if (address.length === 0) { // enable the ui elements again utils.enableAll(); - utils.showAlert("warning", "", "Warning", "Please specify an adlist address"); + utils.showAlert("warning", "", "Warning", "Please specify " + type + "list address"); return; } @@ -498,10 +515,10 @@ function addAdlist() { url: "/api/lists", method: "post", dataType: "json", - data: JSON.stringify({ address: address, comment: comment }), + data: JSON.stringify({ address: address, comment: comment, type: type }), success: function () { utils.enableAll(); - utils.showAlert("success", "fas fa-plus", "Successfully added list", address); + utils.showAlert("success", "fas fa-plus", "Successfully added " + type + "list", address); table.ajax.reload(null, false); table.rows().deselect(); @@ -511,7 +528,7 @@ function addAdlist() { error: function (data, exception) { apiFailure(data); utils.enableAll(); - utils.showAlert("error", "", "Error while adding new list", data.responseText); + utils.showAlert("error", "", "Error while adding new " + type + "list", data.responseText); console.log(exception); // eslint-disable-line no-console }, }); diff --git a/scripts/pi-hole/lua/sidebar.lp b/scripts/pi-hole/lua/sidebar.lp index 4087c288..7f716635 100644 --- a/scripts/pi-hole/lua/sidebar.lp +++ b/scripts/pi-hole/lua/sidebar.lp @@ -66,12 +66,12 @@ -