🔄Sync hub 2.0
Some checks are pending
docker / docker_dev (push) Waiting to run

This commit is contained in:
jokob-sk
2024-09-14 10:37:30 +10:00
parent aefe470d31
commit d858f4f9d0
4 changed files with 11 additions and 10 deletions

0
front/php/templates/language/es_es.json Normal file → Executable file
View File

View File

@@ -24,14 +24,14 @@ function checkAuthorization($method) {
// ----------------------------------------------
// Function to return JSON response
function jsonResponse($status, $data = [], $message = '') {
function jsonResponse($status, $data = '', $message = '') {
http_response_code($status);
header('Content-Type: application/json');
echo json_encode([
'node_name' => getSettingValue('SYNC_node_name'),
'status' => $status,
'message' => $message,
'data' => $data,
'data_base64' => $data,
'timestamp' => date('Y-m-d H:i:s')
]);
}
@@ -50,13 +50,13 @@ if ($method === 'GET') {
$data = file_get_contents($file_path);
// Prepare the data to return as a JSON response
$response_data = [
'data_base64' => base64_encode($data),
];
$response_data = base64_encode($data);
// Return JSON response
jsonResponse(200, $response_data, 'OK');
write_notification("[Plugin: SYNC] Data sent", "info");
}
// receiving data (this is a HUB)
else if ($method === 'POST') {

View File

@@ -7,6 +7,7 @@ import hashlib
import requests
import json
import sqlite3
import base64
# Define the installation path and extend the system path for plugin imports
@@ -106,7 +107,7 @@ def main():
# pull data from nodes if specified
if len(pull_nodes) > 0:
for node_url in pull_nodes:
response_json, node_name = get_data(api_token, node_url)
response_json = get_data(api_token, node_url)
# Extract node_name and base64 data
node_name = response_json.get('node_name', 'unknown_node')
@@ -119,10 +120,10 @@ def main():
log_file_name = f'{file_prefix}.{node_name}.log'
# Write decoded data to log file
with open(file_path = os.path.join(file_dir, log_file_name), 'wb') as log_file:
with open(os.path.join(file_dir, log_file_name), 'wb') as log_file:
log_file.write(decoded_data)
message = f'[{pluginName}] Data for "{plugin_folder}" from node "{node_name}" written to {log_file_name}'
message = f'[{pluginName}] Device data from node "{node_name}" written to {log_file_name}'
mylog('verbose', [message])
write_notification(message, 'info', timeNowTZ())
@@ -269,7 +270,7 @@ def get_data(api_token, node_url):
# mylog('verbose', [f'[{pluginName}] response: "{response}"'])
if response.status_code == 200:
if response.status_code == 200:
try:
# Parse JSON response
response_json = response.json()

View File

@@ -342,7 +342,7 @@ def importConfigs (db, all_plugins):
# ccd(key, default, config_dir, name, inputtype, options, group, events=None, desc="", regex="", setJsonMetadata=None, overrideTemplate=None, forceDefault=False)
ccd('VERSION', buildTimestamp , c_d, '_KEEP_', '_KEEP_', '_KEEP_', '_KEEP_', None, "_KEEP_", "", None, None, True)
write_notification(f'[Upgrade] : App upgraded 🚀 Please clear the cache: <ol> <li>Clear the browser cache (shift + browser refresh button)</li> <li> Clear app cache with the 🔄 (reload) button in the header</li></ol> Check out new features and what has changed in the <a href="https://github.com/jokob-sk/NetAlertX/releases" target="_blank">📓 release notes</a>.', 'interrupt', timeNowTZ())
write_notification(f'[Upgrade] : App upgraded 🚀 Please clear the cache: <ol> <li>Click OK below</li> <li>Clear the browser cache (shift + browser refresh button)</li> <li> Clear app cache with the 🔄 (reload) button in the header</li><li>Go to Settings and click Save</li> </ol> Check out new features and what has changed in the <a href="https://github.com/jokob-sk/NetAlertX/releases" target="_blank">📓 release notes</a>.', 'interrupt', timeNowTZ())
# Insert settings into the DB