Handle "Show Explainations scenario" correctly

This commit is contained in:
Lord-Grey 2021-05-05 13:31:31 +02:00
parent 184cfb1e72
commit 7a31ef559f
3 changed files with 170 additions and 175 deletions

View File

@ -1,196 +1,182 @@
$(document).ready( function() { $(document).ready(function () {
performTranslation(); performTranslation();
var importedConf; var importedConf;
var confName; var confName;
var conf_editor = null; var conf_editor = null;
$('#conf_cont').append(createOptPanel('fa-wrench', $.i18n("edt_conf_gen_heading_title"), 'editor_container', 'btn_submit', 'panel-system')); $('#conf_cont').append(createOptPanel('fa-wrench', $.i18n("edt_conf_gen_heading_title"), 'editor_container', 'btn_submit', 'panel-system'));
if(window.showOptHelp) if (window.showOptHelp) {
{ $('#conf_cont').append(createHelpTable(window.schema.general.properties, $.i18n("edt_conf_gen_heading_title")));
$('#conf_cont').append(createHelpTable(window.schema.general.properties, $.i18n("edt_conf_gen_heading_title"))); }
} else
else $('#conf_imp').appendTo('#conf_cont');
$('#conf_imp').appendTo('#conf_cont');
conf_editor = createJsonEditor('editor_container', { conf_editor = createJsonEditor('editor_container', {
general: window.schema.general general: window.schema.general
}, true, true); }, true, true);
conf_editor.on('change',function() { conf_editor.on('change', function () {
conf_editor.validate().length || window.readOnlyMode ? $('#btn_submit').attr('disabled', true) : $('#btn_submit').attr('disabled', false); conf_editor.validate().length || window.readOnlyMode ? $('#btn_submit').attr('disabled', true) : $('#btn_submit').attr('disabled', false);
}); });
$('#btn_submit').off().on('click',function() { $('#btn_submit').off().on('click', function () {
requestWriteConfig(conf_editor.getValue()); window.showOptHelp = conf_editor.getEditor("root.general.showOptHelp").getValue();
}); requestWriteConfig(conf_editor.getValue());
});
// Instance handling // Instance handling
function handleInstanceRename(e) function handleInstanceRename(e) {
{
conf_editor.on('change',function() { conf_editor.on('change', function () {
window.readOnlyMode ? $('#btn_cl_save').attr('disabled', true) : $('#btn_submit').attr('disabled', false); window.readOnlyMode ? $('#btn_cl_save').attr('disabled', true) : $('#btn_submit').attr('disabled', false);
window.readOnlyMode ? $('#btn_ma_save').attr('disabled', true) : $('#btn_submit').attr('disabled', false); window.readOnlyMode ? $('#btn_ma_save').attr('disabled', true) : $('#btn_submit').attr('disabled', false);
}); });
var inst = e.currentTarget.id.split("_")[1]; var inst = e.currentTarget.id.split("_")[1];
showInfoDialog('renInst', $.i18n('conf_general_inst_renreq_t'), getInstanceNameByIndex(inst)); showInfoDialog('renInst', $.i18n('conf_general_inst_renreq_t'), getInstanceNameByIndex(inst));
$("#id_btn_ok").off().on('click', function(){ $("#id_btn_ok").off().on('click', function () {
requestInstanceRename(inst, $('#renInst_name').val()) requestInstanceRename(inst, $('#renInst_name').val())
}); });
$('#renInst_name').off().on('input',function(e) { $('#renInst_name').off().on('input', function (e) {
(e.currentTarget.value.length >= 5 && e.currentTarget.value != getInstanceNameByIndex(inst)) ? $('#id_btn_ok').attr('disabled', false) : $('#id_btn_ok').attr('disabled', true); (e.currentTarget.value.length >= 5 && e.currentTarget.value != getInstanceNameByIndex(inst)) ? $('#id_btn_ok').attr('disabled', false) : $('#id_btn_ok').attr('disabled', true);
}); });
} }
function handleInstanceDelete(e) function handleInstanceDelete(e) {
{ var inst = e.currentTarget.id.split("_")[1];
var inst = e.currentTarget.id.split("_")[1]; showInfoDialog('delInst', $.i18n('conf_general_inst_delreq_h'), $.i18n('conf_general_inst_delreq_t', getInstanceNameByIndex(inst)));
showInfoDialog('delInst',$.i18n('conf_general_inst_delreq_h'),$.i18n('conf_general_inst_delreq_t',getInstanceNameByIndex(inst))); $("#id_btn_yes").off().on('click', function () {
$("#id_btn_yes").off().on('click', function(){ requestInstanceDelete(inst)
requestInstanceDelete(inst) });
}); }
}
function buildInstanceList() function buildInstanceList() {
{ var inst = serverInfo.instance
var inst = serverInfo.instance $('.itbody').html("");
$('.itbody').html(""); for (var key in inst) {
for(var key in inst) var enable_style = inst[key].running ? "checked" : "";
{ var renameBtn = '<button id="instren_' + inst[key].instance + '" type="button" class="btn btn-primary"><i class="mdi mdi-lead-pencil""></i></button>';
var enable_style = inst[key].running ? "checked" : ""; var startBtn = ""
var renameBtn = '<button id="instren_'+inst[key].instance+'" type="button" class="btn btn-primary"><i class="mdi mdi-lead-pencil""></i></button>'; var delBtn = "";
var startBtn = "" if (inst[key].instance > 0) {
var delBtn = ""; delBtn = '<button id="instdel_' + inst[key].instance + '" type="button" class="btn btn-danger"><i class="mdi mdi-delete-forever""></i></button>';
if(inst[key].instance > 0) startBtn = '<input id="inst_' + inst[key].instance + '"' + enable_style + ' type="checkbox" data-toggle="toggle" data-onstyle="success font-weight-bold" data-on="' + $.i18n('general_btn_on') + '" data-offstyle="default font-weight-bold" data-off="' + $.i18n('general_btn_off') + '">';
{
delBtn = '<button id="instdel_'+inst[key].instance+'" type="button" class="btn btn-danger"><i class="mdi mdi-delete-forever""></i></button>';
startBtn = '<input id="inst_'+inst[key].instance+'"'+enable_style+' type="checkbox" data-toggle="toggle" data-onstyle="success font-weight-bold" data-on="'+$.i18n('general_btn_on')+'" data-offstyle="default font-weight-bold" data-off="'+$.i18n('general_btn_off')+'">';
} }
$('.itbody').append(createTableRow([inst[key].friendly_name, startBtn, renameBtn, delBtn], false, true)); $('.itbody').append(createTableRow([inst[key].friendly_name, startBtn, renameBtn, delBtn], false, true));
$('#instren_'+inst[key].instance).off().on('click', handleInstanceRename); $('#instren_' + inst[key].instance).off().on('click', handleInstanceRename);
$('#inst_'+inst[key].instance).bootstrapToggle(); $('#inst_' + inst[key].instance).bootstrapToggle();
$('#inst_'+inst[key].instance).change(e => { $('#inst_' + inst[key].instance).change(e => {
requestInstanceStartStop(e.currentTarget.id.split('_').pop(), e.currentTarget.checked); requestInstanceStartStop(e.currentTarget.id.split('_').pop(), e.currentTarget.checked);
}); });
$('#instdel_'+inst[key].instance).off().on('click', handleInstanceDelete); $('#instdel_' + inst[key].instance).off().on('click', handleInstanceDelete);
window.readOnlyMode ? $('#instren_'+inst[key].instance).attr('disabled', true) : $('#btn_submit').attr('disabled', false); window.readOnlyMode ? $('#instren_' + inst[key].instance).attr('disabled', true) : $('#btn_submit').attr('disabled', false);
window.readOnlyMode ? $('#inst_'+inst[key].instance).attr('disabled', true) : $('#btn_submit').attr('disabled', false); window.readOnlyMode ? $('#inst_' + inst[key].instance).attr('disabled', true) : $('#btn_submit').attr('disabled', false);
window.readOnlyMode ? $('#instdel_'+inst[key].instance).attr('disabled', true) : $('#btn_submit').attr('disabled', false); window.readOnlyMode ? $('#instdel_' + inst[key].instance).attr('disabled', true) : $('#btn_submit').attr('disabled', false);
} }
} }
createTable('ithead', 'itbody', 'itable'); createTable('ithead', 'itbody', 'itable');
$('.ithead').html(createTableRow([$.i18n('conf_general_inst_namehead'), "", $.i18n('conf_general_inst_actionhead'), ""], true, true)); $('.ithead').html(createTableRow([$.i18n('conf_general_inst_namehead'), "", $.i18n('conf_general_inst_actionhead'), ""], true, true));
buildInstanceList(); buildInstanceList();
$('#inst_name').off().on('input',function(e) { $('#inst_name').off().on('input', function (e) {
(e.currentTarget.value.length >= 5) && !window.readOnlyMode ? $('#btn_create_inst').attr('disabled', false) : $('#btn_create_inst').attr('disabled', true); (e.currentTarget.value.length >= 5) && !window.readOnlyMode ? $('#btn_create_inst').attr('disabled', false) : $('#btn_create_inst').attr('disabled', true);
if(5-e.currentTarget.value.length >= 1 && 5-e.currentTarget.value.length <= 4) if (5 - e.currentTarget.value.length >= 1 && 5 - e.currentTarget.value.length <= 4)
$('#inst_chars_needed').html(5-e.currentTarget.value.length + " " + $.i18n('general_chars_needed')) $('#inst_chars_needed').html(5 - e.currentTarget.value.length + " " + $.i18n('general_chars_needed'))
else else
$('#inst_chars_needed').html("<br />") $('#inst_chars_needed').html("<br />")
}); });
$('#btn_create_inst').off().on('click',function(e) { $('#btn_create_inst').off().on('click', function (e) {
requestInstanceCreate($('#inst_name').val()); requestInstanceCreate($('#inst_name').val());
$('#inst_name').val(""); $('#inst_name').val("");
$('#btn_create_inst').attr('disabled', true) $('#btn_create_inst').attr('disabled', true)
}); });
$(hyperion).off("instance-updated").on("instance-updated", function(event) { $(hyperion).off("instance-updated").on("instance-updated", function (event) {
buildInstanceList() buildInstanceList()
}); });
//import //import
function dis_imp_btn(state) function dis_imp_btn(state) {
{ state || window.readOnlyMode ? $('#btn_import_conf').attr('disabled', true) : $('#btn_import_conf').attr('disabled', false);
state || window.readOnlyMode ? $('#btn_import_conf').attr('disabled', true) : $('#btn_import_conf').attr('disabled', false); }
}
function readFile(evt) function readFile(evt) {
{ var f = evt.target.files[0];
var f = evt.target.files[0];
if (f) if (f) {
{ var r = new FileReader();
var r = new FileReader(); r.onload = function (e) {
r.onload = function(e) var content = e.target.result.replace(/[^:]?\/\/.*/g, ''); //remove Comments
{
var content = e.target.result.replace(/[^:]?\/\/.*/g, ''); //remove Comments
//check file is json //check file is json
var check = isJsonString(content); var check = isJsonString(content);
if(check.length != 0) if (check.length != 0) {
{ showInfoDialog('error', "", $.i18n('infoDialog_import_jsonerror_text', f.name, JSON.stringify(check)));
showInfoDialog('error', "", $.i18n('infoDialog_import_jsonerror_text', f.name, JSON.stringify(check))); dis_imp_btn(true);
dis_imp_btn(true); }
} else {
else content = JSON.parse(content);
{ //check for hyperion json
content = JSON.parse(content); if (typeof content.leds === 'undefined' || typeof content.general === 'undefined') {
//check for hyperion json showInfoDialog('error', "", $.i18n('infoDialog_import_hyperror_text', f.name));
if(typeof content.leds === 'undefined' || typeof content.general === 'undefined') dis_imp_btn(true);
{ }
showInfoDialog('error', "", $.i18n('infoDialog_import_hyperror_text', f.name)); else {
dis_imp_btn(true); dis_imp_btn(false);
} importedConf = content;
else confName = f.name;
{ }
dis_imp_btn(false); }
importedConf = content; }
confName = f.name; r.readAsText(f);
} }
} }
}
r.readAsText(f);
}
}
$('#btn_import_conf').off().on('click', function(){ $('#btn_import_conf').off().on('click', function () {
showInfoDialog('import', $.i18n('infoDialog_import_confirm_title'), $.i18n('infoDialog_import_confirm_text', confName)); showInfoDialog('import', $.i18n('infoDialog_import_confirm_title'), $.i18n('infoDialog_import_confirm_text', confName));
$('#id_btn_import').off().on('click', function(){ $('#id_btn_import').off().on('click', function () {
requestWriteConfig(importedConf, true); requestWriteConfig(importedConf, true);
setTimeout(initRestart, 100); setTimeout(initRestart, 100);
}); });
}); });
$('#select_import_conf').off().on('change', function(e){ $('#select_import_conf').off().on('change', function (e) {
if (window.File && window.FileReader && window.FileList && window.Blob) if (window.File && window.FileReader && window.FileList && window.Blob)
readFile(e); readFile(e);
else else
showInfoDialog('error', "", $.i18n('infoDialog_import_comperror_text')); showInfoDialog('error', "", $.i18n('infoDialog_import_comperror_text'));
}); });
//export //export
$('#btn_export_conf').off().on('click', function(){ $('#btn_export_conf').off().on('click', function () {
var name = window.serverConfig.general.name; var name = window.serverConfig.general.name;
var d = new Date(); var d = new Date();
var month = d.getMonth()+1; var month = d.getMonth() + 1;
var day = d.getDate(); var day = d.getDate();
var timestamp = d.getFullYear() + '.' + var timestamp = d.getFullYear() + '.' +
(month<10 ? '0' : '') + month + '.' + (month < 10 ? '0' : '') + month + '.' +
(day<10 ? '0' : '') + day; (day < 10 ? '0' : '') + day;
download(JSON.stringify(window.serverConfig, null, "\t"), 'Hyperion-'+window.currentVersion+'-Backup ('+name+') '+timestamp+'.json', "application/json"); download(JSON.stringify(window.serverConfig, null, "\t"), 'Hyperion-' + window.currentVersion + '-Backup (' + name + ') ' + timestamp + '.json', "application/json");
}); });
//create introduction //create introduction
if(window.showOptHelp) if (window.showOptHelp) {
{ createHint("intro", $.i18n('conf_general_intro'), "editor_container");
createHint("intro", $.i18n('conf_general_intro'), "editor_container"); createHint("intro", $.i18n('conf_general_tok_desc'), "tok_desc_cont");
createHint("intro", $.i18n('conf_general_tok_desc'), "tok_desc_cont"); createHint("intro", $.i18n('conf_general_inst_desc'), "inst_desc_cont");
createHint("intro", $.i18n('conf_general_inst_desc'), "inst_desc_cont"); }
}
removeOverlay(); removeOverlay();
}); });

View File

@ -13,21 +13,21 @@ $(document).ready(function () {
// Screen-Grabber // Screen-Grabber
$('#conf_cont').append(createRow('conf_cont_screen')); $('#conf_cont').append(createRow('conf_cont_screen'));
$('#conf_cont_screen').append(createOptPanel('fa-camera', $.i18n("edt_conf_fg_heading_title"), 'editor_container_screengrabber', 'btn_submit_screengrabber', 'panel-system')); $('#conf_cont_screen').append(createOptPanel('fa-camera', $.i18n("edt_conf_fg_heading_title"), 'editor_container_screengrabber', 'btn_submit_screengrabber', 'panel-system', 'screengrabberPanelId'));
$('#conf_cont_screen').append(createHelpTable(window.schema.framegrabber.properties, $.i18n("edt_conf_fg_heading_title"))); $('#conf_cont_screen').append(createHelpTable(window.schema.framegrabber.properties, $.i18n("edt_conf_fg_heading_title"), "screengrabberHelpPanelId"));
// Video-Grabber - hide if not available // Video-Grabber - hide if not available
if (VIDEOGRABBER_AVAIL) { if (VIDEOGRABBER_AVAIL) {
$('#conf_cont').append(createRow('conf_cont_video')); $('#conf_cont').append(createRow('conf_cont_video'));
$('#conf_cont_video').append(createOptPanel('fa-camera', $.i18n("edt_conf_v4l2_heading_title"), 'editor_container_videograbber', 'btn_submit_videograbber', 'panel-system')); $('#conf_cont_video').append(createOptPanel('fa-camera', $.i18n("edt_conf_v4l2_heading_title"), 'editor_container_videograbber', 'btn_submit_videograbber', 'panel-system', 'videograbberPanelId'));
$('#conf_cont_video').append(createHelpTable(window.schema.grabberV4L2.properties, $.i18n("edt_conf_v4l2_heading_title"))); $('#conf_cont_video').append(createHelpTable(window.schema.grabberV4L2.properties, $.i18n("edt_conf_v4l2_heading_title"), "videograbberHelpPanelId"));
} }
} else { } else {
$('#conf_cont').addClass('row'); $('#conf_cont').addClass('row');
$('#conf_cont').append(createOptPanel('fa-camera', $.i18n("edt_conf_instCapture_heading_title"), 'editor_container_instCapt', 'btn_submit_instCapt', 'panel-system')); $('#conf_cont').append(createOptPanel('fa-camera', $.i18n("edt_conf_instCapture_heading_title"), 'editor_container_instCapt', 'btn_submit_instCapt', 'panel-system'));
$('#conf_cont').append(createOptPanel('fa-camera', $.i18n("edt_conf_fg_heading_title"), 'editor_container_screengrabber', 'btn_submit_screengrabber', 'panel-system')); $('#conf_cont').append(createOptPanel('fa-camera', $.i18n("edt_conf_fg_heading_title"), 'editor_container_screengrabber', 'btn_submit_screengrabber', 'panel-system', 'screengrabberPanelId'));
if (VIDEOGRABBER_AVAIL) { if (VIDEOGRABBER_AVAIL) {
$('#conf_cont').append(createOptPanel('fa-camera', $.i18n("edt_conf_v4l2_heading_title"), 'editor_container_videograbber', 'btn_submit_videograbber', 'panel-system')); $('#conf_cont').append(createOptPanel('fa-camera', $.i18n("edt_conf_v4l2_heading_title"), 'editor_container_videograbber', 'btn_submit_videograbber', 'panel-system', 'videograbberPanelId'));
} }
} }
@ -46,9 +46,13 @@ $(document).ready(function () {
var screenEnable = conf_editor_instCapt.getEditor("root.instCapture.systemEnable").getValue(); var screenEnable = conf_editor_instCapt.getEditor("root.instCapture.systemEnable").getValue();
if (screenEnable) { if (screenEnable) {
showInputOptions("instCapture", ["systemPriority"], true); showInputOptions("instCapture", ["systemPriority"], true);
$('#conf_cont_screen').show(); $('#screengrabberPanelId').show();
if (window.showOptHelp) {
$('#screengrabberHelpPanelId').show();
}
} else { } else {
$('#conf_cont_screen').hide(); $('#screengrabberPanelId').hide();
$('#screengrabberHelpPanelId').hide();
showInputOptions("instCapture", ["systemPriority"], false); showInputOptions("instCapture", ["systemPriority"], false);
} }
@ -56,11 +60,15 @@ $(document).ready(function () {
var videoEnable = conf_editor_instCapt.getEditor("root.instCapture.v4lEnable").getValue(); var videoEnable = conf_editor_instCapt.getEditor("root.instCapture.v4lEnable").getValue();
if (videoEnable) { if (videoEnable) {
showInputOptions("instCapture", ["v4lPriority"], true); showInputOptions("instCapture", ["v4lPriority"], true);
$('#conf_cont_video').show(); $('#videograbberPanelId').show();
if (window.showOptHelp) {
$('#videograbberHelpPanelId').show();
}
} }
else { else {
showInputOptions("instCapture", ["v4lPriority"], false); showInputOptions("instCapture", ["v4lPriority"], false);
$('#conf_cont_video').hide(); $('#videograbberPanelId').hide();
$('#videograbberHelpPanelId').hide();
} }
} }

View File

@ -809,14 +809,15 @@ function createRow(id) {
return el; return el;
} }
function createOptPanel(phicon, phead, bodyid, footerid, css) { function createOptPanel(phicon, phead, bodyid, footerid, css, panelId) {
phead = '<i class="fa ' + phicon + ' fa-fw"></i>' + phead; phead = '<i class="fa ' + phicon + ' fa-fw"></i>' + phead;
var pfooter = document.createElement('button'); var pfooter = document.createElement('button');
pfooter.className = "btn btn-primary"; pfooter.className = "btn btn-primary";
pfooter.setAttribute("id", footerid); pfooter.setAttribute("id", footerid);
pfooter.innerHTML = '<i class="fa fa-fw fa-save"></i>' + $.i18n('general_button_savesettings'); pfooter.innerHTML = '<i class="fa fa-fw fa-save"></i>' + $.i18n('general_button_savesettings');
return createPanel(phead, "", pfooter, "panel-default", bodyid, css); return createPanel(phead, "", pfooter, "panel-default", bodyid, css, panelId);
} }
function compareTwoValues(key1, key2, order = 'asc') { function compareTwoValues(key1, key2, order = 'asc') {