Plugins 1 - Screenshot + fixes

This commit is contained in:
Jokob-sk
2023-03-11 15:49:20 +11:00
parent 2d0a4b79d8
commit b914be9f0e
7 changed files with 38 additions and 23 deletions

View File

@@ -3948,9 +3948,7 @@ def process_plugin_events(plugin):
sql.execute ("INSERT INTO Plugins_Objects (Plugin, Object_PrimaryID, Object_SecondaryID, DateTimeCreated, DateTimeChanged, Watched_Value1, Watched_Value2, Watched_Value3, Watched_Value4, Status, Extra, UserData, ForeignKey) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)", (plugObj.pluginPref, plugObj.primaryId , plugObj.secondaryId , createdTime, plugObj.changed , plugObj.watched1 , plugObj.watched2 , plugObj.watched3 , plugObj.watched4 , plugObj.status , plugObj.extra, plugObj.userData, plugObj.foreignKey )) sql.execute ("INSERT INTO Plugins_Objects (Plugin, Object_PrimaryID, Object_SecondaryID, DateTimeCreated, DateTimeChanged, Watched_Value1, Watched_Value2, Watched_Value3, Watched_Value4, Status, Extra, UserData, ForeignKey) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)", (plugObj.pluginPref, plugObj.primaryId , plugObj.secondaryId , createdTime, plugObj.changed , plugObj.watched1 , plugObj.watched2 , plugObj.watched3 , plugObj.watched4 , plugObj.status , plugObj.extra, plugObj.userData, plugObj.foreignKey ))
else: else:
q = f"UPDATE Plugins_Objects set Plugin = '{plugObj.pluginPref}', DateTimeChanged = '{plugObj.changed}', Watched_Value1 = '{plugObj.watched1}', Watched_Value2 = '{plugObj.watched2}', Watched_Value3 = '{plugObj.watched3}', Watched_Value4 = '{plugObj.watched4}', Status = '{plugObj.status}', Extra = '{plugObj.extra}', ForeignKey = '{plugObj.foreignKey}' WHERE 'Index' = {plugObj.index}" sql.execute (f"UPDATE Plugins_Objects set Plugin = '{plugObj.pluginPref}', DateTimeChanged = '{plugObj.changed}', Watched_Value1 = '{plugObj.watched1}', Watched_Value2 = '{plugObj.watched2}', Watched_Value3 = '{plugObj.watched3}', Watched_Value4 = '{plugObj.watched4}', Status = '{plugObj.status}', Extra = '{plugObj.extra}', ForeignKey = '{plugObj.foreignKey}' WHERE \"Index\" = {plugObj.index}")
sql.execute (q)
# Update the Plugins_Events with the new statuses # Update the Plugins_Events with the new statuses
sql.execute ("DELETE FROM Plugins_Events") sql.execute ("DELETE FROM Plugins_Events")
@@ -3964,7 +3962,7 @@ def process_plugin_events(plugin):
sql.execute ("INSERT INTO Plugins_Events (Plugin, Object_PrimaryID, Object_SecondaryID, DateTimeCreated, DateTimeChanged, Watched_Value1, Watched_Value2, Watched_Value3, Watched_Value4, Status, Extra, UserData, ForeignKey) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)", (plugObj.pluginPref, plugObj.primaryId , plugObj.secondaryId , createdTime, plugObj.changed , plugObj.watched1 , plugObj.watched2 , plugObj.watched3 , plugObj.watched4 , plugObj.status , plugObj.extra, plugObj.userData, plugObj.foreignKey )) sql.execute ("INSERT INTO Plugins_Events (Plugin, Object_PrimaryID, Object_SecondaryID, DateTimeCreated, DateTimeChanged, Watched_Value1, Watched_Value2, Watched_Value3, Watched_Value4, Status, Extra, UserData, ForeignKey) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)", (plugObj.pluginPref, plugObj.primaryId , plugObj.secondaryId , createdTime, plugObj.changed , plugObj.watched1 , plugObj.watched2 , plugObj.watched3 , plugObj.watched4 , plugObj.status , plugObj.extra, plugObj.userData, plugObj.foreignKey ))
commitDB() commitDB()
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
class plugin_object_class: class plugin_object_class:

BIN
docs/img/plugins.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

BIN
docs/img/plugins_settings.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

View File

@@ -64,7 +64,7 @@ function getFormControl(dbColumnDef, value, index) {
result = `<span><a href="${value}" target="_blank">${value}</a><span>`; result = `<span><a href="${value}" target="_blank">${value}</a><span>`;
break; break;
case 'devicemac': case 'devicemac':
result = `<span><a href="/deviceDetails.php?mac=${value}" target="_blank">${value}</a><span>`; result = `<span class="anonymizeMac"><a href="/deviceDetails.php?mac=${value}" target="_blank">${value}</a><span>`;
break; break;
case 'threshold': case 'threshold':
$.each(dbColumnDef.options, function(index, obj) { $.each(dbColumnDef.options, function(index, obj) {
@@ -112,11 +112,6 @@ function saveData (id) {
showMessage('<?= lang('Gen_LockedDB');?>') showMessage('<?= lang('Gen_LockedDB');?>')
} }
// if (result) {
// period = result;
// $('#period').val(period);
// }
}); });
} }
@@ -208,10 +203,7 @@ function generateTabs()
$.each(pluginDefinitions, function(index, obj) { $.each(pluginDefinitions, function(index, obj) {
headersHtml = "" headersHtml = ""
// headers = []
colDefinitions = [] colDefinitions = []
evRows = "" evRows = ""
obRows = "" obRows = ""
@@ -222,7 +214,7 @@ function generateTabs()
if(colDef.show == true) // select only the ones to show if(colDef.show == true) // select only the ones to show
{ {
colDefinitions.push(colDef) colDefinitions.push(colDef)
headersHtml += `<th class="col-sm-2" >${localize(colDef, "name" )}</th>` headersHtml += `<th class="${colDef.css_classes}" >${localize(colDef, "name" )}</th>`
} }
}); });
@@ -247,7 +239,7 @@ function generateTabs()
var histCount = 0 var histCount = 0
var histCountDisplayed = 0 var histCountDisplayed = 0
for(i=0;i<pluginHistory.length;i++) for(i=pluginHistory.length-1;i >= 0;i--) // from latest to the oldest
{ {
if(pluginHistory[i].Plugin == obj.unique_prefix) if(pluginHistory[i].Plugin == obj.unique_prefix)
{ {
@@ -378,7 +370,6 @@ function generateTabs()
}); });
initTabs() initTabs()
} }
// -------------------------------------------------------- // --------------------------------------------------------

View File

@@ -6,7 +6,7 @@ Highly experimental feature. Follow the below very carefully and check example p
These issues will be hopefully fixed with time, so please don't report them. Instead, if you know how, feel free to investigate and submit a PR to fix the below. Keep the PRs small as it's easier to approve them: These issues will be hopefully fixed with time, so please don't report them. Instead, if you know how, feel free to investigate and submit a PR to fix the below. Keep the PRs small as it's easier to approve them:
* Existing plugin objects sometimes not interpreted correctly and a new object is created instead, resulting in dupliucat entries. * Existing plugin objects sometimes not interpreted correctly and a new object is created instead, resulting in duplicate entries.
* Occasional (experienced twice) hanging of processing plugin script file. * Occasional (experienced twice) hanging of processing plugin script file.
* UI displaying outdated values until the API endpoints get refreshed. * UI displaying outdated values until the API endpoints get refreshed.
@@ -245,7 +245,7 @@ The UI will adjust how columns are displayed in the UI based on the definition o
- The `options` property is used in conjunction with these types: - The `options` property is used in conjunction with these types:
- `threshold` - The `options` array contains objects from lowest `maximum` to highest with corresponding `hexColor` used for the value background color if it's less than the specified `maximum`, but more than the previous one in the `options` array - `threshold` - The `options` array contains objects from lowest `maximum` to highest with corresponding `hexColor` used for the value background color if it's less than the specified `maximum`, but more than the previous one in the `options` array
- `replace` - The `options` array contains objects with an `equals` property, that is compared to the "value" and if the values are the same, the string in `replacement` is displayed in the UI instead of the actual "value" - `replace` - The `options` array contains objects with an `equals` property, that is compared to the "value" and if the values are the same, the string in `replacement` is displayed in the UI instead of the actual "value"
- `devicemac` - The value is considered to be a mac adress and a link pointing to the device with teh given mac address is generated. - `devicemac` - The value is considered to be a mac adress and a link pointing to the device with the given mac address is generated.
- `url` - The value is considered to be a url so a link is generated. - `url` - The value is considered to be a url so a link is generated.

View File

@@ -21,6 +21,7 @@
[ [
{ {
"column": "Index", "column": "Index",
"css_classes": "col-sm-2",
"show": false, "show": false,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -33,6 +34,7 @@
} , } ,
{ {
"column": "Plugin", "column": "Plugin",
"css_classes": "col-sm-2",
"show": false, "show": false,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -45,6 +47,7 @@
}, },
{ {
"column": "Object_PrimaryID", "column": "Object_PrimaryID",
"css_classes": "col-sm-2",
"show": true, "show": true,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -57,6 +60,7 @@
}, },
{ {
"column": "Object_SecondaryID", "column": "Object_SecondaryID",
"css_classes": "col-sm-2",
"show": true, "show": true,
"type": "url", "type": "url",
"default_value":"", "default_value":"",
@@ -69,6 +73,7 @@
} , } ,
{ {
"column": "DateTimeCreated", "column": "DateTimeCreated",
"css_classes": "col-sm-2",
"show": true, "show": true,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -81,6 +86,7 @@
}, },
{ {
"column": "DateTimeChanged", "column": "DateTimeChanged",
"css_classes": "col-sm-2",
"show": true, "show": true,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -93,6 +99,7 @@
}, },
{ {
"column": "Watched_Value1", "column": "Watched_Value1",
"css_classes": "col-sm-1",
"show": true, "show": true,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -104,6 +111,7 @@
}, },
{ {
"column": "Watched_Value2", "column": "Watched_Value2",
"css_classes": "col-sm-1",
"show": true, "show": true,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -116,6 +124,7 @@
}, },
{ {
"column": "Watched_Value3", "column": "Watched_Value3",
"css_classes": "col-sm-2",
"show": false, "show": false,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -128,6 +137,7 @@
} , } ,
{ {
"column": "Watched_Value4", "column": "Watched_Value4",
"css_classes": "col-sm-2",
"show": false, "show": false,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -140,6 +150,7 @@
} , } ,
{ {
"column": "Extra", "column": "Extra",
"css_classes": "col-sm-3",
"show": true, "show": true,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -152,6 +163,7 @@
}, },
{ {
"column": "ForeignKey", "column": "ForeignKey",
"css_classes": "col-sm-2",
"show": true, "show": true,
"type": "devicemac", "type": "devicemac",
"default_value":"", "default_value":"",
@@ -164,6 +176,7 @@
}, },
{ {
"column": "Status", "column": "Status",
"css_classes": "col-sm-1",
"show": true, "show": true,
"type": "replace", "type": "replace",
"default_value":"", "default_value":"",

View File

@@ -14,7 +14,7 @@
}], }],
"description": [{ "description": [{
"language_code":"en_us", "language_code":"en_us",
"string" : "This plugin is to monitor status changes of different services or websites." "string" : "This plugin is to monitor status changes of services or websites."
}], }],
"params" : [{ "params" : [{
"name" : "macs", "name" : "macs",
@@ -35,6 +35,7 @@
[ [
{ {
"column": "Index", "column": "Index",
"css_classes": "col-sm-2",
"show": false, "show": false,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -47,6 +48,7 @@
} , } ,
{ {
"column": "Plugin", "column": "Plugin",
"css_classes": "col-sm-2",
"show": false, "show": false,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -59,6 +61,7 @@
}, },
{ {
"column": "Object_PrimaryID", "column": "Object_PrimaryID",
"css_classes": "col-sm-2",
"show": true, "show": true,
"type": "url", "type": "url",
"default_value":"", "default_value":"",
@@ -71,6 +74,7 @@
}, },
{ {
"column": "Object_SecondaryD", "column": "Object_SecondaryD",
"css_classes": "col-sm-2",
"show": false, "show": false,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -83,6 +87,7 @@
} , } ,
{ {
"column": "DateTimeCreated", "column": "DateTimeCreated",
"css_classes": "col-sm-2",
"show": true, "show": true,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -95,6 +100,7 @@
}, },
{ {
"column": "DateTimeChanged", "column": "DateTimeChanged",
"css_classes": "col-sm-2",
"show": true, "show": true,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -107,6 +113,7 @@
}, },
{ {
"column": "Watched_Value1", "column": "Watched_Value1",
"css_classes": "col-sm-2",
"show": true, "show": true,
"type": "threshold", "type": "threshold",
"default_value":"", "default_value":"",
@@ -140,6 +147,7 @@
}, },
{ {
"column": "Watched_Value2", "column": "Watched_Value2",
"css_classes": "col-sm-2",
"show": true, "show": true,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -152,6 +160,7 @@
}, },
{ {
"column": "Watched_Value3", "column": "Watched_Value3",
"css_classes": "col-sm-2",
"show": false, "show": false,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -164,6 +173,7 @@
} , } ,
{ {
"column": "Watched_Value4", "column": "Watched_Value4",
"css_classes": "col-sm-2",
"show": false, "show": false,
"type": "label", "type": "label",
"default_value":"", "default_value":"",
@@ -176,6 +186,7 @@
} , } ,
{ {
"column": "UserData", "column": "UserData",
"css_classes": "col-sm-2",
"show": true, "show": true,
"type": "textboxsave", "type": "textboxsave",
"default_value":"", "default_value":"",
@@ -188,6 +199,7 @@
}, },
{ {
"column": "Status", "column": "Status",
"css_classes": "col-sm-1",
"show": true, "show": true,
"type": "replace", "type": "replace",
"default_value":"", "default_value":"",
@@ -213,6 +225,7 @@
}, },
{ {
"column": "Extra", "column": "Extra",
"css_classes": "col-sm-3",
"show": false, "show": false,
"type": "label", "type": "label",
"default_value":"", "default_value":"",