From a080c7151d3cfca5e640625672b4cea0c52291a8 Mon Sep 17 00:00:00 2001 From: b1rdhous3 Date: Sun, 4 Aug 2019 16:16:39 +0200 Subject: [PATCH] Moved Token Management to Network Setting * Moved Token Management to Network Settings * Fixed alignment of Token Settings Div if Help Tables are switched off * Added Chars counter, new format of the div panel (footer), change i18n * Added Explanation for Token Management * Moved Token Management to Network Settings * Fixed alignment of Token Settings Div if Help Tables are switched off * Added Chars counter, new format of the div panel (footer), change i18n * Added Explanation for Token Management * i18n Fix * Revert "i18n Fix" This reverts commit 0186290689d8b140310d5376617a3d43429bb632. * i18n Fix --- assets/webconfig/content/conf_general.html | 21 ------- assets/webconfig/content/conf_network.html | 31 +++++++++- assets/webconfig/i18n/de.json | 18 +++--- assets/webconfig/i18n/en.json | 18 +++--- assets/webconfig/js/content_general.js | 43 +------------ assets/webconfig/js/content_network.js | 70 +++++++++++++++++++++- libsrc/hyperion/schema/schema-network.json | 23 ++++--- 7 files changed, 133 insertions(+), 91 deletions(-) diff --git a/assets/webconfig/content/conf_general.html b/assets/webconfig/content/conf_general.html index 709fc525..786b8988 100644 --- a/assets/webconfig/content/conf_general.html +++ b/assets/webconfig/content/conf_general.html @@ -4,27 +4,6 @@
-
-
-
-
-
-
-
-
-
-

-
-
- -
-
-
- -
-
-
-
diff --git a/assets/webconfig/content/conf_network.html b/assets/webconfig/content/conf_network.html index 8e503b43..6b370360 100644 --- a/assets/webconfig/content/conf_network.html +++ b/assets/webconfig/content/conf_network.html @@ -2,9 +2,36 @@
-
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+ +
+
+
+
+
+
+ +
+
+
+
- + \ No newline at end of file diff --git a/assets/webconfig/i18n/de.json b/assets/webconfig/i18n/de.json index 9dcc82b4..70ef288e 100644 --- a/assets/webconfig/i18n/de.json +++ b/assets/webconfig/i18n/de.json @@ -103,14 +103,6 @@ "conf_general_impexp_l2": "Exportiere eine Konfiguration, indem du auf \"Exportieren\" klickst. Dein Browser startet einen Download.", "conf_general_impexp_impbtn": "Importieren", "conf_general_impexp_expbtn": "Exportieren", - "conf_general_tok_title" : "Token Management", - "conf_general_tok_desc" : "Tokens erlauben andere Anwendungen auf die Hyperion API zuzugreifen. Eine Anwendung kann ein Token anfordern welches von dir bestätigt werden muss oder du erstellst dir selbst ein neues Token. Diese Tokens werden nur benötigt, wenn \"API Autorisierung\" in den Netzwerkeinstellungen aktiviert ist.", - "conf_general_tok_cidhead" : "Beschreibung", - "conf_general_tok_lastuse" : "Zuletzt genutzt", - "conf_general_tok_comment_title" : "Token Beschreibung", - "conf_general_createToken_btn" : "Erstelle Token", - "conf_general_tok_diaTitle" : "Neues Token erstellt!", - "conf_general_tok_diaMsg" : "Hier ist dein neues Token, welches für den Zugriff auf die Hyperion API verwendet werden kann. Aus Sicherheitsgründen können Tokens nach der Erstellung nur einmalig eingesehen werden, notiere es dir daher jetzt.", "conf_helptable_option": "Option", "conf_helptable_expl": "Erklärung", "conf_effect_path_intro": "Hier kannst du Ordner angeben, die beim Laden von Effekten berücksichtig werden sollen. Zusätzlich können Effekte anhand ihres Namens deaktiviert werden um sie aus Listen zu löschen.", @@ -185,6 +177,16 @@ "conf_network_fbs_intro": "Google Flatbuffers Empfänger. Wird genutzt für schnellen Bildempfang.", "conf_network_proto_intro": "Der PROTO-Port aller Hyperion-Instanzen, wird genutzt für \"Bildstreams\" (HyperionScreenCap, Kodi Addon, Android Hyperion Grabber, ...)", "conf_network_forw_intro": "Leite alles an eine zweite Hyperion Instanz weiter, diese kann dann mit einer anderen LED Steuerung genutzt werden", + "conf_network_tok_title" : "Token Management", + "conf_network_tok_desc" : "Tokens erlauben andere Anwendungen auf die Hyperion API zuzugreifen. Eine Anwendung kann ein Token anfordern welches von dir bestätigt werden muss oder du erstellst dir selbst ein neues Token. Diese Tokens werden nur benötigt, wenn \"API Autorisierung\" in den Netzwerkeinstellungen aktiviert ist.", + "conf_network_tok_cidhead" : "Beschreibung", + "conf_network_tok_lastuse" : "Zuletzt genutzt", + "conf_network_tok_chars_needed" : "weitere Zeichen benötigt", + "conf_network_tok_comment_title" : "Token Beschreibung", + "conf_network_createToken_btn" : "Erstelle Token", + "conf_network_tok_diaTitle" : "Neues Token erstellt!", + "conf_network_tok_diaMsg" : "Hier ist dein neues Token, welches für den Zugriff auf die Hyperion API verwendet werden kann. Aus Sicherheitsgründen können Tokens nach der Erstellung nur einmalig eingesehen werden, notiere es dir daher jetzt.", + "conf_network_tok_intro" : "Hier kannst du Token zur API Authentifizierung erstellen oder löschen. Neu erstellte Token werden einmalig angezeigt.", "conf_logging_label_intro": "Überprüfe die Meldungen im Prokotoll um zu erfahren was Hyperion gerade beschäftigt. Je nach eingestellter Protokoll-Stufe siehst du mehr oder weniger Informationen.", "conf_logging_btn_pbupload": "Bericht für Supportanfrage hochladen", "conf_logging_btn_autoscroll": "Automatisch scrollen", diff --git a/assets/webconfig/i18n/en.json b/assets/webconfig/i18n/en.json index 6d9edea4..aeff1618 100644 --- a/assets/webconfig/i18n/en.json +++ b/assets/webconfig/i18n/en.json @@ -102,14 +102,6 @@ "conf_general_impexp_l2" : "Export a configuration by clicking on \"Export\". Your browser starts a download.", "conf_general_impexp_impbtn" : "Import", "conf_general_impexp_expbtn" : "Export", - "conf_general_tok_title" : "Token Management", - "conf_general_tok_desc" : "Tokens grant other applications access to the Hyperion API, an application can request a token where you need to accept it or you create them on your own below. These tokens are just required when \"API Authorization\" is enabled in network settings.", - "conf_general_tok_cidhead" : "Description", - "conf_general_tok_lastuse" : "Last use", - "conf_general_tok_comment_title" : "Token description", - "conf_general_createToken_btn" : "Create Token", - "conf_general_tok_diaTitle" : "New Token created!", - "conf_general_tok_diaMsg" : "Here is your new token which can be used to grant an application access to the Hyperion API. For security reasons you can't view it again so use/note it now.", "conf_general_inst_title" : "LED Hardware Instance Management", "conf_general_inst_desc" : "Use different LED hardware at the same time. Each instance runs independent of each other which allows different LED layouts and calibration settings. Running instances are available at the top icon bar", "conf_general_inst_namehead" : "Instance name", @@ -192,6 +184,16 @@ "conf_network_fbs_intro" : "Google Flatbuffers Receiver. Used for fast image transmission.", "conf_network_proto_intro" : "The PROTO-Port of all Hyperion instances, used for picture streams (HyperionScreenCap, Kodi Addon, Android Hyperion Grabber, ...)", "conf_network_forw_intro" : "Forward all input to a second Hyperion instance which could be driven with another led controller", + "conf_network_tok_title" : "Token Management", + "conf_network_tok_desc" : "Tokens grant other applications access to the Hyperion API, an application can request a token where you need to accept it or you create them on your own below. These tokens are just required when \"API Authorization\" is enabled in network settings.", + "conf_network_tok_cidhead" : "Description", + "conf_network_tok_lastuse" : "Last use", + "conf_network_tok_comment_title" : "Token description", + "conf_network_tok_chars_needed" : "more characters needed", + "conf_network_createToken_btn" : "Create Token", + "conf_network_tok_diaTitle" : "New Token created!", + "conf_network_tok_diaMsg" : "Here is your new token which can be used to grant an application access to the Hyperion API. For security reasons you can't view it again so use/note it now.", + "conf_network_tok_intro" : "Here you can create and delete tokens for API authentification. Created tokens will only be deisplayed once.", "conf_logging_label_intro" : "Area to check log messages, depending on loglevel setting you see more or less information.", "conf_logging_btn_pbupload" : "Upload report for support request", "conf_logging_btn_autoscroll" : "Auto scrolling", diff --git a/assets/webconfig/js/content_general.js b/assets/webconfig/js/content_general.js index 9a9b6226..f35bc0dd 100644 --- a/assets/webconfig/js/content_general.js +++ b/assets/webconfig/js/content_general.js @@ -25,48 +25,7 @@ $(document).ready( function() { requestWriteConfig(conf_editor.getValue()); }); - // Token handling - function buildTokenList() - { - $('.tktbody').html(""); - for(var key in tokenList) - { - var lastUse = (tokenList[key].last_use) ? tokenList[key].last_use : "-"; - var btn = ''; - $('.tktbody').append(createTableRow([tokenList[key].comment, lastUse, btn], false, true)); - $('#tok'+tokenList[key].id).off().on('click', handleDeleteToken); - } - } - - createTable('tkthead', 'tktbody', 'tktable'); - $('.tkthead').html(createTableRow([$.i18n('conf_general_tok_cidhead'), $.i18n('conf_general_tok_lastuse'), $.i18n('general_btn_delete')], true, true)); - buildTokenList(); - - function handleDeleteToken(e) - { - var key = e.currentTarget.id.replace("tok",""); - requestTokenDelete(key); - $('#tok'+key).parent().parent().remove(); - // rm deleted token id - tokenList = tokenList.filter(function( obj ) { - return obj.id !== key; - }); - } - - $('#btn_create_tok').off().on('click',function() { - requestToken($('#tok_comment').val()) - $('#tok_comment').val("") - $('#btn_create_tok').attr('disabled', true) - }); - $('#tok_comment').off().on('input',function(e) { - (e.currentTarget.value.length >= 10) ? $('#btn_create_tok').attr('disabled', false) : $('#btn_create_tok').attr('disabled', true); - }); - $(window.hyperion).off("cmd-authorize-createToken").on("cmd-authorize-createToken", function(event) { - var val = event.response.info; - showInfoDialog("newToken",$.i18n('conf_general_tok_diaTitle'),$.i18n('conf_general_tok_diaMsg')+'
'+val.token+'
') - tokenList.push(val) - buildTokenList() - }); + // Instance handling function handleInstanceStartStop(e) diff --git a/assets/webconfig/js/content_network.js b/assets/webconfig/js/content_network.js index 88b709c4..b7631d2c 100644 --- a/assets/webconfig/js/content_network.js +++ b/assets/webconfig/js/content_network.js @@ -51,7 +51,9 @@ $(document).ready( function() { $('#conf_cont').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_fbs_heading_title"), 'editor_container_fbserver', 'btn_submit_fbserver')); $('#conf_cont').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_pbs_heading_title"), 'editor_container_protoserver', 'btn_submit_protoserver')); $('#conf_cont').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_bobls_heading_title"), 'editor_container_boblightserver', 'btn_submit_boblightserver')); - $('#conf_cont').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_fw_heading_title"), 'editor_container_forwarder', 'btn_submit_forwarder')); + $('#conf_cont').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_fw_heading_title"), 'editor_container_forwarder', 'btn_submit_forwarder')); + + $("#conf_cont_tok").removeClass('row'); } // net @@ -144,7 +146,73 @@ $(document).ready( function() { createHint("intro", $.i18n('conf_network_proto_intro'), "editor_container_protoserver"); createHint("intro", $.i18n('conf_network_bobl_intro'), "editor_container_boblightserver"); createHint("intro", $.i18n('conf_network_forw_intro'), "editor_container_forwarder"); + createHint("intro", $.i18n('conf_network_tok_intro'), "tok_desc_cont"); } + // Token handling + function buildTokenList() + { + $('.tktbody').html(""); + for(var key in tokenList) + { + var lastUse = (tokenList[key].last_use) ? tokenList[key].last_use : "-"; + var btn = ''; + $('.tktbody').append(createTableRow([tokenList[key].comment, lastUse, btn], false, true)); + $('#tok'+tokenList[key].id).off().on('click', handleDeleteToken); + } + } + + createTable('tkthead', 'tktbody', 'tktable'); + $('.tkthead').html(createTableRow([$.i18n('conf_network_tok_cidhead'), $.i18n('conf_network_tok_lastuse'), $.i18n('general_btn_delete')], true, true)); + buildTokenList(); + + function handleDeleteToken(e) + { + var key = e.currentTarget.id.replace("tok",""); + requestTokenDelete(key); + $('#tok'+key).parent().parent().remove(); + // rm deleted token id + tokenList = tokenList.filter(function( obj ) { + return obj.id !== key; + }); + } + + $('#btn_create_tok').off().on('click',function() { + requestToken($('#tok_comment').val()) + $('#tok_comment').val("") + $('#btn_create_tok').attr('disabled', true) + }); + $('#tok_comment').off().on('input',function(e) { + (e.currentTarget.value.length >= 10) ? $('#btn_create_tok').attr('disabled', false) : $('#btn_create_tok').attr('disabled', true); + if(10-e.currentTarget.value.length >= 1 && 10-e.currentTarget.value.length <= 9) + $('#tok_chars_needed').html(10-e.currentTarget.value.length + " " + $.i18n('conf_network_tok_chars_needed')) + else + $('#tok_chars_needed').html("
") + }); + $(window.hyperion).off("cmd-authorize-createToken").on("cmd-authorize-createToken", function(event) { + var val = event.response.info; + showInfoDialog("newToken",$.i18n('conf_network_tok_diaTitle'),$.i18n('conf_network_tok_diaMsg')+'
'+val.token+'
') + tokenList.push(val) + buildTokenList() + }); + + //Reorder hardcoded token div after the general token setting div + $("#conf_cont_tok").insertAfter("#conf_cont_net"); + + function checkApiTokenState(state) + { + if(state == false) + $("#conf_cont_tok").attr('style', 'display:none') + else + $("#conf_cont_tok").removeAttr('style') + } + + $('#root_network_apiAuth').change(function () { + var state = $(this).is(":checked"); + checkApiTokenState(state); + }) + + checkApiTokenState(window.serverConfig.network.apiAuth); + removeOverlay(); }); diff --git a/libsrc/hyperion/schema/schema-network.json b/libsrc/hyperion/schema/schema-network.json index 9fba6d38..cbf2e58d 100644 --- a/libsrc/hyperion/schema/schema-network.json +++ b/libsrc/hyperion/schema/schema-network.json @@ -4,13 +4,26 @@ "required" : true, "properties" : { + "apiAuth" : + { + "type" : "boolean", + "title" : "edt_conf_net_apiAuth_title", + "required" : true, + "default" : true, + "propertyOrder" : 1 + }, "internetAccessAPI" : { "type" : "boolean", "title" : "edt_conf_net_internetAccessAPI_title", "required" : true, "default" : false, - "propertyOrder" : 1 + "options": { + "dependencies": { + "apiAuth": true + } + }, + "propertyOrder" : 2 }, "ipWhitelist" : { @@ -26,14 +39,6 @@ "internetAccessAPI": false } }, - "propertyOrder" : 2 - }, - "apiAuth" : - { - "type" : "boolean", - "title" : "edt_conf_net_apiAuth_title", - "required" : true, - "default" : true, "propertyOrder" : 3 }, "localApiAuth" :