diff --git a/docker-compose.yml b/docker-compose.yml index 082c5fac..74d02ec6 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,9 +6,9 @@ services: network_mode: "host" restart: unless-stopped volumes: - - ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config + - ${APP_DATA_LOCATION}/pialert/config2:/home/pi/pialert/config # - ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db - - ${APP_DATA_LOCATION}/pialert/db:/home/pi/pialert/db + - ${APP_DATA_LOCATION}/pialert/db2:/home/pi/pialert/db # (optional) map an empty file with the name 'setting_darkmode' if you want to force the dark mode on container rebuilt - ${APP_DATA_LOCATION}/pialert/db/setting_darkmode:/home/pi/pialert/db/setting_darkmode # (optional) useful for debugging if you have issues setting up the container diff --git a/front/deviceDetails.php b/front/deviceDetails.php index e5e8e822..103b9409 100755 --- a/front/deviceDetails.php +++ b/front/deviceDetails.php @@ -686,7 +686,7 @@ if ($ENABLED_DARKMODE === True) { 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 pos = -1; + var pos = -1; var parPeriod = 'Front_Details_Period'; var parTab = 'Front_Details_Tab'; var parSessionsRows = 'Front_Details_Sessions_Rows'; @@ -783,13 +783,6 @@ function main () { } }); - // Ask before exit without saving data - window.onbeforeunload = function(){ - if ( ! document.getElementById('btnSave').hasAttribute('disabled') ) { - return 'Are you sure you want to discard unsaved changes?'; - } - }; - }); }); @@ -841,7 +834,7 @@ function initializeiCheck () { setParameter (parEventsHide, event.currentTarget.checked); } else { // Activate save & restore - activateSaveRestoreData(); + // activateSaveRestoreData(); // Ask skip notifications // if (event.currentTarget.id == 'chkArchived' ) { @@ -1342,8 +1335,7 @@ function getDeviceData (readAllData=false) { if (deviceData['dev_RandomMAC'] == 1) {$('#iconRandomMACactive').removeClass ('hidden'); $('#iconRandomMACinactive').addClass ('hidden'); } else {$('#iconRandomMACactive').addClass ('hidden'); - $('#iconRandomMACinactive').removeClass ('hidden'); }; - deactivateSaveRestoreData (); + $('#iconRandomMACinactive').removeClass ('hidden'); }; } // Check if device is part of the devicesList @@ -1388,8 +1380,49 @@ function getDeviceData (readAllData=false) { // cycle between devices function recordSwitch(direction) { - var recordToSave = null; + if(somethingChanged) + { + showModalDefaultStrParam ('Unsaved changes', 'Do you want to discard your changes?', + '', '', performSwitch, direction); + } else + { + performSwitch(direction) + } + // // update the global position in the devices list variable 'pos' + // if(direction == "next") + // { + // // Next Record + // if (pos < (devicesList.length-1) ) { + // pos++; + // } + // }else if (direction == "prev") + // { + // if (pos > 0) { + // pos--; + // } + // } + + // // get new mac from the devicesList. Don't change to the commented out line below, the mac query string in the URL isn't updated yet! + // // mac = params.mac; + // mac = devicesList[pos].mac.toString(); + + // // Save Changes + // // if ( ! document.getElementById('btnSave').hasAttribute('disabled') ) { + // // setDeviceData (direction, recordSwitch); + // // } + + // getDeviceData (true); + + // // reload current tab + // reloadTab() + +} + +function performSwitch(direction) +{ + somethingChanged = false; + // update the global position in the devices list variable 'pos' if(direction == "next") { @@ -1404,20 +1437,21 @@ function recordSwitch(direction) { } } + console.log('here ' + pos) + // get new mac from the devicesList. Don't change to the commented out line below, the mac query string in the URL isn't updated yet! // mac = params.mac; mac = devicesList[pos].mac.toString(); // Save Changes - if ( ! document.getElementById('btnSave').hasAttribute('disabled') ) { - setDeviceData (direction, recordSwitch); - } + // if ( ! document.getElementById('btnSave').hasAttribute('disabled') ) { + // setDeviceData (direction, recordSwitch); + // } getDeviceData (true); // reload current tab reloadTab() - } // ----------------------------------------------------------------------------- @@ -1447,9 +1481,7 @@ function setDeviceData (direction='', refreshCallback='') { + '&newdevice=' + ($('#chkNewDevice')[0].checked * 1) + '&archived=' + ($('#chkArchived')[0].checked * 1) , function(msg) { - - // deactivate button - deactivateSaveRestoreData (); + showMessage (msg); // clear session storage @@ -1459,6 +1491,10 @@ function setDeviceData (direction='', refreshCallback='') { setCache("#dropdownLocation",""); setCache("#dropdownNetworkNodeMac",""); + // Remove navigation prompt "Are you sure you want to leave..." + window.onbeforeunload = null; + somethingChanged = false; + // Callback fuction if (typeof refreshCallback == 'function') { refreshCallback(direction); @@ -1491,8 +1527,7 @@ function skipNotifications () { } // Set cycle 0 - $('#txtScanCycle').val ('no'); - activateSaveRestoreData(); + $('#txtScanCycle').val ('no'); } // ----------------------------------------------------------------------------- @@ -1581,32 +1616,13 @@ function getDeviceEvents () { // ----------------------------------------------------------------------------- // Activate save & restore on any value change -$(document).on('input', 'input:text', function() { - activateSaveRestoreData(); +$(document).on('input', 'input:text', function() { + settingsChanged(); }); -$(document).on('input', 'textarea', function() { - activateSaveRestoreData(); -}); - - -// ----------------------------------------------------------------------------- -function activateSaveRestoreData () { - $('#btnRestore').removeAttr ('disabled'); - $('#btnSave').removeAttr ('disabled'); -} - - -function deactivateSaveRestoreData () { - //$('#btnRestore').attr ('disabled',''); - $('#btnSave').attr ('disabled',''); -} - - // ----------------------------------------------------------------------------- function setTextValue (textElement, textValue) { - $('#'+textElement).val (textValue); - activateSaveRestoreData (); + $('#'+textElement).val (textValue); } // ----------------------------------------------------------------------------- @@ -1647,10 +1663,7 @@ function initializeTabsNew () { function loadNmap() { - // console.log(mac) - // console.log('php/server/devices.php?action=getPholus&mac='+ mac) - - $(".deviceSpecific").remove(); + $(".deviceSpecific").remove(); // remove any previous data listed in teh table $.get('php/server/devices.php?action=getNmap&mac='+ mac, function(data) { @@ -1660,20 +1673,26 @@ function loadNmap() { var listData = JSON.parse(data); var order = 1; - - // console.log(listData) - // console.log(listData[0].MAC) tableRows = ""; // for each item listData.forEach(function (item, index) { - tableRows += '