Add cur_ScanMethod & fix Plugins display name in lists

This commit is contained in:
Jokob-sk
2023-09-06 22:03:28 +10:00
parent cd43935656
commit 8676b7ccde
10 changed files with 123 additions and 41 deletions

View File

@@ -795,27 +795,7 @@ if ($ENABLED_DARKMODE === True) {
var devicesList = []; // this will contain a list the database row IDs of the devices ordered by the position displayed in the UI var devicesList = []; // this will contain a list the database row IDs of the devices ordered by the position displayed in the UI
var devicesListAll = []; // this will contain a list off all devices var devicesListAll = []; // this will contain a list off all devices
main();
$.get('php/server/devices.php?action=getDevicesList&status=all&forceDefaultOrder', function(data) {
rawData = JSON.parse (data)
devicesListAll = rawData["data"].map(item => { return {
"name":item[0],
"type":item[2],
"icon":item[3],
"mac":item[11],
"parentMac":item[14],
"rowid":item[13],
"status":item[10]
}})
setCache('devicesListAll', JSON.stringify(devicesListAll))
// Read parameters & Initialize components
main();
});
var pos = -1; var pos = -1;
var parPeriod = 'Front_Details_Period'; var parPeriod = 'Front_Details_Period';
@@ -834,7 +814,6 @@ if ($ENABLED_DARKMODE === True) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
function main () { function main () {
// Initialize MAC // Initialize MAC

View File

@@ -506,6 +506,32 @@ function getNameByMacAddress(macAddress) {
return "Unknown"; // Return a default value if MAC address is not found return "Unknown"; // Return a default value if MAC address is not found
} }
// -----------------------------------------------------------------------------
function initDeviceListAll()
{
$.get('php/server/devices.php?action=getDevicesList&status=all&forceDefaultOrder', function(data) {
rawData = JSON.parse (data)
devicesListAll = rawData["data"].map(item => { return {
"name":item[0],
"type":item[2],
"icon":item[3],
"mac":item[11],
"parentMac":item[14],
"rowid":item[13],
"status":item[10]
}})
setCache('devicesListAll', JSON.stringify(devicesListAll))
});
}
var devicesListAll = []; // this will contain a list off all devices
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
function isEmpty(value) function isEmpty(value)
{ {
@@ -515,6 +541,7 @@ function isEmpty(value)
// initialize // initialize
cacheSettings() cacheSettings()
cacheStrings() cacheStrings()
initDeviceListAll()
console.log("init pialert_common.js") console.log("init pialert_common.js")

View File

@@ -267,22 +267,25 @@
}] }]
} , } ,
{ {
"column": "Extra", "column": "Dummy",
"mapped_to_column": "cur_ScanMethod", "mapped_to_column": "cur_ScanMethod",
"css_classes": "col-sm-2", "mapped_to_column_data": {
"show": true, "value": "arp-scan"
"type": "label", },
"default_value":"", "css_classes": "col-sm-2",
"options": [], "show": true,
"localized": ["name"], "type": "label",
"name":[{ "default_value":"",
"language_code":"en_us", "options": [],
"string" : "Scan method" "localized": ["name"],
}, "name":[{
{ "language_code":"en_us",
"language_code":"es_es", "string" : "Scan method"
"string" : "Método de escaneado" },
}] {
"language_code":"es_es",
"string" : "Método de escaneo"
}]
} , } ,
{ {
"column": "DateTimeCreated", "column": "DateTimeCreated",

View File

@@ -5,6 +5,7 @@ import pathlib
import subprocess import subprocess
import argparse import argparse
import os import os
import sys
sys.path.append("/home/pi/pialert/front/plugins") sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/pialert') sys.path.append('/home/pi/pialert/pialert')

View File

@@ -3,6 +3,12 @@
import subprocess import subprocess
from datetime import datetime from datetime import datetime
import sys
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/pialert')
from plugin_helper import Plugin_Objects, Plugin_Object from plugin_helper import Plugin_Objects, Plugin_Object
from logger import mylog from logger import mylog

View File

@@ -266,8 +266,11 @@
}] }]
}, },
{ {
"column": "Extra", "column": "Dummy",
"mapped_to_column": "cur_ScanMethod", "mapped_to_column": "cur_ScanMethod",
"mapped_to_column_data": {
"value": "PIHOLE"
},
"css_classes": "col-sm-2", "css_classes": "col-sm-2",
"show": true, "show": true,
"type": "label", "type": "label",

View File

@@ -246,7 +246,28 @@
"language_code":"es_es", "language_code":"es_es",
"string" : "salida RAW" "string" : "salida RAW"
}] }]
}, },
{
"column": "Dummy",
"mapped_to_column": "cur_ScanMethod",
"mapped_to_column_data": {
"value": "SNMPDSC"
},
"css_classes": "col-sm-2",
"show": true,
"type": "label",
"default_value":"",
"options": [],
"localized": ["name"],
"name":[{
"language_code":"en_us",
"string" : "Scan method"
},
{
"language_code":"es_es",
"string" : "Método de escaneo"
}]
} ,
{ {
"column": "Status", "column": "Status",
"css_classes": "col-sm-1", "css_classes": "col-sm-1",

View File

@@ -79,7 +79,7 @@ def main():
plugin_objects.add_object( plugin_objects.add_object(
primaryId=macAddress, primaryId=macAddress,
secondaryId=ipAddress, secondaryId=ipAddress.strip(), # Remove leading/trailing spaces from IP
watched1='(unknown)', watched1='(unknown)',
watched2=snmpwalkArgs[6], # router IP watched2=snmpwalkArgs[6], # router IP
extra=line, extra=line,

View File

@@ -292,6 +292,27 @@
"string" : "Cambiado" "string" : "Cambiado"
}] }]
}, },
{
"column": "Dummy",
"mapped_to_column": "cur_ScanMethod",
"mapped_to_column_data": {
"value": "UNDIS"
},
"css_classes": "col-sm-2",
"show": true,
"type": "label",
"default_value":"",
"options": [],
"localized": ["name"],
"name":[{
"language_code":"en_us",
"string" : "Scan method"
},
{
"language_code":"es_es",
"string" : "Método de escaneo"
}]
} ,
{ {
"column": "ForeignKey", "column": "ForeignKey",
"css_classes": "col-sm-2", "css_classes": "col-sm-2",

View File

@@ -319,6 +319,27 @@
"string" : "Kommentar" "string" : "Kommentar"
}] }]
}, },
{
"column": "Dummy",
"mapped_to_column": "cur_ScanMethod",
"mapped_to_column_data": {
"value": "UNFIMP"
},
"css_classes": "col-sm-2",
"show": true,
"type": "label",
"default_value":"",
"options": [],
"localized": ["name"],
"name":[{
"language_code":"en_us",
"string" : "Scan method"
},
{
"language_code":"es_es",
"string" : "Método de escaneo"
}]
} ,
{ {
"column": "Extra", "column": "Extra",
"css_classes": "col-sm-3", "css_classes": "col-sm-3",