From 46e7e7bc0166473d788e25cded64273e33edd589 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Mon, 3 Jun 2024 23:06:25 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=83=20Sync=20Hub=20v0.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/js/ui_components.js | 31 ++----------------------------- front/plugins/sync/config.json | 6 +++--- front/plugins/sync/hub.php | 6 ++++++ front/plugins/sync/sync.py | 12 ++++++++---- 4 files changed, 19 insertions(+), 36 deletions(-) diff --git a/front/js/ui_components.js b/front/js/ui_components.js index c362cfa1..10292579 100755 --- a/front/js/ui_components.js +++ b/front/js/ui_components.js @@ -74,16 +74,10 @@ function initDeviceSelectors() { } }, 10); - } - - - - - // ----------------------------------------------------------------------------- // Initiate dropdown function initSettingDropdown(settingKey, // Identifier for the setting @@ -95,29 +89,10 @@ function initSettingDropdown(settingKey, // Identifier for the setting { var optionsHtml = "" - - - if(settingKey == 'SYNC_plugins' || settingKey == 'VNDRPDT_WATCH') - { - console.log('getSettingOptions(settingKey)'); - console.log(getSettingOptions(settingKey)); - - } - + // NOTE {value} options to replace with a setting or SQL value are handled in the cacheSettings() function 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 if(isSQLQuery(optionsArray[0])) { @@ -170,8 +145,6 @@ function hideUIelements(settingKey) { } - - // ----------------------------------------------------------------------------- // Data processors // ----------------------------------------------------------------------------- @@ -235,7 +208,7 @@ function genListWithInputSet(data, valuesArray, targetField, nameTransformer) { let selected = valuesArray.includes(item.id) ? 'selected' : ''; - console.log(item); + // console.log(item); labelName = item.name diff --git a/front/plugins/sync/config.json b/front/plugins/sync/config.json index 2b96df65..af2c10b1 100755 --- a/front/plugins/sync/config.json +++ b/front/plugins/sync/config.json @@ -5,7 +5,7 @@ "plugin_type": "system", "enabled": true, "data_source": "template", - "show_ui": false, + "show_ui": true, "localized": ["display_name", "description", "icon"], "display_name": [{ "language_code": "en_us", @@ -330,7 +330,7 @@ }] }, { - "function": "target_url", + "function": "hub_url", "type": "text", "display_condition": { "type" : "setting", @@ -350,7 +350,7 @@ "description": [ { "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 http://192.168.1.82:20211" } ] }, diff --git a/front/plugins/sync/hub.php b/front/plugins/sync/hub.php index 7796963f..d2f3fabc 100755 --- a/front/plugins/sync/hub.php +++ b/front/plugins/sync/hub.php @@ -1,5 +1,8 @@ diff --git a/front/plugins/sync/sync.py b/front/plugins/sync/sync.py index 9d005be6..113e8bf7 100755 --- a/front/plugins/sync/sync.py +++ b/front/plugins/sync/sync.py @@ -5,15 +5,17 @@ import pathlib import sys import hashlib 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 INSTALL_PATH = "/app" 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 CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) LOG_FILE = os.path.join(CUR_PATH, 'script.log') @@ -43,6 +45,8 @@ def main(): # Get all plugin configurations 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 for plugin in all_plugins: