mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Plugins 0.3 - UI fixes 0.1
This commit is contained in:
@@ -1013,8 +1013,7 @@ def scan_network ():
|
|||||||
updateState("Scan: Network")
|
updateState("Scan: Network")
|
||||||
mylog('verbose', ['[', startTime, '] Scan Devices:' ])
|
mylog('verbose', ['[', startTime, '] Scan Devices:' ])
|
||||||
|
|
||||||
# # Query ScanCycle properties
|
# Query ScanCycle properties
|
||||||
print_log ('Query ScanCycle confinguration')
|
|
||||||
scanCycle_data = query_ScanCycle_Data (True)
|
scanCycle_data = query_ScanCycle_Data (True)
|
||||||
if scanCycle_data is None:
|
if scanCycle_data is None:
|
||||||
mylog('none', ['\n*************** ERROR ***************'])
|
mylog('none', ['\n*************** ERROR ***************'])
|
||||||
@@ -3790,12 +3789,12 @@ def execute_plugin(plugin):
|
|||||||
# prepare command from plugin settings, custom parameters
|
# prepare command from plugin settings, custom parameters
|
||||||
command = resolve_wildcards(set_CMD, params).split()
|
command = resolve_wildcards(set_CMD, params).split()
|
||||||
|
|
||||||
# Execute command
|
|
||||||
mylog('verbose', [' [Plugins] Executing: ', set_CMD])
|
|
||||||
|
|
||||||
# python-script
|
# python-script
|
||||||
if plugin['data_source'] == 'python-script':
|
if plugin['data_source'] == 'python-script':
|
||||||
|
|
||||||
|
# Execute command
|
||||||
|
mylog('verbose', [' [Plugins] Executing: ', set_CMD])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# try runnning a subprocess with a forced timeout in case the subprocess hangs
|
# try runnning a subprocess with a forced timeout in case the subprocess hangs
|
||||||
output = subprocess.check_output (command, universal_newlines=True, stderr=subprocess.STDOUT, timeout=(set_RUN_TIMEOUT))
|
output = subprocess.check_output (command, universal_newlines=True, stderr=subprocess.STDOUT, timeout=(set_RUN_TIMEOUT))
|
||||||
@@ -3815,8 +3814,6 @@ def execute_plugin(plugin):
|
|||||||
# cleanup - select only lines containing a separator to filter out unnecessary data
|
# cleanup - select only lines containing a separator to filter out unnecessary data
|
||||||
newLines = list(filter(lambda x: '|' in x, newLines))
|
newLines = list(filter(lambda x: '|' in x, newLines))
|
||||||
|
|
||||||
pluginEventCount = len(newLines)
|
|
||||||
|
|
||||||
# # regular logging
|
# # regular logging
|
||||||
# for line in newLines:
|
# for line in newLines:
|
||||||
# append_line_to_file (pluginsPath + '/plugin.log', line +'\n')
|
# append_line_to_file (pluginsPath + '/plugin.log', line +'\n')
|
||||||
@@ -3834,11 +3831,17 @@ def execute_plugin(plugin):
|
|||||||
|
|
||||||
# pialert-db-query
|
# pialert-db-query
|
||||||
if plugin['data_source'] == 'pialert-db-query':
|
if plugin['data_source'] == 'pialert-db-query':
|
||||||
|
# replace single quotes wildcards
|
||||||
|
q = set_CMD.replace("{s-quote}", '\'')
|
||||||
|
|
||||||
|
# Execute command
|
||||||
|
mylog('verbose', [' [Plugins] Executing: ', q])
|
||||||
|
|
||||||
# build SQL query parameters to insert into the DB
|
# build SQL query parameters to insert into the DB
|
||||||
sqlParams = []
|
sqlParams = []
|
||||||
|
|
||||||
# set_CMD should contain a SQL query
|
# set_CMD should contain a SQL query
|
||||||
arr = get_sql_array (set_CMD.replace("{s-quote}", '\''))
|
arr = get_sql_array (q)
|
||||||
|
|
||||||
for row in arr:
|
for row in arr:
|
||||||
# There has to be always 8 columns
|
# There has to be always 8 columns
|
||||||
@@ -3853,7 +3856,7 @@ def execute_plugin(plugin):
|
|||||||
mylog('none', [' [Plugins] No output received from the plugin ', plugin["unique_prefix"], ' - enable LOG_LEVEL=debug and check logs'])
|
mylog('none', [' [Plugins] No output received from the plugin ', plugin["unique_prefix"], ' - enable LOG_LEVEL=debug and check logs'])
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
mylog('verbose', ['[', timeNow(), '] [Plugins]: SUCCESS, received ', pluginEventCount, ' entries'])
|
mylog('verbose', ['[', timeNow(), '] [Plugins]: SUCCESS, received ', len(sqlParams), ' entries'])
|
||||||
|
|
||||||
# process results if any
|
# process results if any
|
||||||
if len(sqlParams) > 0:
|
if len(sqlParams) > 0:
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ function getFormControl(dbColumnDef, value, index) {
|
|||||||
|
|
||||||
switch(dbColumnDef.type)
|
switch(dbColumnDef.type)
|
||||||
{
|
{
|
||||||
case 'label':
|
case 'label':
|
||||||
result = `<span>${value}<span>`;
|
result = `<span>${value}<span>`;
|
||||||
break;
|
break;
|
||||||
case 'textboxsave':
|
case 'textboxsave':
|
||||||
@@ -97,7 +97,7 @@ function saveData (id) {
|
|||||||
$.get(`php/server/dbHelper.php?action=update&dbtable=Plugins_Objects&key=Index&id=${index}&columns=UserData&values=${columnValue}`, function(data) {
|
$.get(`php/server/dbHelper.php?action=update&dbtable=Plugins_Objects&key=Index&id=${index}&columns=UserData&values=${columnValue}`, function(data) {
|
||||||
|
|
||||||
// var result = JSON.parse(data);
|
// var result = JSON.parse(data);
|
||||||
console.log(data)
|
console.log(data)
|
||||||
|
|
||||||
// if (result) {
|
// if (result) {
|
||||||
// period = result;
|
// period = result;
|
||||||
@@ -211,8 +211,6 @@ function generateTabs()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Generate the event rows
|
// Generate the event rows
|
||||||
for(i=0;i<pluginUnprocessedEvents.length;i++)
|
for(i=0;i<pluginUnprocessedEvents.length;i++)
|
||||||
{
|
{
|
||||||
@@ -243,18 +241,19 @@ function generateTabs()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Generate the object rows
|
// Generate the object rows
|
||||||
for(i=0;i<pluginObjects.length;i++)
|
for(var i=0;i<pluginObjects.length;i++)
|
||||||
{
|
{
|
||||||
if(pluginObjects[i].Plugin == obj.unique_prefix)
|
if(pluginObjects[i].Plugin == obj.unique_prefix)
|
||||||
{
|
{
|
||||||
clm = ""
|
clm = ""
|
||||||
|
|
||||||
for(j=0;j<colDefinitions.length;j++)
|
for(var j=0;j<colDefinitions.length;j++)
|
||||||
{
|
{
|
||||||
|
|
||||||
clm += '<td>'+ getFormControl(colDefinitions[j], pluginObjects[i][colDefinitions[j].column], pluginObjects[i]["Index"]) +'</td>'
|
clm += '<td>'+ getFormControl(colDefinitions[j], pluginObjects[i][colDefinitions[j].column], pluginObjects[i]["Index"]) +'</td>'
|
||||||
}
|
}
|
||||||
obRows += '<tr>' + clm + '</tr>'
|
obRows += '<tr>' + clm + '</tr>'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"column": "Object_SecondaryD",
|
"column": "Object_SecondaryID",
|
||||||
"show": true,
|
"show": true,
|
||||||
"type": "label",
|
"type": "label",
|
||||||
"default_value":"",
|
"default_value":"",
|
||||||
|
|||||||
Reference in New Issue
Block a user