mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
- The first part
- Added CodeDocs config file for customization - Fixing LGTM alerts - LGTM bug fixed again - added token option to hyperion-remote - fix DBManager::getDB() - next bugfix - correct broken signal from SettingManager to Hyperion - Token list is created after the schema is fetched Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
@@ -25,6 +25,50 @@ $(document).ready( function() {
|
||||
requestWriteConfig(conf_editor.getValue());
|
||||
});
|
||||
|
||||
// Token handling
|
||||
function buildTokenList()
|
||||
{
|
||||
console.log(tokenList)
|
||||
$('.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()
|
||||
});
|
||||
|
||||
//import
|
||||
function dis_imp_btn(state)
|
||||
{
|
||||
@@ -104,6 +148,7 @@ $(document).ready( function() {
|
||||
//create introduction
|
||||
if(window.showOptHelp)
|
||||
createHint("intro", $.i18n('conf_general_intro'), "editor_container");
|
||||
createHint("intro", $.i18n('conf_general_tok_desc'), "tok_desc_cont");
|
||||
|
||||
removeOverlay();
|
||||
});
|
||||
|
@@ -34,6 +34,11 @@ $(document).ready( function() {
|
||||
updateSessions();
|
||||
});
|
||||
|
||||
$(window.hyperion).one("cmd-authorize-getTokenList", function(event) {
|
||||
tokenList = event.response.info;
|
||||
requestServerInfo();
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-sysinfo", function(event) {
|
||||
requestServerInfo();
|
||||
window.sysInfo = event.response.info;
|
||||
@@ -45,6 +50,7 @@ $(document).ready( function() {
|
||||
$(window.hyperion).one("cmd-config-getschema", function(event) {
|
||||
window.serverSchema = event.response.info;
|
||||
requestServerConfig();
|
||||
requestTokenInfo();
|
||||
|
||||
window.schema = window.serverSchema.properties;
|
||||
});
|
||||
@@ -62,12 +68,16 @@ $(document).ready( function() {
|
||||
}
|
||||
});
|
||||
|
||||
$(window.hyperion).one("cmd-authorize-login", function(event) {
|
||||
requestServerConfigSchema();
|
||||
});
|
||||
|
||||
$(window.hyperion).on("error",function(event){
|
||||
showInfoDialog("error","Error", event.reason);
|
||||
});
|
||||
|
||||
$(window.hyperion).on("open",function(event){
|
||||
requestServerConfigSchema();
|
||||
requestAuthorization();
|
||||
});
|
||||
|
||||
$(window.hyperion).one("ready", function(event) {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
$(document).ready( function() {
|
||||
performTranslation();
|
||||
|
||||
var conf_editor_net = null;
|
||||
var conf_editor_json = null;
|
||||
var conf_editor_proto = null;
|
||||
var conf_editor_fbs = null;
|
||||
@@ -10,6 +11,11 @@ $(document).ready( function() {
|
||||
|
||||
if(window.showOptHelp)
|
||||
{
|
||||
//network
|
||||
$('#conf_cont').append(createRow('conf_cont_net'))
|
||||
$('#conf_cont_net').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_net_heading_title"), 'editor_container_net', 'btn_submit_net'));
|
||||
$('#conf_cont_net').append(createHelpTable(window.schema.network.properties, $.i18n("edt_conf_net_heading_title")));
|
||||
|
||||
//jsonserver
|
||||
$('#conf_cont').append(createRow('conf_cont_json'))
|
||||
$('#conf_cont_json').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_js_heading_title"), 'editor_container_jsonserver', 'btn_submit_jsonserver'));
|
||||
@@ -46,6 +52,7 @@ $(document).ready( function() {
|
||||
else
|
||||
{
|
||||
$('#conf_cont').addClass('row');
|
||||
$('#conf_cont').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_net_heading_title"), 'editor_container_net', 'btn_submit_net'));
|
||||
$('#conf_cont').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_js_heading_title"), 'editor_container_jsonserver', 'btn_submit_jsonserver'));
|
||||
$('#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'));
|
||||
@@ -54,7 +61,20 @@ $(document).ready( function() {
|
||||
if(storedAccess != 'default')
|
||||
$('#conf_cont').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_fw_heading_title"), 'editor_container_forwarder', 'btn_submit_forwarder'));
|
||||
}
|
||||
|
||||
|
||||
// net
|
||||
conf_editor_net = createJsonEditor('editor_container_net', {
|
||||
network : window.schema.network
|
||||
}, true, true);
|
||||
|
||||
conf_editor_net.on('change',function() {
|
||||
conf_editor_net.validate().length ? $('#btn_submit_net').attr('disabled', true) : $('#btn_submit_net').attr('disabled', false);
|
||||
});
|
||||
|
||||
$('#btn_submit_net').off().on('click',function() {
|
||||
requestWriteConfig(conf_editor_net.getValue());
|
||||
});
|
||||
|
||||
//json
|
||||
conf_editor_json = createJsonEditor('editor_container_jsonserver', {
|
||||
jsonServer : window.schema.jsonServer
|
||||
@@ -139,6 +159,7 @@ $(document).ready( function() {
|
||||
//create introduction
|
||||
if(window.showOptHelp)
|
||||
{
|
||||
createHint("intro", $.i18n('conf_network_net_intro'), "editor_container_net");
|
||||
createHint("intro", $.i18n('conf_network_json_intro'), "editor_container_jsonserver");
|
||||
createHint("intro", $.i18n('conf_network_fbs_intro'), "editor_container_fbserver");
|
||||
createHint("intro", $.i18n('conf_network_proto_intro'), "editor_container_protoserver");
|
||||
|
@@ -26,6 +26,7 @@ window.watchdog = 0;
|
||||
window.debugMessagesActive = true;
|
||||
window.wSess = [];
|
||||
window.comps = [];
|
||||
tokenList = {};
|
||||
|
||||
function initRestart()
|
||||
{
|
||||
@@ -162,7 +163,31 @@ function sendToHyperion(command, subcommand, msg)
|
||||
// -----------------------------------------------------------
|
||||
// wrapped server commands
|
||||
|
||||
// also used for watchdog
|
||||
function requestAuthorization()
|
||||
{
|
||||
sendToHyperion("authorize","login",'"username": "Hyperion", "password": "hyperion"');
|
||||
}
|
||||
|
||||
function requestToken(comment)
|
||||
{
|
||||
sendToHyperion("authorize","createToken",'"comment": "'+comment+'"');
|
||||
}
|
||||
|
||||
function requestTokenInfo()
|
||||
{
|
||||
sendToHyperion("authorize","getTokenList","");
|
||||
}
|
||||
|
||||
function requestHandleTokenRequest(id, state)
|
||||
{
|
||||
sendToHyperion("authorize","answerRequest",'"id":"'+id+'", "accept":'+state);
|
||||
}
|
||||
|
||||
function requestTokenDelete(id)
|
||||
{
|
||||
sendToHyperion("authorize","deleteToken",'"id":"'+id+'"');
|
||||
}
|
||||
|
||||
function requestServerInfo()
|
||||
{
|
||||
sendToHyperion("serverinfo","",'"subscribe":["components-update","sessions-update","priorities-update", "imageToLedMapping-update", "adjustment-update", "videomode-update", "effects-update", "settings-update"]');
|
||||
|
@@ -125,6 +125,7 @@ $(document).ready( function() {
|
||||
for (var i = 0; i<window.wSess.length; i++)
|
||||
{
|
||||
if(lsys != window.wSess[i].host+':'+window.wSess[i].port)
|
||||
{
|
||||
var hyperionAddress
|
||||
|
||||
if (window.wSess[i].address.indexOf(':') > -1 && window.wSess[i].address.length == 36)
|
||||
@@ -133,6 +134,7 @@ $(document).ready( function() {
|
||||
hyperionAddress = 'http://'+window.wSess[i].address+':'+window.wSess[i].port
|
||||
|
||||
$('#id_select').append(createSelOpt(hyperionAddress, window.wSess[i].host))
|
||||
}
|
||||
}
|
||||
|
||||
$('#id_btn_saveset').off().on('click',function() {
|
||||
|
@@ -198,6 +198,17 @@ function showInfoDialog(type,header,message)
|
||||
$('#id_body').append(message);
|
||||
$('#id_footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
||||
}
|
||||
else if (type == "newToken")
|
||||
{
|
||||
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
||||
$('#id_footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
||||
}
|
||||
else if (type == "grantToken")
|
||||
{
|
||||
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
||||
$('#id_footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal" id="tok_grant_acc">'+$.i18n('general_btn_grantAccess')+'</button>');
|
||||
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal" id="tok_deny_acc">'+$.i18n('general_btn_denyAccess')+'</button>');
|
||||
}
|
||||
|
||||
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+header+'</h4>');
|
||||
$('#id_body').append(message);
|
||||
|
Reference in New Issue
Block a user