Plugins 0.4 - Further UI work

This commit is contained in:
Jokob-sk
2023-03-04 20:41:48 +11:00
parent 49ce3edbdb
commit 1a05435691
7 changed files with 58 additions and 18 deletions

View File

@@ -105,6 +105,16 @@ Instructions for [pucherot's original code can be found here](https://github.com
- [jokob-sk](https://github.com/jokob-sk/Pi.Alert): DB Maintenance tools - [jokob-sk](https://github.com/jokob-sk/Pi.Alert): DB Maintenance tools
- Please see the [Git commit history](https://github.com/jokob-sk/Pi.Alert/commits/main) for a full list of people and their contributions to the project - Please see the [Git commit history](https://github.com/jokob-sk/Pi.Alert/commits/main) for a full list of people and their contributions to the project
## ☕ Support me
Disclaimer: Please only donate if you don't have any debt yourself. Support yourself first, then others.
<a href="https://github.com/sponsors/jokob-sk" target="_blank"><img src="https://i.imgur.com/X6p5ACK.png" alt="Sponsor Me on GitHub" style="height: 30px !important;width: 117px !important;" width="150px" ></a>
<a href="https://www.buymeacoffee.com/jokobsk" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 30px !important;width: 117px !important;" width="117px" height="30px" ></a>
<a href="https://www.patreon.com/user?u=84385063" target="_blank"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Patreon_logo_with_wordmark.svg/512px-Patreon_logo_with_wordmark.svg.png" alt="Support me on patreon" style="height: 30px !important;width: 117px !important;" width="117px" ></a>
BTC: 1N8tupjeCK12qRVU2XrV17WvKK7LCawyZM
<!--- --------------------------------------------------------------------- ---> <!--- --------------------------------------------------------------------- --->
[main]: ./docs/img/devices_split.png "Main screen" [main]: ./docs/img/devices_split.png "Main screen"
[screen1]: ./docs/img/device_details.png "Screen 1" [screen1]: ./docs/img/device_details.png "Screen 1"

View File

@@ -3760,6 +3760,8 @@ def execute_plugin(plugin):
else: else:
set_RUN_TIMEOUT = set["value"] set_RUN_TIMEOUT = set["value"]
mylog('debug', [' [Plugins] Timeout: ', set_RUN_TIMEOUT])
# Prepare custom params # Prepare custom params
params = [] params = []

View File

@@ -20,7 +20,7 @@ services:
- ${DEV_LOCATION}/pholus:/home/pi/pialert/pholus - ${DEV_LOCATION}/pholus:/home/pi/pialert/pholus
- ${DEV_LOCATION}/dockerfiles:/home/pi/pialert/dockerfiles - ${DEV_LOCATION}/dockerfiles:/home/pi/pialert/dockerfiles
- ${APP_DATA_LOCATION}/pialert/php.ini:/etc/php/7.4/fpm/php.ini - ${APP_DATA_LOCATION}/pialert/php.ini:/etc/php/7.4/fpm/php.ini
- ${DEV_LOCATION}/front/api:/home/pi/pialert/front/api # - ${DEV_LOCATION}/front/api:/home/pi/pialert/front/api
- ${DEV_LOCATION}/front/css:/home/pi/pialert/front/css - ${DEV_LOCATION}/front/css:/home/pi/pialert/front/css
- ${DEV_LOCATION}/front/lib/AdminLTE:/home/pi/pialert/front/lib/AdminLTE - ${DEV_LOCATION}/front/lib/AdminLTE:/home/pi/pialert/front/lib/AdminLTE
- ${DEV_LOCATION}/front/js:/home/pi/pialert/front/js - ${DEV_LOCATION}/front/js:/home/pi/pialert/front/js

View File

@@ -193,3 +193,5 @@ Disclaimer: Please only donate if you don't have any debt yourself. Support your
<a href="https://github.com/sponsors/jokob-sk" target="_blank"><img src="https://i.imgur.com/X6p5ACK.png" alt="Sponsor Me on GitHub" style="height: 30px !important;width: 117px !important;" width="150px" ></a> <a href="https://github.com/sponsors/jokob-sk" target="_blank"><img src="https://i.imgur.com/X6p5ACK.png" alt="Sponsor Me on GitHub" style="height: 30px !important;width: 117px !important;" width="150px" ></a>
<a href="https://www.buymeacoffee.com/jokobsk" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 30px !important;width: 117px !important;" width="117px" height="30px" ></a> <a href="https://www.buymeacoffee.com/jokobsk" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 30px !important;width: 117px !important;" width="117px" height="30px" ></a>
<a href="https://www.patreon.com/user?u=84385063" target="_blank"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Patreon_logo_with_wordmark.svg/512px-Patreon_logo_with_wordmark.svg.png" alt="Support me on patreon" style="height: 30px !important;width: 117px !important;" width="117px" ></a> <a href="https://www.patreon.com/user?u=84385063" target="_blank"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Patreon_logo_with_wordmark.svg/512px-Patreon_logo_with_wordmark.svg.png" alt="Support me on patreon" style="height: 30px !important;width: 117px !important;" width="117px" ></a>
BTC: 1N8tupjeCK12qRVU2XrV17WvKK7LCawyZM

View File

@@ -244,7 +244,7 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<option value="16"><?= lang('Device_TableHead_Location');?></option> <option value="16"><?= lang('Device_TableHead_Location');?></option>
<option value="17"><?= lang('Device_TableHead_Vendor');?></option> <option value="17"><?= lang('Device_TableHead_Vendor');?></option>
</select> </select>
<span class="input-group-addon"><i title="<?= lang('DevDetail_GoToNetworkNode');?>" class="fa fa-save pointer" onclick="saveSelectedColumns();"></i></span> <span class="input-group-addon"><i title="<?= lang('Gen_Save');?>" class="fa fa-save pointer" onclick="saveSelectedColumns();"></i></span>
</div> </div>
</div> </div>

View File

@@ -23,7 +23,7 @@
<ul id="tabs-location" class="nav nav-tabs"> <ul id="tabs-location" class="nav nav-tabs">
<!-- PLACEHOLDER --> <!-- PLACEHOLDER -->
</ul> </ul>
<div id="tabs-content-location" class="nav nav-tabs"> <div id="tabs-content-location" class="tab-content">
<!-- PLACEHOLDER --> <!-- PLACEHOLDER -->
</div> </div>
@@ -49,6 +49,8 @@ function getFormControl(dbColumnDef, value, index) {
break; break;
case 'textboxsave': case 'textboxsave':
console.log(value)
value = value == 'null' ? '' : value; // hide 'null' values value = value == 'null' ? '' : value; // hide 'null' values
id = `${dbColumnDef.column}_${index}` id = `${dbColumnDef.column}_${index}`
@@ -98,6 +100,16 @@ function saveData (id) {
// var result = JSON.parse(data); // var result = JSON.parse(data);
console.log(data) console.log(data)
if(sanitize(data) == 'OK')
{
showMessage("Saved")
// Remove navigation prompt "Are you sure you want to leave..."
window.onbeforeunload = null;
} else
{
showMessage("ERROR")
}
// if (result) { // if (result) {
// period = result; // period = result;
@@ -161,6 +173,8 @@ function getData(){
$.get('api/table_plugins_objects.json', function(res) { $.get('api/table_plugins_objects.json', function(res) {
pluginObjects = res["data"]; pluginObjects = res["data"];
console.log(pluginObjects)
$.get('api/table_plugins_history.json', function(res) { $.get('api/table_plugins_history.json', function(res) {
@@ -212,6 +226,7 @@ function generateTabs()
}); });
// Generate the event rows // Generate the event rows
var eveCount = 0;
for(i=0;i<pluginUnprocessedEvents.length;i++) for(i=0;i<pluginUnprocessedEvents.length;i++)
{ {
if(pluginUnprocessedEvents[i].Plugin == obj.unique_prefix) if(pluginUnprocessedEvents[i].Plugin == obj.unique_prefix)
@@ -223,10 +238,12 @@ function generateTabs()
clm += '<td>'+ pluginUnprocessedEvents[i][colDefinitions[j].column] +'</td>' clm += '<td>'+ pluginUnprocessedEvents[i][colDefinitions[j].column] +'</td>'
} }
evRows += '<tr>' + clm + '</tr>' evRows += '<tr>' + clm + '</tr>'
eveCount++;
} }
} }
// Generate the history rows // Generate the history rows
var histCount = 0
for(i=0;i<pluginHistory.length;i++) for(i=0;i<pluginHistory.length;i++)
{ {
if(pluginHistory[i].Plugin == obj.unique_prefix) if(pluginHistory[i].Plugin == obj.unique_prefix)
@@ -238,12 +255,14 @@ function generateTabs()
clm += '<td>'+ pluginHistory[i][colDefinitions[j].column] +'</td>' clm += '<td>'+ pluginHistory[i][colDefinitions[j].column] +'</td>'
} }
hiRows += '<tr>' + clm + '</tr>' hiRows += '<tr>' + clm + '</tr>'
histCount++;
} }
} }
console.log(pluginObjects)
// Generate the object rows // Generate the object rows
var obCount = 0;
for(var 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)
@@ -252,9 +271,16 @@ function generateTabs()
for(var j=0;j<colDefinitions.length;j++) for(var j=0;j<colDefinitions.length;j++)
{ {
if(colDefinitions[j].column == 'UserData' )
{
console.log(colDefinitions[j].column)
console.log(pluginObjects[i][colDefinitions[j].column])
console.log(pluginObjects[i])
}
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>'
obCount++;
} }
} }
@@ -265,25 +291,25 @@ function generateTabs()
<div class="nav-tabs-custom" style="margin-bottom: 0px"> <div class="nav-tabs-custom" style="margin-bottom: 0px">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"> <li class="active">
<a href="#objectsTarget" data-toggle="tab" > <a href="#objectsTarget_${obj.unique_prefix}" data-toggle="tab" >
<i class="fa fa-cube"></i> <?= lang('Plugins_Objects');?> (${pluginObjects.length}) <i class="fa fa-cube"></i> <?= lang('Plugins_Objects');?> (${obCount})
</a> </a>
</li> </li>
<li> <li>
<a href="#eventsTarget" data-toggle="tab" > <a href="#eventsTarget_${obj.unique_prefix}" data-toggle="tab" >
<i class="fa fa-bolt"></i> <?= lang('Plugins_Unprocessed_Events');?> (${pluginUnprocessedEvents.length}) <i class="fa fa-bolt"></i> <?= lang('Plugins_Unprocessed_Events');?> (${eveCount})
</a> </a>
</li> </li>
<li> <li>
<a href="#historyTarget" data-toggle="tab" > <a href="#historyTarget_${obj.unique_prefix}" data-toggle="tab" >
<i class="fa fa-clock"></i> <?= lang('Plugins_History');?> (${pluginHistory.length}) <i class="fa fa-clock"></i> <?= lang('Plugins_History');?> (${histCount})
</a> </a>
</li> </li>
@@ -294,7 +320,7 @@ function generateTabs()
<div class="tab-content"> <div class="tab-content">
<div id="objectsTarget" class="tab-pane active"> <div id="objectsTarget_${obj.unique_prefix}" class="tab-pane ${activetab}">
<table class="table table-striped"> <table class="table table-striped">
<tbody> <tbody>
<tr> <tr>
@@ -304,7 +330,7 @@ function generateTabs()
</tbody> </tbody>
</table> </table>
</div> </div>
<div id="eventsTarget" class="tab-pane"> <div id="eventsTarget_${obj.unique_prefix}" class="tab-pane">
<table class="table table-striped"> <table class="table table-striped">
<tbody> <tbody>
@@ -315,7 +341,7 @@ function generateTabs()
</tbody> </tbody>
</table> </table>
</div> </div>
<div id="historyTarget" class="tab-pane"> <div id="historyTarget_${obj.unique_prefix}" class="tab-pane">
<table class="table table-striped"> <table class="table table-striped">
<tbody> <tbody>

View File

@@ -9,7 +9,7 @@
}], }],
"icon":[{ "icon":[{
"language_code":"en_us", "language_code":"en_us",
"string" : "<i class=\"fa-solid fa-search\"></i>" "string" : "<i class=\"fa-solid fa-satellite-dish\"></i>"
}], }],
"description": [{ "description": [{
"language_code":"en_us", "language_code":"en_us",
@@ -45,7 +45,7 @@
{ {
"column": "Object_PrimaryID", "column": "Object_PrimaryID",
"show": true, "show": true,
"type": "url", "type": "label",
"default_value":"", "default_value":"",
"options": [], "options": [],
"localized": ["name"], "localized": ["name"],
@@ -57,7 +57,7 @@
{ {
"column": "Object_SecondaryID", "column": "Object_SecondaryID",
"show": true, "show": true,
"type": "label", "type": "url",
"default_value":"", "default_value":"",
"options": [], "options": [],
"localized": ["name"], "localized": ["name"],
@@ -194,7 +194,7 @@
{ {
"function": "CMD", "function": "CMD",
"type": "text", "type": "text",
"default_value":"SELECT dv.dev_Name as Object_PrimaryID, cast(dv.dev_LastIP as VARCHAR(100)) || ':' || cast( SUBSTR(ns.Port ,0, INSTR(ns.Port , '/')) as VARCHAR(100)) as Object_SecondaryID, datetime() as DateTime, ns.Service as Watched_Value1, ns.State as Watched_Value2, 'null' as Watched_Value3, 'null' as Watched_Value4, ns.Extra as Extra FROM (SELECT * FROM Nmap_Scan) ns LEFT JOIN (SELECT dev_Name, dev_MAC, dev_LastIP FROM Devices) dv ON ns.MAC = dv.dev_MAC", "default_value":"SELECT dv.dev_Name as Object_PrimaryID, cast('http://' || dv.dev_LastIP as VARCHAR(100)) || ':' || cast( SUBSTR(ns.Port ,0, INSTR(ns.Port , '/')) as VARCHAR(100)) as Object_SecondaryID, datetime() as DateTime, ns.Service as Watched_Value1, ns.State as Watched_Value2, 'null' as Watched_Value3, 'null' as Watched_Value4, ns.Extra as Extra FROM (SELECT * FROM Nmap_Scan) ns LEFT JOIN (SELECT dev_Name, dev_MAC, dev_LastIP FROM Devices) dv ON ns.MAC = dv.dev_MAC",
"options": [], "options": [],
"localized": ["name", "description"], "localized": ["name", "description"],
"name" : [{ "name" : [{