Plugins 0.3 - UI fixes 0.1

This commit is contained in:
Jokob-sk
2023-02-26 16:27:14 +11:00
parent d87d933058
commit 992aa00c3c
3 changed files with 20 additions and 18 deletions

View File

@@ -1013,8 +1013,7 @@ def scan_network ():
updateState("Scan: Network")
mylog('verbose', ['[', startTime, '] Scan Devices:' ])
# # Query ScanCycle properties
print_log ('Query ScanCycle confinguration')
# Query ScanCycle properties
scanCycle_data = query_ScanCycle_Data (True)
if scanCycle_data is None:
mylog('none', ['\n*************** ERROR ***************'])
@@ -3790,12 +3789,12 @@ def execute_plugin(plugin):
# prepare command from plugin settings, custom parameters
command = resolve_wildcards(set_CMD, params).split()
# Execute command
mylog('verbose', [' [Plugins] Executing: ', set_CMD])
# python-script
if plugin['data_source'] == 'python-script':
# Execute command
mylog('verbose', [' [Plugins] Executing: ', set_CMD])
try:
# 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))
@@ -3815,8 +3814,6 @@ def execute_plugin(plugin):
# cleanup - select only lines containing a separator to filter out unnecessary data
newLines = list(filter(lambda x: '|' in x, newLines))
pluginEventCount = len(newLines)
# # regular logging
# for line in newLines:
# append_line_to_file (pluginsPath + '/plugin.log', line +'\n')
@@ -3834,11 +3831,17 @@ def execute_plugin(plugin):
# 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
sqlParams = []
# 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:
# 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'])
return
else:
mylog('verbose', ['[', timeNow(), '] [Plugins]: SUCCESS, received ', pluginEventCount, ' entries'])
mylog('verbose', ['[', timeNow(), '] [Plugins]: SUCCESS, received ', len(sqlParams), ' entries'])
# process results if any
if len(sqlParams) > 0:

View File

@@ -44,7 +44,7 @@ function getFormControl(dbColumnDef, value, index) {
switch(dbColumnDef.type)
{
case 'label':
case 'label':
result = `<span>${value}<span>`;
break;
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) {
// var result = JSON.parse(data);
console.log(data)
console.log(data)
// if (result) {
// period = result;
@@ -211,8 +211,6 @@ function generateTabs()
}
});
// Generate the event rows
for(i=0;i<pluginUnprocessedEvents.length;i++)
{
@@ -243,18 +241,19 @@ function generateTabs()
}
}
// 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)
{
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>'
}
}
obRows += '<tr>' + clm + '</tr>'
}
}

View File

@@ -55,7 +55,7 @@
}]
},
{
"column": "Object_SecondaryD",
"column": "Object_SecondaryID",
"show": true,
"type": "label",
"default_value":"",