mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
🔄Sync: Generate token/key buttons #838
This commit is contained in:
@@ -67,6 +67,35 @@ function initDeviceSelectors(devicesListAll_JSON) {
|
|||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Utility function to generate a random API token in the format t_<random string of specified length>
|
||||||
|
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_<random string of length>
|
||||||
|
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
|
// Updates the icon preview
|
||||||
|
|||||||
@@ -284,6 +284,7 @@
|
|||||||
"Gen_Description": "",
|
"Gen_Description": "",
|
||||||
"Gen_Error": "",
|
"Gen_Error": "",
|
||||||
"Gen_Filter": "",
|
"Gen_Filter": "",
|
||||||
|
"Gen_Generate": "",
|
||||||
"Gen_LockedDB": "",
|
"Gen_LockedDB": "",
|
||||||
"Gen_Offline": "",
|
"Gen_Offline": "",
|
||||||
"Gen_Okay": "",
|
"Gen_Okay": "",
|
||||||
|
|||||||
@@ -284,6 +284,7 @@
|
|||||||
"Gen_Description": "",
|
"Gen_Description": "",
|
||||||
"Gen_Error": "",
|
"Gen_Error": "",
|
||||||
"Gen_Filter": "",
|
"Gen_Filter": "",
|
||||||
|
"Gen_Generate": "",
|
||||||
"Gen_LockedDB": "",
|
"Gen_LockedDB": "",
|
||||||
"Gen_Offline": "",
|
"Gen_Offline": "",
|
||||||
"Gen_Okay": "",
|
"Gen_Okay": "",
|
||||||
|
|||||||
@@ -296,6 +296,7 @@
|
|||||||
"Gen_Description": "Beschreibung",
|
"Gen_Description": "Beschreibung",
|
||||||
"Gen_Error": "Fehler",
|
"Gen_Error": "Fehler",
|
||||||
"Gen_Filter": "Filter",
|
"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_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_Offline": "Offline",
|
||||||
"Gen_Okay": "Ok",
|
"Gen_Okay": "Ok",
|
||||||
|
|||||||
@@ -284,6 +284,7 @@
|
|||||||
"Gen_Description": "Description",
|
"Gen_Description": "Description",
|
||||||
"Gen_Error": "Error",
|
"Gen_Error": "Error",
|
||||||
"Gen_Filter": "Filter",
|
"Gen_Filter": "Filter",
|
||||||
|
"Gen_Generate": "Generate",
|
||||||
"Gen_LockedDB": "ERROR - DB might be locked - Check F12 Dev tools -> Console or try later.",
|
"Gen_LockedDB": "ERROR - DB might be locked - Check F12 Dev tools -> Console or try later.",
|
||||||
"Gen_Offline": "Offline",
|
"Gen_Offline": "Offline",
|
||||||
"Gen_Okay": "Ok",
|
"Gen_Okay": "Ok",
|
||||||
|
|||||||
@@ -294,6 +294,7 @@
|
|||||||
"Gen_Description": "Descripción",
|
"Gen_Description": "Descripción",
|
||||||
"Gen_Error": "Error",
|
"Gen_Error": "Error",
|
||||||
"Gen_Filter": "Filtro",
|
"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_LockedDB": "Fallo - La base de datos puede estar bloqueada - Pulsa F1 -> Ajustes de desarrolladores -> Consola o prueba más tarde.",
|
||||||
"Gen_Offline": "Desconectado",
|
"Gen_Offline": "Desconectado",
|
||||||
"Gen_Okay": "Aceptar",
|
"Gen_Okay": "Aceptar",
|
||||||
|
|||||||
@@ -284,6 +284,7 @@
|
|||||||
"Gen_Description": "Description",
|
"Gen_Description": "Description",
|
||||||
"Gen_Error": "Erreur",
|
"Gen_Error": "Erreur",
|
||||||
"Gen_Filter": "Filtrer",
|
"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_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_Offline": "Hors ligne",
|
||||||
"Gen_Okay": "OK",
|
"Gen_Okay": "OK",
|
||||||
|
|||||||
@@ -284,6 +284,7 @@
|
|||||||
"Gen_Description": "Descrizione",
|
"Gen_Description": "Descrizione",
|
||||||
"Gen_Error": "Errore",
|
"Gen_Error": "Errore",
|
||||||
"Gen_Filter": "Filtro",
|
"Gen_Filter": "Filtro",
|
||||||
|
"Gen_Generate": "",
|
||||||
"Gen_LockedDB": "ERRORE: il DB potrebbe essere bloccato, controlla F12 Strumenti di sviluppo -> Console o riprova più tardi.",
|
"Gen_LockedDB": "ERRORE: il DB potrebbe essere bloccato, controlla F12 Strumenti di sviluppo -> Console o riprova più tardi.",
|
||||||
"Gen_Offline": "Offline",
|
"Gen_Offline": "Offline",
|
||||||
"Gen_Okay": "Ok",
|
"Gen_Okay": "Ok",
|
||||||
|
|||||||
@@ -284,6 +284,7 @@
|
|||||||
"Gen_Description": "",
|
"Gen_Description": "",
|
||||||
"Gen_Error": "Feil",
|
"Gen_Error": "Feil",
|
||||||
"Gen_Filter": "Filter",
|
"Gen_Filter": "Filter",
|
||||||
|
"Gen_Generate": "",
|
||||||
"Gen_LockedDB": "FEIL - DB kan være låst - Sjekk F12 Dev tools -> Konsoll eller prøv senere.",
|
"Gen_LockedDB": "FEIL - DB kan være låst - Sjekk F12 Dev tools -> Konsoll eller prøv senere.",
|
||||||
"Gen_Offline": "Frakoblet",
|
"Gen_Offline": "Frakoblet",
|
||||||
"Gen_Okay": "Ok",
|
"Gen_Okay": "Ok",
|
||||||
|
|||||||
@@ -284,6 +284,7 @@
|
|||||||
"Gen_Description": "",
|
"Gen_Description": "",
|
||||||
"Gen_Error": "Błąd",
|
"Gen_Error": "Błąd",
|
||||||
"Gen_Filter": "Filtr",
|
"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_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_Offline": "Wyłączone",
|
||||||
"Gen_Okay": "Ok",
|
"Gen_Okay": "Ok",
|
||||||
|
|||||||
@@ -284,6 +284,7 @@
|
|||||||
"Gen_Description": "",
|
"Gen_Description": "",
|
||||||
"Gen_Error": "Erro",
|
"Gen_Error": "Erro",
|
||||||
"Gen_Filter": "Filtro",
|
"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_LockedDB": "ERRO - O banco de dados pode estar bloqueado - Verifique F12 Ferramentas de desenvolvimento -> Console ou tente mais tarde.",
|
||||||
"Gen_Offline": "Offline",
|
"Gen_Offline": "Offline",
|
||||||
"Gen_Okay": "Ok",
|
"Gen_Okay": "Ok",
|
||||||
|
|||||||
@@ -284,6 +284,7 @@
|
|||||||
"Gen_Description": "Описание",
|
"Gen_Description": "Описание",
|
||||||
"Gen_Error": "Ошибка",
|
"Gen_Error": "Ошибка",
|
||||||
"Gen_Filter": "Фильтр",
|
"Gen_Filter": "Фильтр",
|
||||||
|
"Gen_Generate": "",
|
||||||
"Gen_LockedDB": "ОШИБКА - Возможно, база данных заблокирована. Проверьте инструменты разработчика F12 -> Консоль или повторите попытку позже.",
|
"Gen_LockedDB": "ОШИБКА - Возможно, база данных заблокирована. Проверьте инструменты разработчика F12 -> Консоль или повторите попытку позже.",
|
||||||
"Gen_Offline": "Оффлайн",
|
"Gen_Offline": "Оффлайн",
|
||||||
"Gen_Okay": "OK",
|
"Gen_Okay": "OK",
|
||||||
|
|||||||
@@ -284,6 +284,7 @@
|
|||||||
"Gen_Description": "",
|
"Gen_Description": "",
|
||||||
"Gen_Error": "Hata",
|
"Gen_Error": "Hata",
|
||||||
"Gen_Filter": "Filtre",
|
"Gen_Filter": "Filtre",
|
||||||
|
"Gen_Generate": "",
|
||||||
"Gen_LockedDB": "",
|
"Gen_LockedDB": "",
|
||||||
"Gen_Offline": "Çevrimdışı",
|
"Gen_Offline": "Çevrimdışı",
|
||||||
"Gen_Okay": "Tamam",
|
"Gen_Okay": "Tamam",
|
||||||
|
|||||||
@@ -284,6 +284,7 @@
|
|||||||
"Gen_Description": "",
|
"Gen_Description": "",
|
||||||
"Gen_Error": "错误",
|
"Gen_Error": "错误",
|
||||||
"Gen_Filter": "筛选",
|
"Gen_Filter": "筛选",
|
||||||
|
"Gen_Generate": "",
|
||||||
"Gen_LockedDB": "错误 - DB 可能被锁定 - 检查 F12 开发工具 -> 控制台或稍后重试。",
|
"Gen_LockedDB": "错误 - DB 可能被锁定 - 检查 F12 开发工具 -> 控制台或稍后重试。",
|
||||||
"Gen_Offline": "离线",
|
"Gen_Offline": "离线",
|
||||||
"Gen_Okay": "Ok",
|
"Gen_Okay": "Ok",
|
||||||
|
|||||||
@@ -115,7 +115,21 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"dataType": "string",
|
"dataType": "string",
|
||||||
"elements": [
|
"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,
|
"maxLength": 50,
|
||||||
@@ -131,7 +145,7 @@
|
|||||||
"description": [
|
"description": [
|
||||||
{
|
{
|
||||||
"language_code": "en_us",
|
"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": {
|
"type": {
|
||||||
"dataType": "string",
|
"dataType": "string",
|
||||||
"elements": [
|
"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,
|
"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."
|
"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",
|
"function": "nodes",
|
||||||
"type": {
|
"type": {
|
||||||
"dataType": "array",
|
"dataType": "array",
|
||||||
|
|||||||
Reference in New Issue
Block a user