UI System Log - Fixes and enhancements (#1223)

This commit is contained in:
LordGrey 2021-04-25 17:22:59 +02:00 committed by GitHub
parent 724d90bfdb
commit 71e34a6a55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 351 additions and 393 deletions

View File

@ -32,38 +32,8 @@
lang = lang.toString().replace(/,/g, ", ");
// Github Issue bugreport infos
var sys = window.sysInfo.system;
var shy = window.sysInfo.hyperion;
var info = "<pre>Hyperion Server: \n";
info += '- Build: ' + shy.build + '\n';
info += '- Build time: ' + shy.time + '\n';
info += '- Git Remote: ' + shy.gitremote + '\n';
info += '- Version: ' + shy.version + '\n';
info += '- UI Lang: ' + storedLang + ' (BrowserLang: ' + navigator.language + ')\n';
info += '- UI Access: ' + storedAccess + '\n';
//info += '- Log lvl: ' + window.serverConfig.logger.level + '\n';
info += '- Avail Capt: ' + window.serverInfo.grabbers.available + '\n';
info += '- Database: ' + (shy.readOnlyMode ? "ready-only" : "read/write") + '\n';
info += '\n';
info += 'Hyperion Server OS: \n';
info += '- Distribution: ' + sys.prettyName + '\n';
info += '- Architecture: ' + sys.architecture + '\n';
if (sys.cpuModelName)
info += '- CPU Model: ' + sys.cpuModelName + '\n';
if (sys.cpuModelType)
info += '- CPU Type: ' + sys.cpuModelType + '\n';
if (sys.cpuRevision)
info += '- CPU Revision: ' + sys.cpuRevision + '\n';
if (sys.cpuHardware)
info += '- CPU Hardware: ' + sys.cpuHardware + '\n';
info += '- Kernel: ' + sys.kernelType + ' (' + sys.kernelVersion + ' (WS: ' + sys.wordSize + '))\n';
info += '- Qt Version: ' + sys.qtVersion + '\n';
info += '- Python Version: ' + sys.pyVersion + '\n';
info += '- Browser: ' + navigator.userAgent + ' </pre>';
var sysInfo = getSystemInfo();
var info = '<pre>' + sysInfo + '</pre>';
var fc = ['<span id="danger_trig">' + $.i18n("about_version") + '<span>', $.i18n("about_build"), $.i18n("about_builddate"), $.i18n("about_translations"), $.i18n("about_resources", $.i18n("general_webui_title")), "System info (Github Issue)", $.i18n("about_3rd_party_licenses")];
var sc = [currentVersion, si.build, si.time, '(' + availLang.length + ')<p>' + lang + '</p><p><a href="https://github.com/hyperion-project/hyperion.ng" target="_blank">' + $.i18n("about_contribute") + '</a></p>', libh, info, '<pre><div id="3rdpartylicenses" style="overflow:scroll;max-height:400px"></div></pre>'];

View File

@ -4,18 +4,19 @@
<h3 class="page-header"><i class="fa fa-reorder fa-fw"></i><span data-i18n="main_menu_logging_token">Log</span></h3>
<div id="log_head"></div>
<div class="row" id='conf_cont'></div>
<hr />
</div>
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-book fa-fw"></i><span data-i18n="conf_logging_logoutput"></span></div>
<div class="panel-body">
<div id="log_content"><span style="font-weight:bold;font-size:17px" data-i18n="conf_logging_nomessage"></span></div>
<hr>
<div style="display:none">
<h4 style="font-weight:bold"><i class="fa fa-reorder fa-fw"></i><span data-i18n="conf_logging_report">Bericht</span></h4>
<button class="btn btn-primary" id="btn_logupload"><i class="fa fa-upload fa-fw"></i><span data-i18n="conf_logging_btn_pbupload"></span></button>
<div id="log_upl_pol"></div>
<div id="upl_link" style="margin-top:10px;font-weight:bold;"></div>
<div id="prev_reports"></div>
</div>
<div class="panel-footer" id="log_footer">
</div>
</div>
</div>
</div>
</div>
<script src="/js/content_logging.js"></script>

View File

@ -125,6 +125,7 @@
"conf_logging_label_intro": "Area to check log messages, you will see more or less information depending on the logging level set.",
"conf_logging_lastreports": "Previous reports",
"conf_logging_nomessage": "No log messages available.",
"conf_logging_logoutput": "Log output",
"conf_logging_report": "Report",
"conf_logging_uplfailed": "Upload failed! Please check your internet connection!",
"conf_logging_uploading": "Prepare data...",

View File

@ -24,8 +24,6 @@ $(document).ready(function () {
$(window.hyperion).on("cmd-serverinfo", function (event) {
window.serverInfo = event.response.info;
window.readOnlyMode = window.sysInfo.hyperion.readOnlyMode;
// comps
window.comps = event.response.info.components
@ -123,6 +121,7 @@ $(document).ready(function () {
window.currentVersion = window.sysInfo.hyperion.version;
window.currentChannel = window.sysInfo.hyperion.channel;
window.readOnlyMode = window.sysInfo.hyperion.readOnlyMode;
});
$(window.hyperion).one("cmd-config-getschema", function (event) {
@ -340,7 +339,6 @@ $("#btn_darkmode").off().on("click", function (e) {
setStorage("darkModeOverwrite", true, true);
location.reload();
}
});
// Menuitem toggle;

View File

@ -1,184 +1,125 @@
var conf_editor = null;
var createdCont = false;
var isScroll = true;
performTranslation();
requestLoggingStop();
requestLoggingStart();
$(document).ready(function() {
var messages;
var loguplmess = "";
var reportUrl = 'https://report.hyperion-project.org/#';
$(document).ready(function () {
$('#conf_cont').append(createOptPanel('fa-reorder', $.i18n("edt_conf_log_heading_title"), 'editor_container', 'btn_submit'));
if(window.showOptHelp)
{
if (window.showOptHelp) {
$('#conf_cont').append(createHelpTable(window.schema.logger.properties, $.i18n("edt_conf_log_heading_title")));
createHintH("intro", $.i18n('conf_logging_label_intro'), "log_head");
}
$("#log_upl_pol").append('<span style="color:grey;font-size:80%">'+$.i18n("conf_logging_uplpolicy")+' '+buildWL("user/support#report_privacy_policy",$.i18n("conf_logging_contpolicy")));
conf_editor = createJsonEditor('editor_container', {
logger : window.schema.logger
logger: window.schema.logger
}, 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);
});
$('#btn_submit').off().on('click',function() {
requestWriteConfig(conf_editor.getValue());
$('#btn_submit').off().on('click', function () {
var displayedLogLevel = conf_editor.getEditor("root.logger.level").getValue();
var newLogLevel = {logger:{}};
newLogLevel.logger.level = displayedLogLevel;
requestWriteConfig(newLogLevel);
});
$('#btn_logupload').off().on('click',function() {
uploadLog();
$(this).attr("disabled", true);
$('#upl_link').html($.i18n('conf_logging_uploading'))
});
function infoSummary() {
var info = "";
//show prev uploads
var ent;
info += 'Hyperion System Summary Report (' + window.serverConfig.general.name + '), Reported instance: ' + window.currentHyperionInstanceName + '\n';
if(getStorage("prev_reports"))
{
ent = JSON.parse(getStorage("prev_reports"));
$('#prev_reports').append('<h4 style="margin-top:30px">'+$.i18n('conf_logging_lastreports')+'</h4>');
for(var i = 0; i<ent.length; i++)
{
$('#prev_reports').append('<p><a href="'+reportUrl+ent[i].id+'" target="_blank">'+ent[i].title+'('+ent[i].time+')</a></p>');
}
}
else
ent = [];
info += "\n< ----- System information -------------------- >\n";
info += getSystemInfo() + '\n';
function updateLastReports(id,time,title)
{
if(ent.length > 4)
ent.pop();
ent.unshift({"id": id ,"time": time,"title": title})
setStorage("prev_reports",JSON.stringify(ent));
info += "\n< ----- Configured Instances ------------------ >\n";
var instances = window.serverInfo.instance;
for (var i = 0; i < instances.length; i++) {
info += instances[i].instance + ': ' + instances[i].friendly_name + ' Running: ' + instances[i].running + '\n';
}
function uploadLog()
{
var log = "";
var config = JSON.stringify(window.serverConfig, null).replace(/"/g, '\\"');
info += "\n< ----- This instance's priorities ------------ >\n";
var prios = window.serverInfo.priorities;
var comps = window.serverInfo.components;
var sys = window.sysInfo.system;
var shy = window.sysInfo.hyperion;
var info;
//create log
log = (messages ? loguplmess : "Log was empty!");
//create general info
info = "### GENERAL ### \n";
info += 'Build: '+shy.build+'\n';
info += 'Build time: '+shy.time+'\n';
info += 'Version: '+shy.version+'\n';
info += 'UI Lang: '+storedLang+' (BrowserL: '+navigator.language+')\n';
info += 'UI Access: '+storedAccess+'\n';
info += 'Log lvl: '+window.serverConfig.logger.level+'\n';
info += 'Avail Capt: '+window.serverInfo.grabbers.available+'\n';
info += 'Database: '+(shy.readOnlyMode ? "ready-only" : "read/write")+'\n';
info += '\n';
info += 'Distribution: '+sys.prettyName+'\n';
info += 'Architecture: '+sys.architecture+'\n';
if (sys.cpuModelName)
info += 'CPU Model: ' + sys.cpuModelName + '\n';
if (sys.cpuModelType)
info += 'CPU Type: ' + sys.cpuModelType + '\n';
if (sys.cpuRevision)
info += 'CPU Revision: ' + sys.cpuRevision + '\n';
if (sys.cpuHardware)
info += 'CPU Hardware: ' + sys.cpuHardware + '\n';
info += 'Kernel: ' + sys.kernelType+' ('+sys.kernelVersion+' (WS: '+sys.wordSize+'))' + '\n';
info += 'Qt Version: ' + sys.qtVersion + '\n';
info += 'Python Version: ' + sys.pyVersion + '\n';
info += 'Browser/OS: ' + navigator.userAgent + '\n\n';
//create prios
info += "### PRIORITIES ### \n";
for(var i = 0; i<prios.length; i++)
{
info += prios[i].priority;
if(prios[i].visible)
for (var i = 0; i < prios.length; i++) {
info += prios[i].priority + ': ';
if (prios[i].visible) {
info += ' VISIBLE!';
else
}
else {
info += ' ';
info += ' ('+prios[i].component+') Owner: '+prios[i].owner+'\n';
}
info += '\npriorities_autoselect: '+window.serverInfo.priorities_autoselect+'\n\n';
info += ' (' + prios[i].componentId + ') Owner: ' + prios[i].owner + '\n';
}
info += 'priorities_autoselect: ' + window.serverInfo.priorities_autoselect + '\n';
//create comps
info += '### COMPONENTS ### \n';
for(var i = 0; i<comps.length; i++)
{
info += comps[i].enabled+' - '+comps[i].name+'\n';
info += "\n< ----- This instance components' status ------->\n";
var comps = window.serverInfo.components;
for (var i = 0; i < comps.length; i++) {
info += comps[i].name + ' - ' + comps[i].enabled + '\n';
}
//escape data
info = JSON.stringify(info);
log = JSON.stringify(log);
config = JSON.stringify(config);
var title = 'Hyperion '+window.currentVersion+' Report ('+window.serverConfig.general.name+' ('+window.serverInfo.ledDevices.active+'))';
info += "\n< ----- This instance's configuration --------- >\n";
info += JSON.stringify(window.serverConfig) + '\n';
$.ajax({
url: 'https://api.hyperion-project.org/report.php',
crossDomain: true,
contentType: 'application/json',
type: 'POST',
timeout: 7000,
data: '{"title":"'+title+'","info":'+info+',"log":'+log+',"config":'+config+'}'
})
.done( function( data, textStatus, jqXHR ) {
reportUrl += data.id;
if(textStatus == "success")
{
$('#upl_link').html($.i18n('conf_logging_yourlink')+': <a href="'+reportUrl+'" target="_blank">'+reportUrl+'</a>');
$("html, body").animate({ scrollTop: 9999 }, "fast");
updateLastReports(data.id,data.time,title);
info += "\n< ----- Current Log --------------------------- >\n";
var logMsgs = document.getElementById("logmessages").textContent;
if (logMsgs.length !== 0) {
info += logMsgs;
} else {
info += "Log is empty!";
}
else
{
$('#btn_logupload').attr("disabled", false);
$('#upl_link').html('<span style="color:red">'+$.i18n('conf_logging_uplfailed')+'<span>');
return info;
}
})
.fail( function( jqXHR, textStatus ) {
console.log(jqXHR,textStatus);
$('#btn_logupload').attr("disabled", false);
$('#upl_link').html('<span style="color:red">'+$.i18n('conf_logging_uplfailed')+'<span>');
function createLogContainer() {
const isScrollEnableStyle = (isScroll ? "checked" : "");
$('#log_content').html('<pre><div id="logmessages" style="overflow:scroll;max-height:400px"></div></pre>');
$('#log_footer').append('<label class="checkbox-inline">'
+ '<input id = "btn_scroll"' + isScrollEnableStyle + ' type = "checkbox"'
+ 'data-toggle="toggle" data-onstyle="success" data-on="' + $.i18n('general_btn_on') + '" data-off="' + $.i18n('general_btn_off') + '">'
+ $.i18n('conf_logging_btn_autoscroll') + '</label>'
);
$(`#btn_scroll`).bootstrapToggle();
$(`#btn_scroll`).change(e => {
if (e.currentTarget.checked) {
//Scroll to end of log
isScroll = true;
if ($("#logmessages").length > 0) {
$('#logmessages')[0].scrollTop = $('#logmessages')[0].scrollHeight;
}
} else {
isScroll = false;
}
});
$('#log_footer').append('<button class="btn btn-primary pull-right" id="btn_clipboard"><i class="fa fa-fw fa-clipboard"></i>Copy Log to Clipboard</button>');
$('#btn_clipboard').off().on('click', function () {
const temp = document.createElement('textarea');
temp.textContent = infoSummary();
document.body.append(temp);
temp.select();
document.execCommand("copy");
temp.remove();
});
}
if (!window.loggingHandlerInstalled)
{
window.loggingHandlerInstalled = true;
$(window.hyperion).on("cmd-logging-update",function(event){
function updateLogOutput(messages) {
if ($("#logmessages").length == 0 && window.loggingStreamActive)
{
requestLoggingStop();
window.loggingStreamActive = false;
}
if (messages.length != 0) {
messages = (event.response.result.messages);
if(messages.length != 0 && !createdCont)
{
$('#log_content').html('<pre><div id="logmessages" style="overflow:scroll;max-height:400px"></div></pre><button class="btn btn-primary" id="btn_autoscroll"><i class="fa fa-long-arrow-down fa-fw"></i>'+$.i18n('conf_logging_btn_autoscroll')+'</button>');
createdCont = true;
$('#btn_autoscroll').off().on('click',function() {
toggleClass('#btn_autoscroll', "btn-success", "btn-danger");
});
}
for(var idx = 0; idx < messages.length; idx++)
{
for (var idx = 0; idx < messages.length; idx++) {
var app_name = messages[idx].appName;
var logger_name = messages[idx].loggerName;
var function_ = messages[idx].function;
@ -189,24 +130,63 @@ $(document).ready(function() {
var utime = messages[idx].utime;
var debug = "";
if(level_string == "DEBUG") {
debug = "("+file_name+":"+line+":"+function_+"()) ";
if (level_string == "DEBUG") {
debug = "(" + file_name + ":" + line + ":" + function_ + "()) ";
}
var date = new Date(parseInt(utime));
var newLogLine = date.toISOString() + " [" + app_name + " " + logger_name + "] (" + level_string + ") " + debug + msg;
$("#logmessages").append("\n <code>"+date.toISOString()+" ["+app_name+" "+logger_name+"] ("+level_string+") "+debug+msg+"</code>");
loguplmess += "["+app_name+" "+logger_name+"] ("+level_string+") "+debug+msg+"\n";
$("#logmessages").append("<code>" + newLogLine + "</code>\n");
}
if($("#btn_autoscroll").hasClass('btn-success'))
{
if (isScroll && $("#logmessages").length > 0) {
$('#logmessages').stop().animate({
scrollTop: $('#logmessages')[0].scrollHeight
}, 800);
}
}
}
if (!window.loggingHandlerInstalled) {
window.loggingHandlerInstalled = true;
$(window.hyperion).on("cmd-logging-update", function (event) {
messages = (event.response.result.messages);
if (messages.length != 0) {
if (!createdCont) {
createLogContainer();
createdCont = true;
}
var currentlogLevel = window.serverConfig.logger.level;
updateLogOutput(messages)
}
});
}
$(window.hyperion).on("cmd-settings-update", function (event) {
var obj = event.response.data
if (obj.logger) {
Object.getOwnPropertyNames(obj).forEach(function (val, idx, array) {
window.serverConfig[val] = obj[val];
});
var currentlogLevel = window.serverConfig.logger.level;
var displayedLogLevel = conf_editor.getEditor("root.logger.level").getValue();
//if ( currentlogLevel !== displayedLogLevel )
{
conf_editor.getEditor("root.logger.level").setValue(currentlogLevel);
location.reload();
}
}
});
removeOverlay();
});

View File

@ -1,13 +1,13 @@
$(document).ready(function() {
$(document).ready(function () {
performTranslation();
var oldEffects = [];
var cpcolor = '#B500FF';
var mappingList = window.serverSchema.properties.color.properties.imageToLedMappingType.enum;
var duration = 0;
var rgb = {r:255,g:0,b:0};
var rgb = { r: 255, g: 0, b: 0 };
var lastImgData = "";
var lastFileName= "";
var lastFileName = "";
//create html
createTable('ssthead', 'sstbody', 'sstcont');
@ -16,8 +16,7 @@ $(document).ready(function() {
//create introduction
if(window.showOptHelp)
{
if (window.showOptHelp) {
createHint("intro", $.i18n('remote_color_intro', $.i18n('remote_losthint')), "color_intro");
createHint("intro", $.i18n('remote_input_intro', $.i18n('remote_losthint')), "sstcont");
createHint("intro", $.i18n('remote_adjustment_intro', $.i18n('remote_losthint')), "adjust_content");
@ -30,72 +29,62 @@ $(document).ready(function() {
var sColor = sortProperties(window.serverSchema.properties.color.properties.channelAdjustment.items.properties);
var values = window.serverInfo.adjustment[0];
for(var key in sColor)
{
if(sColor[key].key != "id" && sColor[key].key != "leds")
{
var title = '<label for="cr_'+sColor[key].key+'">'+$.i18n(sColor[key].title)+'</label>';
for (var key in sColor) {
if (sColor[key].key != "id" && sColor[key].key != "leds") {
var title = '<label for="cr_' + sColor[key].key + '">' + $.i18n(sColor[key].title) + '</label>';
var property;
var value = values[sColor[key].key];
if(sColor[key].type == "array")
{
property = '<div id="cr_'+sColor[key].key+'" class="input-group colorpicker-component" ><input type="text" class="form-control" /><span class="input-group-addon"><i></i></span></div>';
if (sColor[key].type == "array") {
property = '<div id="cr_' + sColor[key].key + '" class="input-group colorpicker-component" ><input type="text" class="form-control" /><span class="input-group-addon"><i></i></span></div>';
$('.crtbody').append(createTableRow([title, property], false, true));
createCP('cr_'+sColor[key].key, value, function(rgb,hex,e){
requestAdjustment(e.target.id.substr(e.target.id.indexOf("_") + 1), '['+rgb.r+','+rgb.g+','+rgb.b+']');
createCP('cr_' + sColor[key].key, value, function (rgb, hex, e) {
requestAdjustment(e.target.id.substr(e.target.id.indexOf("_") + 1), '[' + rgb.r + ',' + rgb.g + ',' + rgb.b + ']');
});
}
else if(sColor[key].type == "boolean")
{
property = '<div class="checkbox"><input id="cr_'+sColor[key].key+'" type="checkbox" value="'+value+'"/><label></label></div>';
else if (sColor[key].type == "boolean") {
property = '<div class="checkbox"><input id="cr_' + sColor[key].key + '" type="checkbox" value="' + value + '"/><label></label></div>';
$('.crtbody').append(createTableRow([title, property], false, true));
$('#cr_'+sColor[key].key).off().on('change', function(e){
$('#cr_' + sColor[key].key).off().on('change', function (e) {
requestAdjustment(e.target.id.substr(e.target.id.indexOf("_") + 1), e.currentTarget.checked);
});
}
else {
if (sColor[key].key == "brightness" || sColor[key].key == "brightnessCompensation" || sColor[key].key == "backlightThreshold")
property = '<div class="input-group"><input id="cr_' + sColor[key].key + '" type="number" class="form-control" min="0" max="100" step="10" value="' + value + '"/><span class="input-group-addon">' + $.i18n("edt_append_percent") + '</span></div>';
else
{
if(sColor[key].key == "brightness" || sColor[key].key == "brightnessCompensation" || sColor[key].key == "backlightThreshold")
property = '<div class="input-group"><input id="cr_'+sColor[key].key+'" type="number" class="form-control" min="0" max="100" step="10" value="'+value+'"/><span class="input-group-addon">'+$.i18n("edt_append_percent")+'</span></div>';
else
property = '<input id="cr_'+sColor[key].key+'" type="number" class="form-control" min="0.1" max="4.0" step="0.1" value="'+value+'"/>';
property = '<input id="cr_' + sColor[key].key + '" type="number" class="form-control" min="0.1" max="4.0" step="0.1" value="' + value + '"/>';
$('.crtbody').append(createTableRow([title, property], false, true));
$('#cr_'+sColor[key].key).off().on('change', function(e){
valValue(this.id,this.value,this.min,this.max);
$('#cr_' + sColor[key].key).off().on('change', function (e) {
valValue(this.id, this.value, this.min, this.max);
requestAdjustment(e.target.id.substr(e.target.id.indexOf("_") + 1), e.currentTarget.value);
});
}
}
}
function sendEffect()
{
function sendEffect() {
var efx = $("#effect_select").val();
if(efx != "__none__")
{
if (efx != "__none__") {
requestPriorityClear();
$(window.hyperion).one("cmd-clear", function(event) {
setTimeout(function() {requestPlayEffect(efx,duration)}, 100);
$(window.hyperion).one("cmd-clear", function (event) {
setTimeout(function () { requestPlayEffect(efx, duration) }, 100);
});
}
}
function sendColor()
{
requestSetColor(rgb.r, rgb.g, rgb.b,duration);
function sendColor() {
requestSetColor(rgb.r, rgb.g, rgb.b, duration);
}
function updateInputSelect()
{
function updateInputSelect() {
$('.sstbody').html("");
var prios = window.serverInfo.priorities;
var clearAll = false;
for(var i = 0; i < prios.length; i++)
{
for (var i = 0; i < prios.length; i++) {
var origin = prios[i].origin ? prios[i].origin : "System";
origin = origin.split("@");
var ip = origin[1];
@ -106,7 +95,7 @@ $(document).ready(function() {
var visible = prios[i].visible;
var priority = prios[i].priority;
var compId = prios[i].componentId;
var duration = prios[i].duration_ms/1000;
var duration = prios[i].duration_ms / 1000;
var value = "0,0,0";
var btn_type = "default";
var btn_text = $.i18n('remote_input_setsource_btn');
@ -115,40 +104,38 @@ $(document).ready(function() {
if (active)
btn_type = "primary";
if(priority > 254)
if (priority > 254)
continue;
if(priority < 254 && (compId == "EFFECT" || compId == "COLOR" || compId == "IMAGE") )
if (priority < 254 && (compId == "EFFECT" || compId == "COLOR" || compId == "IMAGE"))
clearAll = true;
if (visible)
{
if (visible) {
btn_state = "disabled";
btn_type = "success";
btn_text = $.i18n('remote_input_sourceactiv_btn');
}
if(ip)
origin += '<br/><span style="font-size:80%; color:grey;">'+$.i18n('remote_input_ip')+' '+ip+'</span>';
if (ip)
origin += '<br/><span style="font-size:80%; color:grey;">' + $.i18n('remote_input_ip') + ' ' + ip + '</span>';
if("value" in prios[i])
if ("value" in prios[i])
value = prios[i].value.RGB;
switch (compId)
{
switch (compId) {
case "EFFECT":
owner = $.i18n('remote_effects_label_effects')+' '+owner;
owner = $.i18n('remote_effects_label_effects') + ' ' + owner;
break;
case "COLOR":
owner = $.i18n('remote_color_label_color')+' '+'<div style="width:18px; height:18px; border-radius:20px; margin-bottom:-4px; border:1px grey solid; background-color: rgb('+value+'); display:inline-block" title="RGB: ('+value+')"></div>';
owner = $.i18n('remote_color_label_color') + ' ' + '<div style="width:18px; height:18px; border-radius:20px; margin-bottom:-4px; border:1px grey solid; background-color: rgb(' + value + '); display:inline-block" title="RGB: (' + value + ')"></div>';
break;
case "IMAGE":
owner = $.i18n('remote_effects_label_picture')+' '+owner;
owner = $.i18n('remote_effects_label_picture') + ' ' + owner;
break;
case "GRABBER":
owner = $.i18n('general_comp_GRABBER')+': ('+owner+')';
owner = $.i18n('general_comp_GRABBER') + ': (' + owner + ')';
break;
case "V4L":
owner = $.i18n('general_comp_V4L')+': ('+owner+')';
owner = $.i18n('general_comp_V4L') + ': (' + owner + ')';
break;
case "BOBLIGHTSERVER":
owner = $.i18n('general_comp_BOBLIGHTSERVER');
@ -161,126 +148,112 @@ $(document).ready(function() {
break;
}
if(duration && compId != "GRABBER" && compId != "FLATBUFSERVER" && compId != "PROTOSERVER")
owner += '<br/><span style="font-size:80%; color:grey;">'+$.i18n('remote_input_duration')+' '+duration.toFixed(0)+$.i18n('edt_append_s')+'</span>';
if (duration && compId != "GRABBER" && compId != "FLATBUFSERVER" && compId != "PROTOSERVER")
owner += '<br/><span style="font-size:80%; color:grey;">' + $.i18n('remote_input_duration') + ' ' + duration.toFixed(0) + $.i18n('edt_append_s') + '</span>';
var btn = '<button id="srcBtn'+i+'" type="button" '+btn_state+' class="btn btn-'+btn_type+' btn_input_selection" onclick="requestSetSource('+priority+');">'+btn_text+'</button>';
var btn = '<button id="srcBtn' + i + '" type="button" ' + btn_state + ' class="btn btn-' + btn_type + ' btn_input_selection" onclick="requestSetSource(' + priority + ');">' + btn_text + '</button>';
if((compId == "EFFECT" || compId == "COLOR" || compId == "IMAGE") && priority < 254)
btn += '<button type="button" class="btn btn-sm btn-danger" style="margin-left:10px;" onclick="requestPriorityClear('+priority+');"><i class="fa fa-close"></button>';
if ((compId == "EFFECT" || compId == "COLOR" || compId == "IMAGE") && priority < 254)
btn += '<button type="button" class="btn btn-sm btn-danger" style="margin-left:10px;" onclick="requestPriorityClear(' + priority + ');"><i class="fa fa-close"></button>';
if(btn_type != 'default')
if (btn_type != 'default')
$('.sstbody').append(createTableRow([origin, owner, priority, btn], false, true));
}
var btn_auto_color = (window.serverInfo.priorities_autoselect? "btn-success" : "btn-danger");
var btn_auto_state = (window.serverInfo.priorities_autoselect? "disabled" : "enabled");
var btn_auto_text = (window.serverInfo.priorities_autoselect? $.i18n('general_btn_on') : $.i18n('general_btn_off'));
var btn_call_state = (clearAll? "enabled" : "disabled");
$('#auto_btn').html('<button id="srcBtn'+i+'" type="button" '+btn_auto_state+' class="btn '+btn_auto_color+'" style="margin-right:5px;display:inline-block;" onclick="requestSetSource(\'auto\');">'+$.i18n('remote_input_label_autoselect')+' ('+btn_auto_text+')</button>');
$('#auto_btn').append('<button type="button" '+btn_call_state+' class="btn btn-danger" style="display:inline-block;" onclick="requestClearAll();">'+$.i18n('remote_input_clearall')+'</button>');
var btn_auto_color = (window.serverInfo.priorities_autoselect ? "btn-success" : "btn-danger");
var btn_auto_state = (window.serverInfo.priorities_autoselect ? "disabled" : "enabled");
var btn_auto_text = (window.serverInfo.priorities_autoselect ? $.i18n('general_btn_on') : $.i18n('general_btn_off'));
var btn_call_state = (clearAll ? "enabled" : "disabled");
$('#auto_btn').html('<button id="srcBtn' + i + '" type="button" ' + btn_auto_state + ' class="btn ' + btn_auto_color + '" style="margin-right:5px;display:inline-block;" onclick="requestSetSource(\'auto\');">' + $.i18n('remote_input_label_autoselect') + ' (' + btn_auto_text + ')</button>');
$('#auto_btn').append('<button type="button" ' + btn_call_state + ' class="btn btn-danger" style="display:inline-block;" onclick="requestClearAll();">' + $.i18n('remote_input_clearall') + '</button>');
var max_width=100;
$('.btn_input_selection').each(function() {
var max_width = 100;
$('.btn_input_selection').each(function () {
if ($(this).innerWidth() > max_width)
max_width = $(this).innerWidth();
});
$('.btn_input_selection').css("min-width",max_width+"px");
$('.btn_input_selection').css("min-width", max_width + "px");
}
function updateLedMapping()
{
function updateLedMapping() {
var mapping = window.serverInfo.imageToLedMappingType;
$('#mappingsbutton').html("");
for(var ix = 0; ix < mappingList.length; ix++)
{
if(mapping == mappingList[ix])
for (var ix = 0; ix < mappingList.length; ix++) {
if (mapping == mappingList[ix])
var btn_style = 'btn-success';
else
var btn_style = 'btn-primary';
$('#mappingsbutton').append('<button type="button" id="lmBtn_'+mappingList[ix]+'" class="btn '+btn_style+'" style="margin:3px;min-width:200px" onclick="requestMappingType(\''+mappingList[ix]+'\');">'+$.i18n('remote_maptype_label_'+mappingList[ix])+'</button><br/>');
$('#mappingsbutton').append('<button type="button" id="lmBtn_' + mappingList[ix] + '" class="btn ' + btn_style + '" style="margin:3px;min-width:200px" onclick="requestMappingType(\'' + mappingList[ix] + '\');">' + $.i18n('remote_maptype_label_' + mappingList[ix]) + '</button><br/>');
}
}
function initComponents()
{
function initComponents() {
var components = window.comps;
var hyperionEnabled = true;
components.forEach( function(obj) {
if (obj.name == "ALL")
{
components.forEach(function (obj) {
if (obj.name == "ALL") {
hyperionEnabled = obj.enabled;
}
});
for (const comp of components)
{
if(comp.name === "ALL")
for (const comp of components) {
if (comp.name === "ALL")
continue;
const enable_style = (comp.enabled? "checked" : "");
const comp_btn_id = "comp_btn_"+comp.name;
const enable_style = (comp.enabled ? "checked" : "");
const comp_btn_id = "comp_btn_" + comp.name;
if ($("#"+comp_btn_id).length === 0)
{
var d='<span style="display:block;margin:3px">'
+'<input id="'+comp_btn_id+'"'+enable_style+' type="checkbox"'
+'data-toggle="toggle" data-onstyle="success" data-on="'+$.i18n('general_btn_on')+'" data-off="'+$.i18n('general_btn_off')+'">'
+'&nbsp;&nbsp;&nbsp;<label>'+$.i18n('general_comp_'+comp.name)+'</label>'
+'</span>';
if ($("#" + comp_btn_id).length === 0) {
var d = '<span style="display:block;margin:3px">'
+ '<label class="checkbox-inline">'
+ '<input id = "' + comp_btn_id + '"' + enable_style + ' type = "checkbox"'
+ 'data-toggle="toggle" data-onstyle="success" data-on="' + $.i18n('general_btn_on') + '" data-off="' + $.i18n('general_btn_off') + '">'
+ $.i18n('general_comp_' + comp.name) + '</label > '
+ '</span>';
$('#componentsbutton').append(d);
$(`#${comp_btn_id}`).bootstrapToggle();
$(`#${comp_btn_id}`).bootstrapToggle((hyperionEnabled ? "enable" : "disable"));
$(`#${comp_btn_id}`).change(e => {
requestSetComponentState(e.currentTarget.id.split('_').pop(), e.currentTarget.checked);
//console.log(e.currentTarget.checked)
});
}
}
}
function updateComponent( component )
{
if (component.name == "ALL")
{
function updateComponent(component) {
if (component.name == "ALL") {
var components = window.comps;
var hyperionEnabled = component.enabled;
for (const comp of components)
{
for (const comp of components) {
if(comp.name === "ALL")
if (comp.name === "ALL")
continue;
const comp_btn_id = "comp_btn_"+comp.name;
const comp_btn_id = "comp_btn_" + comp.name;
if ( !hyperionEnabled )
{
if (!hyperionEnabled) {
$(`#${comp_btn_id}`).bootstrapToggle('off');
$(`#${comp_btn_id}`).bootstrapToggle("disable");
}
else
{
else {
$(`#${comp_btn_id}`).bootstrapToggle("enable");
if ( comp.enabled !== $(`#${comp_btn_id}`).prop("checked") )
{
if (comp.enabled !== $(`#${comp_btn_id}`).prop("checked")) {
$(`#${comp_btn_id}`).bootstrapToggle().prop('checked', comp.enabled).change();
}
}
}
}
else
{
const comp_btn_id = "comp_btn_"+component.name;
else {
const comp_btn_id = "comp_btn_" + component.name;
//console.log ("updateComponent: ", component.name, "Current Checked: ", $(`#${comp_btn_id}`).prop("checked"), "New Checked: ", component.enabled, );
// In case Buttons were disabled before, status may be different to component status
if ( component.enabled != $(`#${comp_btn_id}`).prop("checked") )
{
if (component.enabled != $(`#${comp_btn_id}`).prop("checked")) {
// console.log ("Update status to Checked = ", component.enabled);
if ( component.enabled )
if (component.enabled)
$(`#${comp_btn_id}`).bootstrapToggle("on");
else
$(`#${comp_btn_id}`).bootstrapToggle("off");
@ -288,21 +261,19 @@ $(document).ready(function() {
}
}
function updateEffectlist()
{
function updateEffectlist() {
var newEffects = window.serverInfo.effects;
if (newEffects.length != oldEffects.length)
{
if (newEffects.length != oldEffects.length) {
$('#effect_select').html('<option value="__none__"></option>');
var usrEffArr = [];
var sysEffArr = [];
for(var i = 0; i < newEffects.length; i++) {
for (var i = 0; i < newEffects.length; i++) {
var effectName = newEffects[i].name;
if(!/^\:/.test(newEffects[i].file)){
if (!/^\:/.test(newEffects[i].file)) {
usrEffArr.push(effectName);
}
else{
else {
sysEffArr.push(effectName);
}
}
@ -312,74 +283,70 @@ $(document).ready(function() {
}
}
function updateVideoMode()
{
var videoModes = ["2D","3DSBS","3DTAB"];
function updateVideoMode() {
var videoModes = ["2D", "3DSBS", "3DTAB"];
var currVideoMode = window.serverInfo.videomode;
$('#videomodebtns').html("");
for(var ix = 0; ix < videoModes.length; ix++)
{
if(currVideoMode == videoModes[ix])
for (var ix = 0; ix < videoModes.length; ix++) {
if (currVideoMode == videoModes[ix])
var btn_style = 'btn-success';
else
var btn_style = 'btn-primary';
$('#videomodebtns').append('<button type="button" id="vModeBtn_'+videoModes[ix]+'" class="btn '+btn_style+'" style="margin:3px;min-width:200px" onclick="requestVideoMode(\''+videoModes[ix]+'\');">'+$.i18n('remote_videoMode_'+videoModes[ix])+'</button><br/>');
$('#videomodebtns').append('<button type="button" id="vModeBtn_' + videoModes[ix] + '" class="btn ' + btn_style + '" style="margin:3px;min-width:200px" onclick="requestVideoMode(\'' + videoModes[ix] + '\');">' + $.i18n('remote_videoMode_' + videoModes[ix]) + '</button><br/>');
}
}
// colorpicker and effect
if (getStorage('rmcpcolor') != null)
{
if (getStorage('rmcpcolor') != null) {
cpcolor = getStorage('rmcpcolor');
rgb = hexToRgb(cpcolor);
}
if (getStorage('rmduration') != null)
{
if (getStorage('rmduration') != null) {
$("#remote_duration").val(getStorage('rmduration'));
duration = getStorage('rmduration');
}
createCP('cp2', cpcolor, function(rgbT,hex){
createCP('cp2', cpcolor, function (rgbT, hex) {
rgb = rgbT;
sendColor();
setStorage('rmcpcolor', hex);
updateInputSelect();
});
$("#reset_color").off().on("click", function(){
$("#reset_color").off().on("click", function () {
requestPriorityClear();
lastImgData = "";
$("#effect_select").val("__none__");
$("#remote_input_img").val("");
});
$("#remote_duration").off().on("change", function(){
duration = valValue(this.id,this.value,this.min,this.max);
$("#remote_duration").off().on("change", function () {
duration = valValue(this.id, this.value, this.min, this.max);
setStorage('rmduration', duration);
});
$("#effect_select").off().on("change", function(event) {
$("#effect_select").off().on("change", function (event) {
sendEffect();
});
$("#remote_input_reseff, #remote_input_rescol").off().on("click", function(){
if(this.id == "remote_input_rescol")
$("#remote_input_reseff, #remote_input_rescol").off().on("click", function () {
if (this.id == "remote_input_rescol")
sendColor();
else
sendEffect();
});
$("#remote_input_repimg").off().on("click", function(){
if(lastImgData != "")
$("#remote_input_repimg").off().on("click", function () {
if (lastImgData != "")
requestSetImage(lastImgData, duration, lastFileName);
});
$("#remote_input_img").change(function(){
readImg(this, function(src,fileName){
$("#remote_input_img").change(function () {
readImg(this, function (src, fileName) {
lastFileName = fileName;
if(src.includes(","))
if (src.includes(","))
lastImgData = src.split(",")[1];
else
lastImgData = src;
@ -397,27 +364,27 @@ $(document).ready(function() {
// interval updates
$(window.hyperion).on('components-updated', function(e, comp){
$(window.hyperion).on('components-updated', function (e, comp) {
//console.log ("components-updated", e, comp);
updateComponent (comp);
updateComponent(comp);
});
$(window.hyperion).on("cmd-priorities-update", function(event){
$(window.hyperion).on("cmd-priorities-update", function (event) {
window.serverInfo.priorities = event.response.data.priorities;
window.serverInfo.priorities_autoselect = event.response.data.priorities_autoselect;
updateInputSelect();
});
$(window.hyperion).on("cmd-imageToLedMapping-update", function(event){
$(window.hyperion).on("cmd-imageToLedMapping-update", function (event) {
window.serverInfo.imageToLedMappingType = event.response.data.imageToLedMappingType;
updateLedMapping();
});
$(window.hyperion).on("cmd-videomode-update", function(event){
$(window.hyperion).on("cmd-videomode-update", function (event) {
window.serverInfo.videomode = event.response.data.videomode;
updateVideoMode();
});
$(window.hyperion).on("cmd-effects-update", function(event){
$(window.hyperion).on("cmd-effects-update", function (event) {
window.serverInfo.effects = event.response.data.effects;
updateEffectlist();
});

View File

@ -249,12 +249,16 @@ $(document).ready(function() {
// ------------------------------------------------------------------
$(window.hyperion).on("cmd-settings-update",function(event){
var obj = event.response.data
if ( obj.leds) {
console.log("ledsim: cmd-settings-update", event.response.data);
Object.getOwnPropertyNames(obj).forEach(function(val, idx, array) {
window.serverInfo[val] = obj[val];
});
leds = window.serverConfig.leds
updateLedLayout();
}
});
function resetImage(){

View File

@ -330,7 +330,7 @@ function showInfoDialog(type, header, message) {
$(document).on('click', '[data-dismiss-modal]', function () {
var target = $(this).attr('data-dismiss-modal');
$.find(target).modal.hide();
$(target).modal('hide');
});
}
@ -1070,6 +1070,43 @@ function getReleases(callback) {
});
}
function getSystemInfo() {
var sys = window.sysInfo.system;
var shy = window.sysInfo.hyperion;
var info = "Hyperion Server: \n";
info += '- Build: ' + shy.build + '\n';
info += '- Build time: ' + shy.time + '\n';
info += '- Git Remote: ' + shy.gitremote + '\n';
info += '- Version: ' + shy.version + '\n';
info += '- UI Lang: ' + storedLang + ' (BrowserLang: ' + navigator.language + ')\n';
info += '- UI Access: ' + storedAccess + '\n';
//info += '- Log lvl: ' + window.serverConfig.logger.level + '\n';
info += '- Avail Capt: ' + window.serverInfo.grabbers.available + '\n';
info += '- Database: ' + (shy.readOnlyMode ? "ready-only" : "read/write") + '\n';
info += '\n';
info += 'Hyperion Server OS: \n';
info += '- Distribution: ' + sys.prettyName + '\n';
info += '- Architecture: ' + sys.architecture + '\n';
if (sys.cpuModelName)
info += '- CPU Model: ' + sys.cpuModelName + '\n';
if (sys.cpuModelType)
info += '- CPU Type: ' + sys.cpuModelType + '\n';
if (sys.cpuRevision)
info += '- CPU Revision: ' + sys.cpuRevision + '\n';
if (sys.cpuHardware)
info += '- CPU Hardware: ' + sys.cpuHardware + '\n';
info += '- Kernel: ' + sys.kernelType + ' (' + sys.kernelVersion + ' (WS: ' + sys.wordSize + '))\n';
info += '- Qt Version: ' + sys.qtVersion + '\n';
info += '- Python Version: ' + sys.pyVersion + '\n';
info += '- Browser: ' + navigator.userAgent;
return info;
}
function handleDarkMode() {
$("<link/>", {
rel: "stylesheet",