Skip to content
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
6 changes: 3 additions & 3 deletions login.lp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

mg.include('scripts/lua/header.lp','r')
?>
<body class="hold-transition layout-boxed login-page">
<body class="hold-transition layout-boxed login-page" data-apiurl="<?=pihole.api_url()?>">
<div class="box login-box" id="login-box">
<section style="padding: 15px;">
<div class="login-logo">
<div class="text-center">
<img src="<?=pihole.webhome()?>img/logo.svg" alt="Pi-hole logo" class="loginpage-logo" width="140" height="202">
<img src="<?=webhome?>img/logo.svg" alt="Pi-hole logo" class="loginpage-logo" width="140" height="202">
</div>
<div class="panel-title text-center"><span class="logo-lg" style="font-size: 25px;">Pi-<b>hole</b></span></div>
</div>
Expand Down Expand Up @@ -117,7 +117,7 @@ mg.include('scripts/lua/header.lp','r')
<strong><a href="https://pi-hole.net/donate/" rel="noopener" target="_blank"><i class="fa fa-heart text-red"></i> Donate</a></strong> if you found this useful.
</div>
</div>
<script src="<?=pihole.fileversion('scripts/js/login.js')?>"></script>
<script src="<?=pihole.fileversion('scripts/js/footer.js')?>"></script>
<script src="<?=pihole.fileversion('scripts/js/login.js')?>"></script>
</body>
</html>
18 changes: 9 additions & 9 deletions scripts/js/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

/* global utils:false, moment:false */

//The following functions allow us to display time until pi-hole is enabled after disabling.
//Works between all pages
var _isLoginPage = false;
const apiUrl = document.body.dataset.apiurl;

const REFRESH_INTERVAL = {
logs: 500, // 0.5 sec (logs page)
Expand Down Expand Up @@ -115,7 +115,7 @@ function checkBlocking() {
}

$.ajax({
url: "/api/dns/blocking",
url: apiUrl + "/dns/blocking",
method: "GET",
})
.done(function (data) {
Expand Down Expand Up @@ -144,7 +144,7 @@ function piholeChange(action, duration) {

btnStatus.html("<i class='fa fa-spinner fa-spin'> </i>");
$.ajax({
url: "/api/dns/blocking",
url: apiUrl + "/dns/blocking",
method: "POST",
dataType: "json",
processData: false,
Expand Down Expand Up @@ -267,7 +267,7 @@ function updateQueryFrequency(intl, frequency) {
var ftlinfoTimer = null;
function updateFtlInfo() {
$.ajax({
url: "/api/info/ftl",
url: apiUrl + "/info/ftl",
})
.done(function (data) {
var ftl = data.ftl;
Expand Down Expand Up @@ -324,7 +324,7 @@ function updateFtlInfo() {

function updateSystemInfo() {
$.ajax({
url: "/api/info/system",
url: apiUrl + "/info/system",
})
.done(function (data) {
var system = data.system;
Expand Down Expand Up @@ -484,7 +484,7 @@ function versionCompare(v1, v2) {

function updateVersionInfo() {
$.ajax({
url: "/api/info/version",
url: apiUrl + "/info/version",
}).done(function (data) {
var version = data.version;
var updateAvailable = false;
Expand Down Expand Up @@ -619,7 +619,7 @@ function updateVersionInfo() {
}

$(function () {
if (globalThis.location.pathname !== "/admin/login") updateInfo();
if (!_isLoginPage) updateInfo();
var enaT = $("#enableTimer");
var target = new Date(parseInt(enaT.html(), 10));
var seconds = Math.round((target.getTime() - Date.now()) / 1000);
Expand All @@ -634,7 +634,7 @@ $(function () {
// Apply per-browser styling settings
initCheckboxRadioStyle();

if (globalThis.location.pathname !== "/admin/login") {
if (!_isLoginPage) {
// Run check immediately after page loading ...
utils.checkMessages();
// ... and then periodically
Expand Down
3 changes: 2 additions & 1 deletion scripts/js/gravity.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
/* global apiUrl: false */

function eventsource() {
var alInfo = $("#alInfo");
Expand All @@ -15,7 +16,7 @@ function eventsource() {
alInfo.show();
alSuccess.hide();

fetch("/api/action/gravity", {
fetch(apiUrl + "/action/gravity", {
method: "POST",
headers: { "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content") },
})
Expand Down
10 changes: 5 additions & 5 deletions scripts/js/groups-clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */

/* global utils:false, groups:false,, apiFailure:false, updateFtlInfo:false, getGroups:false, processGroupResult:false, delGroupItems:false */
/* global utils:false, apiUrl:false, groups:false,, apiFailure:false, updateFtlInfo:false, getGroups:false, processGroupResult:false, delGroupItems:false */
/* exported initTable */

var table;

function reloadClientSuggestions() {
$.ajax({
url: "/api/clients/_suggestions",
url: apiUrl + "/clients/_suggestions",
type: "GET",
dataType: "json",
success: function (data) {
Expand Down Expand Up @@ -96,7 +96,7 @@ function initTable() {
table = $("#clientsTable").DataTable({
processing: true,
ajax: {
url: "/api/clients",
url: apiUrl + "/clients",
dataSrc: "clients",
type: "GET",
},
Expand Down Expand Up @@ -402,7 +402,7 @@ function addClient() {
}

$.ajax({
url: "/api/clients",
url: apiUrl + "/clients",
method: "post",
dataType: "json",
processData: false,
Expand Down Expand Up @@ -459,7 +459,7 @@ function editClient() {
const clientDecoded = utils.hexDecode(client);
utils.showAlert("info", "", "Editing client...", clientDecoded);
$.ajax({
url: "/api/clients/" + encodeURIComponent(clientDecoded),
url: apiUrl + "/clients/" + encodeURIComponent(clientDecoded),
method: "put",
dataType: "json",
processData: false,
Expand Down
6 changes: 3 additions & 3 deletions scripts/js/groups-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */

/* global apiFailure:false, utils:false, initTable:false, updateFtlInfo:false */
/* global apiFailure:false, utils:false, apiUrl:false, initTable:false, updateFtlInfo:false */

var groups = [];

Expand Down Expand Up @@ -39,7 +39,7 @@ function populateGroupSelect(selectEl) {
// eslint-disable-next-line no-unused-vars
function getGroups(groupSelector) {
$.ajax({
url: "/api/groups",
url: apiUrl + "/groups",
type: "GET",
dataType: "json",
success: function (data) {
Expand Down Expand Up @@ -79,7 +79,7 @@ function delGroupItems(type, ids, table, listType = undefined) {
// Check input validity
if (!Array.isArray(ids)) return;

const url = "/api/" + type + "s:batchDelete";
const url = apiUrl + "/" + type + "s:batchDelete";

// use utils.hexDecode() to decode all clients
let idstring = "";
Expand Down
8 changes: 4 additions & 4 deletions scripts/js/groups-domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */

/* global utils:false, groups:false,, getGroups:false, updateFtlInfo:false, apiFailure:false, processGroupResult:false, delGroupItems:false */
/* global utils:false, apiUrl:false, groups:false,, getGroups:false, updateFtlInfo:false, apiFailure:false, processGroupResult:false, delGroupItems:false */
/* exported initTable */

var table;
Expand Down Expand Up @@ -91,7 +91,7 @@ function initTable() {
table = $("#domainsTable").DataTable({
processing: true,
ajax: {
url: "/api/domains",
url: apiUrl + "/domains",
dataSrc: "domains",
type: "GET",
},
Expand Down Expand Up @@ -507,7 +507,7 @@ function addDomain() {
const type = action === "add_deny" ? "deny" : "allow";

$.ajax({
url: "/api/domains/" + type + "/" + kind,
url: apiUrl + "/domains/" + type + "/" + kind,
method: "post",
dataType: "json",
processData: false,
Expand Down Expand Up @@ -596,7 +596,7 @@ function editDomain() {
const domainDecoded = utils.hexDecode(domain.split("_")[0]);
utils.showAlert("info", "", "Editing domain...", domainDecoded);
$.ajax({
url: "/api/domains/" + newTypestr + "/" + encodeURIComponent(domainDecoded),
url: apiUrl + "/domains/" + newTypestr + "/" + encodeURIComponent(domainDecoded),
method: "put",
dataType: "json",
processData: false,
Expand Down
8 changes: 4 additions & 4 deletions scripts/js/groups-lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */

/* global utils:false, groups:false, apiFailure:false, updateFtlInfo:false, getGroups:false, processGroupResult:false, delGroupItems:false */
/* global utils:false, apiUrl:false, groups:false, apiFailure:false, updateFtlInfo:false, getGroups:false, processGroupResult:false, delGroupItems:false */
/* exported initTable */

var table;
Expand Down Expand Up @@ -170,7 +170,7 @@ function initTable() {
table = $("#listsTable").DataTable({
processing: true,
ajax: {
url: "/api/lists",
url: apiUrl + "/lists",
dataSrc: "lists",
type: "GET",
},
Expand Down Expand Up @@ -519,7 +519,7 @@ function addList(event) {
}

$.ajax({
url: "/api/lists",
url: apiUrl + "/lists",
method: "post",
dataType: "json",
processData: false,
Expand Down Expand Up @@ -588,7 +588,7 @@ function editList() {
utils.disableAll();
utils.showAlert("info", "", "Editing address...", address);
$.ajax({
url: "/api/lists/" + encodeURIComponent(address) + "?type=" + type,
url: apiUrl + "/lists/" + encodeURIComponent(address) + "?type=" + type,
method: "put",
dataType: "json",
processData: false,
Expand Down
8 changes: 4 additions & 4 deletions scripts/js/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */

/* global utils:false, apiFailure:false, updateFtlInfo:false, processGroupResult:false, delGroupItems:false */
/* global utils:false, apiUrl:false, apiFailure:false, updateFtlInfo:false, processGroupResult:false, delGroupItems:false */

var table;

Expand All @@ -26,7 +26,7 @@ $(function () {
table = $("#groupsTable").DataTable({
processing: true,
ajax: {
url: "/api/groups",
url: apiUrl + "/groups",
error: handleAjaxError,
dataSrc: "groups",
type: "GET",
Expand Down Expand Up @@ -261,7 +261,7 @@ function addGroup() {
}

$.ajax({
url: "/api/groups",
url: apiUrl + "/groups",
method: "post",
dataType: "json",
processData: false,
Expand Down Expand Up @@ -329,7 +329,7 @@ function editGroup() {
utils.disableAll();
utils.showAlert("info", "", "Editing group...", oldName);
$.ajax({
url: "/api/groups/" + oldName,
url: apiUrl + "/groups/" + oldName,
method: "put",
dataType: "json",
processData: false,
Expand Down
20 changes: 10 additions & 10 deletions scripts/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */

/* global utils:false, Chart:false, apiFailure:false, THEME_COLORS:false, customTooltips:false, htmlLegendPlugin:false,doughnutTooltip:false, ChartDeferred:false, REFRESH_INTERVAL: false, updateQueryFrequency: false */
/* global utils:false, apiUrl:false, Chart:false, apiFailure:false, THEME_COLORS:false, customTooltips:false, htmlLegendPlugin:false,doughnutTooltip:false, ChartDeferred:false, REFRESH_INTERVAL: false, updateQueryFrequency: false */

// Define global variables
var timeLineChart, clientsChart;
Expand All @@ -22,7 +22,7 @@ Chart.defaults.set("plugins.deferred", {

var failures = 0;
function updateQueriesOverTime() {
$.getJSON("/api/history", function (data) {
$.getJSON(apiUrl + "/history", function (data) {
// Remove graph if there are no results (e.g. new
// installation or privacy mode enabled)
if (jQuery.isEmptyObject(data.history)) {
Expand Down Expand Up @@ -92,7 +92,7 @@ function updateQueriesOverTime() {
}

function updateQueryTypesPie() {
$.getJSON("/api/stats/query_types", function (data) {
$.getJSON(apiUrl + "/stats/query_types", function (data) {
var v = [],
c = [],
k = [],
Expand Down Expand Up @@ -134,7 +134,7 @@ function updateQueryTypesPie() {
}

function updateClientsOverTime() {
$.getJSON("/api/history/clients", function (data) {
$.getJSON(apiUrl + "/history/clients", function (data) {
// Remove graph if there are no results (e.g. new
// installation or privacy mode enabled)
if (jQuery.isEmptyObject(data.history)) {
Expand Down Expand Up @@ -212,7 +212,7 @@ function updateClientsOverTime() {

var upstreams = {};
function updateForwardDestinationsPie() {
$.getJSON("/api/stats/upstreams", function (data) {
$.getJSON(apiUrl + "/stats/upstreams", function (data) {
var v = [],
c = [],
k = [],
Expand Down Expand Up @@ -273,13 +273,13 @@ function updateForwardDestinationsPie() {
function updateTopClientsTable(blocked) {
let api, style, tablecontent, overlay, clienttable;
if (blocked) {
api = "/api/stats/top_clients?blocked=true";
api = apiUrl + "/stats/top_clients?blocked=true";
style = "queries-blocked";
tablecontent = $("#client-frequency-blocked td").parent();
overlay = $("#client-frequency-blocked .overlay");
clienttable = $("#client-frequency-blocked").find("tbody:last");
} else {
api = "/api/stats/top_clients";
api = apiUrl + "/stats/top_clients";
style = "queries-permitted";
tablecontent = $("#client-frequency td").parent();
overlay = $("#client-frequency .overlay");
Expand Down Expand Up @@ -333,13 +333,13 @@ function updateTopClientsTable(blocked) {
function updateTopDomainsTable(blocked) {
let api, style, tablecontent, overlay, domaintable;
if (blocked) {
api = "/api/stats/top_domains?blocked=true";
api = apiUrl + "/stats/top_domains?blocked=true";
style = "queries-blocked";
tablecontent = $("#ad-frequency td").parent();
overlay = $("#ad-frequency .overlay");
domaintable = $("#ad-frequency").find("tbody:last");
} else {
api = "/api/stats/top_domains";
api = apiUrl + "/stats/top_domains";
style = "queries-permitted";
tablecontent = $("#domain-frequency td").parent();
overlay = $("#domain-frequency .overlay");
Expand Down Expand Up @@ -408,7 +408,7 @@ function updateTopLists() {
var previousCount = 0;
var firstSummaryUpdate = true;
function updateSummaryData(runOnce = false) {
$.getJSON("/api/stats/summary", function (data) {
$.getJSON(apiUrl + "/stats/summary", function (data) {
var intl = new Intl.NumberFormat();
const newCount = parseInt(data.queries.total, 10);

Expand Down
4 changes: 2 additions & 2 deletions scripts/js/interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */

/* global utils */
/* global utils: false, apiUrl: false */

$(function () {
$.ajax({
url: "/api/network/gateway",
url: apiUrl + "/network/gateway",
data: { detailed: true },
}).done(function (data) {
var intl = new Intl.NumberFormat();
Expand Down
Loading