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
This commit is contained in:
b1rdhous3 2019-08-04 16:16:39 +02:00 committed by Paulchen Panther
parent 0733d01e86
commit a080c7151d
7 changed files with 133 additions and 91 deletions

View File

@ -4,27 +4,6 @@
<h3 class="page-header"><i class="fa fa-wrench fa-fw"></i><span data-i18n="conf_general_label_title">General</span></h3>
<div class="row" id="conf_cont"></div>
<div class="row">
<div class="col-lg-6" id="tok_desc">
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-key fa-fw"></i><span data-i18n="conf_general_tok_title"></span></div>
<div class="panel-body">
<div id="tok_desc_cont"></div>
<div id="tktable"></div>
<div style="margin: 30px 0; border-top:1px solid #d0d0d0"></div>
<div class="row">
<div class="col-lg-6">
<p data-i18n="conf_general_tok_comment_title" style="font-weight:bold"></p>
</div>
<div class="col-lg-6">
<input class="form-control" id="tok_comment" type="text"></input>
</div>
</div>
<div>
<button class="btn btn-primary" id="btn_create_tok" data-i18n="conf_general_createToken_btn" disabled>Create New Token</button>
</div>
</div>
</div>
</div>
<div class="col-lg-6" id="inst_desc">
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-plus fa-fw"></i><span data-i18n="conf_general_inst_title"></span></div>

View File

@ -2,9 +2,36 @@
<div class="row">
<div class="col-lg-12">
<h3 class="page-header"><i class="fa fa-sitemap fa-fw"></i><span data-i18n="main_menu_network_conf_token">Network Services</span></h3>
<div id="conf_cont"></div>
<div id="conf_cont">
<div class="row" id="conf_cont_tok">
<div class="col-lg-6" id="tok_desc">
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-key fa-fw"></i><span data-i18n="conf_network_tok_title"></span></div>
<div class="panel-body">
<div id="tok_desc_cont"></div>
<div id="tktable"></div>
<div style="margin: 30px 0; border-top:1px solid #d0d0d0"></div>
<div class="row">
<div class="col-lg-6">
<p data-i18n="conf_network_tok_comment_title" style="font-weight:bold"></p>
</div>
<div class="col-lg-6">
<input class="form-control" id="tok_comment" type="text"></input>
</div>
<div class="col-lg-6">
<span id="tok_chars_needed"><br /></span>
</div>
</div>
</div>
<div class="panel-footer" style="text-align: right;">
<button class="btn btn-primary" id="btn_create_tok" data-i18n="conf_network_createToken_btn" disabled>Create New Token</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="/js/content_network.js"></script>
<script src="/js/content_network.js"></script>

View File

@ -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",

View File

@ -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",

View File

@ -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 = '<button id="tok'+tokenList[key].id+'" type="button" class="btn btn-danger">'+$.i18n('general_btn_delete')+'</button>';
$('.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')+'<br><div style="font-weight:bold">'+val.token+'</div>')
tokenList.push(val)
buildTokenList()
});
// Instance handling
function handleInstanceStartStop(e)

View File

@ -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 = '<button id="tok'+tokenList[key].id+'" type="button" class="btn btn-danger">'+$.i18n('general_btn_delete')+'</button>';
$('.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("<br />")
});
$(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')+'<br><div style="font-weight:bold">'+val.token+'</div>')
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();
});

View File

@ -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" :