mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Fix Network scaling, DeviceDetials link, missing lang string, incorrectly mapped columns, default device values
This commit is contained in:
@@ -383,7 +383,7 @@ def importConfig ():
|
|||||||
lastTimeImported = time.time()
|
lastTimeImported = time.time()
|
||||||
|
|
||||||
# Used to display a message in the UI when old (outdated) settings are loaded
|
# Used to display a message in the UI when old (outdated) settings are loaded
|
||||||
sql.execute ("""UPDATE Parameters set "par_Value" = ? where "par_ID" = "Back_Settings_Imported" """, (round(time.time() * 1000),))
|
initOrSetParam("Back_Settings_Imported",(round(time.time() * 1000),) )
|
||||||
|
|
||||||
commitDB()
|
commitDB()
|
||||||
|
|
||||||
@@ -2840,6 +2840,9 @@ def upgradeDB ():
|
|||||||
AND name='Nmap_Scan';
|
AND name='Nmap_Scan';
|
||||||
""").fetchone() == None
|
""").fetchone() == None
|
||||||
|
|
||||||
|
# Initialize Parameters if unavailable
|
||||||
|
initOrSetParam('Back_App_State','Initializing')
|
||||||
|
|
||||||
# if nmapScanMissing == False:
|
# if nmapScanMissing == False:
|
||||||
# # Re-creating Nmap_Scan table
|
# # Re-creating Nmap_Scan table
|
||||||
# sql.execute("DROP TABLE Nmap_Scan;")
|
# sql.execute("DROP TABLE Nmap_Scan;")
|
||||||
@@ -2859,8 +2862,14 @@ def upgradeDB ():
|
|||||||
PRIMARY KEY("Index" AUTOINCREMENT)
|
PRIMARY KEY("Index" AUTOINCREMENT)
|
||||||
);
|
);
|
||||||
""")
|
""")
|
||||||
|
|
||||||
# don't hog DB access
|
commitDB ()
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
def initOrSetParam(parID, parValue):
|
||||||
|
|
||||||
|
sql.execute ("INSERT INTO Parameters(par_ID, par_Value) VALUES('"+str(parID)+"', '"+str(parValue)+"') ON CONFLICT(par_ID) DO UPDATE SET par_Value='"+str(parValue)+"' where par_ID='"+str(parID)+"'")
|
||||||
|
|
||||||
commitDB ()
|
commitDB ()
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
@@ -2868,7 +2877,6 @@ def updateState(newState):
|
|||||||
|
|
||||||
sql.execute ("UPDATE Parameters SET par_Value='"+ newState +"' WHERE par_ID='Back_App_State'")
|
sql.execute ("UPDATE Parameters SET par_Value='"+ newState +"' WHERE par_ID='Back_App_State'")
|
||||||
|
|
||||||
# don't hog DB access
|
|
||||||
commitDB ()
|
commitDB ()
|
||||||
|
|
||||||
|
|
||||||
@@ -3112,7 +3120,7 @@ def isNewVersion():
|
|||||||
if realeaseTimestamp > buildTimestamp + 600:
|
if realeaseTimestamp > buildTimestamp + 600:
|
||||||
file_print(" New version of the container available!")
|
file_print(" New version of the container available!")
|
||||||
newVersionAvailable = True
|
newVersionAvailable = True
|
||||||
sql.execute ("UPDATE Parameters SET par_Value='"+ str(newVersionAvailable) +"' WHERE par_ID='Back_New_Version_Available'")
|
initOrSetParam('Back_New_Version_Available', str(newVersionAvailable))
|
||||||
|
|
||||||
return newVersionAvailable
|
return newVersionAvailable
|
||||||
|
|
||||||
|
|||||||
@@ -192,9 +192,9 @@
|
|||||||
var parTableOrder = 'Front_Devices_Order';
|
var parTableOrder = 'Front_Devices_Order';
|
||||||
var tableRows = 10;
|
var tableRows = 10;
|
||||||
var tableOrder = [[3,'desc'], [0,'asc']];
|
var tableOrder = [[3,'desc'], [0,'asc']];
|
||||||
var tableColumnVisible = [0,1,2,3,4,5,6,7,8,9,10,12,13,14];
|
var tableColumnVisible = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14];
|
||||||
var columnsStr = '[0,1,2,3,4,5,6,7,8,9,10,12,13,14]';
|
var columnsStr = '[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]';
|
||||||
var tableColumnOrder = [0,1,2,3,4,5,6,7,8,9,10,12,13,14] ;
|
var tableColumnOrder = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14] ;
|
||||||
|
|
||||||
// Read parameters & Initialize components
|
// Read parameters & Initialize components
|
||||||
main();
|
main();
|
||||||
@@ -461,7 +461,7 @@ function getDevicesFromTable(table)
|
|||||||
rowIDs.map(function(rowID, index){
|
rowIDs.map(function(rowID, index){
|
||||||
result.push({
|
result.push({
|
||||||
"rowid": rowID,
|
"rowid": rowID,
|
||||||
"mac":rowMACs[index],
|
"mac" : rowMACs[index],
|
||||||
"name" : rowNames[index],
|
"name" : rowNames[index],
|
||||||
"type" : rowTypes[index],
|
"type" : rowTypes[index],
|
||||||
"icon" : rowIcons[index],
|
"icon" : rowIcons[index],
|
||||||
|
|||||||
@@ -454,7 +454,7 @@
|
|||||||
<script src="js/pialert_common.js"></script>
|
<script src="js/pialert_common.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script defer>
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Tree functionality
|
// Tree functionality
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -580,7 +580,11 @@
|
|||||||
renderNode: nodeData => {
|
renderNode: nodeData => {
|
||||||
|
|
||||||
// calculate the font size of the leaf nodes to fit everything into the tree area
|
// calculate the font size of the leaf nodes to fit everything into the tree area
|
||||||
var fontSize = (nodeData.data.hasChildren) ? "" : "font-size:"+((600/(20*leafNodesCount)).toFixed(2))+"em;";
|
leafNodesCount == 0 ? 1 : leafNodesCount;
|
||||||
|
emSize = ((600/(20*leafNodesCount)).toFixed(2));
|
||||||
|
emSize = emSize > 1 ? 1 : emSize;
|
||||||
|
|
||||||
|
var fontSize = (nodeData.data.hasChildren) ? "" : "font-size:"+emSize+"em;";
|
||||||
|
|
||||||
deviceIcon = (!emptyArr.includes(nodeData.data.icon )) ? "<div class='netIcon '><i class='fa fa-"+nodeData.data.icon +"'></i></div>" : "";
|
deviceIcon = (!emptyArr.includes(nodeData.data.icon )) ? "<div class='netIcon '><i class='fa fa-"+nodeData.data.icon +"'></i></div>" : "";
|
||||||
collapseExpandIcon = nodeData.data.hiddenChildren ? "square-plus" :"square-minus";
|
collapseExpandIcon = nodeData.data.hiddenChildren ? "square-plus" :"square-minus";
|
||||||
@@ -589,7 +593,7 @@
|
|||||||
|
|
||||||
selectedNodeMac = $(".nav-tabs-custom .active a").attr('data-mytabmac')
|
selectedNodeMac = $(".nav-tabs-custom .active a").attr('data-mytabmac')
|
||||||
|
|
||||||
highlightedCss = nodeData.data.mac == selectedNodeMac ? " highlightedNode" : "";
|
highlightedCss = nodeData.data.mac == selectedNodeMac ? " highlightedNode" : "";
|
||||||
|
|
||||||
return result = "<div class='box "+statusCss+" "+highlightedCss+"' data-mytreemacmain='"+nodeData.data.mac+"' \
|
return result = "<div class='box "+statusCss+" "+highlightedCss+"' data-mytreemacmain='"+nodeData.data.mac+"' \
|
||||||
style='height:"+nodeData.settings.nodeHeight+"px;\
|
style='height:"+nodeData.settings.nodeHeight+"px;\
|
||||||
@@ -637,25 +641,7 @@
|
|||||||
|
|
||||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||||
|
|
||||||
// init parent node
|
initButtons()
|
||||||
var currentNodeMac = $(".tab-content .active td[data-mynodemac]").attr('data-mynodemac');
|
|
||||||
|
|
||||||
initButtons(currentNodeMac);
|
|
||||||
|
|
||||||
// change highlighted node in the tree
|
|
||||||
selNode = $("#networkTree .highlightedNode")[0]
|
|
||||||
|
|
||||||
// console.log(selNode)
|
|
||||||
|
|
||||||
if(selNode)
|
|
||||||
{
|
|
||||||
$(selNode).attr('class', $(selNode).attr('class').replace('highlightedNode'))
|
|
||||||
}
|
|
||||||
|
|
||||||
newSelNode = $("#networkTree div[data-mytreemacmain='"+currentNodeMac+"']")[0]
|
|
||||||
|
|
||||||
$(newSelNode).attr('class', $(newSelNode).attr('class') + ' highlightedNode')
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -696,8 +682,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
function initButtons(currentNodeMac)
|
function initButtons()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var currentNodeMac = $(".tab-content .active td[data-mynodemac]").attr('data-mynodemac');
|
||||||
|
|
||||||
|
// change highlighted node in the tree
|
||||||
|
selNode = $("#networkTree .highlightedNode")[0]
|
||||||
|
|
||||||
|
// console.log(selNode)
|
||||||
|
|
||||||
|
if(selNode)
|
||||||
|
{
|
||||||
|
$(selNode).attr('class', $(selNode).attr('class').replace('highlightedNode'))
|
||||||
|
}
|
||||||
|
|
||||||
|
newSelNode = $("#networkTree div[data-mytreemacmain='"+currentNodeMac+"']")[0]
|
||||||
|
|
||||||
|
$(newSelNode).attr('class', $(newSelNode).attr('class') + ' highlightedNode')
|
||||||
|
|
||||||
|
|
||||||
// init the Assign buttons
|
// init the Assign buttons
|
||||||
$('#unassignedDevices button[data-myleafmac]').each(function(){
|
$('#unassignedDevices button[data-myleafmac]').each(function(){
|
||||||
$(this).attr('onclick', 'updateLeaf("'+$(this).attr('data-myleafmac')+'","'+currentNodeMac+'")')
|
$(this).attr('onclick', 'updateLeaf("'+$(this).attr('data-myleafmac')+'","'+currentNodeMac+'")')
|
||||||
@@ -712,6 +716,8 @@
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
function updateLeaf(leafMac,nodeMac)
|
function updateLeaf(leafMac,nodeMac)
|
||||||
{
|
{
|
||||||
|
console.log(leafMac)
|
||||||
|
console.log(nodeMac)
|
||||||
saveData('updateNetworkLeaf', leafMac, nodeMac);
|
saveData('updateNetworkLeaf', leafMac, nodeMac);
|
||||||
setTimeout("location.reload();", 1000); // refresh page after 1s
|
setTimeout("location.reload();", 1000); // refresh page after 1s
|
||||||
}
|
}
|
||||||
@@ -726,6 +732,9 @@
|
|||||||
// attach on-click events
|
// attach on-click events
|
||||||
attachTreeEvents();
|
attachTreeEvents();
|
||||||
|
|
||||||
|
// init Assign/Unassign buttons
|
||||||
|
initButtons()
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -622,8 +622,8 @@ function getDevicesList() {
|
|||||||
|
|
||||||
$defaultOrder = array ($row['dev_Name'],
|
$defaultOrder = array ($row['dev_Name'],
|
||||||
$row['dev_Owner'],
|
$row['dev_Owner'],
|
||||||
$row['dev_DeviceType'],
|
handleNull($row['dev_DeviceType']),
|
||||||
$row['dev_Icon'],
|
handleNull($row['dev_Icon'], "laptop"),
|
||||||
$row['dev_Favorite'],
|
$row['dev_Favorite'],
|
||||||
$row['dev_Group'],
|
$row['dev_Group'],
|
||||||
formatDate ($row['dev_FirstConnection']),
|
formatDate ($row['dev_FirstConnection']),
|
||||||
@@ -634,12 +634,12 @@ function getDevicesList() {
|
|||||||
$row['dev_MAC'], // MAC (hidden)
|
$row['dev_MAC'], // MAC (hidden)
|
||||||
formatIPlong ($row['dev_LastIP']), // IP orderable
|
formatIPlong ($row['dev_LastIP']), // IP orderable
|
||||||
$row['rowid'], // Rowid (hidden)
|
$row['rowid'], // Rowid (hidden)
|
||||||
$row['dev_Network_Node_MAC_ADDR'] //
|
handleNull($row['dev_Network_Node_MAC_ADDR']) //
|
||||||
);
|
);
|
||||||
|
|
||||||
$newOrder = array();
|
$newOrder = array();
|
||||||
|
|
||||||
|
// reorder columns based on user settings
|
||||||
for($index = 0; $index < count($columnOrderMapping); $index++)
|
for($index = 0; $index < count($columnOrderMapping); $index++)
|
||||||
{
|
{
|
||||||
array_push($newOrder, $defaultOrder[$columnOrderMapping[$index][2]]);
|
array_push($newOrder, $defaultOrder[$columnOrderMapping[$index][2]]);
|
||||||
@@ -757,10 +757,11 @@ function getIcons() {
|
|||||||
|
|
||||||
// arrays of rows
|
// arrays of rows
|
||||||
$tableData = array();
|
$tableData = array();
|
||||||
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||||
|
$icon = handleNull($row['dev_Icon'], "laptop");
|
||||||
// Push row data
|
// Push row data
|
||||||
$tableData[] = array('id' => $row['dev_Icon'],
|
$tableData[] = array('id' => $icon,
|
||||||
'name' => '<i class="fa fa-'.$row['dev_Icon'].'"></i> - '.$row['dev_Icon'] );
|
'name' => '<i class="fa fa-'.$icon.'"></i> - '.$icon );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Control no rows
|
// Control no rows
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ function getParameter($skipCache, $defaultValue, $expireMinutes) {
|
|||||||
$value = $row[0];
|
$value = $row[0];
|
||||||
} else{
|
} else{
|
||||||
$value = $defaultValue;
|
$value = $defaultValue;
|
||||||
|
|
||||||
|
// Nothing found in the DB, Insert new value
|
||||||
|
insertNew($parameter, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update cache
|
// update cache
|
||||||
@@ -113,15 +116,7 @@ function setParameter($expireMinutes) {
|
|||||||
$changes = $db->changes();
|
$changes = $db->changes();
|
||||||
if ($changes == 0) {
|
if ($changes == 0) {
|
||||||
// Insert new value
|
// Insert new value
|
||||||
$sql = 'INSERT INTO Parameters (par_ID, par_Value)
|
insertNew($parameter, $value);
|
||||||
VALUES ("'. quotes($parameter) .'",
|
|
||||||
"'. quotes($value) .'")';
|
|
||||||
$result = $db->query($sql);
|
|
||||||
|
|
||||||
if (! $result == TRUE) {
|
|
||||||
echo "Error creating parameter\n\n$sql \n\n". $db->lastErrorMsg();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update cache
|
// update cache
|
||||||
@@ -130,4 +125,21 @@ function setParameter($expireMinutes) {
|
|||||||
echo 'OK';
|
echo 'OK';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function insertNew($parameter, $value)
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
|
||||||
|
// Insert new value
|
||||||
|
$sql = 'INSERT INTO Parameters (par_ID, par_Value)
|
||||||
|
VALUES ("'. quotes($parameter) .'",
|
||||||
|
"'. quotes($value) .'")';
|
||||||
|
$result = $db->query($sql);
|
||||||
|
|
||||||
|
if (! $result == TRUE) {
|
||||||
|
echo "Error creating parameter\n\n$sql \n\n". $db->lastErrorMsg();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -353,6 +353,18 @@ function logServerConsole ($text) {
|
|||||||
$x = array();
|
$x = array();
|
||||||
$y = $x['__________'. $text .'__________'];
|
$y = $x['__________'. $text .'__________'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------
|
||||||
|
function handleNull ($text, $default = "") {
|
||||||
|
if($text == NULL || $text == 'NULL')
|
||||||
|
{
|
||||||
|
return $default;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user