Docs + show_ui
This commit is contained in:
@@ -102,10 +102,13 @@ More on specifics below.
|
|||||||
|
|
||||||
Currently, these data sources are supported (valid `data_source` value).
|
Currently, these data sources are supported (valid `data_source` value).
|
||||||
|
|
||||||
- Script (`script`)
|
| Name | `data_source` value | Needs to return a "table" | Overview (more details on this page below) |
|
||||||
- SQL query on the PiAlert database (`pialert-db-query`)
|
|----------------------|----------------------|----------------------|----------------------|
|
||||||
- Template (`template`)
|
| Script | `script` | no | Executes any linux command in the `CMD` setting. |
|
||||||
- External SQLite database (`sqlite-db-query`)
|
| Pialert DB query | `pialert-db-query` | yes | Executes a SQL query on the PiAlert database in the `CMD` setting. |
|
||||||
|
| Template | `template` | no | Used to generate internal settings, such a sdefault values. |
|
||||||
|
| External SQLite DB query | `sqlite-db-query` | yes | Executes a SQL query from the `CMD` setting on an external SQLite database mapped in the `DB_PATH` setting. |
|
||||||
|
|
||||||
|
|
||||||
> 🔎Example
|
> 🔎Example
|
||||||
>```json
|
>```json
|
||||||
@@ -113,6 +116,13 @@ Currently, these data sources are supported (valid `data_source` value).
|
|||||||
>```
|
>```
|
||||||
Any of the above data sources have to return a "table" of the exact structure as outlined above.
|
Any of the above data sources have to return a "table" of the exact structure as outlined above.
|
||||||
|
|
||||||
|
You can show or hide the UI on the "Plugins" page and "Plugins" tab on devices via the `show_ui` property:
|
||||||
|
|
||||||
|
> 🔎Example
|
||||||
|
>```json
|
||||||
|
> "show_ui": true,
|
||||||
|
> ```
|
||||||
|
|
||||||
### "data_source": "script"
|
### "data_source": "script"
|
||||||
|
|
||||||
If the `data_source` is set to `script` the `CMD` setting (that you specify in the `settings` array section in the `config.json`) needs to contain an executable Linux command, that generates a `last_result.log` file. This file needs to be stored in the same folder as the plugin.
|
If the `data_source` is set to `script` the `CMD` setting (that you specify in the `settings` array section in the `config.json`) needs to contain an executable Linux command, that generates a `last_result.log` file. This file needs to be stored in the same folder as the plugin.
|
||||||
@@ -208,17 +218,29 @@ Used to initialize internal settings. Check the `newdev_template` plugin for det
|
|||||||
|
|
||||||
### "data_source": "sqlite-db-query"
|
### "data_source": "sqlite-db-query"
|
||||||
|
|
||||||
You can execute a SQL query on an external database connected to the current PiALert database via a temporary `EXTERNAL.` prefix. The external SQLite database file has to be mapped in the container to the path specified in the `db_path` property:
|
You can execute a SQL query on an external database connected to the current PiALert database via a temporary `EXTERNAL.` prefix. The external SQLite database file has to be mapped in the container to the path specified in the `DB_PATH` setting:
|
||||||
|
|
||||||
```json
|
> 🔎Example
|
||||||
...
|
>
|
||||||
"data_source": "sqlite-db-query",
|
>```json
|
||||||
"data_source_settings":
|
> ...
|
||||||
{
|
>{
|
||||||
"db_path":"/etc/pihole/pihole-FTL.db"
|
> "function": "DB_PATH",
|
||||||
},
|
> "type": "readonly",
|
||||||
...
|
> "default_value":"/etc/pihole/pihole-FTL.db",
|
||||||
```
|
> "options": [],
|
||||||
|
> "localized": ["name", "description"],
|
||||||
|
> "name" : [{
|
||||||
|
> "language_code":"en_us",
|
||||||
|
> "string" : "DB Path"
|
||||||
|
> }],
|
||||||
|
> "description": [{
|
||||||
|
> "language_code":"en_us",
|
||||||
|
> "string" : "Required setting for the <code>sqlite-db-query</code> plugin type. Is used to mount an external SQLite database and execute the SQL query stored in the <code>CMD</code> setting."
|
||||||
|
> }]
|
||||||
|
> }
|
||||||
|
> ...
|
||||||
|
>```
|
||||||
|
|
||||||
The actual SQL query you want to execute is then stored as a `CMD` setting, similar to the `pialert-db-query` plugin type.
|
The actual SQL query you want to execute is then stored as a `CMD` setting, similar to the `pialert-db-query` plugin type.
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
"compare_use_quotes": true
|
"compare_use_quotes": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"show_ui": true,
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
|
|
||||||
"display_name": [
|
"display_name": [
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
"compare_use_quotes": true
|
"compare_use_quotes": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"show_ui": true,
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
"mapped_to_table": "DHCP_Leases",
|
"mapped_to_table": "DHCP_Leases",
|
||||||
"display_name" : [{
|
"display_name" : [{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"unique_prefix": "DHCPSRVS",
|
"unique_prefix": "DHCPSRVS",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
|
"show_ui": true,
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
"display_name" : [{
|
"display_name" : [{
|
||||||
"language_code":"en_us",
|
"language_code":"en_us",
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
"template_type": "database-entry",
|
"template_type": "database-entry",
|
||||||
"unique_prefix": "KNWN",
|
"unique_prefix": "KNWN",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "template",
|
"data_source": "template",
|
||||||
|
"show_ui": false,
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
"display_name": [{
|
"display_name": [{
|
||||||
"language_code": "en_us",
|
"language_code": "en_us",
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"unique_prefix": "NEWDEV",
|
"unique_prefix": "NEWDEV",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "template",
|
"data_source": "template",
|
||||||
|
"show_ui": false,
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
"display_name": [{
|
"display_name": [{
|
||||||
"language_code": "en_us",
|
"language_code": "en_us",
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
"compare_use_quotes": true
|
"compare_use_quotes": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"show_ui": true,
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
"display_name" : [{
|
"display_name" : [{
|
||||||
"language_code":"en_us",
|
"language_code":"en_us",
|
||||||
|
|||||||
@@ -3,10 +3,6 @@
|
|||||||
"unique_prefix": "PIHOLE",
|
"unique_prefix": "PIHOLE",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "sqlite-db-query",
|
"data_source": "sqlite-db-query",
|
||||||
"data_source_settings":
|
|
||||||
{
|
|
||||||
"db_path":"/etc/pihole/pihole-FTL.db"
|
|
||||||
},
|
|
||||||
"mapped_to_table": "CurrentScan",
|
"mapped_to_table": "CurrentScan",
|
||||||
"data_filters": [
|
"data_filters": [
|
||||||
{
|
{
|
||||||
@@ -17,6 +13,7 @@
|
|||||||
"compare_use_quotes": true
|
"compare_use_quotes": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"show_ui": true,
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
|
|
||||||
"display_name": [
|
"display_name": [
|
||||||
@@ -57,7 +54,7 @@
|
|||||||
}],
|
}],
|
||||||
"description": [{
|
"description": [{
|
||||||
"language_code":"en_us",
|
"language_code":"en_us",
|
||||||
"string" : "Specify when your PiHole device import from the PiHole databse will run. The typical setting would be <code>schedule</code> and then you specify a cron-like schedule in the <a href=\"#PIHOLE_RUN_SCHD\"><code>PIHOLE_RUN_SCHD</code>setting</a>. If enabled, you must map the pihole db into your container to the <code>:/etc/pihole/pihole-FTL.db</code> mount path."
|
"string" : "Specify when your PiHole device import from the PiHole databse will run. The typical setting would be <code>schedule</code> and then you specify a cron-like schedule in the <a href=\"#PIHOLE_RUN_SCHD\"><code>PIHOLE_RUN_SCHD</code>setting</a>. If enabled, you must map the pihole db into your container to the <code>:/etc/pihole/pihole-FTL.db</code> mount path as specified in the <code>DB_PATH</code> setting."
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -94,6 +91,21 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"function": "DB_PATH",
|
||||||
|
"type": "readonly",
|
||||||
|
"default_value":"/etc/pihole/pihole-FTL.db",
|
||||||
|
"options": [],
|
||||||
|
"localized": ["name", "description"],
|
||||||
|
"name" : [{
|
||||||
|
"language_code":"en_us",
|
||||||
|
"string" : "DB Path"
|
||||||
|
}],
|
||||||
|
"description": [{
|
||||||
|
"language_code":"en_us",
|
||||||
|
"string" : "Required setting for the <code>sqlite-db-query</code> plugin type. Is used to mount an external SQLite database and execute the SQL query stored in the <code>CMD</code> setting."
|
||||||
|
}]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"function": "RUN_SCHD",
|
"function": "RUN_SCHD",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
{
|
{
|
||||||
"code_name": "set_webui_password",
|
"code_name": "set_password",
|
||||||
"template_type": "database-entry",
|
"template_type": "database-entry",
|
||||||
"unique_prefix": "SETPWD",
|
"unique_prefix": "SETPWD",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
|
"show_ui": false,
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
"display_name": [{
|
"display_name": [{
|
||||||
"language_code": "en_us",
|
"language_code": "en_us",
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
"compare_use_quotes": true
|
"compare_use_quotes": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"show_ui": true,
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
"mapped_to_table": "DHCP_Leases",
|
"mapped_to_table": "DHCP_Leases",
|
||||||
"display_name" : [{
|
"display_name" : [{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
"mapped_to_table": "DHCP_Leases",
|
"mapped_to_table": "DHCP_Leases",
|
||||||
|
"show_ui": true,
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
|
|
||||||
"display_name": [
|
"display_name": [
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"unique_prefix": "UNFIMP",
|
"unique_prefix": "UNFIMP",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
|
"show_ui": true,
|
||||||
"data_filters": [
|
"data_filters": [
|
||||||
{
|
{
|
||||||
"compare_column" : "Object_PrimaryID",
|
"compare_column" : "Object_PrimaryID",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"unique_prefix": "WEBMON",
|
"unique_prefix": "WEBMON",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "python-script",
|
"data_source": "python-script",
|
||||||
|
"show_ui": true,
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
"display_name" : [{
|
"display_name" : [{
|
||||||
"language_code": "en_us",
|
"language_code": "en_us",
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ function generateTabs()
|
|||||||
|
|
||||||
// console.log(pluginObj)
|
// console.log(pluginObj)
|
||||||
|
|
||||||
if(pluginObj.data_source != "template") // hiding template-based plugins as they don't produce any output
|
if(pluginObj.show_ui) // hiding plugins where specified
|
||||||
{
|
{
|
||||||
$('#tabs-location').append(
|
$('#tabs-location').append(
|
||||||
`<li class=" left-nav ${activetab}">
|
`<li class=" left-nav ${activetab}">
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ def run_plugin_scripts(db, runType):
|
|||||||
shouldRun = True
|
shouldRun = True
|
||||||
elif runType == "schedule":
|
elif runType == "schedule":
|
||||||
# run if overdue scheduled time
|
# run if overdue scheduled time
|
||||||
|
|
||||||
|
|
||||||
# check schedules if any contains a unique plugin prefix matching the current plugin
|
# check schedules if any contains a unique plugin prefix matching the current plugin
|
||||||
for schd in conf.mySchedules:
|
for schd in conf.mySchedules:
|
||||||
if schd.service == prefix:
|
if schd.service == prefix:
|
||||||
@@ -250,8 +248,16 @@ def execute_plugin(db, plugin):
|
|||||||
|
|
||||||
# Execute command
|
# Execute command
|
||||||
mylog('verbose', ['[Plugins] Executing: ', q])
|
mylog('verbose', ['[Plugins] Executing: ', q])
|
||||||
|
|
||||||
|
# ------- necessary settings check --------
|
||||||
|
set = get_plugin_setting(plugin, "DB_PATH")
|
||||||
|
|
||||||
|
# handle missing "function":"DB_PATH" setting
|
||||||
|
if set == None:
|
||||||
|
mylog('none', ['[Plugins] Error: DB_PATH setting for plugin type sqlite-db-query missing.'])
|
||||||
|
return
|
||||||
|
|
||||||
fullSqlitePath = plugin['data_source_settings']['db_path']
|
fullSqlitePath = set["value"]
|
||||||
|
|
||||||
# try attaching the sqlite DB
|
# try attaching the sqlite DB
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user