Merge pull request #46 from Final-Hawk/main

Device Navigation Fixes
This commit is contained in:
jokob-sk
2022-07-26 14:09:52 +10:00
committed by GitHub
+10 -1
View File
@@ -687,7 +687,6 @@ function main () {
// Read Cookies // Read Cookies
devicesList = getCookie('devicesList'); devicesList = getCookie('devicesList');
deleteCookie ('devicesList');
if (devicesList != '') { if (devicesList != '') {
devicesList = JSON.parse (devicesList); devicesList = JSON.parse (devicesList);
} else { } else {
@@ -1174,6 +1173,13 @@ function getDeviceData (readAllData=false) {
mac =deviceData['dev_MAC']; mac =deviceData['dev_MAC'];
// update the mac parameter in the URL, this makes the selected device persistent when the page is reloaded
var searchParams = new URLSearchParams(window.location.search);
searchParams.set("mac", mac);
var newRelativePathQuery = window.location.pathname + '?' + searchParams.toString();
history.pushState(null, '', newRelativePathQuery);
getSessionsPresenceEvents();
$('#txtMAC').val (deviceData['dev_MAC']); $('#txtMAC').val (deviceData['dev_MAC']);
$('#txtName').val (deviceData['dev_Name']); $('#txtName').val (deviceData['dev_Name']);
$('#txtOwner').val (deviceData['dev_Owner']); $('#txtOwner').val (deviceData['dev_Owner']);
@@ -1372,6 +1378,9 @@ function deleteDevice () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
function getSessionsPresenceEvents () { function getSessionsPresenceEvents () {
// Check MAC in url
var urlParams = new URLSearchParams(window.location.search);
mac = urlParams.get ('mac');
// Define Sessions datasource and query dada // Define Sessions datasource and query dada
$('#tableSessions').DataTable().ajax.url('php/server/events.php?action=getDeviceSessions&mac=' + mac +'&period='+ period).load(); $('#tableSessions').DataTable().ajax.url('php/server/events.php?action=getDeviceSessions&mac=' + mac +'&period='+ period).load();