🔃 Sync Hub v0.3
This commit is contained in:
@@ -74,16 +74,10 @@ function initDeviceSelectors() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Initiate dropdown
|
// Initiate dropdown
|
||||||
function initSettingDropdown(settingKey, // Identifier for the setting
|
function initSettingDropdown(settingKey, // Identifier for the setting
|
||||||
@@ -96,28 +90,9 @@ function initSettingDropdown(settingKey, // Identifier for the setting
|
|||||||
|
|
||||||
var optionsHtml = ""
|
var optionsHtml = ""
|
||||||
|
|
||||||
|
// NOTE {value} options to replace with a setting or SQL value are handled in the cacheSettings() function
|
||||||
if(settingKey == 'SYNC_plugins' || settingKey == 'VNDRPDT_WATCH')
|
|
||||||
{
|
|
||||||
console.log('getSettingOptions(settingKey)');
|
|
||||||
console.log(getSettingOptions(settingKey));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
optionsArray = createArray(getSettingOptions(settingKey))
|
optionsArray = createArray(getSettingOptions(settingKey))
|
||||||
|
|
||||||
|
|
||||||
if(settingKey == 'SYNC_plugins' || settingKey == 'VNDRPDT_WATCH')
|
|
||||||
{
|
|
||||||
console.log('settingKey');
|
|
||||||
console.log(settingKey);
|
|
||||||
console.log('valuesArray');
|
|
||||||
console.log(valuesArray);
|
|
||||||
console.log('optionsArray');
|
|
||||||
console.log(optionsArray);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if the result is a SQL query
|
// check if the result is a SQL query
|
||||||
if(isSQLQuery(optionsArray[0]))
|
if(isSQLQuery(optionsArray[0]))
|
||||||
{
|
{
|
||||||
@@ -170,8 +145,6 @@ function hideUIelements(settingKey) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Data processors
|
// Data processors
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -235,7 +208,7 @@ function genListWithInputSet(data, valuesArray, targetField, nameTransformer) {
|
|||||||
|
|
||||||
let selected = valuesArray.includes(item.id) ? 'selected' : '';
|
let selected = valuesArray.includes(item.id) ? 'selected' : '';
|
||||||
|
|
||||||
console.log(item);
|
// console.log(item);
|
||||||
|
|
||||||
labelName = item.name
|
labelName = item.name
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"plugin_type": "system",
|
"plugin_type": "system",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "template",
|
"data_source": "template",
|
||||||
"show_ui": false,
|
"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",
|
||||||
@@ -330,7 +330,7 @@
|
|||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"function": "target_url",
|
"function": "hub_url",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"display_condition": {
|
"display_condition": {
|
||||||
"type" : "setting",
|
"type" : "setting",
|
||||||
@@ -350,7 +350,7 @@
|
|||||||
"description": [
|
"description": [
|
||||||
{
|
{
|
||||||
"language_code": "en_us",
|
"language_code": "en_us",
|
||||||
"string": "Target hub URL to send the data to."
|
"string": "Target hub URL to send the data to without a trailig slash, for example <code>http://192.168.1.82:20211</code>"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
// External files
|
||||||
|
require '/app/front/php/server/init.php';
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
// Retrieve the authorization header
|
// Retrieve the authorization header
|
||||||
$headers = apache_request_headers();
|
$headers = apache_request_headers();
|
||||||
@@ -10,6 +13,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
if ($auth_header !== $expected_token) {
|
if ($auth_header !== $expected_token) {
|
||||||
http_response_code(403);
|
http_response_code(403);
|
||||||
echo 'Forbidden';
|
echo 'Forbidden';
|
||||||
|
write_notification("[Plugin: Sync hub API] Incorrect API Token", "alert");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,6 +28,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
// Create the storage directory if it doesn't exist
|
// Create the storage directory if it doesn't exist
|
||||||
if (!is_dir($storage_path)) {
|
if (!is_dir($storage_path)) {
|
||||||
echo "Could not open folder: {$storage_path}";
|
echo "Could not open folder: {$storage_path}";
|
||||||
|
write_notification("[Plugin: Sync hub API] Could not open folder: {$storage_path}", "alert");
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@@ -43,5 +48,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
} else {
|
} else {
|
||||||
http_response_code(405);
|
http_response_code(405);
|
||||||
echo 'Method Not Allowed';
|
echo 'Method Not Allowed';
|
||||||
|
write_notification("[Plugin: Sync hub API] Method Not Allowed", "alert");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -5,15 +5,17 @@ import pathlib
|
|||||||
import sys
|
import sys
|
||||||
import hashlib
|
import hashlib
|
||||||
import requests
|
import requests
|
||||||
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64
|
|
||||||
from plugin_utils import get_plugins_configs
|
|
||||||
from logger import mylog
|
|
||||||
from helper import get_setting_value
|
|
||||||
|
|
||||||
# Define the installation path and extend the system path for plugin imports
|
# Define the installation path and extend the system path for plugin imports
|
||||||
INSTALL_PATH = "/app"
|
INSTALL_PATH = "/app"
|
||||||
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
|
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
|
||||||
|
|
||||||
|
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64
|
||||||
|
from plugin_utils import get_plugins_configs
|
||||||
|
from logger import mylog
|
||||||
|
from helper import timeNowTZ, get_setting_value
|
||||||
|
|
||||||
# Define the current path and log file paths
|
# Define the current path and log file paths
|
||||||
CUR_PATH = str(pathlib.Path(__file__).parent.resolve())
|
CUR_PATH = str(pathlib.Path(__file__).parent.resolve())
|
||||||
LOG_FILE = os.path.join(CUR_PATH, 'script.log')
|
LOG_FILE = os.path.join(CUR_PATH, 'script.log')
|
||||||
@@ -43,6 +45,8 @@ def main():
|
|||||||
# Get all plugin configurations
|
# Get all plugin configurations
|
||||||
all_plugins = get_plugins_configs()
|
all_plugins = get_plugins_configs()
|
||||||
|
|
||||||
|
mylog('verbose', [f'[{pluginName}] DEBUG {len(all_plugins)}'])
|
||||||
|
mylog('verbose', [f'[{pluginName}] plugins_to_sync {plugins_to_sync}'])
|
||||||
|
|
||||||
index = 0
|
index = 0
|
||||||
for plugin in all_plugins:
|
for plugin in all_plugins:
|
||||||
|
|||||||
Reference in New Issue
Block a user