mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
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:
committed by
Paulchen Panther
parent
0733d01e86
commit
a080c7151d
@@ -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)
|
||||
|
@@ -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();
|
||||
});
|
||||
|
Reference in New Issue
Block a user