Flows + settings metadata work
This commit is contained in:
@@ -11,10 +11,10 @@ services:
|
||||
network_mode: host
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
# - ${APP_DATA_LOCATION}/pialert_dev/config:/home/pi/pialert/config
|
||||
- ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config
|
||||
# - ${APP_DATA_LOCATION}/pialert_dev/db:/home/pi/pialert/db
|
||||
- ${APP_DATA_LOCATION}/pialert/db:/home/pi/pialert/db
|
||||
- ${APP_DATA_LOCATION}/pialert_dev/config:/home/pi/pialert/config
|
||||
# - ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config
|
||||
- ${APP_DATA_LOCATION}/pialert_dev/db:/home/pi/pialert/db
|
||||
# - ${APP_DATA_LOCATION}/pialert/db:/home/pi/pialert/db
|
||||
# (optional) useful for debugging if you have issues setting up the container
|
||||
- ${LOGS_LOCATION}:/home/pi/pialert/front/log
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@@ -37,6 +37,11 @@ function handleVersion(){
|
||||
{
|
||||
release_timestamp = getCookie("release_timestamp")
|
||||
|
||||
release_timestampNum = Number(release_timestamp)
|
||||
|
||||
// logging
|
||||
console.log(`Latest release in cookie: ${new Date(release_timestampNum*1000)}`)
|
||||
|
||||
// no cached value available
|
||||
if(release_timestamp == "")
|
||||
{
|
||||
@@ -44,10 +49,12 @@ function handleVersion(){
|
||||
// Handle successful response
|
||||
var releases = response;
|
||||
|
||||
console.log(response)
|
||||
|
||||
if(releases.length > 0)
|
||||
{
|
||||
|
||||
release_datetime = releases[0].published_at;
|
||||
release_datetime = releases[0].published_at; // get latest release
|
||||
release_timestamp = new Date(release_datetime).getTime() / 1000;
|
||||
|
||||
// cache value
|
||||
|
||||
@@ -287,6 +287,11 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
$input = $input.'<div><button class="btn btn-primary" onclick="removeFromList'.$set['Code_Name'].'()">Remove last</button></div>';
|
||||
|
||||
}
|
||||
// json
|
||||
elseif ($set['Type'] == 'json')
|
||||
{
|
||||
$input = '<input class="form-control input" my-data-type="'.$set['Type'].'" id="'.$set['Code_Name'].'" value="'.$set['Value'].'" readonly/>';
|
||||
}
|
||||
|
||||
$html = $html.$input;
|
||||
|
||||
@@ -428,7 +433,6 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
foreach ($settings as $set) {
|
||||
if(in_array($set['Type'] , $noConversion))
|
||||
{
|
||||
|
||||
echo 'settingsArray.push(["'.$set["Group"].'", "'.$set["Code_Name"].'", "'.$set["Type"].'", $("#'.$set["Code_Name"].'").val() ]);';
|
||||
}
|
||||
elseif ($set['Type'] == "boolean")
|
||||
@@ -469,6 +473,10 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
";
|
||||
echo 'settingsArray.push(["'.$set["Group"].'", "'.$set["Code_Name"].'", "'.$set["Type"].'", temps ]);';
|
||||
}
|
||||
elseif ($set['Type'] == "json")
|
||||
{
|
||||
// todo
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
61
pialert/flows/unmark_new.json
Normal file
61
pialert/flows/unmark_new.json
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"name":"unmark_new",
|
||||
"triggers": [
|
||||
{
|
||||
"type": "new",
|
||||
"object":
|
||||
{
|
||||
"type": "db.row",
|
||||
"target": "Devices"
|
||||
}
|
||||
}
|
||||
],
|
||||
"steps": [
|
||||
{
|
||||
"step_type":"wait",
|
||||
"params": [
|
||||
{
|
||||
"days": 3,
|
||||
"hours": 0,
|
||||
"minutes": 0,
|
||||
"seconds": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step_type":"condition",
|
||||
"params": [
|
||||
{
|
||||
"left": {
|
||||
"value": "triggers[0].object['dev_NewDevice']",
|
||||
"use_quotes": true,
|
||||
"js_template": "'{value}'.toString()"
|
||||
},
|
||||
"operator": {
|
||||
"value" : "==",
|
||||
"data_type": "boolean"
|
||||
},
|
||||
"right": {
|
||||
"value": true,
|
||||
"use_quotes": false,
|
||||
"js_template": "'{value}'.toString()"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step_type":"action",
|
||||
"params": [
|
||||
{
|
||||
"type": "plugin",
|
||||
"params":
|
||||
{
|
||||
"name": "UNMRK_NEW",
|
||||
"CMD": "db.row"
|
||||
}
|
||||
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -5,6 +5,7 @@ from pytz import timezone
|
||||
from cron_converter import Cron
|
||||
from pathlib import Path
|
||||
import datetime
|
||||
import json
|
||||
|
||||
import conf
|
||||
from const import fullConfPath
|
||||
@@ -23,7 +24,7 @@ from plugin import get_plugins_configs, print_plugin_info
|
||||
#-------------------------------------------------------------------------------
|
||||
# Import user values
|
||||
# Check config dictionary
|
||||
def ccd(key, default, config_dir, name, inputtype, options, group, events=[], desc = "", regex = ""):
|
||||
def ccd(key, default, config_dir, name, inputtype, options, group, events=[], desc = "", regex = "", setJsonMetadata = {}):
|
||||
result = default
|
||||
|
||||
# use existing value if already supplied, otherwise default value is used
|
||||
@@ -33,8 +34,16 @@ def ccd(key, default, config_dir, name, inputtype, options, group, events=[], de
|
||||
if inputtype == 'text':
|
||||
result = result.replace('\'', "{s-quote}")
|
||||
|
||||
# # store setting metadata as a JSON
|
||||
# ccd(f'{key}__metadata', set, c_d, "", "json" , "", pref)
|
||||
# if inputtype == 'json':
|
||||
# result = json.dumps(result)
|
||||
|
||||
conf.mySettingsSQLsafe.append((key, name, desc, inputtype, options, regex, str(result), group, str(events)))
|
||||
conf.mySettingsSQLsafe.append((f'{key}__metadata', "metadata name", "metadata desc", 'json', "", "", json.dumps(setJsonMetadata), group, ""))
|
||||
|
||||
conf.mySettings.append((key, name, desc, inputtype, options, regex, result, group, str(events)))
|
||||
conf.mySettings.append((f'{key}__metadata', "metadata name", "metadata desc", 'json', "", "", json.dumps(setJsonMetadata), group, ""))
|
||||
|
||||
return result
|
||||
#-------------------------------------------------------------------------------
|
||||
@@ -199,7 +208,7 @@ def importConfigs (db):
|
||||
# Setting code name / key
|
||||
key = pref + "_" + setFunction
|
||||
|
||||
v = ccd(key, set["default_value"], c_d, set["name"][0]["string"], set["type"] , str(set["options"]), pref)
|
||||
v = ccd(key, set["default_value"], c_d, set["name"][0]["string"], set["type"] , str(set["options"]), pref, set)
|
||||
|
||||
# Save the user defined value into the object
|
||||
set["value"] = v
|
||||
|
||||
Reference in New Issue
Block a user