Maintaining

This commit is contained in:
leiweibau
2022-08-03 08:34:04 +02:00
parent e174d1113d
commit 711507fa1d
4 changed files with 81 additions and 22 deletions

View File

@@ -266,14 +266,25 @@ if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $D
<div class="form-group"> <div class="form-group">
<label class="col-sm-6 control-label"><?php echo $pia_lang['DevDetail_MainInfo_Network'];?></label> <label class="col-sm-6 control-label"><?php echo $pia_lang['DevDetail_MainInfo_Network'];?></label>
<div class="col-sm-6"> <div class="col-sm-6">
<input class="form-control" id="txtInfrastructure" type="text" value="--"> <div class="input-group">
<input class="form-control" id="txtNetworkNodeMac" type="text" value="--">
<div class="input-group-btn">
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-expanded="false" id="buttonNetworkNodeMac">
<span class="fa fa-caret-down"></span></button>
<ul id="dropdownNetworkNodeMac" class="dropdown-menu dropdown-menu-right">
</ul>
</div>
</div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-6 control-label"><?php echo $pia_lang['DevDetail_MainInfo_Network_Port'];?></label> <label class="col-sm-6 control-label"><?php echo $pia_lang['DevDetail_MainInfo_Network_Port'];?></label>
<div class="col-sm-6"> <div class="col-sm-6">
<input class="form-control" id="txtInfrastructurePort" type="text" value="--"> <input class="form-control" id="txtNetworkPort" type="text" value="--">
</div> </div>
</div> </div>
@@ -704,7 +715,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 {
@@ -804,10 +814,11 @@ function initializeiCheck () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
function initializeCombos () { function initializeCombos () {
// Initialize combos with queries // Initialize combos with queries
initializeCombo ( $('#dropdownOwner')[0], 'getOwners', 'txtOwner'); initializeCombo ( $('#dropdownOwner')[0], 'getOwners', 'txtOwner');
initializeCombo ( $('#dropdownDeviceType')[0], 'getDeviceTypes', 'txtDeviceType'); initializeCombo ( $('#dropdownDeviceType')[0], 'getDeviceTypes', 'txtDeviceType');
initializeCombo ( $('#dropdownGroup')[0], 'getGroups', 'txtGroup'); initializeCombo ( $('#dropdownGroup')[0], 'getGroups', 'txtGroup');
initializeCombo ( $('#dropdownLocation')[0], 'getLocations', 'txtLocation'); initializeCombo ( $('#dropdownLocation')[0], 'getLocations', 'txtLocation');
initializeCombo ( $('#dropdownNetworkNodeMac')[0], 'getNetworkNodes', 'txtNetworkNodeMac');
// Initialize static combos // Initialize static combos
initializeComboSkipRepeated (); initializeComboSkipRepeated ();
@@ -828,10 +839,17 @@ function initializeCombo (HTMLelement, queryAction, txtDataField) {
order = item['order']; order = item['order'];
} }
id = item['name'];
// use explicitly specified id (value) if avaliable
if(item['id'])
{
id = item['id'];
}
// add dropdown item // add dropdown item
HTMLelement.innerHTML += HTMLelement.innerHTML +=
'<li><a href="javascript:void(0)" onclick="setTextValue(\''+ '<li><a href="javascript:void(0)" onclick="setTextValue(\''+
txtDataField +'\',\''+ item['name'] +'\')">'+ item['name'] + '</a></li>' txtDataField +'\',\''+ id +'\')">'+ item['name'] + '</a></li>'
}); });
}); });
} }
@@ -1121,8 +1139,8 @@ function getDeviceData (readAllData=false) {
$('#txtGroup').val ('--'); $('#txtGroup').val ('--');
$('#txtLocation').val ('--'); $('#txtLocation').val ('--');
$('#txtComments').val ('--'); $('#txtComments').val ('--');
$('#txtInfrastructure').val ('--'); $('#txtNetworkNodeMac').val ('--');
$('#txtInfrastructurePort').val ('--'); $('#txtNetworkPort').val ('--');
$('#txtFirstConnection').val ('--'); $('#txtFirstConnection').val ('--');
$('#txtLastConnection').val ('--'); $('#txtLastConnection').val ('--');
@@ -1193,6 +1211,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']);
@@ -1203,8 +1228,8 @@ function getDeviceData (readAllData=false) {
$('#txtGroup').val (deviceData['dev_Group']); $('#txtGroup').val (deviceData['dev_Group']);
$('#txtLocation').val (deviceData['dev_Location']); $('#txtLocation').val (deviceData['dev_Location']);
$('#txtComments').val (deviceData['dev_Comments']); $('#txtComments').val (deviceData['dev_Comments']);
$('#txtInfrastructure').val (deviceData['dev_Infrastructure']); $('#txtNetworkNodeMac').val (deviceData['dev_Network_Node_MAC']);
$('#txtInfrastructurePort').val (deviceData['dev_Infrastructure_port']); $('#txtNetworkPort').val (deviceData['dev_Network_Node_port']);
$('#txtFirstConnection').val (deviceData['dev_FirstConnection']); $('#txtFirstConnection').val (deviceData['dev_FirstConnection']);
$('#txtLastConnection').val (deviceData['dev_LastConnection']); $('#txtLastConnection').val (deviceData['dev_LastConnection']);
@@ -1254,7 +1279,7 @@ function getDeviceData (readAllData=false) {
$('#btnNext').removeAttr ('disabled'); $('#btnNext').removeAttr ('disabled');
$('#btnNext').removeClass ('text-gray50'); $('#btnNext').removeClass ('text-gray50');
} }
// Timer for refresh data // Timer for refresh data
$("body").css("cursor", "default"); $("body").css("cursor", "default");
newTimerRefreshData (getDeviceData); newTimerRefreshData (getDeviceData);
@@ -1313,8 +1338,8 @@ function setDeviceData (refreshCallback='') {
+ '&group=' + $('#txtGroup').val() + '&group=' + $('#txtGroup').val()
+ '&location=' + $('#txtLocation').val() + '&location=' + $('#txtLocation').val()
+ '&comments=' + $('#txtComments').val() + '&comments=' + $('#txtComments').val()
+ '&infrastructure=' + $('#txtInfrastructure').val() + '&networknode=' + $('#txtNetworkNodeMac').val()
+ '&infrastructureport=' + $('#txtInfrastructurePort').val() + '&networknodeport=' + $('#txtNetworkPort').val()
+ '&staticIP=' + ($('#chkStaticIP')[0].checked * 1) + '&staticIP=' + ($('#chkStaticIP')[0].checked * 1)
+ '&scancycle=' + $('#txtScanCycle').val().split(' ')[0] + '&scancycle=' + $('#txtScanCycle').val().split(' ')[0]
+ '&alertevents=' + ($('#chkAlertEvents')[0].checked * 1) + '&alertevents=' + ($('#chkAlertEvents')[0].checked * 1)
@@ -1336,6 +1361,7 @@ function setDeviceData (refreshCallback='') {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
function askSkipNotifications () { function askSkipNotifications () {
// Check MAC // Check MAC
@@ -1422,13 +1448,16 @@ 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();
// Define Presence datasource and query data // Define Presence datasource and query data
$('#calendar').fullCalendar('removeEventSources'); $('#calendar').fullCalendar('removeEventSources');
$('#calendar').fullCalendar('addEventSource', $('#calendar').fullCalendar('addEventSource',
{ url: 'php/server/events.php?action=getDevicePresence&mac=' + mac +'&period='+ period }); { url: 'php/server/events.php?action=getDevicePresence&mac=' + mac});
// Query events // Query events
getDeviceEvents(); getDeviceEvents();

View File

@@ -35,6 +35,7 @@ if (strlen($pia_lang_selected) == 0) {$pia_lang_selected = 'en_us';}
case 'getDeviceData': getDeviceData(); break; case 'getDeviceData': getDeviceData(); break;
case 'setDeviceData': setDeviceData(); break; case 'setDeviceData': setDeviceData(); break;
case 'deleteDevice': deleteDevice(); break; case 'deleteDevice': deleteDevice(); break;
case 'getNetworkNodes': getNetworkNodes(); break;
case 'deleteAllWithEmptyMACs': deleteAllWithEmptyMACs(); break; case 'deleteAllWithEmptyMACs': deleteAllWithEmptyMACs(); break;
case 'createBackupDB': createBackupDB(); break; case 'createBackupDB': createBackupDB(); break;
case 'restoreBackupDB': restoreBackupDB(); break; case 'restoreBackupDB': restoreBackupDB(); break;
@@ -87,8 +88,8 @@ function getDeviceData() {
$deviceData = $row; $deviceData = $row;
$mac = $deviceData['dev_MAC']; $mac = $deviceData['dev_MAC'];
$deviceData['dev_Infrastructure'] = $row['dev_Infrastructure']; $deviceData['dev_Network_Node_MAC'] = $row['dev_Infrastructure'];
$deviceData['dev_Infrastructure_port'] = $row['dev_Infrastructure_port']; $deviceData['dev_Network_Node_port'] = $row['dev_Infrastructure_port'];
$deviceData['dev_FirstConnection'] = formatDate ($row['dev_FirstConnection']); // Date formated $deviceData['dev_FirstConnection'] = formatDate ($row['dev_FirstConnection']); // Date formated
$deviceData['dev_LastConnection'] = formatDate ($row['dev_LastConnection']); // Date formated $deviceData['dev_LastConnection'] = formatDate ($row['dev_LastConnection']); // Date formated
@@ -156,8 +157,8 @@ function setDeviceData() {
dev_Group = "'. quotes($_REQUEST['group']) .'", dev_Group = "'. quotes($_REQUEST['group']) .'",
dev_Location = "'. quotes($_REQUEST['location']) .'", dev_Location = "'. quotes($_REQUEST['location']) .'",
dev_Comments = "'. quotes($_REQUEST['comments']) .'", dev_Comments = "'. quotes($_REQUEST['comments']) .'",
dev_Infrastructure = "'. quotes($_REQUEST['infrastructure']).'", dev_Infrastructure = "'. quotes($_REQUEST['networknode']).'",
dev_Infrastructure_port = "'. quotes($_REQUEST['infrastructureport']).'", dev_Infrastructure_port = "'. quotes($_REQUEST['networknodeport']).'",
dev_StaticIP = "'. quotes($_REQUEST['staticIP']) .'", dev_StaticIP = "'. quotes($_REQUEST['staticIP']) .'",
dev_ScanCycle = "'. quotes($_REQUEST['scancycle']) .'", dev_ScanCycle = "'. quotes($_REQUEST['scancycle']) .'",
dev_AlertEvents = "'. quotes($_REQUEST['alertevents']) .'", dev_AlertEvents = "'. quotes($_REQUEST['alertevents']) .'",
@@ -733,6 +734,35 @@ function getLocations() {
} }
//------------------------------------------------------------------------------
// Query Device Data
//------------------------------------------------------------------------------
function getNetworkNodes() {
global $db;
// Device Data
$sql = 'SELECT * FROM network_infrastructure';
$result = $db->query($sql);
// arrays of rows
$tableData = array();
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
// Push row data
$tableData[] = array('id' => $row['device_id'],
'name' => $row['net_device_name'].'/'.$row['net_device_typ'] );
}
// Control no rows
if (empty($tableData)) {
$tableData = [];
}
// Return json
echo (json_encode ($tableData));
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Status Where conditions // Status Where conditions
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@@ -19,7 +19,7 @@ tar tvf pialert/tar/pialert_latest.tar | wc -l
rm pialert/tar/pialert_*.tar rm pialert/tar/pialert_*.tar
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
tar cvf pialert/tar/pialert_latest.tar --exclude="pialert/tar" --exclude="pialert/.git" pialert | wc -l tar cvf pialert/tar/pialert_latest.tar --no-xattrs --exclude="pialert/tar" --exclude="pialert/.git" --exclude="pialert/.gitignore" pialert | wc -l
#ln -s pialert_$PIALERT_VERSION.tar pialert/package/pialert_latest.tar #ln -s pialert_$PIALERT_VERSION.tar pialert/package/pialert_latest.tar
#ls -l pialert/package/pialert*.tar #ls -l pialert/package/pialert*.tar

Binary file not shown.