FE: cleaner getMac()

Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
jokob-sk
2025-12-23 10:21:49 +11:00
parent aef1f89ca4
commit 9b0c916bba
2 changed files with 60 additions and 55 deletions
+55 -54
View File
@@ -1,7 +1,7 @@
<!-- <!--
#---------------------------------------------------------------------------------# #---------------------------------------------------------------------------------#
# NetAlertX # # NetAlertX #
# Open Source Network Guard / WIFI & LAN intrusion detector # # Open Source Network Guard / WIFI & LAN intrusion detector #
# # # #
# deviceDetails.php - Front module. Device management page # # deviceDetails.php - Front module. Device management page #
#---------------------------------------------------------------------------------# #---------------------------------------------------------------------------------#
@@ -34,8 +34,8 @@
<div id="devicePageInfoPlc" class="card-body bg-light"> <div id="devicePageInfoPlc" class="card-body bg-light">
<div class="small-box panel rounded"> <div class="small-box panel rounded">
<div class="inner text-center"> <div class="inner text-center">
</div> </div>
</div> </div>
</div> </div>
@@ -50,7 +50,7 @@
</select> </select>
</span> </span>
</section> </section>
<!-- Main content ---------------------------------------------------------- --> <!-- Main content ---------------------------------------------------------- -->
<section class="content"> <section class="content">
@@ -62,51 +62,51 @@
<!-- <div class="box-transparent"> --> <!-- <div class="box-transparent"> -->
<div id="navDevice" class="nav-tabs-custom"> <div id="navDevice" class="nav-tabs-custom">
<ul class="nav nav-tabs" style="font-size:16px;"> <ul class="nav nav-tabs" style="font-size:16px;">
<li> <li>
<a id="tabDetails" href="#panDetails" data-toggle="tab"> <a id="tabDetails" href="#panDetails" data-toggle="tab">
<i class="fa fa-info-circle"></i> <i class="fa fa-info-circle"></i>
<span class="dev-detail-tab-name"> <span class="dev-detail-tab-name">
<?= lang('DevDetail_Tab_Details');?> <?= lang('DevDetail_Tab_Details');?>
</span> </span>
</a> </a>
</li> </li>
<li> <li>
<a id="tabTools" href="#panTools" data-toggle="tab"> <a id="tabTools" href="#panTools" data-toggle="tab">
<i class="fa fa-screwdriver-wrench"></i> <i class="fa fa-screwdriver-wrench"></i>
<span class="dev-detail-tab-name"> <span class="dev-detail-tab-name">
<?= lang('DevDetail_Tab_Tools');?> <?= lang('DevDetail_Tab_Tools');?>
</span> </span>
</a> </a>
</li> </li>
<li> <li>
<a id="tabSessions" href="#panSessions" data-toggle="tab"> <a id="tabSessions" href="#panSessions" data-toggle="tab">
<i class="fa fa-list-ol"></i> <i class="fa fa-list-ol"></i>
<span class="dev-detail-tab-name"> <span class="dev-detail-tab-name">
<?= lang('DevDetail_Tab_Sessions');?> <?= lang('DevDetail_Tab_Sessions');?>
</span> </span>
</a> </a>
</li> </li>
<li> <li>
<a id="tabPresence" href="#panPresence" data-toggle="tab"> <a id="tabPresence" href="#panPresence" data-toggle="tab">
<i class="fa fa-calendar"></i> <i class="fa fa-calendar"></i>
<span class="dev-detail-tab-name"> <span class="dev-detail-tab-name">
<?= lang('DevDetail_Tab_Presence');?> <?= lang('DevDetail_Tab_Presence');?>
</span> </span>
</a> </a>
</li> </li>
<li> <li>
<a id="tabEvents" href="#panEvents" data-toggle="tab"> <a id="tabEvents" href="#panEvents" data-toggle="tab">
<i class="fa fa-bolt"></i> <i class="fa fa-bolt"></i>
<span class="dev-detail-tab-name"> <span class="dev-detail-tab-name">
<?= lang('DevDetail_Tab_Events');?> <?= lang('DevDetail_Tab_Events');?>
</span> </span>
</a> </a>
</li> </li>
<li> <li>
<a id="tabPlugins" href="#panPlugins" data-toggle="tab"> <a id="tabPlugins" href="#panPlugins" data-toggle="tab">
<i class="fa fa-plug"></i> <i class="fa fa-plug"></i>
<span class="dev-detail-tab-name"> <span class="dev-detail-tab-name">
<?= lang('DevDetail_Tab_Plugins');?> <?= lang('DevDetail_Tab_Plugins');?>
</span> </span>
</a> </a>
</li> </li>
@@ -122,34 +122,34 @@
id="btnNext" onclick="recordSwitch('next')"> <i class="fa fa-chevron-right"></i> </button> id="btnNext" onclick="recordSwitch('next')"> <i class="fa fa-chevron-right"></i> </button>
</div> </div>
</ul> </ul>
<div class="tab-content spinnerTarget" style="min-height: 430px;"> <div class="tab-content spinnerTarget" style="min-height: 430px;">
<!-- tab page 1 ------------------------------------------------------------ --> <!-- tab page 1 ------------------------------------------------------------ -->
<div class="tab-pane fade" id="panDetails"> <div class="tab-pane fade" id="panDetails">
<?php <?php
require 'deviceDetailsEdit.php'; require 'deviceDetailsEdit.php';
?> ?>
</div> </div>
<!-- tab page 2 ------------------------------------------------------------ --> <!-- tab page 2 ------------------------------------------------------------ -->
<div class="tab-pane fade table-responsive" id="panSessions"> <div class="tab-pane fade table-responsive" id="panSessions">
<?php <?php
require 'deviceDetailsSessions.php'; require 'deviceDetailsSessions.php';
?> ?>
</div> </div>
<!-- tab page "Tools" ------------------------------------------------------------ --> <!-- tab page "Tools" ------------------------------------------------------------ -->
<div class="tab-pane fade" id="panTools"> <div class="tab-pane fade" id="panTools">
<?php <?php
require 'deviceDetailsTools.php'; require 'deviceDetailsTools.php';
?> ?>
</div> </div>
<!-- tab page 3 ------------------------------------------------------------ --> <!-- tab page 3 ------------------------------------------------------------ -->
<div class="tab-pane fade table-responsive" id="panPresence"> <div class="tab-pane fade table-responsive" id="panPresence">
<?php <?php
// Include the other page // Include the other page
include 'deviceDetailsPresence.php'; include 'deviceDetailsPresence.php';
@@ -161,7 +161,7 @@
<?php <?php
// Include the other page // Include the other page
include 'deviceDetailsEvents.php'; include 'deviceDetailsEvents.php';
?> ?>
</div> </div>
<!-- tab page 7 ------------------------------------------------------------ --> <!-- tab page 7 ------------------------------------------------------------ -->
@@ -194,7 +194,7 @@
require 'php/templates/footer.php'; require 'php/templates/footer.php';
?> ?>
<!-- ----------------------------------------------------------------------- --> <!-- ----------------------------------------------------------------------- -->
<!-- Dark-Mode Patch --> <!-- Dark-Mode Patch -->
@@ -215,10 +215,10 @@ switch ($UI_THEME) {
// ------------------------------------------------------------ // ------------------------------------------------------------
mac = getMac() // can also be rowID!! not only mac mac = getMac() // can also be rowID!! not only mac
var devicesList = []; // this will contain a list the database row IDs of the devices ordered by the position displayed in the UI var devicesList = []; // this will contain a list the database row IDs of the devices ordered by the position displayed in the UI
var pos = -1; var pos = -1;
var parPeriod = 'Front_Details_Period'; var parPeriod = 'Front_Details_Period';
var tab = 'tabDetails' var tab = 'tabDetails'
@@ -250,16 +250,16 @@ function main () {
period = '1 day'; period = '1 day';
sessionsRows = 50; sessionsRows = 50;
eventsRows = 50; eventsRows = 50;
// $('#chkHideConnectionEvents')[0].checked = eval(eventsHide == 'true'); // $('#chkHideConnectionEvents')[0].checked = eval(eventsHide == 'true');
// Initialize components with parameters // Initialize components with parameters
// Init tabs once DOM ready // Init tabs once DOM ready
$( document ).ready(function() { $( document ).ready(function() {
initializeTabs(); initializeTabs();
}); });
} }
@@ -272,7 +272,7 @@ function periodChanged () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Left (prev) < > (next) Right toggles at the top right of device details to // Left (prev) < > (next) Right toggles at the top right of device details to
// cycle between devices // cycle between devices
function recordSwitch(direction) { function recordSwitch(direction) {
@@ -281,7 +281,7 @@ function recordSwitch(direction) {
showModalDefaultStrParam ('Unsaved changes', 'Do you want to discard your changes?', showModalDefaultStrParam ('Unsaved changes', 'Do you want to discard your changes?',
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Okay');?>', performSwitch, direction); '<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Okay');?>', performSwitch, direction);
} else } else
{ {
performSwitch(direction) performSwitch(direction)
} }
} }
@@ -354,7 +354,7 @@ function performSwitch(direction)
// Update the global position in the devices list variable 'pos' // Update the global position in the devices list variable 'pos'
if (direction === "next") { if (direction === "next") {
console.log("direction:" + direction); console.log("direction:" + direction);
if (pos < devicesList.length) { if (pos < devicesList.length) {
pos++; pos++;
} }
@@ -377,13 +377,13 @@ function performSwitch(direction)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Activate save & restore on any value change // Activate save & restore on any value change
$(document).on('input', 'input:text', function() { $(document).on('input', 'input:text', function() {
settingsChanged(); settingsChanged();
}); });
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
function initializeTabs () { function initializeTabs () {
key ="activeDevicesTab" key ="activeDevicesTab"
@@ -392,7 +392,7 @@ function initializeTabs () {
{ {
selectedTab = getCache(key); selectedTab = getCache(key);
} }
$('.nav-tabs a[id='+ selectedTab +']').tab('show'); $('.nav-tabs a[id='+ selectedTab +']').tab('show');
// When changed save new current tab // When changed save new current tab
@@ -410,7 +410,7 @@ function initializeTabs () {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Render the small boxes on top // Render the small boxes on top
async function renderSmallBoxes() { async function renderSmallBoxes() {
try { try {
// Show loading dialog // Show loading dialog
showSpinner(); showSpinner();
@@ -549,6 +549,7 @@ function updateDevicePageName(mac) {
window.onload = function async() window.onload = function async()
{ {
mac = getMac()
// initializeTabs(); // initializeTabs();
updateChevrons(mac); updateChevrons(mac);
updateDevicePageName(mac); updateDevicePageName(mac);
+5 -1
View File
@@ -288,7 +288,11 @@
// Save device data to DB // Save device data to DB
function setDeviceData(direction = '', refreshCallback = '') { function setDeviceData(direction = '', refreshCallback = '') {
// Check MAC // Check MAC
if (mac === '') { mac = getMac()
if (isEmpty(mac)) {
console.error("Mac not defined");
return; return;
} }