mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
fix dev_Network_Node_MAC bug (rename was needed)
This commit is contained in:
@@ -1555,6 +1555,26 @@ def upgradeDB ():
|
||||
);
|
||||
""")
|
||||
|
||||
# Alter Devices table
|
||||
# dev_Network_Node_MAC_ADDR column
|
||||
dev_Network_Node_MAC_ADDR_missing = sql.execute ("""
|
||||
SELECT COUNT(*) AS CNTREC FROM pragma_table_info('Devices') WHERE name='dev_Network_Node_MAC_ADDR'
|
||||
""").fetchone()[0] == 0
|
||||
|
||||
if dev_Network_Node_MAC_ADDR_missing :
|
||||
sql.execute("""
|
||||
ALTER TABLE "Devices" ADD "dev_Network_Node_MAC_ADDR" TEXT
|
||||
""")
|
||||
|
||||
# dev_Network_Node_port column
|
||||
dev_Network_Node_port_missing = sql.execute ("""
|
||||
SELECT COUNT(*) AS CNTREC FROM pragma_table_info('Devices') WHERE name='dev_Network_Node_port'
|
||||
""").fetchone()[0] == 0
|
||||
|
||||
if dev_Network_Node_port_missing :
|
||||
sql.execute("""
|
||||
ALTER TABLE "Devices" ADD "dev_Network_Node_port" INTEGER
|
||||
""")
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1229,8 +1229,8 @@ function getDeviceData (readAllData=false) {
|
||||
$('#txtGroup').val (deviceData['dev_Group']);
|
||||
$('#txtLocation').val (deviceData['dev_Location']);
|
||||
$('#txtComments').val (deviceData['dev_Comments']);
|
||||
$('#txtNetworkNodeMac').val (deviceData['dev_Network_Node_MAC']);
|
||||
$('#txtNetworkPort').val (deviceData['dev_Network_Node_port']);
|
||||
$('#txtNetworkNodeMac').val (deviceData['dev_Network_Node_MAC_ADDR']);
|
||||
$('#txtNetworkPort').val (deviceData['dev_Network_Node_port']);
|
||||
|
||||
$('#txtFirstConnection').val (deviceData['dev_FirstConnection']);
|
||||
$('#txtLastConnection').val (deviceData['dev_LastConnection']);
|
||||
|
||||
@@ -21,14 +21,6 @@
|
||||
$NETWORKTYPES = getNetworkTypes();
|
||||
|
||||
OpenDB();
|
||||
|
||||
// #####################################
|
||||
// ## Expand Devices Table
|
||||
// #####################################
|
||||
$sql = 'ALTER TABLE "Devices" ADD "dev_Network_Node_MAC" INTEGER';
|
||||
$result = $db->query($sql);
|
||||
$sql = 'ALTER TABLE "Devices" ADD "dev_Network_Node_port" INTEGER';
|
||||
$result = $db->query($sql);
|
||||
?>
|
||||
|
||||
<!-- Page ------------------------------------------------------------------ -->
|
||||
@@ -156,7 +148,7 @@
|
||||
dev_DeviceType as type,
|
||||
dev_LastIP as last_ip,
|
||||
(select dev_DeviceType from Devices a where dev_MAC = "'.$node_mac.'") as node_type
|
||||
FROM Devices WHERE dev_Network_Node_MAC = "'.$node_mac.'" order by port asc';
|
||||
FROM Devices WHERE dev_Network_Node_MAC_ADDR = "'.$node_mac.'" order by port asc';
|
||||
|
||||
global $db;
|
||||
$func_result = $db->query($func_sql);
|
||||
@@ -274,10 +266,10 @@
|
||||
) t1
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT b.dev_Network_Node_MAC as node_mac_2,
|
||||
SELECT b.dev_Network_Node_MAC_ADDR as node_mac_2,
|
||||
count() as node_ports_count
|
||||
FROM Devices b
|
||||
WHERE b.dev_Network_Node_MAC NOT NULL group by b.dev_Network_Node_MAC
|
||||
WHERE b.dev_Network_Node_MAC_ADDR NOT NULL group by b.dev_Network_Node_MAC_ADDR
|
||||
) t2
|
||||
ON (t1.node_mac = t2.node_mac_2);
|
||||
";
|
||||
|
||||
@@ -96,7 +96,7 @@ function getDeviceData() {
|
||||
$deviceData = $row;
|
||||
$mac = $deviceData['dev_MAC'];
|
||||
|
||||
$deviceData['dev_Network_Node_MAC'] = $row['dev_Network_Node_MAC'];
|
||||
$deviceData['dev_Network_Node_MAC_ADDR'] = $row['dev_Network_Node_MAC_ADDR'];
|
||||
$deviceData['dev_Network_Node_port'] = $row['dev_Network_Node_port'];
|
||||
$deviceData['dev_FirstConnection'] = formatDate ($row['dev_FirstConnection']); // Date formated
|
||||
$deviceData['dev_LastConnection'] = formatDate ($row['dev_LastConnection']); // Date formated
|
||||
@@ -159,23 +159,23 @@ function setDeviceData() {
|
||||
|
||||
// sql
|
||||
$sql = 'UPDATE Devices SET
|
||||
dev_Name = "'. quotes($_REQUEST['name']) .'",
|
||||
dev_Owner = "'. quotes($_REQUEST['owner']) .'",
|
||||
dev_DeviceType = "'. quotes($_REQUEST['type']) .'",
|
||||
dev_Vendor = "'. quotes($_REQUEST['vendor']) .'",
|
||||
dev_Favorite = "'. quotes($_REQUEST['favorite']) .'",
|
||||
dev_Group = "'. quotes($_REQUEST['group']) .'",
|
||||
dev_Location = "'. quotes($_REQUEST['location']) .'",
|
||||
dev_Comments = "'. quotes($_REQUEST['comments']) .'",
|
||||
dev_Network_Node_MAC = "'. quotes($_REQUEST['networknode']).'",
|
||||
dev_Network_Node_port = "'. quotes($_REQUEST['networknodeport']).'",
|
||||
dev_StaticIP = "'. quotes($_REQUEST['staticIP']) .'",
|
||||
dev_ScanCycle = "'. quotes($_REQUEST['scancycle']) .'",
|
||||
dev_AlertEvents = "'. quotes($_REQUEST['alertevents']) .'",
|
||||
dev_AlertDeviceDown = "'. quotes($_REQUEST['alertdown']) .'",
|
||||
dev_SkipRepeated = "'. quotes($_REQUEST['skiprepeated']) .'",
|
||||
dev_NewDevice = "'. quotes($_REQUEST['newdevice']) .'",
|
||||
dev_Archived = "'. quotes($_REQUEST['archived']) .'"
|
||||
dev_Name = "'. quotes($_REQUEST['name']) .'",
|
||||
dev_Owner = "'. quotes($_REQUEST['owner']) .'",
|
||||
dev_DeviceType = "'. quotes($_REQUEST['type']) .'",
|
||||
dev_Vendor = "'. quotes($_REQUEST['vendor']) .'",
|
||||
dev_Favorite = "'. quotes($_REQUEST['favorite']) .'",
|
||||
dev_Group = "'. quotes($_REQUEST['group']) .'",
|
||||
dev_Location = "'. quotes($_REQUEST['location']) .'",
|
||||
dev_Comments = "'. quotes($_REQUEST['comments']) .'",
|
||||
dev_Network_Node_MAC_ADDR = "'. quotes($_REQUEST['networknode']).'",
|
||||
dev_Network_Node_port = "'. quotes($_REQUEST['networknodeport']).'",
|
||||
dev_StaticIP = "'. quotes($_REQUEST['staticIP']) .'",
|
||||
dev_ScanCycle = "'. quotes($_REQUEST['scancycle']) .'",
|
||||
dev_AlertEvents = "'. quotes($_REQUEST['alertevents']) .'",
|
||||
dev_AlertDeviceDown = "'. quotes($_REQUEST['alertdown']) .'",
|
||||
dev_SkipRepeated = "'. quotes($_REQUEST['skiprepeated']) .'",
|
||||
dev_NewDevice = "'. quotes($_REQUEST['newdevice']) .'",
|
||||
dev_Archived = "'. quotes($_REQUEST['archived']) .'"
|
||||
WHERE dev_MAC="' . $_REQUEST['mac'] .'"';
|
||||
// update Data
|
||||
$result = $db->query($sql);
|
||||
|
||||
Reference in New Issue
Block a user