diff --git a/front/js/ui_components.js b/front/js/ui_components.js index 087fe2d3..81aa9245 100755 --- a/front/js/ui_components.js +++ b/front/js/ui_components.js @@ -67,6 +67,35 @@ function initDeviceSelectors(devicesListAll_JSON) { }, 10); } +// ------------------------------------------------------------------- +// Utility function to generate a random API token in the format t_ +function generateApiToken(elem, length) { + // Retrieve and parse custom parameters from the element + let params = $(elem).attr("my-customparams")?.split(',').map(param => param.trim()); + if (params && params.length >= 1) { + var targetElementID = params[0]; // Get the target element's ID + } + + let targetElement = $('#' + targetElementID); + + // Function to generate a random string of a specified length + function generateRandomString(len) { + let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + let result = ''; + for (let i = 0; i < len; i++) { + result += characters.charAt(Math.floor(Math.random() * characters.length)); + } + return result; + } + + // Generate the token in the format t_ + let randomToken = 't_' + generateRandomString(length); + + // Set the generated token as the value of the target element + if (targetElement.length) { + targetElement.val(randomToken); + } +} // ---------------------------------------------- // Updates the icon preview diff --git a/front/php/templates/language/ar_ar.json b/front/php/templates/language/ar_ar.json index 0f2261a7..cc88796d 100755 --- a/front/php/templates/language/ar_ar.json +++ b/front/php/templates/language/ar_ar.json @@ -284,6 +284,7 @@ "Gen_Description": "", "Gen_Error": "", "Gen_Filter": "", + "Gen_Generate": "", "Gen_LockedDB": "", "Gen_Offline": "", "Gen_Okay": "", diff --git a/front/php/templates/language/cs_cz.json b/front/php/templates/language/cs_cz.json index 0f2261a7..cc88796d 100755 --- a/front/php/templates/language/cs_cz.json +++ b/front/php/templates/language/cs_cz.json @@ -284,6 +284,7 @@ "Gen_Description": "", "Gen_Error": "", "Gen_Filter": "", + "Gen_Generate": "", "Gen_LockedDB": "", "Gen_Offline": "", "Gen_Okay": "", diff --git a/front/php/templates/language/de_de.json b/front/php/templates/language/de_de.json index f9248fa1..d20344ba 100755 --- a/front/php/templates/language/de_de.json +++ b/front/php/templates/language/de_de.json @@ -296,6 +296,7 @@ "Gen_Description": "Beschreibung", "Gen_Error": "Fehler", "Gen_Filter": "Filter", + "Gen_Generate": "", "Gen_LockedDB": "ERROR - DB eventuell gesperrt - Nutze die Konsole in den Entwickler Werkzeugen (F12) zur Überprüfung oder probiere es später erneut.", "Gen_Offline": "Offline", "Gen_Okay": "Ok", @@ -782,4 +783,4 @@ "settings_update_item_warning": "", "test_event_icon": "", "test_event_tooltip": "Speichere die Änderungen, bevor Sie die Einstellungen testen." -} +} \ No newline at end of file diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index cef155f1..ed4f29d7 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -284,6 +284,7 @@ "Gen_Description": "Description", "Gen_Error": "Error", "Gen_Filter": "Filter", + "Gen_Generate": "Generate", "Gen_LockedDB": "ERROR - DB might be locked - Check F12 Dev tools -> Console or try later.", "Gen_Offline": "Offline", "Gen_Okay": "Ok", diff --git a/front/php/templates/language/es_es.json b/front/php/templates/language/es_es.json index ff0edf25..af297ce4 100755 --- a/front/php/templates/language/es_es.json +++ b/front/php/templates/language/es_es.json @@ -294,6 +294,7 @@ "Gen_Description": "Descripción", "Gen_Error": "Error", "Gen_Filter": "Filtro", + "Gen_Generate": "", "Gen_LockedDB": "Fallo - La base de datos puede estar bloqueada - Pulsa F1 -> Ajustes de desarrolladores -> Consola o prueba más tarde.", "Gen_Offline": "Desconectado", "Gen_Okay": "Aceptar", @@ -780,4 +781,4 @@ "settings_update_item_warning": "Actualice el valor a continuación. Tenga cuidado de seguir el formato anterior. O la validación no se realiza.", "test_event_icon": "fa-vial-circle-check", "test_event_tooltip": "Guarda tus cambios antes de probar nuevos ajustes." -} +} \ No newline at end of file diff --git a/front/php/templates/language/fr_fr.json b/front/php/templates/language/fr_fr.json index a2d895fd..f2949f2f 100755 --- a/front/php/templates/language/fr_fr.json +++ b/front/php/templates/language/fr_fr.json @@ -284,6 +284,7 @@ "Gen_Description": "Description", "Gen_Error": "Erreur", "Gen_Filter": "Filtrer", + "Gen_Generate": "", "Gen_LockedDB": "Erreur - La base de données est peut-être verrouillée - Vérifier avec les outils de dév via F12 -> Console ou essayer plus tard.", "Gen_Offline": "Hors ligne", "Gen_Okay": "OK", @@ -701,4 +702,4 @@ "settings_update_item_warning": "Mettre à jour la valeur ci-dessous. Veillez à bien suivre le même format qu'auparavant. Il n'y a pas de pas de contrôle.", "test_event_icon": "fa-vial-circle-check", "test_event_tooltip": "Enregistrer d'abord vos modifications avant de tester vôtre paramétrage." -} +} \ No newline at end of file diff --git a/front/php/templates/language/it_it.json b/front/php/templates/language/it_it.json index 13544e64..63a834fc 100755 --- a/front/php/templates/language/it_it.json +++ b/front/php/templates/language/it_it.json @@ -284,6 +284,7 @@ "Gen_Description": "Descrizione", "Gen_Error": "Errore", "Gen_Filter": "Filtro", + "Gen_Generate": "", "Gen_LockedDB": "ERRORE: il DB potrebbe essere bloccato, controlla F12 Strumenti di sviluppo -> Console o riprova più tardi.", "Gen_Offline": "Offline", "Gen_Okay": "Ok", @@ -701,4 +702,4 @@ "settings_update_item_warning": "Aggiorna il valore qui sotto. Fai attenzione a seguire il formato precedente. La convalida non viene eseguita.", "test_event_icon": "fa-vial-circle-check", "test_event_tooltip": "Salva le modifiche prima di provare le nuove impostazioni." -} +} \ No newline at end of file diff --git a/front/php/templates/language/nb_no.json b/front/php/templates/language/nb_no.json index 7a3e240d..66256dd6 100755 --- a/front/php/templates/language/nb_no.json +++ b/front/php/templates/language/nb_no.json @@ -284,6 +284,7 @@ "Gen_Description": "", "Gen_Error": "Feil", "Gen_Filter": "Filter", + "Gen_Generate": "", "Gen_LockedDB": "FEIL - DB kan være låst - Sjekk F12 Dev tools -> Konsoll eller prøv senere.", "Gen_Offline": "Frakoblet", "Gen_Okay": "Ok", @@ -701,4 +702,4 @@ "settings_update_item_warning": "Oppdater verdien nedenfor. Pass på å følge forrige format. Validering etterpå utføres ikke.", "test_event_icon": "fa-vial-circle-check", "test_event_tooltip": "Lagre endringene først, før du tester innstillingene dine." -} +} \ No newline at end of file diff --git a/front/php/templates/language/pl_pl.json b/front/php/templates/language/pl_pl.json index beac6611..9edc9505 100755 --- a/front/php/templates/language/pl_pl.json +++ b/front/php/templates/language/pl_pl.json @@ -284,6 +284,7 @@ "Gen_Description": "", "Gen_Error": "Błąd", "Gen_Filter": "Filtr", + "Gen_Generate": "", "Gen_LockedDB": "BŁĄD - BAZA DANYCH może być zablokowana - Sprawdź F12 narzędzia dewelopera -> Konsola lub spróbuj ponownie później.", "Gen_Offline": "Wyłączone", "Gen_Okay": "Ok", @@ -701,4 +702,4 @@ "settings_update_item_warning": "Zaktualizuj poniższą wartość. Zachowaj ostrożność i postępuj zgodnie z poprzednim formatem. Walidacja nie jest wykonywana.", "test_event_icon": "fa-vial-circle-check", "test_event_tooltip": "Zapisz zmiany zanim będziesz testować swoje ustawienia." -} +} \ No newline at end of file diff --git a/front/php/templates/language/pt_br.json b/front/php/templates/language/pt_br.json index 56bb5bbd..5e4ea2b7 100755 --- a/front/php/templates/language/pt_br.json +++ b/front/php/templates/language/pt_br.json @@ -284,6 +284,7 @@ "Gen_Description": "", "Gen_Error": "Erro", "Gen_Filter": "Filtro", + "Gen_Generate": "", "Gen_LockedDB": "ERRO - O banco de dados pode estar bloqueado - Verifique F12 Ferramentas de desenvolvimento -> Console ou tente mais tarde.", "Gen_Offline": "Offline", "Gen_Okay": "Ok", diff --git a/front/php/templates/language/ru_ru.json b/front/php/templates/language/ru_ru.json index f06d1fd5..ec56b01d 100755 --- a/front/php/templates/language/ru_ru.json +++ b/front/php/templates/language/ru_ru.json @@ -284,6 +284,7 @@ "Gen_Description": "Описание", "Gen_Error": "Ошибка", "Gen_Filter": "Фильтр", + "Gen_Generate": "", "Gen_LockedDB": "ОШИБКА - Возможно, база данных заблокирована. Проверьте инструменты разработчика F12 -> Консоль или повторите попытку позже.", "Gen_Offline": "Оффлайн", "Gen_Okay": "OK", @@ -701,4 +702,4 @@ "settings_update_item_warning": "Обновить значение ниже. Будьте осторожны, следуя предыдущему формату. Проверка не выполняется.", "test_event_icon": "fa-vial-circle-check", "test_event_tooltip": "Сначала сохраните изменения, прежде чем проверять настройки." -} +} \ No newline at end of file diff --git a/front/php/templates/language/tr_tr.json b/front/php/templates/language/tr_tr.json index 4263ab7e..302254cc 100755 --- a/front/php/templates/language/tr_tr.json +++ b/front/php/templates/language/tr_tr.json @@ -284,6 +284,7 @@ "Gen_Description": "", "Gen_Error": "Hata", "Gen_Filter": "Filtre", + "Gen_Generate": "", "Gen_LockedDB": "", "Gen_Offline": "Çevrimdışı", "Gen_Okay": "Tamam", diff --git a/front/php/templates/language/zh_cn.json b/front/php/templates/language/zh_cn.json index bb342c55..9f88c4b1 100755 --- a/front/php/templates/language/zh_cn.json +++ b/front/php/templates/language/zh_cn.json @@ -284,6 +284,7 @@ "Gen_Description": "", "Gen_Error": "错误", "Gen_Filter": "筛选", + "Gen_Generate": "", "Gen_LockedDB": "错误 - DB 可能被锁定 - 检查 F12 开发工具 -> 控制台或稍后重试。", "Gen_Offline": "离线", "Gen_Okay": "Ok", @@ -701,4 +702,4 @@ "settings_update_item_warning": "更新下面的值。请注意遵循先前的格式。未执行验证。", "test_event_icon": "", "test_event_tooltip": "在测试设置之前,请先保存更改。" -} +} \ No newline at end of file diff --git a/front/plugins/sync/config.json b/front/plugins/sync/config.json index 97c1756a..ec301fc0 100755 --- a/front/plugins/sync/config.json +++ b/front/plugins/sync/config.json @@ -47,7 +47,7 @@ }, "default_value": "unused", - "options": [ + "options": [ "unused", "once", "schedule", @@ -115,7 +115,21 @@ "type": { "dataType": "string", "elements": [ - { "elementType": "input", "elementOptions": [], "transformers": [] } + { + "elementType": "input", + "elementOptions": [{ "cssClasses": "col-xs-12" }], + "transformers": [] + }, + { + "elementType": "button", + "elementOptions": [ + { "getStringKey": "Gen_Generate" }, + { "customParams": "SYNC_api_token" }, + { "onClick": "generateApiToken(this, 20)" }, + { "cssClasses": "col-xs-12" } + ], + "transformers": [] + } ] }, "maxLength": 50, @@ -131,7 +145,7 @@ "description": [ { "language_code": "en_us", - "string": "API token to secure communication. It's sent in the request header. The API token needs to be the same on the hub and on the nodes." + "string": "API token to secure communication, you can generate one or enter any value. It's sent in the request header. The API token needs to be the same on the hub and on the nodes." } ] }, @@ -140,7 +154,21 @@ "type": { "dataType": "string", "elements": [ - { "elementType": "input", "elementOptions": [], "transformers": [] } + { + "elementType": "input", + "elementOptions": [{ "cssClasses": "col-xs-12" }], + "transformers": [] + }, + { + "elementType": "button", + "elementOptions": [ + { "getStringKey": "Gen_Generate" }, + { "customParams": "SYNC_encryption_key" }, + { "onClick": "generateApiToken(this, 30)" }, + { "cssClasses": "col-xs-12" } + ], + "transformers": [] + } ] }, "maxLength": 50, @@ -159,7 +187,8 @@ "string": "Encryption key used to encrypt the data before sending and for decryption on the hub. The key needs to be the same on the hub and on the nodes." } ] - },{ + }, + { "function": "nodes", "type": { "dataType": "array",