Skip to content

Commit

Permalink
Network fixes #475
Browse files Browse the repository at this point in the history
  • Loading branch information
jokob-sk committed Oct 27, 2023
1 parent 536ef9e commit 4767dec
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 17 deletions.
3 changes: 1 addition & 2 deletions front/css/pialert.css
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,7 @@ input[readonly] {
{
display: block;
position: absolute;
margin-left: 170px;
top: 5px;
margin-left: 170px;
font-size: large;
left: -15px;
}
Expand Down
44 changes: 33 additions & 11 deletions front/network.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,18 +597,19 @@ function attachTreeEvents()
}

// ---------------------------------------------------------------------------
// Handle network node click - select correct tab in teh bottom table
function handleNodeClick(event)
{

console.log(event.target.offsetParent)

const targetTabMAC = $(event.target.offsetParent).attr("data-mytreemacmain");
console.log(event.target.offsetParent.offsetParent)

const targetTabMAC = $(event.target.offsetParent.offsetParent).attr("data-mytreemacmain");

var targetTab = $(`a[data-mytabmac="${targetTabMAC}"]`);

// Simulate a click event on the target tab
targetTab.click();
}

// ---------------------------------------------------------------------------
var myTree;
var treeAreaHeight = 800;
Expand Down Expand Up @@ -637,16 +638,37 @@ function initTree(myHierarchy)

(port == "" || port == 0 ) ? portBckgIcon = `<i class="fa fa-wifi"></i>` : portBckgIcon = `<i class="fa fa-ethernet"></i>`;

// Build HTML for individual nodes in the network diagram
deviceIcon = (!emptyArr.includes(nodeData.data.icon )) ? `<div class="netIcon"><i class="fa fa-${nodeData.data.icon}"></i></div>` : "";
devicePort = `<div class="netPort" style="width:${emSize*sizeCoefficient}em;height:${emSize*sizeCoefficient}em">${port}</div> <div class="portBckgIcon" style="margin-left:-${emSize*sizeCoefficient}em;">${portBckgIcon}</div>`;
collapseExpandIcon = nodeData.data.hiddenChildren ? "square-plus" : "square-minus";
collapseExpandHtml = nodeData.data.hasChildren ? `<div class="netCollapse" style="font-size:${emSize*sizeCoefficient}em;" data-mytreepath='${nodeData.data.path}" data-mytreemac="${nodeData.data.mac}"><i class='fa fa-${collapseExpandIcon} pointer"></i></div>` : "";
statusCss = ` netStatus-${nodeData.data.status}`;
// Build HTML for individual nodes in the network diagram
deviceIcon = (!emptyArr.includes(nodeData.data.icon )) ?
`<div class="netIcon">
<i class="fa fa-${nodeData.data.icon}"></i>
</div>` : "";
devicePort = `<div class="netPort"
style="width:${emSize*sizeCoefficient}em;height:${emSize*sizeCoefficient}em">
${port}</div>
<div class="portBckgIcon"
style="margin-left:-${emSize*sizeCoefficient}em;">
${portBckgIcon}
</div>`;
collapseExpandIcon = nodeData.data.hiddenChildren ?
"square-plus" : "square-minus";

// generate +/- icon if node has children nodes
collapseExpandHtml = nodeData.data.hasChildren ?
`<div class="netCollapse"
style="font-size:${emSize*sizeCoefficient}em;top:${1/2*emSize*sizeCoefficient}em"
data-mytreepath="${nodeData.data.path}"
data-mytreemac="${nodeData.data.mac}">
<i class="fa fa-${collapseExpandIcon} pointer"></i>
</div>` : "";

selectedNodeMac = $(".nav-tabs-custom .active a").attr('data-mytabmac')

highlightedCss = nodeData.data.mac == selectedNodeMac ? " highlightedNode" : "";
highlightedCss = nodeData.data.mac == selectedNodeMac ?
" highlightedNode" : "";

// css indicating online/offline status
statusCss = ` netStatus-${nodeData.data.status}`;

return result = `<div class="box ${nodeData.data.hasChildren ? "pointer":""} ${statusCss} ${highlightedCss}"
data-mytreemacmain="${nodeData.data.mac}"
Expand Down
2 changes: 1 addition & 1 deletion front/php/templates/language/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@
"run_event_tooltip" : "Enable the setting and save your changes at first before you run it.",
"run_event_icon" : "fa-play",
"general_event_title" : "Executing an ad-hoc event",
"general_event_description" : " The event you nove triggered might take a while until background processes finish. The execution ended once the below execution queue empties (Check the <a href='/maintenance.php#tab_Logging'>error log</a> if you envounter issues). <br/> <br/> Execution queue:",
"general_event_description" : " The event you nove triggered might take a while until background processes finish. The execution ended once the below execution queue empties (Check the <a href='/maintenance.php#tab_Logging'>error log</a> if you encounter issues). <br/> <br/> Execution queue:",
"Plugins_Unprocessed_Events" : "Unprocessed Events",
"Plugins_Objects" : "Plugin Objects",
"Plugins_DeleteAll" : "Delete all (filters are ignored)",
Expand Down
10 changes: 7 additions & 3 deletions front/plugins/db_cleanup/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64
from logger import mylog, append_line_to_file
from helper import timeNowTZ
from helper import timeNowTZ, get_setting_value
from const import logPath, pialertPath


Expand Down Expand Up @@ -92,8 +92,12 @@ def cleanup_database (dbPath, DAYS_TO_KEEP_EVENTS, PHOLUS_DAYS_DATA, HRS_TO_KEEP

cursor.execute(delete_query)


# Trim Notifications entries to less than DBCLNP_NOTIFI_HIST setting
mylog('verbose', [f'[DBCLNP] Plugins_History: Trim Notifications entries to less than {str(get_setting_value('DBCLNP_NOTIFI_HIST'))} )'])

histCount = get_setting_value('DBCLNP_NOTIFI_HIST')

mylog('verbose', [f'[DBCLNP] Plugins_History: Trim Notifications entries to less than {histCount}'])

# Build the SQL query to delete entries
delete_query = f"""DELETE FROM Notifications
Expand All @@ -104,7 +108,7 @@ def cleanup_database (dbPath, DAYS_TO_KEEP_EVENTS, PHOLUS_DAYS_DATA, HRS_TO_KEEP
ROW_NUMBER() OVER(PARTITION BY "Notifications" ORDER BY DateTimeCreated DESC) AS row_num
FROM Notifications
) AS ranked_objects
WHERE row_num <= {str(get_setting_value('DBCLNP_NOTIFI_HIST'))}
WHERE row_num <= {histCount}
);"""

cursor.execute(delete_query)
Expand Down

0 comments on commit 4767dec

Please sign in to comment.