mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-15 22:51:37 -07:00
refactor: Clean up whitespace and improve API token verification in network initialization
This commit is contained in:
@@ -7,12 +7,12 @@
|
|||||||
*/
|
*/
|
||||||
function getApiToken() {
|
function getApiToken() {
|
||||||
let token = getSetting("API_TOKEN");
|
let token = getSetting("API_TOKEN");
|
||||||
|
|
||||||
// If token is not yet available, log warning
|
// If token is not yet available, log warning
|
||||||
if (!token || token.trim() === '') {
|
if (!token || token.trim() === '') {
|
||||||
console.warn("API_TOKEN not yet loaded from settings");
|
console.warn("API_TOKEN not yet loaded from settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,13 +54,13 @@ function loadNetworkNodes() {
|
|||||||
|
|
||||||
const apiBase = getApiBase();
|
const apiBase = getApiBase();
|
||||||
const apiToken = getApiToken();
|
const apiToken = getApiToken();
|
||||||
|
|
||||||
// Verify token is available
|
// Verify token is available
|
||||||
if (!apiToken || apiToken.trim() === '') {
|
if (!apiToken || apiToken.trim() === '') {
|
||||||
console.error("API_TOKEN not available. Settings may not be loaded yet.");
|
console.error("API_TOKEN not available. Settings may not be loaded yet.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = `${apiBase}/dbquery/read`;
|
const url = `${apiBase}/dbquery/read`;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -97,13 +97,13 @@ function loadNetworkNodes() {
|
|||||||
function loadDeviceTable({ sql, containerSelector, tableId, wrapperHtml = null, assignMode = true }) {
|
function loadDeviceTable({ sql, containerSelector, tableId, wrapperHtml = null, assignMode = true }) {
|
||||||
const apiBase = getApiBase();
|
const apiBase = getApiBase();
|
||||||
const apiToken = getApiToken();
|
const apiToken = getApiToken();
|
||||||
|
|
||||||
// Verify token is available
|
// Verify token is available
|
||||||
if (!apiToken || apiToken.trim() === '') {
|
if (!apiToken || apiToken.trim() === '') {
|
||||||
console.error("API_TOKEN not available. Settings may not be loaded yet.");
|
console.error("API_TOKEN not available. Settings may not be loaded yet.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = `${apiBase}/dbquery/read`;
|
const url = `${apiBase}/dbquery/read`;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ function initNetworkTopology() {
|
|||||||
|
|
||||||
const apiBase = getApiBase();
|
const apiBase = getApiBase();
|
||||||
const apiToken = getApiToken();
|
const apiToken = getApiToken();
|
||||||
|
|
||||||
// Verify token is available before making API call
|
// Verify token is available before making API call
|
||||||
if (!apiToken || apiToken.trim() === '') {
|
if (!apiToken || apiToken.trim() === '') {
|
||||||
console.error("API_TOKEN not available. Settings may not be loaded yet. Retrying in 500ms...");
|
console.error("API_TOKEN not available. Settings may not be loaded yet. Retrying in 500ms...");
|
||||||
@@ -45,7 +45,7 @@ function initNetworkTopology() {
|
|||||||
}, 500);
|
}, 500);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = `${apiBase}/dbquery/read`;
|
const url = `${apiBase}/dbquery/read`;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -143,7 +143,7 @@ function initNetworkTopology() {
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
// show spinning icon
|
// show spinning icon
|
||||||
showSpinner();
|
showSpinner();
|
||||||
|
|
||||||
// Start loading the network topology
|
// Start loading the network topology
|
||||||
initNetworkTopology();
|
initNetworkTopology();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user