From 58616bc8afcbf3788df841848fcd1eac802714dd Mon Sep 17 00:00:00 2001
From: DL6ER
Date: Mon, 31 Mar 2025 21:30:27 +0200
Subject: [PATCH 007/106] Remove remaining hard-coded /admin/ paths in the
webinterface
Signed-off-by: DL6ER
---
login.lp | 2 +-
scripts/js/footer.js | 6 ++++--
scripts/js/logout.js | 2 +-
scripts/lua/header_authenticated.lp | 2 +-
settings-teleporter.lp | 2 +-
5 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/login.lp b/login.lp
index 450cae74..204daaab 100644
--- a/login.lp
+++ b/login.lp
@@ -9,7 +9,7 @@
mg.include('scripts/lua/header.lp','r')
?>
-
+
diff --git a/scripts/js/footer.js b/scripts/js/footer.js
index 5e6c8460..ee685bfc 100644
--- a/scripts/js/footer.js
+++ b/scripts/js/footer.js
@@ -197,7 +197,8 @@ function applyCheckboxRadioStyle() {
function initCheckboxRadioStyle() {
function getCheckboxURL(style) {
var extra = style.startsWith("material-") ? "material" : "bootstrap";
- return "/admin/vendor/icheck/icheck-" + extra + ".min.css";
+ const webhome = document.body.dataset.webhome;
+ return webhome + "vendor/icheck/icheck-" + extra + ".min.css";
}
// Read from local storage, initialize if needed
@@ -728,7 +729,8 @@ function applyExpertSettings() {
// functionality there), and
// - there are no visible boxes (the page is empty)
if ($(".settings-selector").length > 0 && $(".box:visible").length === 0) {
- globalThis.location.href = "/admin/settings/system";
+ const webhome = document.body.dataset.webhome;
+ globalThis.location.href = webhome + "settings/system";
}
}
}
diff --git a/scripts/js/logout.js b/scripts/js/logout.js
index 97658f8e..96a56a80 100644
--- a/scripts/js/logout.js
+++ b/scripts/js/logout.js
@@ -9,7 +9,7 @@
document.addEventListener("DOMContentLoaded", () => {
const logoutButton = document.getElementById("logout-button");
- const logoutUrl = document.body.dataset.logoutUrl;
+ const logoutUrl = document.body.dataset.webhome + "login";
logoutButton.addEventListener("click", event => {
event.preventDefault();
diff --git a/scripts/lua/header_authenticated.lp b/scripts/lua/header_authenticated.lp
index a6bd53e9..cf506ba2 100644
--- a/scripts/lua/header_authenticated.lp
+++ b/scripts/lua/header_authenticated.lp
@@ -22,7 +22,7 @@ mg.include('header.lp','r')
-
+
diff --git a/settings-teleporter.lp b/settings-teleporter.lp
index 938ed212..6bf5b336 100644
--- a/settings-teleporter.lp
+++ b/settings-teleporter.lp
@@ -89,7 +89,7 @@ mg.include('scripts/lua/settings_header.lp','r')
From b524a2f4b608de352093d36ad574cae6feda6841 Mon Sep 17 00:00:00 2001
From: DL6ER
Date: Mon, 31 Mar 2025 21:38:28 +0200
Subject: [PATCH 008/106] Always use document.body.dataset.apiurl instead of
the intermediate const apiUrl
Signed-off-by: DL6ER
---
scripts/js/charts.js | 2 +-
scripts/js/footer.js | 11 +++++------
scripts/js/gravity.js | 3 +--
scripts/js/groups-clients.js | 10 +++++-----
scripts/js/groups-common.js | 6 +++---
scripts/js/groups-domains.js | 13 +++++++++----
scripts/js/groups-lists.js | 8 ++++----
scripts/js/groups.js | 8 ++++----
scripts/js/index.js | 20 ++++++++++----------
scripts/js/interfaces.js | 4 ++--
scripts/js/login.js | 8 ++++----
scripts/js/messages.js | 9 ++++++---
scripts/js/network.js | 6 +++---
scripts/js/queries.js | 14 +++++++-------
scripts/js/search.js | 4 ++--
scripts/js/settings-advanced.js | 4 ++--
scripts/js/settings-api.js | 18 +++++++++---------
scripts/js/settings-dhcp.js | 8 ++++----
scripts/js/settings-dns-records.js | 11 ++++++-----
scripts/js/settings-dns.js | 4 ++--
scripts/js/settings-privacy.js | 4 ++--
scripts/js/settings-system.js | 18 +++++++++---------
scripts/js/settings-teleporter.js | 6 +++---
scripts/js/settings.js | 4 ++--
scripts/js/taillog.js | 4 ++--
scripts/js/utils.js | 13 ++++++++-----
26 files changed, 115 insertions(+), 105 deletions(-)
diff --git a/scripts/js/charts.js b/scripts/js/charts.js
index 1fbc8fe7..bbbbe9df 100644
--- a/scripts/js/charts.js
+++ b/scripts/js/charts.js
@@ -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 upstreams */
+/* global upstreams:false */
// eslint-disable-next-line no-unused-vars
var THEME_COLORS = [
diff --git a/scripts/js/footer.js b/scripts/js/footer.js
index 5e6c8460..689e0616 100644
--- a/scripts/js/footer.js
+++ b/scripts/js/footer.js
@@ -8,7 +8,6 @@
/* global utils:false, moment:false */
var _isLoginPage = false;
-const apiUrl = document.body.dataset.apiurl;
const REFRESH_INTERVAL = {
logs: 500, // 0.5 sec (logs page)
@@ -115,7 +114,7 @@ function checkBlocking() {
}
$.ajax({
- url: apiUrl + "/dns/blocking",
+ url: document.body.dataset.apiurl + "/dns/blocking",
method: "GET",
})
.done(function (data) {
@@ -144,7 +143,7 @@ function piholeChange(action, duration) {
btnStatus.html(" ");
$.ajax({
- url: apiUrl + "/dns/blocking",
+ url: document.body.dataset.apiurl + "/dns/blocking",
method: "POST",
dataType: "json",
processData: false,
@@ -267,7 +266,7 @@ function updateQueryFrequency(intl, frequency) {
var ftlinfoTimer = null;
function updateFtlInfo() {
$.ajax({
- url: apiUrl + "/info/ftl",
+ url: document.body.dataset.apiurl + "/info/ftl",
})
.done(function (data) {
var ftl = data.ftl;
@@ -324,7 +323,7 @@ function updateFtlInfo() {
function updateSystemInfo() {
$.ajax({
- url: apiUrl + "/info/system",
+ url: document.body.dataset.apiurl + "/info/system",
})
.done(function (data) {
var system = data.system;
@@ -484,7 +483,7 @@ function versionCompare(v1, v2) {
function updateVersionInfo() {
$.ajax({
- url: apiUrl + "/info/version",
+ url: document.body.dataset.apiurl + "/info/version",
}).done(function (data) {
var version = data.version;
var updateAvailable = false;
diff --git a/scripts/js/gravity.js b/scripts/js/gravity.js
index 44077ff2..aca729a8 100644
--- a/scripts/js/gravity.js
+++ b/scripts/js/gravity.js
@@ -4,7 +4,6 @@
*
* 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");
@@ -16,7 +15,7 @@ function eventsource() {
alInfo.show();
alSuccess.hide();
- fetch(apiUrl + "/action/gravity", {
+ fetch(document.body.dataset.apiurl + "/action/gravity", {
method: "POST",
headers: { "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content") },
})
diff --git a/scripts/js/groups-clients.js b/scripts/js/groups-clients.js
index adf1a96c..b09b9406 100644
--- a/scripts/js/groups-clients.js
+++ b/scripts/js/groups-clients.js
@@ -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, apiUrl:false, groups:false,, apiFailure:false, updateFtlInfo:false, getGroups:false, processGroupResult:false, delGroupItems:false */
+/* global utils:false, groups:false, apiFailure:false, updateFtlInfo:false, getGroups:false, processGroupResult:false, delGroupItems:false */
/* exported initTable */
var table;
function reloadClientSuggestions() {
$.ajax({
- url: apiUrl + "/clients/_suggestions",
+ url: document.body.dataset.apiurl + "/clients/_suggestions",
type: "GET",
dataType: "json",
success: function (data) {
@@ -96,7 +96,7 @@ function initTable() {
table = $("#clientsTable").DataTable({
processing: true,
ajax: {
- url: apiUrl + "/clients",
+ url: document.body.dataset.apiurl + "/clients",
dataSrc: "clients",
type: "GET",
},
@@ -402,7 +402,7 @@ function addClient() {
}
$.ajax({
- url: apiUrl + "/clients",
+ url: document.body.dataset.apiurl + "/clients",
method: "post",
dataType: "json",
processData: false,
@@ -459,7 +459,7 @@ function editClient() {
const clientDecoded = utils.hexDecode(client);
utils.showAlert("info", "", "Editing client...", clientDecoded);
$.ajax({
- url: apiUrl + "/clients/" + encodeURIComponent(clientDecoded),
+ url: document.body.dataset.apiurl + "/clients/" + encodeURIComponent(clientDecoded),
method: "put",
dataType: "json",
processData: false,
diff --git a/scripts/js/groups-common.js b/scripts/js/groups-common.js
index 73850d6d..c2118757 100644
--- a/scripts/js/groups-common.js
+++ b/scripts/js/groups-common.js
@@ -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, apiUrl:false, initTable:false, updateFtlInfo:false */
+/* global apiFailure:false, utils:false, initTable:false, updateFtlInfo:false */
var groups = [];
@@ -39,7 +39,7 @@ function populateGroupSelect(selectEl) {
// eslint-disable-next-line no-unused-vars
function getGroups(groupSelector) {
$.ajax({
- url: apiUrl + "/groups",
+ url: document.body.dataset.apiurl + "/groups",
type: "GET",
dataType: "json",
success: function (data) {
@@ -79,7 +79,7 @@ function delGroupItems(type, ids, table, listType = undefined) {
// Check input validity
if (!Array.isArray(ids)) return;
- const url = apiUrl + "/" + type + "s:batchDelete";
+ const url = document.body.dataset.apiurl + "/" + type + "s:batchDelete";
// use utils.hexDecode() to decode all clients
let idstring = "";
diff --git a/scripts/js/groups-domains.js b/scripts/js/groups-domains.js
index 2b030bc9..9310fbd3 100644
--- a/scripts/js/groups-domains.js
+++ b/scripts/js/groups-domains.js
@@ -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, apiUrl:false, groups:false,, getGroups:false, updateFtlInfo:false, apiFailure:false, processGroupResult:false, delGroupItems:false */
+/* global utils:false, groups:false, getGroups:false, updateFtlInfo:false, apiFailure:false, processGroupResult:false, delGroupItems:false */
/* exported initTable */
var table;
@@ -91,7 +91,7 @@ function initTable() {
table = $("#domainsTable").DataTable({
processing: true,
ajax: {
- url: apiUrl + "/domains",
+ url: document.body.dataset.apiurl + "/domains",
dataSrc: "domains",
type: "GET",
},
@@ -507,7 +507,7 @@ function addDomain() {
const type = action === "add_deny" ? "deny" : "allow";
$.ajax({
- url: apiUrl + "/domains/" + type + "/" + kind,
+ url: document.body.dataset.apiurl + "/domains/" + type + "/" + kind,
method: "post",
dataType: "json",
processData: false,
@@ -596,7 +596,12 @@ function editDomain() {
const domainDecoded = utils.hexDecode(domain.split("_")[0]);
utils.showAlert("info", "", "Editing domain...", domainDecoded);
$.ajax({
- url: apiUrl + "/domains/" + newTypestr + "/" + encodeURIComponent(domainDecoded),
+ url:
+ document.body.dataset.apiurl +
+ "/domains/" +
+ newTypestr +
+ "/" +
+ encodeURIComponent(domainDecoded),
method: "put",
dataType: "json",
processData: false,
diff --git a/scripts/js/groups-lists.js b/scripts/js/groups-lists.js
index b5646c06..56f195e8 100644
--- a/scripts/js/groups-lists.js
+++ b/scripts/js/groups-lists.js
@@ -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, apiUrl:false, groups:false, apiFailure:false, updateFtlInfo:false, getGroups:false, processGroupResult:false, delGroupItems:false */
+/* global utils:false, groups:false, apiFailure:false, updateFtlInfo:false, getGroups:false, processGroupResult:false, delGroupItems:false */
/* exported initTable */
var table;
@@ -170,7 +170,7 @@ function initTable() {
table = $("#listsTable").DataTable({
processing: true,
ajax: {
- url: apiUrl + "/lists",
+ url: document.body.dataset.apiurl + "/lists",
dataSrc: "lists",
type: "GET",
},
@@ -519,7 +519,7 @@ function addList(event) {
}
$.ajax({
- url: apiUrl + "/lists",
+ url: document.body.dataset.apiurl + "/lists",
method: "post",
dataType: "json",
processData: false,
@@ -588,7 +588,7 @@ function editList() {
utils.disableAll();
utils.showAlert("info", "", "Editing address...", address);
$.ajax({
- url: apiUrl + "/lists/" + encodeURIComponent(address) + "?type=" + type,
+ url: document.body.dataset.apiurl + "/lists/" + encodeURIComponent(address) + "?type=" + type,
method: "put",
dataType: "json",
processData: false,
diff --git a/scripts/js/groups.js b/scripts/js/groups.js
index dc69c3e6..ed7a2eed 100644
--- a/scripts/js/groups.js
+++ b/scripts/js/groups.js
@@ -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, apiUrl:false, apiFailure:false, updateFtlInfo:false, processGroupResult:false, delGroupItems:false */
+/* global utils:false, apiFailure:false, updateFtlInfo:false, processGroupResult:false, delGroupItems:false */
var table;
@@ -26,7 +26,7 @@ $(function () {
table = $("#groupsTable").DataTable({
processing: true,
ajax: {
- url: apiUrl + "/groups",
+ url: document.body.dataset.apiurl + "/groups",
error: handleAjaxError,
dataSrc: "groups",
type: "GET",
@@ -261,7 +261,7 @@ function addGroup() {
}
$.ajax({
- url: apiUrl + "/groups",
+ url: document.body.dataset.apiurl + "/groups",
method: "post",
dataType: "json",
processData: false,
@@ -329,7 +329,7 @@ function editGroup() {
utils.disableAll();
utils.showAlert("info", "", "Editing group...", oldName);
$.ajax({
- url: apiUrl + "/groups/" + oldName,
+ url: document.body.dataset.apiurl + "/groups/" + oldName,
method: "put",
dataType: "json",
processData: false,
diff --git a/scripts/js/index.js b/scripts/js/index.js
index 114984fd..7e0fa91c 100644
--- a/scripts/js/index.js
+++ b/scripts/js/index.js
@@ -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, apiUrl:false, Chart:false, apiFailure:false, THEME_COLORS:false, customTooltips:false, htmlLegendPlugin:false,doughnutTooltip:false, ChartDeferred:false, REFRESH_INTERVAL: false, updateQueryFrequency: false */
+/* global utils: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;
@@ -22,7 +22,7 @@ Chart.defaults.set("plugins.deferred", {
var failures = 0;
function updateQueriesOverTime() {
- $.getJSON(apiUrl + "/history", function (data) {
+ $.getJSON(document.body.dataset.apiurl + "/history", function (data) {
// Remove graph if there are no results (e.g. new
// installation or privacy mode enabled)
if (jQuery.isEmptyObject(data.history)) {
@@ -92,7 +92,7 @@ function updateQueriesOverTime() {
}
function updateQueryTypesPie() {
- $.getJSON(apiUrl + "/stats/query_types", function (data) {
+ $.getJSON(document.body.dataset.apiurl + "/stats/query_types", function (data) {
var v = [],
c = [],
k = [],
@@ -134,7 +134,7 @@ function updateQueryTypesPie() {
}
function updateClientsOverTime() {
- $.getJSON(apiUrl + "/history/clients", function (data) {
+ $.getJSON(document.body.dataset.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)) {
@@ -212,7 +212,7 @@ function updateClientsOverTime() {
var upstreams = {};
function updateForwardDestinationsPie() {
- $.getJSON(apiUrl + "/stats/upstreams", function (data) {
+ $.getJSON(document.body.dataset.apiurl + "/stats/upstreams", function (data) {
var v = [],
c = [],
k = [],
@@ -273,13 +273,13 @@ function updateForwardDestinationsPie() {
function updateTopClientsTable(blocked) {
let api, style, tablecontent, overlay, clienttable;
if (blocked) {
- api = apiUrl + "/stats/top_clients?blocked=true";
+ api = document.body.dataset.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 = apiUrl + "/stats/top_clients";
+ api = document.body.dataset.apiurl + "/stats/top_clients";
style = "queries-permitted";
tablecontent = $("#client-frequency td").parent();
overlay = $("#client-frequency .overlay");
@@ -333,13 +333,13 @@ function updateTopClientsTable(blocked) {
function updateTopDomainsTable(blocked) {
let api, style, tablecontent, overlay, domaintable;
if (blocked) {
- api = apiUrl + "/stats/top_domains?blocked=true";
+ api = document.body.dataset.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 = apiUrl + "/stats/top_domains";
+ api = document.body.dataset.apiurl + "/stats/top_domains";
style = "queries-permitted";
tablecontent = $("#domain-frequency td").parent();
overlay = $("#domain-frequency .overlay");
@@ -408,7 +408,7 @@ function updateTopLists() {
var previousCount = 0;
var firstSummaryUpdate = true;
function updateSummaryData(runOnce = false) {
- $.getJSON(apiUrl + "/stats/summary", function (data) {
+ $.getJSON(document.body.dataset.apiurl + "/stats/summary", function (data) {
var intl = new Intl.NumberFormat();
const newCount = parseInt(data.queries.total, 10);
diff --git a/scripts/js/interfaces.js b/scripts/js/interfaces.js
index cd952257..c90f412c 100644
--- a/scripts/js/interfaces.js
+++ b/scripts/js/interfaces.js
@@ -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: false, apiUrl: false */
+/* global utils: false */
$(function () {
$.ajax({
- url: apiUrl + "/network/gateway",
+ url: document.body.dataset.apiurl + "/network/gateway",
data: { detailed: true },
}).done(function (data) {
var intl = new Intl.NumberFormat();
diff --git a/scripts/js/login.js b/scripts/js/login.js
index b8ce0aa3..ab8d9786 100644
--- a/scripts/js/login.js
+++ b/scripts/js/login.js
@@ -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, apiUrl: false, NProgress:false */
+/* global utils:false, NProgress:false */
var _isLoginPage = true;
@@ -91,7 +91,7 @@ function doLogin(password) {
NProgress.start();
utils.disableAll();
$.ajax({
- url: apiUrl + "/auth",
+ url: document.body.dataset.apiurl + "/auth",
method: "POST",
dataType: "json",
processData: false,
@@ -163,7 +163,7 @@ function showDNSfailure() {
$(function () {
// Check if we need to login at all
$.ajax({
- url: apiUrl + "/auth",
+ url: document.body.dataset.apiurl + "/auth",
})
.done(function (data) {
// If we are already logged in, redirect to dashboard
@@ -182,7 +182,7 @@ $(function () {
// Get information about HTTPS port and DNS status
$.ajax({
- url: apiUrl + "/info/login",
+ url: document.body.dataset.apiurl + "/info/login",
}).done(function (data) {
if (data.dns === false) showDNSfailure();
diff --git a/scripts/js/messages.js b/scripts/js/messages.js
index 56d50a31..da5f0da3 100644
--- a/scripts/js/messages.js
+++ b/scripts/js/messages.js
@@ -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, apiUrl: false */
+/* global utils: false */
var table,
toasts = {};
@@ -13,7 +13,10 @@ $(function () {
var ignoreNonfatal = localStorage
? localStorage.getItem("hideNonfatalDnsmasqWarnings_chkbox") === "true"
: false;
- var url = apiUrl + "/info/messages" + (ignoreNonfatal ? "?filter_dnsmasq_warnings=true" : "");
+ var url =
+ document.body.dataset.apiurl +
+ "/info/messages" +
+ (ignoreNonfatal ? "?filter_dnsmasq_warnings=true" : "");
table = $("#messagesTable").DataTable({
ajax: {
url: url,
@@ -157,7 +160,7 @@ function delMsg(id) {
toasts[id] = utils.showAlert("info", "", "Deleting message...", "ID: " + id, null);
$.ajax({
- url: apiUrl + "/info/messages/" + id,
+ url: document.body.dataset.apiurl + "/info/messages/" + id,
method: "DELETE",
})
.done(function (response) {
diff --git a/scripts/js/network.js b/scripts/js/network.js
index 0c0d0dfc..15a6a0a7 100644
--- a/scripts/js/network.js
+++ b/scripts/js/network.js
@@ -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, apiUrl:false, apiFailure:false */
+/* global utils:false, apiFailure:false */
var tableApi;
@@ -64,7 +64,7 @@ function deleteNetworkEntry() {
utils.disableAll();
utils.showAlert("info", "", "Deleting network table entry...");
$.ajax({
- url: apiUrl + "/network/devices/" + id,
+ url: document.body.dataset.apiurl + "/network/devices/" + id,
method: "DELETE",
success: function () {
utils.enableAll();
@@ -208,7 +208,7 @@ $(function () {
"<'row'<'col-sm-12'<'table-responsive'tr>>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
ajax: {
- url: apiUrl + "/network/devices",
+ url: document.body.dataset.apiurl + "/network/devices",
type: "GET",
dataType: "json",
data: {
diff --git a/scripts/js/queries.js b/scripts/js/queries.js
index bf59e134..a25edbad 100644
--- a/scripts/js/queries.js
+++ b/scripts/js/queries.js
@@ -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 moment:false, utils:false, apiUrl:false, REFRESH_INTERVAL:false */
+/* global moment:false, utils:false, REFRESH_INTERVAL:false */
const beginningOfTime = 1262304000; // Jan 01 2010, 00:00 in seconds
const endOfTime = 2147483647; // Jan 19, 2038, 03:14 in seconds
@@ -431,7 +431,7 @@ function addSelectSuggestion(name, dict, data) {
function getSuggestions(dict) {
$.get(
- apiUrl + "/queries/suggestions",
+ document.body.dataset.apiurl + "/queries/suggestions",
function (data) {
for (var key in filters) {
if (Object.hasOwnProperty.call(filters, key)) {
@@ -462,7 +462,7 @@ function filterOn(param, dict) {
}
function getAPIURL(filters) {
- var apiurl = apiUrl + "/queries?";
+ var apiurl = document.body.dataset.apiurl + "/queries?";
for (var key in filters) {
if (Object.hasOwnProperty.call(filters, key)) {
var filter = filters[key];
@@ -514,7 +514,7 @@ $(function () {
}
getSuggestions(GETDict);
- var apiurl = getAPIURL(GETDict);
+ var apiURL = getAPIURL(GETDict);
if ("from" in GETDict) {
from = GETDict.from;
@@ -530,7 +530,7 @@ $(function () {
table = $("#all-queries").DataTable({
ajax: {
- url: apiurl,
+ url: apiURL,
error: handleAjaxError,
dataSrc: "queries",
data: function (d) {
@@ -740,6 +740,6 @@ function refreshTable() {
var filters = parseFilters();
filters.from = from;
filters.until = until;
- var apiurl = getAPIURL(filters);
- table.ajax.url(apiurl).draw();
+ var apiUrl = getAPIURL(filters);
+ table.ajax.url(apiUrl).draw();
}
diff --git a/scripts/js/search.js b/scripts/js/search.js
index ada949ae..c71d0585 100644
--- a/scripts/js/search.js
+++ b/scripts/js/search.js
@@ -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, apiUrl:false, apiFailure:false */
+/* global utils:false, apiFailure:false */
var GETDict = {};
$(function () {
@@ -35,7 +35,7 @@ function doSearch() {
$.ajax({
method: "GET",
- url: apiUrl + "/search/" + encodeURIComponent(q),
+ url: document.body.dataset.apiurl + "/search/" + encodeURIComponent(q),
async: false,
data: {
partial: partial,
diff --git a/scripts/js/settings-advanced.js b/scripts/js/settings-advanced.js
index e5eb0910..006bbf6f 100644
--- a/scripts/js/settings-advanced.js
+++ b/scripts/js/settings-advanced.js
@@ -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, apiUrl:false, apiFailure: false, applyCheckboxRadioStyle: false, saveSettings:false */
+/* global utils:false, apiFailure: false, applyCheckboxRadioStyle: false, saveSettings:false */
/* exported createDynamicConfigTabs */
function addAllowedValues(allowed) {
@@ -296,7 +296,7 @@ function generateRow(topic, key, value) {
function createDynamicConfigTabs() {
$.ajax({
- url: apiUrl + "/config?detailed=true",
+ url: document.body.dataset.apiurl + "/config?detailed=true",
})
.done(function (data) {
// Create the tabs for the advanced dynamic config topics
diff --git a/scripts/js/settings-api.js b/scripts/js/settings-api.js
index 212e7963..dfcc872d 100644
--- a/scripts/js/settings-api.js
+++ b/scripts/js/settings-api.js
@@ -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, apiUrl:false, setConfigValues: false, apiFailure: false, QRious: false */
+/* global utils:false, setConfigValues: false, apiFailure: false, QRious: false */
var apiSessionsTable = null;
var ownSessionID = null;
@@ -31,7 +31,7 @@ function renderBool(data, type) {
$(function () {
apiSessionsTable = $("#APISessionsTable").DataTable({
ajax: {
- url: apiUrl + "/auth/sessions",
+ url: document.body.dataset.apiurl + "/auth/sessions",
type: "GET",
dataSrc: "sessions",
},
@@ -247,7 +247,7 @@ function deleteOneSession(id, len, ownSessionDelete) {
// our own session is then triggered by the last successful deletion of
// another session (ownSessionDelete == true, len == global deleted)
$.ajax({
- url: apiUrl + "/auth/session/" + id,
+ url: document.body.dataset.apiurl + "/auth/session/" + id,
method: "DELETE",
})
.done(function () {
@@ -272,7 +272,7 @@ function deleteOneSession(id, len, ownSessionDelete) {
function processWebServerConfig() {
$.ajax({
- url: apiUrl + "/config/webserver?detailed=true",
+ url: document.body.dataset.apiurl + "/config/webserver?detailed=true",
})
.done(function (data) {
setConfigValues("webserver", "webserver", data.config.webserver);
@@ -291,7 +291,7 @@ function processWebServerConfig() {
$("#modal-totp").on("shown.bs.modal", function () {
$.ajax({
- url: apiUrl + "/auth/totp",
+ url: document.body.dataset.apiurl + "/auth/totp",
})
.done(function (data) {
TOTPdata = data.totp;
@@ -329,7 +329,7 @@ $("#modal-totp").on("shown.bs.modal", function () {
var apppwhash = null;
$("#modal-apppw").on("shown.bs.modal", function () {
$.ajax({
- url: apiUrl + "/auth/app",
+ url: document.body.dataset.apiurl + "/auth/app",
})
.done(function (data) {
apppwhash = data.app.hash;
@@ -373,7 +373,7 @@ $("#apppw_clear").on("click", function () {
function setAppPassword() {
$.ajax({
- url: apiUrl + "/config",
+ url: document.body.dataset.apiurl + "/config",
type: "PATCH",
dataType: "json",
processData: false,
@@ -426,7 +426,7 @@ $("#totp_code").on("keyup", function () {
function setTOTPSecret(secret) {
$.ajax({
- url: apiUrl + "/config",
+ url: document.body.dataset.apiurl + "/config",
type: "PATCH",
dataType: "json",
processData: false,
@@ -478,7 +478,7 @@ $(document).ready(function () {
processWebServerConfig();
// Check if TOTP is enabled
$.ajax({
- url: apiUrl + "/auth",
+ url: document.body.dataset.apiurl + "/auth",
}).done(function (data) {
if (data.session.totp === false) $("#button-enable-totp").removeClass("hidden");
else $("#button-disable-totp").removeClass("hidden");
diff --git a/scripts/js/settings-dhcp.js b/scripts/js/settings-dhcp.js
index a64ffd8a..280033a4 100644
--- a/scripts/js/settings-dhcp.js
+++ b/scripts/js/settings-dhcp.js
@@ -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, apiUrl:false, setConfigValues: false, apiFailure: false */
+/* global utils:false, setConfigValues: false, apiFailure: false */
var dhcpLeaesTable = null,
toasts = {};
@@ -32,7 +32,7 @@ function renderHostnameCLID(data, type) {
$(function () {
dhcpLeaesTable = $("#DHCPLeasesTable").DataTable({
ajax: {
- url: apiUrl + "/dhcp/leases",
+ url: document.body.dataset.apiurl + "/dhcp/leases",
type: "GET",
dataSrc: "leases",
},
@@ -167,7 +167,7 @@ function delLease(ip) {
toasts[ip] = utils.showAlert("info", "", "Deleting lease...", ip, null);
$.ajax({
- url: apiUrl + "/dhcp/leases/" + encodeURIComponent(ip),
+ url: document.body.dataset.apiurl + "/dhcp/leases/" + encodeURIComponent(ip),
method: "DELETE",
})
.done(function (response) {
@@ -214,7 +214,7 @@ function fillDHCPhosts(data) {
function processDHCPConfig() {
$.ajax({
- url: apiUrl + "/config/dhcp?detailed=true",
+ url: document.body.dataset.apiurl + "/config/dhcp?detailed=true",
})
.done(function (data) {
fillDHCPhosts(data.config.dhcp.hosts);
diff --git a/scripts/js/settings-dns-records.js b/scripts/js/settings-dns-records.js
index c50b1f2f..b4343b9e 100644
--- a/scripts/js/settings-dns-records.js
+++ b/scripts/js/settings-dns-records.js
@@ -5,7 +5,7 @@
* This file is copyright under the latest version of the EUPL.
* Precord see LICENSE file for your rights under this license. */
-/* global utils: false, apiUrl: false, apiFailure:false, setConfigValues: false */
+/* global utils: false, apiFailure:false, setConfigValues: false */
function hostsDomain(data) {
// Split record in format IP NAME1 [NAME2 [NAME3 [NAME...]]]
@@ -156,7 +156,7 @@ function deleteRecord() {
function delHosts(elem) {
utils.disableAll();
utils.showAlert("info", "", "Deleting DNS record...", elem);
- const url = apiUrl + "/config/dns/hosts/" + encodeURIComponent(elem);
+ const url = document.body.dataset.apiurl + "/config/dns/hosts/" + encodeURIComponent(elem);
$.ajax({
url: url,
@@ -183,7 +183,7 @@ function delHosts(elem) {
function delCNAME(elem) {
utils.disableAll();
utils.showAlert("info", "", "Deleting local CNAME record...", elem);
- const url = apiUrl + "/config/dns/cnameRecords/" + encodeURIComponent(elem);
+ const url = document.body.dataset.apiurl + "/config/dns/cnameRecords/" + encodeURIComponent(elem);
$.ajax({
url: url,
@@ -216,7 +216,7 @@ $(document).ready(function () {
$("#btnAdd-host").on("click", function () {
utils.disableAll();
const elem = $("#Hip").val() + " " + $("#Hdomain").val();
- const url = apiUrl + "/config/dns/hosts/" + encodeURIComponent(elem);
+ const url = document.body.dataset.apiurl + "/config/dns/hosts/" + encodeURIComponent(elem);
utils.showAlert("info", "", "Adding DNS record...", elem);
$.ajax({
url: url,
@@ -242,7 +242,8 @@ $(document).ready(function () {
var elem = $("#Cdomain").val() + "," + $("#Ctarget").val();
var ttlVal = parseInt($("#Cttl").val(), 10);
if (isFinite(ttlVal) && ttlVal >= 0) elem += "," + ttlVal;
- const url = apiUrl + "/config/dns/cnameRecords/" + encodeURIComponent(elem);
+ const url =
+ document.body.dataset.apiurl + "/config/dns/cnameRecords/" + encodeURIComponent(elem);
utils.showAlert("info", "", "Adding DNS record...", elem);
$.ajax({
url: url,
diff --git a/scripts/js/settings-dns.js b/scripts/js/settings-dns.js
index 89cd968e..cb556e72 100644
--- a/scripts/js/settings-dns.js
+++ b/scripts/js/settings-dns.js
@@ -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 applyCheckboxRadioStyle:false, setConfigValues: false, apiFailure: false, apiUrl: false */
+/* global applyCheckboxRadioStyle:false, setConfigValues: false, apiFailure: false */
// Remove an element from an array (inline)
function removeFromArray(arr, what) {
@@ -114,7 +114,7 @@ function updateDNSserversTextfield(upstreams, customServers) {
function processDNSConfig() {
$.ajax({
- url: apiUrl + "/config/dns?detailed=true", // We need the detailed output to get the DNS server list
+ url: document.body.dataset.apiurl + "/config/dns?detailed=true", // We need the detailed output to get the DNS server list
})
.done(function (data) {
// Initialize the DNS upstreams
diff --git a/scripts/js/settings-privacy.js b/scripts/js/settings-privacy.js
index 897d2399..68b3371e 100644
--- a/scripts/js/settings-privacy.js
+++ b/scripts/js/settings-privacy.js
@@ -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 setConfigValues: false, apiFailure: false, apiUrl: false */
+/* global setConfigValues: false, apiFailure: false */
function getConfig() {
$.ajax({
- url: apiUrl + "/config/?detailed=true",
+ url: document.body.dataset.apiurl + "/config/?detailed=true",
})
.done(function (data) {
setConfigValues("", "", data.config);
diff --git a/scripts/js/settings-system.js b/scripts/js/settings-system.js
index 653d12d1..be292b1a 100644
--- a/scripts/js/settings-system.js
+++ b/scripts/js/settings-system.js
@@ -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, apiUrl: false, Chart:false, THEME_COLORS:false, customTooltips:false, htmlLegendPlugin:false,doughnutTooltip:false, ChartDeferred:false, REFRESH_INTERVAL: false, utils: false */
+/* global apiFailure:false, Chart:false, THEME_COLORS:false, customTooltips:false, htmlLegendPlugin:false,doughnutTooltip:false, ChartDeferred:false, REFRESH_INTERVAL: false, utils: false */
var hostinfoTimer = null;
var cachePieChart = null;
@@ -83,7 +83,7 @@ function updateCachePie(data) {
function updateHostInfo() {
$.ajax({
- url: apiUrl + "/info/host",
+ url: document.body.dataset.apiurl + "/info/host",
})
.done(function (data) {
var host = data.host;
@@ -155,7 +155,7 @@ var metricsTimer = null;
function updateMetrics() {
$.ajax({
- url: apiUrl + "/info/metrics",
+ url: document.body.dataset.apiurl + "/info/metrics",
})
.done(function (data) {
var metrics = data.metrics;
@@ -196,7 +196,7 @@ function showQueryLoggingButton(state) {
function getLoggingButton() {
$.ajax({
- url: apiUrl + "/config/dns/queryLogging",
+ url: document.body.dataset.apiurl + "/config/dns/queryLogging",
})
.done(function (data) {
showQueryLoggingButton(data.config.dns.queryLogging);
@@ -214,7 +214,7 @@ $(".confirm-restartdns").confirm({
title: "Confirmation required",
confirm: function () {
$.ajax({
- url: apiUrl + "/action/restartdns",
+ url: document.body.dataset.apiurl + "/action/restartdns",
type: "POST",
}).fail(function (data) {
apiFailure(data);
@@ -238,7 +238,7 @@ $(".confirm-flushlogs").confirm({
title: "Confirmation required",
confirm: function () {
$.ajax({
- url: apiUrl + "/action/flush/logs",
+ url: document.body.dataset.apiurl + "/action/flush/logs",
type: "POST",
}).fail(function (data) {
apiFailure(data);
@@ -262,7 +262,7 @@ $(".confirm-flusharp").confirm({
title: "Confirmation required",
confirm: function () {
$.ajax({
- url: apiUrl + "/action/flush/arp",
+ url: document.body.dataset.apiurl + "/action/flush/arp",
type: "POST",
}).fail(function (data) {
apiFailure(data);
@@ -292,7 +292,7 @@ $("#loggingButton").confirm({
data.config.dns = {};
data.config.dns.queryLogging = $("#loggingButton").data("state") !== "enabled";
$.ajax({
- url: apiUrl + "/config/dns/queryLogging",
+ url: document.body.dataset.apiurl + "/config/dns/queryLogging",
type: "PATCH",
dataType: "json",
processData: false,
@@ -364,7 +364,7 @@ $(function () {
});
$.ajax({
- url: apiUrl + "/network/gateway",
+ url: document.body.dataset.apiurl + "/network/gateway",
})
.done(function (data) {
const gateway = data.gateway;
diff --git a/scripts/js/settings-teleporter.js b/scripts/js/settings-teleporter.js
index c92fd6a5..14fad61f 100644
--- a/scripts/js/settings-teleporter.js
+++ b/scripts/js/settings-teleporter.js
@@ -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, apiUrl: false */
+/* global utils:false */
// Add event listener to import button
document.getElementById("submit-import").addEventListener("click", function () {
@@ -37,7 +37,7 @@ function importZIP() {
const formData = new FormData();
formData.append("import", JSON.stringify(imports));
formData.append("file", file);
- fetch(apiUrl + "/teleporter", {
+ fetch(document.body.dataset.apiurl + "/teleporter", {
method: "POST",
body: formData,
headers: { "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content") },
@@ -77,7 +77,7 @@ function importZIP() {
// Inspired by https://stackoverflow.com/a/59576416/2087442
$("#GETTeleporter").on("click", function () {
$.ajax({
- url: apiUrl + "/teleporter",
+ url: document.body.dataset.apiurl + "/teleporter",
headers: { "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content") },
method: "GET",
xhrFields: {
diff --git a/scripts/js/settings.js b/scripts/js/settings.js
index 43b55ca6..be54d643 100644
--- a/scripts/js/settings.js
+++ b/scripts/js/settings.js
@@ -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, apiUrl:false, apiFailure:false*/
+/* global utils:false, apiFailure:false*/
$(function () {
// Handle hiding of alerts
@@ -164,7 +164,7 @@ function saveSettings() {
// Apply changes
$.ajax({
- url: apiUrl + "/config",
+ url: document.body.dataset.apiurl + "/config",
method: "PATCH",
dataType: "json",
processData: false,
diff --git a/scripts/js/taillog.js b/scripts/js/taillog.js
index 778c50c0..d750c23a 100644
--- a/scripts/js/taillog.js
+++ b/scripts/js/taillog.js
@@ -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 moment: false, apiFailure: false, utils: false, REFRESH_INTERVAL: false, apiUrl: false */
+/* global moment: false, apiFailure: false, utils: false, REFRESH_INTERVAL: false */
var nextID = 0;
var lastPID = -1;
@@ -84,7 +84,7 @@ function getData() {
}
$.ajax({
- url: apiUrl + "/logs/" + GETDict.file + "?nextID=" + nextID,
+ url: document.body.dataset.apiurl + "/logs/" + GETDict.file + "?nextID=" + nextID,
timeout: 5000,
method: "GET",
})
diff --git a/scripts/js/utils.js b/scripts/js/utils.js
index 146941ab..8d63111a 100644
--- a/scripts/js/utils.js
+++ b/scripts/js/utils.js
@@ -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 moment:false, apiUrl: false, apiFailure: false, updateFtlInfo: false, NProgress:false, WaitMe:false */
+/* global moment:false, apiFailure: false, updateFtlInfo: false, NProgress:false, WaitMe:false */
$(function () {
// CSRF protection for AJAX requests, this has to be configured globally
@@ -331,7 +331,7 @@ function addFromQueryLog(domain, list) {
// add Domain to List after Modal has faded in
alertModal.one("shown.bs.modal", function () {
$.ajax({
- url: apiUrl + "/domains/" + list + "/exact",
+ url: document.body.dataset.apiurl + "/domains/" + list + "/exact",
method: "post",
dataType: "json",
processData: false,
@@ -411,7 +411,10 @@ function checkMessages() {
? localStorage.getItem("hideNonfatalDnsmasqWarnings_chkbox") === "true"
: false;
$.ajax({
- url: apiUrl + "/info/messages/count" + (ignoreNonfatal ? "?filter_dnsmasq_warnings=true" : ""),
+ url:
+ document.body.dataset.apiurl +
+ "/info/messages/count" +
+ (ignoreNonfatal ? "?filter_dnsmasq_warnings=true" : ""),
method: "GET",
dataType: "json",
})
@@ -465,7 +468,7 @@ function changeBulkDeleteStates(table) {
function doLogout(url) {
$.ajax({
- url: apiUrl + "/auth",
+ url: document.body.dataset.apiurl + "/auth",
method: "DELETE",
}).always(function () {
globalThis.location = url;
@@ -640,7 +643,7 @@ let waitMe = null;
function loadingOverlayTimeoutCallback(reloadAfterTimeout) {
// Try to ping FTL to see if it finished restarting
$.ajax({
- url: apiUrl + "/info/login",
+ url: document.body.dataset.apiurl + "/info/login",
method: "GET",
cache: false,
dataType: "json",
From 2dd128fbfb6ce4e52f31c9215694ab47857a1451 Mon Sep 17 00:00:00 2001
From: XhmikosR
Date: Thu, 3 Apr 2025 07:52:28 +0300
Subject: [PATCH 009/106] Revert the `defer` addition for now
There are still cases we are getting TypeErrors. We should try again after grouping our assets together in all pages.
Signed-off-by: XhmikosR
---
gravity.lp | 2 +-
groups-clients.lp | 10 +++++-----
groups-domains.lp | 8 ++++----
groups-lists.lp | 8 ++++----
groups.lp | 8 ++++----
index.lp | 4 ++--
interfaces.lp | 2 +-
login.lp | 4 ++--
messages.lp | 2 +-
network.lp | 4 ++--
queries.lp | 8 ++++----
scripts/lua/footer.lp | 2 +-
scripts/lua/header.lp | 14 +++++++-------
scripts/lua/header_authenticated.lp | 24 ++++++++++++------------
search.lp | 2 +-
settings-all.lp | 6 +++---
settings-api.lp | 10 +++++-----
settings-dhcp.lp | 8 ++++----
settings-dns.lp | 6 +++---
settings-dnsrecords.lp | 10 +++++-----
settings-privacy.lp | 6 +++---
settings-system.lp | 10 +++++-----
settings-teleporter.lp | 6 +++---
taillog.lp | 2 +-
24 files changed, 83 insertions(+), 83 deletions(-)
diff --git a/gravity.lp b/gravity.lp
index aaef944a..c2312acd 100644
--- a/gravity.lp
+++ b/gravity.lp
@@ -27,5 +27,5 @@ mg.include('scripts/lua/header_authenticated.lp','r')
Update
-
+
mg.include('scripts/lua/footer.lp','r')?>
diff --git a/groups-clients.lp b/groups-clients.lp
index 5fd1e043..061bd0a4 100644
--- a/groups-clients.lp
+++ b/groups-clients.lp
@@ -95,10 +95,10 @@ mg.include('scripts/lua/header_authenticated.lp','r')
-
-
-
-
-
+
+
+
+
+
mg.include('scripts/lua/footer.lp','r')?>
diff --git a/groups-domains.lp b/groups-domains.lp
index 58b64c08..c1aa01fa 100644
--- a/groups-domains.lp
+++ b/groups-domains.lp
@@ -156,9 +156,9 @@ mg.include('scripts/lua/header_authenticated.lp','r')
-
-
-
-
+
+
+
+
mg.include('scripts/lua/footer.lp','r')?>
diff --git a/groups-lists.lp b/groups-lists.lp
index 3e94e83b..b82204ea 100644
--- a/groups-lists.lp
+++ b/groups-lists.lp
@@ -94,9 +94,9 @@ mg.include('scripts/lua/header_authenticated.lp','r')