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

@@ -267,13 +267,24 @@ if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $D
<div class="form-group">
<label class="col-sm-6 control-label"><?php echo $pia_lang['DevDetail_MainInfo_Network'];?></label>
<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 class="form-group">
<label class="col-sm-6 control-label"><?php echo $pia_lang['DevDetail_MainInfo_Network_Port'];?></label>
<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>
@@ -704,7 +715,6 @@ function main () {
// Read Cookies
devicesList = getCookie('devicesList');
deleteCookie ('devicesList');
if (devicesList != '') {
devicesList = JSON.parse (devicesList);
} else {
@@ -804,10 +814,11 @@ function initializeiCheck () {
// -----------------------------------------------------------------------------
function initializeCombos () {
// Initialize combos with queries
initializeCombo ( $('#dropdownOwner')[0], 'getOwners', 'txtOwner');
initializeCombo ( $('#dropdownDeviceType')[0], 'getDeviceTypes', 'txtDeviceType');
initializeCombo ( $('#dropdownGroup')[0], 'getGroups', 'txtGroup');
initializeCombo ( $('#dropdownLocation')[0], 'getLocations', 'txtLocation');
initializeCombo ( $('#dropdownOwner')[0], 'getOwners', 'txtOwner');
initializeCombo ( $('#dropdownDeviceType')[0], 'getDeviceTypes', 'txtDeviceType');
initializeCombo ( $('#dropdownGroup')[0], 'getGroups', 'txtGroup');
initializeCombo ( $('#dropdownLocation')[0], 'getLocations', 'txtLocation');
initializeCombo ( $('#dropdownNetworkNodeMac')[0], 'getNetworkNodes', 'txtNetworkNodeMac');
// Initialize static combos
initializeComboSkipRepeated ();
@@ -828,10 +839,17 @@ function initializeCombo (HTMLelement, queryAction, txtDataField) {
order = item['order'];
}
id = item['name'];
// use explicitly specified id (value) if avaliable
if(item['id'])
{
id = item['id'];
}
// add dropdown item
HTMLelement.innerHTML +=
'<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 ('--');
$('#txtLocation').val ('--');
$('#txtComments').val ('--');
$('#txtInfrastructure').val ('--');
$('#txtInfrastructurePort').val ('--');
$('#txtNetworkNodeMac').val ('--');
$('#txtNetworkPort').val ('--');
$('#txtFirstConnection').val ('--');
$('#txtLastConnection').val ('--');
@@ -1193,6 +1211,13 @@ function getDeviceData (readAllData=false) {
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']);
$('#txtName').val (deviceData['dev_Name']);
$('#txtOwner').val (deviceData['dev_Owner']);
@@ -1203,8 +1228,8 @@ function getDeviceData (readAllData=false) {
$('#txtGroup').val (deviceData['dev_Group']);
$('#txtLocation').val (deviceData['dev_Location']);
$('#txtComments').val (deviceData['dev_Comments']);
$('#txtInfrastructure').val (deviceData['dev_Infrastructure']);
$('#txtInfrastructurePort').val (deviceData['dev_Infrastructure_port']);
$('#txtNetworkNodeMac').val (deviceData['dev_Network_Node_MAC']);
$('#txtNetworkPort').val (deviceData['dev_Network_Node_port']);
$('#txtFirstConnection').val (deviceData['dev_FirstConnection']);
$('#txtLastConnection').val (deviceData['dev_LastConnection']);
@@ -1313,8 +1338,8 @@ function setDeviceData (refreshCallback='') {
+ '&group=' + $('#txtGroup').val()
+ '&location=' + $('#txtLocation').val()
+ '&comments=' + $('#txtComments').val()
+ '&infrastructure=' + $('#txtInfrastructure').val()
+ '&infrastructureport=' + $('#txtInfrastructurePort').val()
+ '&networknode=' + $('#txtNetworkNodeMac').val()
+ '&networknodeport=' + $('#txtNetworkPort').val()
+ '&staticIP=' + ($('#chkStaticIP')[0].checked * 1)
+ '&scancycle=' + $('#txtScanCycle').val().split(' ')[0]
+ '&alertevents=' + ($('#chkAlertEvents')[0].checked * 1)
@@ -1336,6 +1361,7 @@ function setDeviceData (refreshCallback='') {
}
// -----------------------------------------------------------------------------
function askSkipNotifications () {
// Check MAC
@@ -1422,13 +1448,16 @@ function deleteDevice () {
// -----------------------------------------------------------------------------
function getSessionsPresenceEvents () {
// Check MAC in url
var urlParams = new URLSearchParams(window.location.search);
mac = urlParams.get ('mac');
// Define Sessions datasource and query dada
$('#tableSessions').DataTable().ajax.url('php/server/events.php?action=getDeviceSessions&mac=' + mac +'&period='+ period).load();
// Define Presence datasource and query data
$('#calendar').fullCalendar('removeEventSources');
$('#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
getDeviceEvents();

View File

@@ -35,6 +35,7 @@ if (strlen($pia_lang_selected) == 0) {$pia_lang_selected = 'en_us';}
case 'getDeviceData': getDeviceData(); break;
case 'setDeviceData': setDeviceData(); break;
case 'deleteDevice': deleteDevice(); break;
case 'getNetworkNodes': getNetworkNodes(); break;
case 'deleteAllWithEmptyMACs': deleteAllWithEmptyMACs(); break;
case 'createBackupDB': createBackupDB(); break;
case 'restoreBackupDB': restoreBackupDB(); break;
@@ -87,8 +88,8 @@ function getDeviceData() {
$deviceData = $row;
$mac = $deviceData['dev_MAC'];
$deviceData['dev_Infrastructure'] = $row['dev_Infrastructure'];
$deviceData['dev_Infrastructure_port'] = $row['dev_Infrastructure_port'];
$deviceData['dev_Network_Node_MAC'] = $row['dev_Infrastructure'];
$deviceData['dev_Network_Node_port'] = $row['dev_Infrastructure_port'];
$deviceData['dev_FirstConnection'] = formatDate ($row['dev_FirstConnection']); // Date formated
$deviceData['dev_LastConnection'] = formatDate ($row['dev_LastConnection']); // Date formated
@@ -156,8 +157,8 @@ function setDeviceData() {
dev_Group = "'. quotes($_REQUEST['group']) .'",
dev_Location = "'. quotes($_REQUEST['location']) .'",
dev_Comments = "'. quotes($_REQUEST['comments']) .'",
dev_Infrastructure = "'. quotes($_REQUEST['infrastructure']).'",
dev_Infrastructure_port = "'. quotes($_REQUEST['infrastructureport']).'",
dev_Infrastructure = "'. quotes($_REQUEST['networknode']).'",
dev_Infrastructure_port = "'. quotes($_REQUEST['networknodeport']).'",
dev_StaticIP = "'. quotes($_REQUEST['staticIP']) .'",
dev_ScanCycle = "'. quotes($_REQUEST['scancycle']) .'",
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
//------------------------------------------------------------------------------

View File

@@ -19,7 +19,7 @@ tar tvf pialert/tar/pialert_latest.tar | wc -l
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
#ls -l pialert/package/pialert*.tar

Binary file not shown.