From 9b0c212a536b93a7cb0644eeee17bb9ec747a455 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 22 Feb 2025 15:45:33 +0200 Subject: [PATCH 01/68] Ran autoprefixer Move selector where appropriate Signed-off-by: XhmikosR --- style/pi-hole.css | 22 +++------- style/themes/default-dark.css | 1 + style/themes/default-darker.css | 15 ++++++- style/themes/default-light.css | 1 + style/themes/high-contrast-dark.css | 7 +++- style/themes/high-contrast.css | 4 ++ style/themes/lcars.css | 62 +++-------------------------- 7 files changed, 34 insertions(+), 78 deletions(-) diff --git a/style/pi-hole.css b/style/pi-hole.css index 70fbc282..d8e64a6e 100644 --- a/style/pi-hole.css +++ b/style/pi-hole.css @@ -37,20 +37,6 @@ background: url("../img/boxed-bg.png") repeat fixed; } -@-webkit-keyframes Pulse { - from { - opacity: 0; - } - - 50% { - opacity: 1; - } - - to { - opacity: 0; - } -} - @keyframes Pulse { from { opacity: 0; @@ -97,7 +83,6 @@ td.lookatme { inset: 0; z-index: 1; /* 20 steps / 2 seconds = 10fps */ - -webkit-animation: 2s infinite Pulse steps(20); animation: 2s infinite Pulse steps(20); } @@ -188,7 +173,6 @@ td.lookatme { border-radius: 50%; border: 4px solid #c0c0c0; border-right-color: transparent; - -webkit-animation: fa-spin 1s infinite linear; animation: fa-spin 1s infinite linear; } @@ -331,7 +315,6 @@ td.lookatme { .no-user-select { -webkit-user-select: none; -moz-user-select: none; - -ms-user-select: none; user-select: none; } @@ -1141,6 +1124,10 @@ table.dataTable tbody > tr > .selected { letter-spacing: 0.5em; } +.totp_token::-moz-placeholder { + opacity: 0.1; +} + .totp_token::placeholder { opacity: 0.1; } @@ -1151,6 +1138,7 @@ table.dataTable tbody > tr > .selected { right: 0.6em; z-index: 10; background: var(--overlay-bgcolor); + width: -moz-fit-content; width: fit-content; border-radius: 0.5em; padding: 0; diff --git a/style/themes/default-dark.css b/style/themes/default-dark.css index 62475806..76e84636 100644 --- a/style/themes/default-dark.css +++ b/style/themes/default-dark.css @@ -518,6 +518,7 @@ textarea:-webkit-autofill, select:-webkit-autofill { -webkit-text-fill-color: #bec5cb !important; -webkit-box-shadow: 0 0 0px 1000px #353c42 inset; + -webkit-transition: background-color 1s ease-in-out 0s; transition: background-color 1s ease-in-out 0s; } .form-control[disabled], diff --git a/style/themes/default-darker.css b/style/themes/default-darker.css index 709ccfac..4b674611 100644 --- a/style/themes/default-darker.css +++ b/style/themes/default-darker.css @@ -54,6 +54,10 @@ table { border-color: #545b5e; background-color: transparent; } +::-moz-placeholder { + color: #b2aba1; + opacity: 0.5 !important; +} ::placeholder { color: #b2aba1; opacity: 0.5 !important; @@ -66,6 +70,7 @@ textarea:-webkit-autofill, select:-webkit-autofill { -webkit-text-fill-color: #b2aba1 !important; -webkit-box-shadow: 0 0 0px 1000px #181a1b inset; + -webkit-transition: background-color 1s ease-in-out 0s; transition: background-color 1s ease-in-out 0s; } ::-webkit-scrollbar { @@ -87,11 +92,11 @@ select:-webkit-autofill { * { scrollbar-color: #454a4d #202324; } -::selection { +::-moz-selection { background-color: #004daa !important; color: #e8e6e3 !important; } -::-moz-selection { +::selection { background-color: #004daa !important; color: #e8e6e3 !important; } @@ -552,6 +557,9 @@ output { border-color: rgb(44, 103, 137); box-shadow: none; } +.form-control::-moz-placeholder { + color: rgb(168, 160, 149); +} .form-control::placeholder { color: rgb(168, 160, 149); } @@ -2477,6 +2485,9 @@ a:focus { background-color: rgba(24, 26, 27, 0.9); background-image: none; } +.main-header #navbar-search-input.form-control::-moz-placeholder { + color: rgb(200, 195, 188); +} .main-header #navbar-search-input.form-control::placeholder { color: rgb(200, 195, 188); } diff --git a/style/themes/default-light.css b/style/themes/default-light.css index ae25d188..259ed466 100644 --- a/style/themes/default-light.css +++ b/style/themes/default-light.css @@ -294,6 +294,7 @@ textarea:-webkit-autofill, select:-webkit-autofill { -webkit-text-fill-color: #666 !important; -webkit-box-shadow: 0 0 0px 1000px #fff inset; + -webkit-transition: background-color 1s ease-in-out 0s; transition: background-color 1s ease-in-out 0s; } diff --git a/style/themes/high-contrast-dark.css b/style/themes/high-contrast-dark.css index faede82a..1b75ff8e 100644 --- a/style/themes/high-contrast-dark.css +++ b/style/themes/high-contrast-dark.css @@ -675,6 +675,7 @@ textarea:-webkit-autofill, select:-webkit-autofill { -webkit-text-fill-color: var(--main-text-color) !important; -webkit-box-shadow: 0 0 0px 1000px #3c4652 inset; + -webkit-transition: background-color 1s ease-in-out 0s; transition: background-color 1s ease-in-out 0s; } @@ -684,6 +685,7 @@ fieldset[disabled] .form-control { background-color: #3c4652; opacity: 1; -moz-appearance: textfield; + -webkit-appearance: textfield; appearance: textfield; } @@ -854,10 +856,11 @@ input[type="password"]::-webkit-caps-lock-indicator { background-color: transparent; } -.form-control::placeholder { +.form-control::-moz-placeholder { color: #9ab; } -.form-control::-webkit-input-placeholder { + +.form-control::placeholder { color: #9ab; } .form-control:focus::placeholder, diff --git a/style/themes/high-contrast.css b/style/themes/high-contrast.css index ab537b45..d51e6118 100644 --- a/style/themes/high-contrast.css +++ b/style/themes/high-contrast.css @@ -202,6 +202,9 @@ a:hover { .form-control { color: #000; } +.form-control::-moz-placeholder { + color: #6c747b; +} .form-control::placeholder { color: #6c747b; } @@ -331,6 +334,7 @@ textarea:-webkit-autofill, select:-webkit-autofill { -webkit-text-fill-color: #666 !important; -webkit-box-shadow: 0 0 0px 1000px #fff inset; + -webkit-transition: background-color 1s ease-in-out 0s; transition: background-color 1s ease-in-out 0s; } diff --git a/style/themes/lcars.css b/style/themes/lcars.css index 87fc6a48..3a350ee2 100644 --- a/style/themes/lcars.css +++ b/style/themes/lcars.css @@ -306,6 +306,7 @@ textarea:-webkit-autofill, select:-webkit-autofill { -webkit-text-fill-color: #fff !important; -webkit-box-shadow: 0 0 0 1000px #000 inset; + -webkit-transition: background-color 1s ease-in-out 0s; transition: background-color 1s ease-in-out 0s; } @@ -346,13 +347,16 @@ p.login-box-msg, z-index: 1; } +.form-control::-moz-placeholder { + color: #456; +} + .form-control::placeholder { color: #456; } .form-control:focus { border-color: #48f; - -webkit-box-shadow: none; box-shadow: none; } @@ -589,8 +593,6 @@ p.login-box-msg, } .nav.navbar-nav { - display: -webkit-box; - display: -ms-flexbox; display: flex; justify-content: space-between; align-items: center; @@ -1569,38 +1571,6 @@ table.dataTable { } /*** Animation keyframes ***/ -@-webkit-keyframes flash { - 0% { - filter: opacity(0.35) contrast(2); - } - 5% { - filter: opacity(0.7) contrast(2); - } - 10% { - filter: opacity(0.35) contrast(2); - } - 15% { - filter: opacity(0.7) contrast(2); - } - 20% { - filter: opacity(0.35) contrast(2); - } - 25% { - filter: opacity(0.7) contrast(2); - } - 30% { - filter: opacity(0.35) contrast(2); - } - 35% { - filter: opacity(0.7) contrast(1); - } - 70% { - filter: opacity(1) contrast(1) brightness(1.2); - } - 90% { - filter: none; - } -} @keyframes flash { 0% { @@ -1635,37 +1605,15 @@ table.dataTable { } } -@-webkit-keyframes fire { - 0% { - filter: drop-shadow(0 0 2px #f90); - } - 60% { - filter: none; - } -} - @keyframes fire { 0% { filter: drop-shadow(0 0 2px #f90); } 60% { - -webkit-filter: none; filter: none; } } -@-webkit-keyframes warningPulse { - 0% { - opacity: 0; - } - 50% { - opacity: 1; - } - 100% { - opacity: 0; - } -} - @keyframes warningPulse { 0% { opacity: 0; From 9fe93df5536f46183264cb0000abff46e27bae12 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 22 Feb 2025 17:58:11 +0200 Subject: [PATCH 02/68] package.json: properly configure xo and postcss xo doesn't understand CSS syntax so it was useless that it was checking CSS files. Also, configure autoprefixer so that its changes do not need a prettier fix after that. Signed-off-by: XhmikosR --- package.json | 6 ++++-- postcss.config.js | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 postcss.config.js diff --git a/package.json b/package.json index 188282eb..20830013 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "prettier:check": "prettier -l \"style/*.css\" \"style/themes/*.css\" \"scripts/**/*.js\"", "prettier:fix": "prettier --write \"style/*.css\" \"style/themes/*.css\" \"scripts/**/*.js\"", "xo": "xo", - "xo:check": "npm run xo -- \"style/*.css\" \"style/themes/*.css\" \"scripts/**\"", - "xo:fix": "npm run xo -- --fix \"style/*.css\" \"style/themes/*.css\" \"scripts/**\"", + "xo:check": "npm run xo", + "xo:fix": "npm run xo -- --fix", "test": "npm run prettier:check && npm run xo:check", "testpr": "npm run prettier:fix && git diff --ws-error-highlight=all --color=always --exit-code && npm run xo:check" }, @@ -91,11 +91,13 @@ } ], "unicorn/filename-case": "off", + "unicorn/no-anonymous-default-export": "off", "unicorn/no-array-for-each": "off", "unicorn/no-for-loop": "off", "unicorn/no-document-cookie": "off", "unicorn/numeric-separators-style": "off", "unicorn/prefer-includes": "off", + "unicorn/prefer-module": "off", "unicorn/prefer-node-append": "off", "unicorn/prefer-number-properties": "off", "unicorn/prefer-query-selector": "off", diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 00000000..88658064 --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,11 @@ +/* eslint-env node */ + +"use strict"; + +module.exports = (/* ctx */) => ({ + plugins: { + autoprefixer: { + cascade: false, + }, + }, +}); From 714b135afa45f9a69d21507c2e76649c93d88c4d Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 26 Feb 2025 20:10:41 +0100 Subject: [PATCH 03/68] We should show load, not CPU% Signed-off-by: DL6ER --- scripts/js/footer.js | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/scripts/js/footer.js b/scripts/js/footer.js index 63197d35..c5c53643 100644 --- a/scripts/js/footer.js +++ b/scripts/js/footer.js @@ -360,37 +360,33 @@ function updateSystemInfo() { $("#sysinfo-memory-swap").text("No swap space available"); } - color = system.cpu.load.percent[0] > 100 ? "text-red" : "text-green-light"; + color = system.cpu.load.raw[0] > system.cpu.nprocs ? "text-red" : "text-green-light"; $("#cpu").html( '  CPU: ' + - system.cpu.load.percent[0].toFixed(1) + - " %" + '">  Load: ' + + system.cpu.load.raw[0].toFixed(2) + + " / " + + system.cpu.load.raw[1].toFixed(2) + + " / " + + system.cpu.load.raw[2].toFixed(2) ); $("#cpu").prop( "title", - "Load: " + - system.cpu.load.raw[0].toFixed(2) + - " " + - system.cpu.load.raw[1].toFixed(2) + - " " + - system.cpu.load.raw[2].toFixed(2) + - " on " + + "Shown load metrics are load averages for the past 1, 5, and 15 minutes on a system having " + system.cpu.nprocs + - " cores running " + + " cores and running " + system.procs + " processes" ); - $("#sysinfo-cpu").text( - system.cpu.load.percent[0].toFixed(1) + - "% (load: " + + $("#sysinfo-cpu").html( + "Load: " + system.cpu.load.raw[0].toFixed(2) + - " " + + " / " + system.cpu.load.raw[1].toFixed(2) + - " " + + " / " + system.cpu.load.raw[2].toFixed(2) + - ") on " + + " on " + system.cpu.nprocs + " cores running " + system.procs + From 98d162fa0168ca83084469ea807f727cca59b189 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 27 Feb 2025 05:58:44 +0100 Subject: [PATCH 04/68] Show total CPU % on the settings / system info page Signed-off-by: DL6ER --- scripts/js/footer.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/js/footer.js b/scripts/js/footer.js index c5c53643..559d3f8c 100644 --- a/scripts/js/footer.js +++ b/scripts/js/footer.js @@ -377,16 +377,14 @@ function updateSystemInfo() { system.cpu.nprocs + " cores and running " + system.procs + - " processes" + " processes " + + (system.cpu.load.raw[0] > system.cpu.nprocs + ? " (load is higher than the number of cores)" + : "") ); $("#sysinfo-cpu").html( - "Load: " + - system.cpu.load.raw[0].toFixed(2) + - " / " + - system.cpu.load.raw[1].toFixed(2) + - " / " + - system.cpu.load.raw[2].toFixed(2) + - " on " + + system.cpu["%cpu"].toFixed(1) + + "% on " + system.cpu.nprocs + " cores running " + system.procs + From 362ffac148eb457cfe6c898b2e07382022e574c1 Mon Sep 17 00:00:00 2001 From: Dominik Date: Thu, 27 Feb 2025 19:37:35 +0100 Subject: [PATCH 05/68] Improve tooltip wording Co-authored-by: RD WebDesign Signed-off-by: Dominik --- scripts/js/footer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/js/footer.js b/scripts/js/footer.js index 559d3f8c..adad050e 100644 --- a/scripts/js/footer.js +++ b/scripts/js/footer.js @@ -373,7 +373,7 @@ function updateSystemInfo() { ); $("#cpu").prop( "title", - "Shown load metrics are load averages for the past 1, 5, and 15 minutes on a system having " + + "Load averages for the past 1, 5, and 15 minutes\non a system with " + system.cpu.nprocs + " cores and running " + system.procs + From 54e5b29416093ac76cd83d8017fa9e794dfe94a4 Mon Sep 17 00:00:00 2001 From: RD WebDesign Date: Sun, 2 Mar 2025 00:05:01 -0300 Subject: [PATCH 06/68] Setting default values for each property of `versions` object - set Docker versions (local/remote) to `null` if they are empty strings, undefined or null; - set other components versions to `"N/A"` if they are empty strings, undefined or null; - set branches and hashes to `null` if they are empty strings, undefined or null; Signed-off-by: RD WebDesign --- scripts/js/footer.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/scripts/js/footer.js b/scripts/js/footer.js index 63197d35..a48b09db 100644 --- a/scripts/js/footer.js +++ b/scripts/js/footer.js @@ -485,37 +485,37 @@ function updateVersionInfo() { var versions = [ { name: "Docker Tag", - local: version.docker.local, - remote: version.docker.remote, + local: version.docker.local || null, + remote: version.docker.remote || null, branch: null, hash: null, url: "https://github.com/pi-hole/docker-pi-hole/releases", }, { name: "Core", - local: version.core.local.version, - remote: version.core.remote.version, - branch: version.core.local.branch, - hash: version.core.local.hash, - hash_remote: version.core.remote.hash, + local: version.core.local.version || "N/A", + remote: version.core.remote.version || "N/A", + branch: version.core.local.branch || null, + hash: version.core.local.hash || null, + hash_remote: version.core.remote.hash || null, url: "https://github.com/pi-hole/pi-hole/releases", }, { name: "FTL", - local: version.ftl.local.version, - remote: version.ftl.remote.version, - branch: version.ftl.local.branch, - hash: version.ftl.local.hash, - hash_remote: version.ftl.remote.hash, + local: version.ftl.local.version || "N/A", + remote: version.ftl.remote.version || "N/A", + branch: version.ftl.local.branch || null, + hash: version.ftl.local.hash || null, + hash_remote: version.ftl.remote.hash || null, url: "https://github.com/pi-hole/FTL/releases", }, { name: "Web interface", - local: version.web.local.version, - remote: version.web.remote.version, - branch: version.web.local.branch, - hash: version.web.local.hash, - hash_remote: version.web.remote.hash, + local: version.web.local.version || "N/A", + remote: version.web.remote.version || "N/A", + branch: version.web.local.branch || null, + hash: version.web.local.hash || null, + hash_remote: version.web.remote.hash || null, url: "https://github.com/pi-hole/web/releases", }, ]; From a7f1ca780093f4d6344fd4abeac75fb71eb4f74e Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 2 Mar 2025 20:20:10 +0100 Subject: [PATCH 07/68] Allow path prefix multiplexing the dashboard and API. See https://github.com/pi-hole/FTL/pull/2319 for further details Signed-off-by: DL6ER --- login.lp | 3 ++- scripts/js/footer.js | 18 +++++++++--------- scripts/js/gravity.js | 3 ++- scripts/js/groups-clients.js | 10 +++++----- scripts/js/groups-common.js | 6 +++--- scripts/js/groups-domains.js | 8 ++++---- 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 | 10 ++++++---- scripts/js/messages.js | 6 +++--- scripts/js/network.js | 6 +++--- scripts/js/queries.js | 6 +++--- 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 | 10 +++++----- 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 | 10 +++++----- scripts/lua/footer.lp | 1 + 27 files changed, 108 insertions(+), 103 deletions(-) diff --git a/login.lp b/login.lp index f97b837f..13497d0a 100644 --- a/login.lp +++ b/login.lp @@ -117,7 +117,8 @@ mg.include('scripts/lua/header.lp','r') Donate if you found this useful. - + + diff --git a/scripts/js/footer.js b/scripts/js/footer.js index 63197d35..930756da 100644 --- a/scripts/js/footer.js +++ b/scripts/js/footer.js @@ -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.getElementById("api-url").textContent; const REFRESH_INTERVAL = { logs: 500, // 0.5 sec (logs page) @@ -115,7 +115,7 @@ function checkBlocking() { } $.ajax({ - url: "/api/dns/blocking", + url: apiUrl + "/dns/blocking", method: "GET", }) .done(function (data) { @@ -144,7 +144,7 @@ function piholeChange(action, duration) { btnStatus.html(" "); $.ajax({ - url: "/api/dns/blocking", + url: apiUrl + "/dns/blocking", method: "POST", dataType: "json", processData: false, @@ -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; @@ -324,7 +324,7 @@ function updateFtlInfo() { function updateSystemInfo() { $.ajax({ - url: "/api/info/system", + url: apiUrl + "/info/system", }) .done(function (data) { var system = data.system; @@ -474,7 +474,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; @@ -609,7 +609,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); @@ -624,7 +624,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 diff --git a/scripts/js/gravity.js b/scripts/js/gravity.js index 26573246..9f5b66cb 100644 --- a/scripts/js/gravity.js +++ b/scripts/js/gravity.js @@ -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"); @@ -24,7 +25,7 @@ function eventsource() { alSuccess.hide(); // eslint-disable-next-line compat/compat - fetch("/api/action/gravity", { + fetch(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 791de55f..adf1a96c 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, 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) { @@ -96,7 +96,7 @@ function initTable() { table = $("#clientsTable").DataTable({ processing: true, ajax: { - url: "/api/clients", + url: apiUrl + "/clients", dataSrc: "clients", type: "GET", }, @@ -402,7 +402,7 @@ function addClient() { } $.ajax({ - url: "/api/clients", + url: 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: "/api/clients/" + encodeURIComponent(clientDecoded), + url: 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 e32ef189..73850d6d 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, initTable:false, updateFtlInfo:false */ +/* global apiFailure:false, utils:false, apiUrl: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: "/api/groups", + url: 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 = "/api/" + type + "s:batchDelete"; + const url = 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 8ffc2054..a4fd7aa1 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, 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; @@ -97,7 +97,7 @@ function initTable() { table = $("#domainsTable").DataTable({ processing: true, ajax: { - url: "/api/domains", + url: apiUrl + "/domains", dataSrc: "domains", type: "GET", }, @@ -511,7 +511,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, @@ -600,7 +600,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, diff --git a/scripts/js/groups-lists.js b/scripts/js/groups-lists.js index f66145c6..b5646c06 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, 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; @@ -170,7 +170,7 @@ function initTable() { table = $("#listsTable").DataTable({ processing: true, ajax: { - url: "/api/lists", + url: apiUrl + "/lists", dataSrc: "lists", type: "GET", }, @@ -519,7 +519,7 @@ function addList(event) { } $.ajax({ - url: "/api/lists", + url: apiUrl + "/lists", method: "post", dataType: "json", processData: false, @@ -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, diff --git a/scripts/js/groups.js b/scripts/js/groups.js index d886aee2..dc69c3e6 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, apiFailure:false, updateFtlInfo:false, processGroupResult:false, delGroupItems:false */ +/* global utils:false, apiUrl:false, apiFailure:false, updateFtlInfo:false, processGroupResult:false, delGroupItems:false */ var table; @@ -26,7 +26,7 @@ $(function () { table = $("#groupsTable").DataTable({ processing: true, ajax: { - url: "/api/groups", + url: apiUrl + "/groups", error: handleAjaxError, dataSrc: "groups", type: "GET", @@ -261,7 +261,7 @@ function addGroup() { } $.ajax({ - url: "/api/groups", + url: apiUrl + "/groups", method: "post", dataType: "json", processData: false, @@ -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, diff --git a/scripts/js/index.js b/scripts/js/index.js index 749bdb31..53128623 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, 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; @@ -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)) { @@ -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 = [], @@ -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)) { @@ -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 = [], @@ -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"); @@ -332,13 +332,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"); @@ -401,7 +401,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); diff --git a/scripts/js/interfaces.js b/scripts/js/interfaces.js index 7091a967..ee5abe09 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 */ +/* 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(); diff --git a/scripts/js/login.js b/scripts/js/login.js index b30fd5d8..d27191ac 100644 --- a/scripts/js/login.js +++ b/scripts/js/login.js @@ -5,7 +5,9 @@ * This file is copyright under the latest version of the EUPL. * Please see LICENSE file for your rights under this license. */ -/* global utils:false, NProgress:false */ +/* global utils:false, apiUrl: false, NProgress:false */ + +var _isLoginPage = true; function redirect() { // Login succeeded or not needed (empty password) @@ -89,7 +91,7 @@ function doLogin(password) { NProgress.start(); utils.disableAll(); $.ajax({ - url: "/api/auth", + url: apiUrl + "/auth", method: "POST", dataType: "json", processData: false, @@ -161,7 +163,7 @@ function showDNSfailure() { $(function () { // Check if we need to login at all $.ajax({ - url: "/api/auth", + url: apiUrl + "/auth", }) .done(function (data) { // If we are already logged in, redirect to dashboard @@ -180,7 +182,7 @@ $(function () { // Get information about HTTPS port and DNS status $.ajax({ - url: "/api/info/login", + url: apiUrl + "/info/login", }).done(function (data) { if (data.dns === false) showDNSfailure(); diff --git a/scripts/js/messages.js b/scripts/js/messages.js index e97f5cfd..56d50a31 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 */ +/* global utils: false, apiUrl: false */ var table, toasts = {}; @@ -13,7 +13,7 @@ $(function () { var ignoreNonfatal = localStorage ? localStorage.getItem("hideNonfatalDnsmasqWarnings_chkbox") === "true" : false; - var url = "/api/info/messages" + (ignoreNonfatal ? "?filter_dnsmasq_warnings=true" : ""); + var url = apiUrl + "/info/messages" + (ignoreNonfatal ? "?filter_dnsmasq_warnings=true" : ""); table = $("#messagesTable").DataTable({ ajax: { url: url, @@ -157,7 +157,7 @@ function delMsg(id) { toasts[id] = utils.showAlert("info", "", "Deleting message...", "ID: " + id, null); $.ajax({ - url: "/api/info/messages/" + id, + url: apiUrl + "/info/messages/" + id, method: "DELETE", }) .done(function (response) { diff --git a/scripts/js/network.js b/scripts/js/network.js index 10397bbd..89cef728 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, apiFailure:false */ +/* global utils:false, apiUrl:false, apiFailure:false */ var tableApi; @@ -64,7 +64,7 @@ function deleteNetworkEntry() { utils.disableAll(); utils.showAlert("info", "", "Deleting network table entry..."); $.ajax({ - url: "/api/network/devices/" + id, + url: apiUrl + "/network/devices/" + id, method: "DELETE", success: function () { utils.enableAll(); @@ -195,7 +195,7 @@ $(function () { "<'row'<'col-sm-12'<'table-responsive'tr>>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", ajax: { - url: "/api/network/devices", + url: apiUrl + "/network/devices", type: "GET", dataType: "json", data: { diff --git a/scripts/js/queries.js b/scripts/js/queries.js index d4dd7b91..27c796ec 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, REFRESH_INTERVAL:false */ +/* global moment:false, utils:false, apiUrl:false, REFRESH_INTERVAL:false */ const beginningOfTime = 1262304000; // Jan 01 2010, 00:00 in seconds const endOfTime = 2147483647; // Jan 19, 2038, 03:14 in seconds @@ -424,7 +424,7 @@ function addSelectSuggestion(name, dict, data) { function getSuggestions(dict) { $.get( - "/api/queries/suggestions", + apiUrl + "/queries/suggestions", function (data) { for (var key in filters) { if (Object.hasOwnProperty.call(filters, key)) { @@ -455,7 +455,7 @@ function filterOn(param, dict) { } function getAPIURL(filters) { - var apiurl = "/api/queries?"; + var apiurl = apiUrl + "/queries?"; for (var key in filters) { if (Object.hasOwnProperty.call(filters, key)) { var filter = filters[key]; diff --git a/scripts/js/search.js b/scripts/js/search.js index f15c7934..8aa588cb 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, apiFailure:false */ +/* global utils:false, apiUrl:false, apiFailure:false */ var GETDict = {}; $(function () { @@ -35,7 +35,7 @@ function doSearch() { $.ajax({ method: "GET", - url: "/api/search/" + encodeURIComponent(q), + url: apiUrl + "/search/" + encodeURIComponent(q), async: false, data: { partial: partial, diff --git a/scripts/js/settings-advanced.js b/scripts/js/settings-advanced.js index 3d7e4332..c8bc63df 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, apiFailure: false, applyCheckboxRadioStyle: false, saveSettings:false */ +/* global utils:false, apiUrl: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: "/api/config?detailed=true", + url: 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 124d135a..212e7963 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, setConfigValues: false, apiFailure: false, QRious: false */ +/* global utils:false, apiUrl: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: "/api/auth/sessions", + url: 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: "/api/auth/session/" + id, + url: apiUrl + "/auth/session/" + id, method: "DELETE", }) .done(function () { @@ -272,7 +272,7 @@ function deleteOneSession(id, len, ownSessionDelete) { function processWebServerConfig() { $.ajax({ - url: "/api/config/webserver?detailed=true", + url: 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: "/api/auth/totp", + url: 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: "/api/auth/app", + url: apiUrl + "/auth/app", }) .done(function (data) { apppwhash = data.app.hash; @@ -373,7 +373,7 @@ $("#apppw_clear").on("click", function () { function setAppPassword() { $.ajax({ - url: "/api/config", + url: apiUrl + "/config", type: "PATCH", dataType: "json", processData: false, @@ -426,7 +426,7 @@ $("#totp_code").on("keyup", function () { function setTOTPSecret(secret) { $.ajax({ - url: "/api/config", + url: apiUrl + "/config", type: "PATCH", dataType: "json", processData: false, @@ -478,7 +478,7 @@ $(document).ready(function () { processWebServerConfig(); // Check if TOTP is enabled $.ajax({ - url: "/api/auth", + url: 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 6e467668..a64ffd8a 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, setConfigValues: false, apiFailure: false */ +/* global utils:false, apiUrl:false, setConfigValues: false, apiFailure: false */ var dhcpLeaesTable = null, toasts = {}; @@ -32,7 +32,7 @@ function renderHostnameCLID(data, type) { $(function () { dhcpLeaesTable = $("#DHCPLeasesTable").DataTable({ ajax: { - url: "/api/dhcp/leases", + url: 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: "/api/dhcp/leases/" + encodeURIComponent(ip), + url: apiUrl + "/dhcp/leases/" + encodeURIComponent(ip), method: "DELETE", }) .done(function (response) { @@ -214,7 +214,7 @@ function fillDHCPhosts(data) { function processDHCPConfig() { $.ajax({ - url: "/api/config/dhcp?detailed=true", + url: 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 93c7d475..99a6dbb3 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, apiFailure:false, setConfigValues: false */ +/* global utils: false, apiUrl: 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 = "/api/config/dns/hosts/" + encodeURIComponent(elem); + const url = 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 = "/api/config/dns/cnameRecords/" + encodeURIComponent(elem); + const url = 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 = "/api/config/dns/hosts/" + encodeURIComponent(elem); + const url = apiUrl + "/config/dns/hosts/" + encodeURIComponent(elem); utils.showAlert("info", "", "Adding DNS record...", elem); $.ajax({ url: url, @@ -242,7 +242,7 @@ $(document).ready(function () { var elem = $("#Cdomain").val() + "," + $("#Ctarget").val(); var ttlVal = parseInt($("#Cttl").val(), 10); if (isFinite(ttlVal) && ttlVal >= 0) elem += "," + ttlVal; - const url = "/api/config/dns/cnameRecords/" + encodeURIComponent(elem); + const url = 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 7059fc5e..1719d01d 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 */ +/* global applyCheckboxRadioStyle:false, setConfigValues: false, apiFailure: false, apiUrl: false */ // Remove an element from an array (inline) function removeFromArray(arr, what) { @@ -109,7 +109,7 @@ function updateDNSserversTextfield(upstreams, customServers) { function processDNSConfig() { $.ajax({ - url: "/api/config/dns?detailed=true", // We need the detailed output to get the DNS server list + url: 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 5c57e979..897d2399 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 */ +/* global setConfigValues: false, apiFailure: false, apiUrl: false */ function getConfig() { $.ajax({ - url: "/api/config/?detailed=true", + url: 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 79fafb09..653d12d1 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, Chart:false, THEME_COLORS:false, customTooltips:false, htmlLegendPlugin:false,doughnutTooltip:false, ChartDeferred:false, REFRESH_INTERVAL: false, utils: false */ +/* global apiFailure:false, apiUrl: 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: "/api/info/host", + url: apiUrl + "/info/host", }) .done(function (data) { var host = data.host; @@ -155,7 +155,7 @@ var metricsTimer = null; function updateMetrics() { $.ajax({ - url: "/api/info/metrics", + url: apiUrl + "/info/metrics", }) .done(function (data) { var metrics = data.metrics; @@ -196,7 +196,7 @@ function showQueryLoggingButton(state) { function getLoggingButton() { $.ajax({ - url: "/api/config/dns/queryLogging", + url: 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: "/api/action/restartdns", + url: apiUrl + "/action/restartdns", type: "POST", }).fail(function (data) { apiFailure(data); @@ -238,7 +238,7 @@ $(".confirm-flushlogs").confirm({ title: "Confirmation required", confirm: function () { $.ajax({ - url: "/api/action/flush/logs", + url: 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: "/api/action/flush/arp", + url: 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: "/api/config/dns/queryLogging", + url: apiUrl + "/config/dns/queryLogging", type: "PATCH", dataType: "json", processData: false, @@ -364,7 +364,7 @@ $(function () { }); $.ajax({ - url: "/api/network/gateway", + url: 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 b337fa90..fb2c3113 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 */ +/* global utils:false, apiUrl: false */ // Add event listener to import button document.getElementById("submit-import").addEventListener("click", function () { @@ -45,7 +45,7 @@ function importZIP() { formData.append("import", JSON.stringify(imports)); formData.append("file", file); // eslint-disable-next-line compat/compat - fetch("/api/teleporter", { + fetch(apiUrl + "/teleporter", { method: "POST", body: formData, headers: { "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content") }, @@ -85,7 +85,7 @@ function importZIP() { // Inspired by https://stackoverflow.com/a/59576416/2087442 $("#GETTeleporter").on("click", function () { $.ajax({ - url: "/api/teleporter", + url: 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 444af212..43b55ca6 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, apiFailure:false*/ +/* global utils:false, apiUrl:false, apiFailure:false*/ $(function () { // Handle hiding of alerts @@ -164,7 +164,7 @@ function saveSettings() { // Apply changes $.ajax({ - url: "/api/config", + url: apiUrl + "/config", method: "PATCH", dataType: "json", processData: false, diff --git a/scripts/js/taillog.js b/scripts/js/taillog.js index 01c1e48e..9a9d3700 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 */ +/* global moment: false, apiFailure: false, utils: false, REFRESH_INTERVAL: false, apiUrl: false */ var nextID = 0; var lastPID = -1; @@ -84,7 +84,7 @@ function getData() { } $.ajax({ - url: "/api/logs/" + GETDict.file + "?nextID=" + nextID, + url: apiUrl + "/logs/" + GETDict.file + "?nextID=" + nextID, timeout: 5000, method: "GET", }) diff --git a/scripts/js/utils.js b/scripts/js/utils.js index d83cdf2c..4209f34a 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, apiFailure: false, updateFtlInfo: false, NProgress:false */ +/* global moment:false, apiUrl: false, apiFailure: false, updateFtlInfo: false, NProgress: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: "/api/domains/" + list + "/exact", + url: apiUrl + "/domains/" + list + "/exact", method: "post", dataType: "json", processData: false, @@ -411,7 +411,7 @@ function checkMessages() { ? localStorage.getItem("hideNonfatalDnsmasqWarnings_chkbox") === "true" : false; $.ajax({ - url: "/api/info/messages/count" + (ignoreNonfatal ? "?filter_dnsmasq_warnings=true" : ""), + url: apiUrl + "/info/messages/count" + (ignoreNonfatal ? "?filter_dnsmasq_warnings=true" : ""), method: "GET", dataType: "json", }) @@ -465,7 +465,7 @@ function changeBulkDeleteStates(table) { function doLogout() { $.ajax({ - url: "/api/auth", + url: apiUrl + "/auth", method: "DELETE", }).always(function () { location.reload(); @@ -646,7 +646,7 @@ function listAlert(type, items, data) { function loadingOverlayTimeoutCallback(reloadAfterTimeout) { // Try to ping FTL to see if it finished restarting $.ajax({ - url: "/api/info/login", + url: apiUrl + "/info/login", method: "GET", cache: false, dataType: "json", diff --git a/scripts/lua/footer.lp b/scripts/lua/footer.lp index 6dcb5640..d465cf26 100644 --- a/scripts/lua/footer.lp +++ b/scripts/lua/footer.lp @@ -66,6 +66,7 @@ end + From dc0dc62151380b9d1a5e845e104ec908808b02e6 Mon Sep 17 00:00:00 2001 From: Alex Whitman Date: Thu, 27 Feb 2025 18:12:23 +0000 Subject: [PATCH 08/68] Fix typo in DHCP settings page Signed-off-by: Alex Whitman --- settings-dhcp.lp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings-dhcp.lp b/settings-dhcp.lp index 196c039f..0e918e26 100644 --- a/settings-dhcp.lp +++ b/settings-dhcp.lp @@ -202,7 +202,7 @@ mg.include('scripts/lua/settings_header.lp','r')