Skip to content

Commit

Permalink
css, pluginsCore, less verbose debug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jokob-sk committed Jan 19, 2025
1 parent b18ee70 commit e766b19
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 22 deletions.
7 changes: 7 additions & 0 deletions front/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,11 @@ input[readonly] {
min-width: 40px;
}

.iconPreview svg{
min-width: 20px;
max-width: 20px;
}


.dummyDevice
{
Expand Down Expand Up @@ -1465,6 +1470,8 @@ input[readonly] {
display: none;
}



#panDetails #NEWDEV_devCustomProps_label
{
display: none;
Expand Down
12 changes: 6 additions & 6 deletions front/deviceDetailsEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function getDeviceData(readAllData){
data: ["devMac", "devLastIP", "devName", "devOwner", "devType", "devVendor", "devGroup", "devIcon", "devLocation", "devComments"],
docs: "https://github.com/jokob-sk/NetAlertX/blob/main/docs/DEVICE_MANAGEMENT.md",
iconClass: "fa fa-pencil",
inputGroupClasses: "field-group col-lg-4 col-sm-6 col-xs-12",
inputGroupClasses: "field-group main-group col-lg-4 col-sm-6 col-xs-12",
labelClasses: "col-sm-4 col-xs-12 control-label",
inputClasses: "col-sm-8 col-xs-12 input-group"
},
Expand All @@ -88,7 +88,7 @@ function getDeviceData(readAllData){
data: ["devStatus", "devLastConnection", "devFirstConnection"],
docs: "https://github.com/jokob-sk/NetAlertX/blob/main/docs/SESSION_INFO.md",
iconClass: "fa fa-calendar",
inputGroupClasses: "field-group col-lg-4 col-sm-6 col-xs-12",
inputGroupClasses: "field-group session-group col-lg-4 col-sm-6 col-xs-12",
labelClasses: "col-sm-4 col-xs-12 control-label",
inputClasses: "col-sm-8 col-xs-12 input-group"
},
Expand All @@ -97,7 +97,7 @@ function getDeviceData(readAllData){
data: ["devAlertEvents", "devAlertDown", "devSkipRepeated"],
docs: "https://github.com/jokob-sk/NetAlertX/blob/main/docs/NOTIFICATIONS.md",
iconClass: "fa fa-bell",
inputGroupClasses: "field-group col-lg-4 col-sm-6 col-xs-12",
inputGroupClasses: "field-group alert-group col-lg-4 col-sm-6 col-xs-12",
labelClasses: "col-sm-4 col-xs-12 control-label",
inputClasses: "col-sm-8 col-xs-12 input-group"
},
Expand All @@ -106,7 +106,7 @@ function getDeviceData(readAllData){
data: ["devParentMAC", "devParentPort", "devSSID", "devSite", "devSyncHubNode"],
docs: "https://github.com/jokob-sk/NetAlertX/blob/main/docs/NETWORK_TREE.md",
iconClass: "fa fa-network-wired",
inputGroupClasses: "field-group col-lg-4 col-sm-6 col-xs-12",
inputGroupClasses: "field-group network-group col-lg-4 col-sm-6 col-xs-12",
labelClasses: "col-sm-4 col-xs-12 control-label",
inputClasses: "col-sm-8 col-xs-12 input-group"
},
Expand All @@ -115,7 +115,7 @@ function getDeviceData(readAllData){
data: ["devStaticIP", "devIsNew", "devFavorite", "devIsArchived"],
docs: "https://github.com/jokob-sk/NetAlertX/blob/main/docs/DEVICE_DISPLAY_SETTINGS.md",
iconClass: "fa fa-list-check",
inputGroupClasses: "field-group col-lg-4 col-sm-6 col-xs-12",
inputGroupClasses: "field-group display-group col-lg-4 col-sm-6 col-xs-12",
labelClasses: "col-sm-4 col-xs-12 control-label",
inputClasses: "col-sm-8 col-xs-12 input-group"
},
Expand All @@ -124,7 +124,7 @@ function getDeviceData(readAllData){
data: ["devCustomProps"],
docs: "https://github.com/jokob-sk/NetAlertX/blob/main/docs/CUSTOM_PROPERTIES.md",
iconClass: "fa fa-list",
inputGroupClasses: "field-group col-lg-12 col-sm-12 col-xs-12",
inputGroupClasses: "field-group cutprop-group col-lg-12 col-sm-12 col-xs-12",
labelClasses: "col-sm-12 col-xs-12 control-label",
inputClasses: "col-sm-12 col-xs-12 input-group"
}
Expand Down
Empty file modified front/php/templates/language/fr_fr.json
100644 → 100755
Empty file.
Empty file modified front/php/templates/language/uk_ua.json
100644 → 100755
Empty file.
4 changes: 1 addition & 3 deletions front/plugins/_publisher_pushover/pushover.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
pluginName = "PUSHOVER"

LOG_PATH = logPath + '/plugins'
RESULT_FILE = os.path.join(LOG_PATH, "last_result.log")


RESULT_FILE = os.path.join(LOG_PATH, f'last_result.{pluginName}.log')


def main():
Expand Down
11 changes: 10 additions & 1 deletion front/plugins/dhcp_servers/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Based on the work of https://github.com/leiweibau/Pi.Alert

import subprocess
import os
from datetime import datetime

import sys
Expand All @@ -15,17 +16,25 @@
from helper import timeNowTZ, get_setting_value
import conf
from pytz import timezone
from const import logPath


# Make sure the TIMEZONE for logging is correct
conf.tz = timezone(get_setting_value('TIMEZONE'))

# Make sure log level is initialized correctly
Logger(get_setting_value('LOG_LEVEL'))

pluginName = 'DHCPSRVS'

LOG_PATH = logPath + '/plugins'
LOG_FILE = os.path.join(LOG_PATH, f'script.{pluginName}.log')
RESULT_FILE = os.path.join(LOG_PATH, f'last_result.{pluginName}.log')

def main():

mylog('verbose', ['[DHCPSRVS] In script'])
RESULT_FILE = 'last_result.log'

last_run_logfile = open(RESULT_FILE, 'a')
last_run_logfile.write("")

Expand Down
1 change: 0 additions & 1 deletion front/plugins/nmap_scan/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def main():
foreignKey = entry.mac
)

# generate last_result.log file
plugin_objects.write_result_file()

#-------------------------------------------------------------------------------
Expand Down
12 changes: 9 additions & 3 deletions front/pluginsCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,16 @@ function getObjectData(prefix, colDefinitions, pluginObj) {
}

function getHistoryData(prefix, colDefinitions, pluginObj) {
// Extract history data for the plugin, limiting to the first 50 entries for performance

return pluginHistory
.filter((history, index) => history.Plugin === prefix && index < 50) // Filter history for the specific plugin
.map(object => colDefinitions.map(colDef => getFormControl(colDef, object[colDef.column], object["Index"], colDefinitions, object)));
.filter(history => history.Plugin === prefix) // First, filter based on the plugin prefix
.sort((a, b) => b.Index - a.Index) // Then, sort by the Index field in descending order
.slice(0, 50) // Limit the result to the first 50 entries
.map(object =>
colDefinitions.map(colDef =>
getFormControl(colDef, object[colDef.column], object["Index"], colDefinitions, object)
)
);
}

function generateTabNavigation(prefix, objectCount, eventCount, historyCount) {
Expand Down
6 changes: 3 additions & 3 deletions server/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ def try_write(self, forceUpdate):
execution_log.finalize_event("update_api")
self.is_ad_hoc_user_event = False

else:
# Debugging if write is skipped
mylog('trace', [f'[API] api_endpoint_class: Skipping write for {self.fileName}, debounce time not passed.'])
# else:
# # Debugging if write is skipped
# mylog('trace', [f'[API] api_endpoint_class: Skipping write for {self.fileName}, debounce time not passed.'])



Expand Down
14 changes: 9 additions & 5 deletions server/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
# Register NetAlertX modules
import conf
from const import pluginsPath, logPath, applicationPath, reportTemplatesPath
from logger import mylog
from logger import mylog, Logger
from helper import timeNowTZ, updateState, get_file_content, write_file, get_setting, get_setting_value
from api import update_api
from plugin_utils import logEventStatusCounts, get_plugin_string, get_plugin_setting_obj, print_plugin_info, list_to_csv, combine_plugin_objects, resolve_wildcards_arr, handle_empty, custom_plugin_decoder, decode_and_rename_files
from notification import Notification_obj, write_notification
from execution_log import ExecutionLog

# Make sure log level is initialized correctly
Logger(get_setting_value('LOG_LEVEL'))

#-------------------------------------------------------------------------------
class plugin_param:
Expand Down Expand Up @@ -316,7 +318,7 @@ def execute_plugin(db, all_plugins, plugin, pluginsState = plugins_state() ):

# keep current instance log file, delete all from other nodes
if filename != 'last_result.log' and os.path.exists(full_path):
os.remove(full_path)
os.remove(full_path) # DEBUG:TODO uncomment 🐛
mylog('verbose', [f'[Plugins] Processed and deleted file: {full_path} '])


Expand Down Expand Up @@ -453,15 +455,14 @@ def execute_plugin(db, all_plugins, plugin, pluginsState = plugins_state() ):
sqlParams.append(tuple(base_params))
else:
mylog('none', ['[Plugins] Skipped invalid sql result'])


# check if the subprocess / SQL query failed / there was no valid output
if len(sqlParams) == 0:
mylog('none', [f'[Plugins] No output received from the plugin "{plugin["unique_prefix"]}"'])
return pluginsState
else:
mylog('verbose', ['[Plugins] SUCCESS, received ', len(sqlParams), ' entries'])
mylog('debug', ['[Plugins] sqlParam entries: ', sqlParams])
# mylog('debug', ['[Plugins] sqlParam entries: ', sqlParams]) # not working for som reason

# process results if any
if len(sqlParams) > 0:
Expand Down Expand Up @@ -605,7 +606,6 @@ def process_plugin_events(db, plugin, pluginsState, plugEventsArr):

# combine all DB insert and update events into one for history
history_to_insert.append(values)


mylog('debug', ['[Plugins] pluginEvents count: ', len(pluginEvents)])
mylog('debug', ['[Plugins] pluginObjects count: ', len(pluginObjects)])
Expand All @@ -614,6 +614,10 @@ def process_plugin_events(db, plugin, pluginsState, plugEventsArr):
mylog('debug', ['[Plugins] history_to_insert count: ', len(history_to_insert)])
mylog('debug', ['[Plugins] objects_to_insert count: ', len(objects_to_insert)])
mylog('debug', ['[Plugins] objects_to_update count: ', len(objects_to_update)])

mylog('trace', ['[Plugins] objects_to_update: ', objects_to_update])
mylog('trace', ['[Plugins] events_to_insert: ', events_to_insert])
mylog('trace', ['[Plugins] history_to_insert: ', history_to_insert])

logEventStatusCounts('pluginEvents', pluginEvents)
logEventStatusCounts('pluginObjects', pluginObjects)
Expand Down

0 comments on commit e766b19

Please sign in to comment.