mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
deviceDetails change notification overhaul
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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' ) {
|
||||
@@ -1343,7 +1336,6 @@ function getDeviceData (readAllData=false) {
|
||||
$('#iconRandomMACinactive').addClass ('hidden'); }
|
||||
else {$('#iconRandomMACactive').addClass ('hidden');
|
||||
$('#iconRandomMACinactive').removeClass ('hidden'); };
|
||||
deactivateSaveRestoreData ();
|
||||
}
|
||||
|
||||
// Check if device is part of the devicesList
|
||||
@@ -1388,7 +1380,48 @@ 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?',
|
||||
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Okay');?>', 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()
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -1448,8 +1482,6 @@ function setDeviceData (direction='', refreshCallback='') {
|
||||
+ '&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);
|
||||
@@ -1492,7 +1528,6 @@ function skipNotifications () {
|
||||
|
||||
// Set cycle 0
|
||||
$('#txtScanCycle').val ('no');
|
||||
activateSaveRestoreData();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -1582,31 +1617,12 @@ function getDeviceEvents () {
|
||||
// -----------------------------------------------------------------------------
|
||||
// Activate save & restore on any value change
|
||||
$(document).on('input', 'input:text', function() {
|
||||
activateSaveRestoreData();
|
||||
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 ();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -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) {
|
||||
|
||||
@@ -1661,19 +1674,25 @@ 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 += '<tr class="deviceSpecific"><td>'+item.Index+'</td><td>'+item.Time+'</td><td>'+item.Port+'</td><td>'+item.State+'</td><td>'+item.Service+'</td><td>'+item.Extra+'</td></tr>';
|
||||
tableRows += '<tr class="deviceSpecific"><td>'
|
||||
+item.Index+'</td><td>'
|
||||
+item.Time+'</td><td>'
|
||||
+item.Port+'</td><td>'
|
||||
+item.State+'</td><td>'
|
||||
+item.Service+'</td><td>'
|
||||
+'<div class="input-group">\
|
||||
<input class="form-control" id="port_'+item.Index+'" type="text" value="'+item.Extra+'">\
|
||||
<span class="input-group-addon"><i class="fa fa-save " onclick="saveNmapPort('+item.Index+')"></i></span>\
|
||||
</div>\
|
||||
</td></tr>';
|
||||
});
|
||||
|
||||
$("#tableNmapBody").html($("#tableNmapBody").html()+tableRows);
|
||||
// $("#tablePholusPlc").attr("style", "display:none");
|
||||
$("#tableNmapPlc").hide();
|
||||
}
|
||||
else
|
||||
@@ -1689,10 +1708,7 @@ function loadNmap()
|
||||
|
||||
function loadPholus()
|
||||
{
|
||||
// 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=getPholus&mac='+ mac, function(data) {
|
||||
|
||||
@@ -1703,19 +1719,14 @@ function loadPholus()
|
||||
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 += '<tr class="deviceSpecific"><td>'+item.Index+'</td><td>'+item.Info+'</td><td>'+item.Time+'</td><td>'+item.IP_v4_or_v6+'</td><td>'+item.Record_Type+'</td><td>'+item.Value+'</td><td>'+item.Extra+'</td></tr>';
|
||||
tableRows += '<tr class="deviceSpecific"><td>'+item.Index+'</td><td>'+item.Info+'</td><td>'+item.Time+'</td><td>'+item.IP_v4_or_v6+'</td><td>'+item.Record_Type+'</td><td>'+item.Value+'</td><td>'+ item.Extra +'</td></tr>';
|
||||
});
|
||||
|
||||
$("#tablePholusBody").html($("#tablePholusBody").html()+tableRows);
|
||||
// $("#tablePholusPlc").attr("style", "display:none");
|
||||
$("#tablePholusPlc").hide();
|
||||
}
|
||||
else
|
||||
@@ -1776,8 +1787,6 @@ function loadPholus()
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// });
|
||||
// }
|
||||
|
||||
@@ -1857,5 +1866,10 @@ function reloadTab()
|
||||
}
|
||||
}
|
||||
|
||||
function saveNmapPort(index)
|
||||
{
|
||||
saveData('saveNmapPort',index , $('#port_'+index).val())
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -117,6 +117,24 @@ function showModalDefault (title, message, btnCancel, btnOK, callbackFunction) {
|
||||
$('#modal-default').modal('show');
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
function showModalDefaultStrParam (title, message, btnCancel, btnOK, callbackFunction, param='') {
|
||||
// set captions
|
||||
$('#modal-str-title').html (title);
|
||||
$('#modal-str-message').html (message);
|
||||
$('#modal-str-cancel').html (btnCancel);
|
||||
$('#modal-str-OK').html (btnOK);
|
||||
$("#modal-str-OK").off("click"); //remove existing handlers
|
||||
$('#modal-str-OK').on('click', function (){
|
||||
$('#modal-str').modal('hide');
|
||||
callbackFunction(param)
|
||||
})
|
||||
|
||||
// Show modal
|
||||
$('#modal-str').modal('show');
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function showModalWarning (title, message, btnCancel, btnOK, callbackFunction) {
|
||||
// set captions
|
||||
@@ -199,6 +217,25 @@ function setParameter (parameter, value) {
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function saveData(functionName, index, value) {
|
||||
|
||||
console.log(functionName + ' ' + index +' ' + value)
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/home/pi/pialert/front/php/server/util.php",
|
||||
data: { function: functionName, index: index, value:value },
|
||||
success: function(data) {
|
||||
// console.log(data);
|
||||
showModalOk ('Result', data );
|
||||
// Remove navigation prompt "Are you sure you want to leave..."
|
||||
window.onbeforeunload = null;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function sleep(milliseconds) {
|
||||
const date = Date.now();
|
||||
@@ -208,6 +245,16 @@ function sleep(milliseconds) {
|
||||
} while (currentDate - date < milliseconds);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
somethingChanged = false;
|
||||
function settingsChanged()
|
||||
{
|
||||
somethingChanged = true;
|
||||
// Enable navigation prompt ... "Are you sure you want to leave..."
|
||||
window.onbeforeunload = function() {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function translateHTMLcodes (text) {
|
||||
|
||||
@@ -12,6 +12,7 @@ require '/home/pi/pialert/front/php/templates/timezone.php';
|
||||
require '/home/pi/pialert/front/php/templates/skinUI.php';
|
||||
|
||||
|
||||
|
||||
$FUNCTION = [];
|
||||
$SETTINGS = [];
|
||||
|
||||
@@ -35,6 +36,10 @@ elseif ($FUNCTION == 'cleanLog')
|
||||
{
|
||||
cleanLog($SETTINGS);
|
||||
}
|
||||
elseif ($FUNCTION == 'saveNmapPort' && array_key_exists('index', $_REQUEST) && array_key_exists('value', $_REQUEST) )
|
||||
{
|
||||
saveNmapPort($_REQUEST['index'], $_REQUEST['value']);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Formatting data functions
|
||||
@@ -281,6 +286,29 @@ function saveSettings()
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------
|
||||
function saveNmapPort($portIndex, $value)
|
||||
{
|
||||
if(is_integer($portIndex))
|
||||
{
|
||||
$value = escapeString($value);
|
||||
|
||||
// sql
|
||||
$sql = 'UPDATE Nmap_Scan SET Extra = "'. quotes($value) .'" WHERE Index="' . $portIndex .'"';
|
||||
// update Data
|
||||
$result = $db->query($sql);
|
||||
|
||||
// check result
|
||||
if ($result == TRUE) {
|
||||
echo lang('Gen_Upd');
|
||||
} else {
|
||||
echo lang('Gen_Upd_Fail')."\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
}
|
||||
}
|
||||
echo "asdasdasasd";
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------
|
||||
|
||||
function getString ($codeName, $default) {
|
||||
|
||||
$result = lang($codeName);
|
||||
|
||||
@@ -20,6 +20,8 @@ $lang['en_us'] = array(
|
||||
'Gen_Restore' => 'Run Restore',
|
||||
'Gen_Switch' => 'Switch',
|
||||
'Gen_AreYouSure' => 'Are you sure?',
|
||||
'Gen_Upd' => 'Updated successfully',
|
||||
'Gen_Upd_Fail' => 'Update failed',
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Login Page - Update by @TeroRERO 03ago2022
|
||||
|
||||
@@ -50,6 +50,28 @@
|
||||
<!-- /.modal-dialog -->
|
||||
</div>
|
||||
|
||||
<!-- Modal Default Str -->
|
||||
<div class="modal fade" id="modal-str" style="display: none;">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-header" >
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 id="modal-str-title" class="modal-title"> Modal Default Title </h4>
|
||||
</div>
|
||||
|
||||
<div id="modal-str-message" class="modal-body"> Modal Default message </div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button id="modal-str-cancel" type="button" class="btn btn-default pull-left" style="min-width: 80px;" data-dismiss="modal"> Cancel </button>
|
||||
<button id="modal-str-OK" type="button" class="btn btn-primary" style="min-width: 80px;" > OK </button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal-dialog -->
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Modal warning -->
|
||||
<div class="modal modal-warning fade" id="modal-warning" style="display: none;">
|
||||
|
||||
@@ -383,16 +383,6 @@ CommitDB();
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
function settingsChanged()
|
||||
{
|
||||
// Enable navigation prompt ... "Are you sure you want to leave..."
|
||||
window.onbeforeunload = function() {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user