mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Media Foundation/V4L2 grabber ... (#1119)
* - New Media Foundation grabber
- JsonAPI available grabber fix
- commented json config removed
* Added libjpeg-turbo to dependencies
* Fix OSX build
Removed Azure Pipelines from build scripts
* Remove Platform from Dashboard
* Correct Grabber Namings
* Grabber UI improvements, generic JSONEditor Selection Update
* Active grabber fix
* Stop Framebuffer grabber on failure
* - Image format NV12 and I420 added
- Flip mode
- Scaling factor for MJPEG
- VSCode (compile before run)
- CI (push) dependency libjpeg-turbo added
* Refactor MediaFoundation (Part 1)
* Remove QDebug output
* Added image flipping ability to MF Grabber
* fix issue 1160
* -Reload MF Grabber only once per WebUI update
- Cleanup
* Improvements
* - Set 'Software Frame Decimation' begin to 0
- Removed grabber specific device name from Log
- Keep pixel format when switching resolution
- Display 'Flip mode' correct in Log
- BGR24 images always flipped
* Refactor MediaFoundation (Part 2)
* Refactor V4L2 grabber (part 1) (#62)
* Media Foundation grabber adapted to V4L2 change
* Enable Media Foundation grabber on windows
* Have fps as int, fix height typo
* Added video standards to JsonAPI output
* Error handling in source reader improved
* Fix "Frame to small" error
* Discovery VideoSources and Dynamically Update Editor
* Hide all element when no video grabber discovered, upate naming
* Do not show unsupported grabbers
* Copy Log to Clipboard
* Update Grabber schema and Defaults
* Update access levels and validate crop ranges
* Height and width in Qt grabber corrected
* Correct formatting
* Untabify
* Global component states across instances
* Components divided on the dashboard
* refactor
* Fix Merge-issues
* Database migration aligning with updated grabber model
* Align Grabber.js with new utility functions
* Allow editor-validation for enum-lists
* Handle "Show Explainations scenario" correctly
* Grabber - Ensure save is only possible on valid content
* Dashboard update + fix GlobalSignal connection
* Ensure default database is populated with current release
* Correct grabber4L2 access level
* Display Signal detection area in preview
* Write Hyperion version into default config on compiling.
* Create defaultconfig.json dynamically
* WebUI changes
* Correct grabber config look-ups
* Refactor i18n language loading
* Fix en.json
* Split global capture from instance capture config
* Update grabber default values
* Standalone grabber: Add --debug switch
* Enhance showInputOptionsForKey for multiple keys
* Add grabber instance link to system grabber config
* Only show signal detection area, if grabber is enabled
* Always show Active element on grabber page
* Remote control - Only display gabber status, if global grabber is enabled
* WebUI optimization (thx to @mkcologne)
Start Grabber only when global settings are enabled
Fixed an issue in the WebUI preview
* V4L2/MF changes
* Jsoneditor, Correct translation for default values
* Refactor LED-Device handling in UI and make element naming consistent
* MF Discovery extended
* Fix LGTM finding
* Support Grabber Bri, Hue, Sat and Con in UI, plus their defaults
* Concider Access level for item filtering
* Concider Access level for item filtering
* Revert "Concider Access level for item filtering"
This reverts commit 5b0ce3c0f2
.
* Disable fpsSoftwareDecimation for framegrabber, as not supported yet
* JSON-Editor- Add updated schema for validation on dynamic elements
* added V4L2 color IDs
* LGTM findings fix
* destroy SR callback only on exit
* Grabber.js - Hide elements not supported by platform
* Fixed freezing start effect
* Grabber UI - Hardware controls - Show current values and allow to reset to defaults
* Grabber - Discovery - Add current values to properties
* Small things
* Clean-up Effects and have ENDLESS consistently defined
* Fix on/off/on priority during startup, by initializing _prevVisComp in line with background priority
* Add missing translation mappings
* DirectX Grabber reactivated/ QT Grabber size decimation fixed
* typo in push-master workflow
* Use PreciseTimer for Grabber to ensure stable FPS timing
* Set default Screencapture rate consistently
* Fix libjpeg-turbo download
* Remove Zero character from file
* docker-compile Add PLATFORM parameter, only copy output file after successful compile
* Framebuffer, Dispmanx, OSX, AML Grabber discovery, various clean-up and consistencies across grabbers
* Fix merge problem - on docker-compile Add PLATFORM parameter, only copy output file after successful compile
* Fix definition
* OSXFRameGrabber - Revert cast
* Clean-ups nach Feedback
* Disable certain libraries when building armlogic via standard stretch image as developer
* Add CEC availability to ServerInfo to have it platform independent
* Grabber UI - Fix problem that crop values are not populated when refining editor rage
* Preserve value when updating json-editor range
* LEDVisualisation - Clear image when source changes
* Fix - Preserve value when updating json-editor range
* LEDVisualisation - Clear image when no component is active
* Allow to have password handled by Password-Manager (#1263)
* Update default signal detection area to green assuming rainbow grabber
* LED Visualisation - Handle empty priority update
* Fix yuv420 in v4l2 grabber
* V4L2-Grabber discovery - Only report grabbers with valid video input information
* Grabber - Update static variables to have them working in release build
* LED Visualisation - ClearImage when no priorities
* LED Visualisation - Fix Logo resizing issue
* LED Visualisation - Have nearly black background and negative logo
Co-authored-by: LordGrey <lordgrey.emmel@gmail.com>
Co-authored-by: LordGrey <48840279+Lord-Grey@users.noreply.github.com>
This commit is contained in:
@@ -13,7 +13,6 @@ $(document).ready(function () {
|
||||
instances_html += '</a><ul id="hyp_inst_listing" class="dropdown-menu dropdown-alerts" style="cursor:pointer;"></ul>'
|
||||
instances_html += '</div></div>';
|
||||
|
||||
|
||||
instances_html += '<div class="panel-body">';
|
||||
instances_html += '<table class="table borderless">';
|
||||
instances_html += '<thead><tr><th style="vertical-align:middle"><i class="mdi mdi-lightbulb-on fa-fw"></i>';
|
||||
@@ -39,10 +38,13 @@ $(document).ready(function () {
|
||||
instances_html += '<i class="fa fa-info-circle fa-fw"></i>';
|
||||
instances_html += '<span>' + $.i18n('dashboard_infobox_label_title') + '</span>';
|
||||
instances_html += '</th></tr></thead>';
|
||||
instances_html += '<tbody><tr><td></td>';
|
||||
instances_html += '<td>' + $.i18n('conf_leds_contr_label_contrtype') + '</td>';
|
||||
instances_html += '<td style="text-align:right">' + window.serverConfig.device.type + '</td>';
|
||||
instances_html += '</tr><tr></tbody></table>';
|
||||
instances_html += '<tbody>';
|
||||
instances_html += '<tr><td></td><td>' + $.i18n('conf_leds_contr_label_contrtype') + '</td>';
|
||||
instances_html += '<td style="text-align:right; padding-right:0">';
|
||||
instances_html += '<span>' + window.serverConfig.device.type + '</span>';
|
||||
instances_html += '<a class="fa fa-cog fa-fw" onclick="SwitchToMenuItem(\'MenuItemLeds\')" style="text-decoration:none;cursor:pointer"></a>';
|
||||
instances_html += '</td></tr>';
|
||||
instances_html += '</tbody></table>';
|
||||
|
||||
instances_html += '<table class="table first_cell_borderless">';
|
||||
instances_html += '<thead><tr><th colspan="3">';
|
||||
@@ -50,28 +52,35 @@ $(document).ready(function () {
|
||||
instances_html += '<span>' + $.i18n('dashboard_componentbox_label_title') + '</span>';
|
||||
instances_html += '</th></tr></thead>';
|
||||
|
||||
var tab_components = "";
|
||||
var componentBtn = "";
|
||||
var instance_components = "";
|
||||
for (var idx = 0; idx < components.length; idx++) {
|
||||
if (components[idx].name != "ALL") {
|
||||
var comp_enabled = components[idx].enabled ? "checked" : "";
|
||||
const general_comp = "general_comp_" + components[idx].name;
|
||||
var componentBtn = '<input ' +
|
||||
'id="' + general_comp + '" ' + comp_enabled +
|
||||
' type="checkbox" ' +
|
||||
'data-toggle="toggle" ' +
|
||||
'data-size="mini" ' +
|
||||
'data-onstyle="success" ' +
|
||||
'data-on="' + $.i18n('general_btn_on') + '" ' +
|
||||
'data-off="' + $.i18n('general_btn_off') + '">';
|
||||
if ((components[idx].name === "FORWARDER" && window.currentHyperionInstance != 0) ||
|
||||
(components[idx].name === "GRABBER" && !window.serverConfig.framegrabber.enable) ||
|
||||
(components[idx].name === "V4L" && !window.serverConfig.grabberV4L2.enable))
|
||||
continue;
|
||||
|
||||
tab_components += '<tr><td></td><td>' + $.i18n('general_comp_' + components[idx].name) + '</td><td style="text-align:right">' + componentBtn + '</td></tr>';
|
||||
var comp_enabled = components[idx].enabled ? "checked" : "";
|
||||
const general_comp = "general_comp_" + components[idx].name;
|
||||
componentBtn = '<input ' +
|
||||
'id="' + general_comp + '" ' + comp_enabled +
|
||||
' type="checkbox" ' +
|
||||
'data-toggle="toggle" ' +
|
||||
'data-size="mini" ' +
|
||||
'data-onstyle="success" ' +
|
||||
'data-on="' + $.i18n('general_btn_on') + '" ' +
|
||||
'data-off="' + $.i18n('general_btn_off') + '">';
|
||||
|
||||
instance_components += '<tr><td></td><td>' + $.i18n('general_comp_' + components[idx].name) + '</td><td style="text-align:right">' + componentBtn + '</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
instances_html += '<tbody>' + tab_components + '</tbody></table>';
|
||||
instances_html += '<tbody>' + instance_components + '</tbody></table>';
|
||||
instances_html += '</div></div></div>';
|
||||
|
||||
$('.instances').prepend(instances_html);
|
||||
|
||||
updateUiOnInstance(window.currentHyperionInstance);
|
||||
updateHyperionInstanceListing();
|
||||
|
||||
@@ -83,7 +92,7 @@ $(document).ready(function () {
|
||||
for (var idx = 0; idx < components.length; idx++) {
|
||||
if (components[idx].name != "ALL") {
|
||||
$("#general_comp_" + components[idx].name).bootstrapToggle();
|
||||
$("#general_comp_" + components[idx].name).bootstrapToggle(hyperion_enabled ? "enable" : "disable")
|
||||
$("#general_comp_" + components[idx].name).bootstrapToggle(hyperion_enabled ? "enable" : "disable");
|
||||
$("#general_comp_" + components[idx].name).change(e => {
|
||||
requestSetComponentState(e.currentTarget.id.split('_')[2], e.currentTarget.checked);
|
||||
});
|
||||
@@ -92,6 +101,12 @@ $(document).ready(function () {
|
||||
}
|
||||
|
||||
// add more info
|
||||
|
||||
var screenGrabber = window.serverConfig.framegrabber.enable ? $.i18n('general_enabled') : $.i18n('general_disabled');
|
||||
$('#dash_screen_grabber').html(screenGrabber);
|
||||
var videoGrabber = window.serverConfig.grabberV4L2.enable ? $.i18n('general_enabled') : $.i18n('general_disabled');
|
||||
$('#dash_video_grabber').html(videoGrabber);
|
||||
|
||||
var fbPort = window.serverConfig.flatbufServer.enable ? window.serverConfig.flatbufServer.port : $.i18n('general_disabled');
|
||||
$('#dash_fbPort').html(fbPort);
|
||||
var pbPort = window.serverConfig.protoServer.enable ? window.serverConfig.protoServer.port : $.i18n('general_disabled');
|
||||
|
@@ -1,196 +1,182 @@
|
||||
$(document).ready( function() {
|
||||
performTranslation();
|
||||
$(document).ready(function () {
|
||||
performTranslation();
|
||||
|
||||
var importedConf;
|
||||
var confName;
|
||||
var conf_editor = null;
|
||||
var importedConf;
|
||||
var confName;
|
||||
var conf_editor = null;
|
||||
|
||||
$('#conf_cont').append(createOptPanel('fa-wrench', $.i18n("edt_conf_gen_heading_title"), 'editor_container', 'btn_submit', 'panel-system'));
|
||||
if(window.showOptHelp)
|
||||
{
|
||||
$('#conf_cont').append(createHelpTable(window.schema.general.properties, $.i18n("edt_conf_gen_heading_title")));
|
||||
}
|
||||
else
|
||||
$('#conf_imp').appendTo('#conf_cont');
|
||||
$('#conf_cont').append(createOptPanel('fa-wrench', $.i18n("edt_conf_gen_heading_title"), 'editor_container', 'btn_submit', 'panel-system'));
|
||||
if (window.showOptHelp) {
|
||||
$('#conf_cont').append(createHelpTable(window.schema.general.properties, $.i18n("edt_conf_gen_heading_title")));
|
||||
}
|
||||
else
|
||||
$('#conf_imp').appendTo('#conf_cont');
|
||||
|
||||
conf_editor = createJsonEditor('editor_container', {
|
||||
general: window.schema.general
|
||||
}, true, true);
|
||||
conf_editor = createJsonEditor('editor_container', {
|
||||
general: window.schema.general
|
||||
}, true, true);
|
||||
|
||||
conf_editor.on('change',function() {
|
||||
conf_editor.validate().length || window.readOnlyMode ? $('#btn_submit').attr('disabled', true) : $('#btn_submit').attr('disabled', false);
|
||||
});
|
||||
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 () {
|
||||
window.showOptHelp = conf_editor.getEditor("root.general.showOptHelp").getValue();
|
||||
requestWriteConfig(conf_editor.getValue());
|
||||
});
|
||||
|
||||
// Instance handling
|
||||
function handleInstanceRename(e)
|
||||
{
|
||||
// Instance handling
|
||||
function handleInstanceRename(e) {
|
||||
|
||||
conf_editor.on('change',function() {
|
||||
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);
|
||||
});
|
||||
conf_editor.on('change', function () {
|
||||
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);
|
||||
});
|
||||
|
||||
var inst = e.currentTarget.id.split("_")[1];
|
||||
showInfoDialog('renInst', $.i18n('conf_general_inst_renreq_t'), getInstanceNameByIndex(inst));
|
||||
var inst = e.currentTarget.id.split("_")[1];
|
||||
showInfoDialog('renInst', $.i18n('conf_general_inst_renreq_t'), getInstanceNameByIndex(inst));
|
||||
|
||||
$("#id_btn_ok").off().on('click', function(){
|
||||
requestInstanceRename(inst, $('#renInst_name').val())
|
||||
});
|
||||
$("#id_btn_ok").off().on('click', function () {
|
||||
requestInstanceRename(inst, $('#renInst_name').val())
|
||||
});
|
||||
|
||||
$('#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);
|
||||
});
|
||||
}
|
||||
$('#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);
|
||||
});
|
||||
}
|
||||
|
||||
function handleInstanceDelete(e)
|
||||
{
|
||||
var inst = e.currentTarget.id.split("_")[1];
|
||||
showInfoDialog('delInst',$.i18n('conf_general_inst_delreq_h'),$.i18n('conf_general_inst_delreq_t',getInstanceNameByIndex(inst)));
|
||||
$("#id_btn_yes").off().on('click', function(){
|
||||
requestInstanceDelete(inst)
|
||||
});
|
||||
}
|
||||
function handleInstanceDelete(e) {
|
||||
var inst = e.currentTarget.id.split("_")[1];
|
||||
showInfoDialog('delInst', $.i18n('conf_general_inst_delreq_h'), $.i18n('conf_general_inst_delreq_t', getInstanceNameByIndex(inst)));
|
||||
$("#id_btn_yes").off().on('click', function () {
|
||||
requestInstanceDelete(inst)
|
||||
});
|
||||
}
|
||||
|
||||
function buildInstanceList()
|
||||
{
|
||||
var inst = serverInfo.instance
|
||||
$('.itbody').html("");
|
||||
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 startBtn = ""
|
||||
var delBtn = "";
|
||||
if(inst[key].instance > 0)
|
||||
{
|
||||
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')+'">';
|
||||
function buildInstanceList() {
|
||||
var inst = serverInfo.instance
|
||||
$('.itbody').html("");
|
||||
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 startBtn = ""
|
||||
var delBtn = "";
|
||||
if (inst[key].instance > 0) {
|
||||
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));
|
||||
$('#instren_'+inst[key].instance).off().on('click', handleInstanceRename);
|
||||
}
|
||||
$('.itbody').append(createTableRow([inst[key].friendly_name, startBtn, renameBtn, delBtn], false, true));
|
||||
$('#instren_' + inst[key].instance).off().on('click', handleInstanceRename);
|
||||
|
||||
$('#inst_'+inst[key].instance).bootstrapToggle();
|
||||
$('#inst_'+inst[key].instance).change(e => {
|
||||
requestInstanceStartStop(e.currentTarget.id.split('_').pop(), e.currentTarget.checked);
|
||||
});
|
||||
$('#instdel_'+inst[key].instance).off().on('click', handleInstanceDelete);
|
||||
$('#inst_' + inst[key].instance).bootstrapToggle();
|
||||
$('#inst_' + inst[key].instance).change(e => {
|
||||
requestInstanceStartStop(e.currentTarget.id.split('_').pop(), e.currentTarget.checked);
|
||||
});
|
||||
$('#instdel_' + inst[key].instance).off().on('click', handleInstanceDelete);
|
||||
|
||||
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 ? $('#instdel_'+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 ? $('#instdel_' + inst[key].instance).attr('disabled', true) : $('#btn_submit').attr('disabled', false);
|
||||
}
|
||||
}
|
||||
|
||||
createTable('ithead', 'itbody', 'itable');
|
||||
$('.ithead').html(createTableRow([$.i18n('conf_general_inst_namehead'), "", $.i18n('conf_general_inst_actionhead'), ""], true, true));
|
||||
buildInstanceList();
|
||||
createTable('ithead', 'itbody', 'itable');
|
||||
$('.ithead').html(createTableRow([$.i18n('conf_general_inst_namehead'), "", $.i18n('conf_general_inst_actionhead'), ""], true, true));
|
||||
buildInstanceList();
|
||||
|
||||
$('#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);
|
||||
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'))
|
||||
else
|
||||
$('#inst_chars_needed').html("<br />")
|
||||
});
|
||||
$('#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);
|
||||
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'))
|
||||
else
|
||||
$('#inst_chars_needed').html("<br />")
|
||||
});
|
||||
|
||||
$('#btn_create_inst').off().on('click',function(e) {
|
||||
requestInstanceCreate($('#inst_name').val());
|
||||
$('#inst_name').val("");
|
||||
$('#btn_create_inst').attr('disabled', true)
|
||||
});
|
||||
$('#btn_create_inst').off().on('click', function (e) {
|
||||
requestInstanceCreate($('#inst_name').val());
|
||||
$('#inst_name').val("");
|
||||
$('#btn_create_inst').attr('disabled', true)
|
||||
});
|
||||
|
||||
$(hyperion).off("instance-updated").on("instance-updated", function(event) {
|
||||
buildInstanceList()
|
||||
});
|
||||
$(hyperion).off("instance-updated").on("instance-updated", function (event) {
|
||||
buildInstanceList()
|
||||
});
|
||||
|
||||
//import
|
||||
function dis_imp_btn(state)
|
||||
{
|
||||
state || window.readOnlyMode ? $('#btn_import_conf').attr('disabled', true) : $('#btn_import_conf').attr('disabled', false);
|
||||
}
|
||||
//import
|
||||
function dis_imp_btn(state) {
|
||||
state || window.readOnlyMode ? $('#btn_import_conf').attr('disabled', true) : $('#btn_import_conf').attr('disabled', false);
|
||||
}
|
||||
|
||||
function readFile(evt)
|
||||
{
|
||||
var f = evt.target.files[0];
|
||||
function readFile(evt) {
|
||||
var f = evt.target.files[0];
|
||||
|
||||
if (f)
|
||||
{
|
||||
var r = new FileReader();
|
||||
r.onload = function(e)
|
||||
{
|
||||
var content = e.target.result.replace(/[^:]?\/\/.*/g, ''); //remove Comments
|
||||
if (f) {
|
||||
var r = new FileReader();
|
||||
r.onload = function (e) {
|
||||
var content = e.target.result.replace(/[^:]?\/\/.*/g, ''); //remove Comments
|
||||
|
||||
//check file is json
|
||||
var check = isJsonString(content);
|
||||
if(check.length != 0)
|
||||
{
|
||||
showInfoDialog('error', "", $.i18n('infoDialog_import_jsonerror_text', f.name, JSON.stringify(check)));
|
||||
dis_imp_btn(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
content = JSON.parse(content);
|
||||
//check for hyperion json
|
||||
if(typeof content.leds === 'undefined' || typeof content.general === 'undefined')
|
||||
{
|
||||
showInfoDialog('error', "", $.i18n('infoDialog_import_hyperror_text', f.name));
|
||||
dis_imp_btn(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
dis_imp_btn(false);
|
||||
importedConf = content;
|
||||
confName = f.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
r.readAsText(f);
|
||||
}
|
||||
}
|
||||
//check file is json
|
||||
var check = isJsonString(content);
|
||||
if (check.length != 0) {
|
||||
showInfoDialog('error', "", $.i18n('infoDialog_import_jsonerror_text', f.name, JSON.stringify(check)));
|
||||
dis_imp_btn(true);
|
||||
}
|
||||
else {
|
||||
content = JSON.parse(content);
|
||||
//check for hyperion json
|
||||
if (typeof content.leds === 'undefined' || typeof content.general === 'undefined') {
|
||||
showInfoDialog('error', "", $.i18n('infoDialog_import_hyperror_text', f.name));
|
||||
dis_imp_btn(true);
|
||||
}
|
||||
else {
|
||||
dis_imp_btn(false);
|
||||
importedConf = content;
|
||||
confName = f.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
r.readAsText(f);
|
||||
}
|
||||
}
|
||||
|
||||
$('#btn_import_conf').off().on('click', function(){
|
||||
showInfoDialog('import', $.i18n('infoDialog_import_confirm_title'), $.i18n('infoDialog_import_confirm_text', confName));
|
||||
$('#btn_import_conf').off().on('click', function () {
|
||||
showInfoDialog('import', $.i18n('infoDialog_import_confirm_title'), $.i18n('infoDialog_import_confirm_text', confName));
|
||||
|
||||
$('#id_btn_import').off().on('click', function(){
|
||||
requestWriteConfig(importedConf, true);
|
||||
setTimeout(initRestart, 100);
|
||||
});
|
||||
});
|
||||
$('#id_btn_import').off().on('click', function () {
|
||||
requestWriteConfig(importedConf, true);
|
||||
setTimeout(initRestart, 100);
|
||||
});
|
||||
});
|
||||
|
||||
$('#select_import_conf').off().on('change', function(e){
|
||||
if (window.File && window.FileReader && window.FileList && window.Blob)
|
||||
readFile(e);
|
||||
else
|
||||
showInfoDialog('error', "", $.i18n('infoDialog_import_comperror_text'));
|
||||
});
|
||||
$('#select_import_conf').off().on('change', function (e) {
|
||||
if (window.File && window.FileReader && window.FileList && window.Blob)
|
||||
readFile(e);
|
||||
else
|
||||
showInfoDialog('error', "", $.i18n('infoDialog_import_comperror_text'));
|
||||
});
|
||||
|
||||
//export
|
||||
$('#btn_export_conf').off().on('click', function(){
|
||||
var name = window.serverConfig.general.name;
|
||||
//export
|
||||
$('#btn_export_conf').off().on('click', function () {
|
||||
var name = window.serverConfig.general.name;
|
||||
|
||||
var d = new Date();
|
||||
var month = d.getMonth()+1;
|
||||
var day = d.getDate();
|
||||
var d = new Date();
|
||||
var month = d.getMonth() + 1;
|
||||
var day = d.getDate();
|
||||
|
||||
var timestamp = d.getFullYear() + '.' +
|
||||
(month<10 ? '0' : '') + month + '.' +
|
||||
(day<10 ? '0' : '') + day;
|
||||
var timestamp = d.getFullYear() + '.' +
|
||||
(month < 10 ? '0' : '') + month + '.' +
|
||||
(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
|
||||
if(window.showOptHelp)
|
||||
{
|
||||
createHint("intro", $.i18n('conf_general_intro'), "editor_container");
|
||||
createHint("intro", $.i18n('conf_general_tok_desc'), "tok_desc_cont");
|
||||
createHint("intro", $.i18n('conf_general_inst_desc'), "inst_desc_cont");
|
||||
}
|
||||
//create introduction
|
||||
if (window.showOptHelp) {
|
||||
createHint("intro", $.i18n('conf_general_intro'), "editor_container");
|
||||
createHint("intro", $.i18n('conf_general_tok_desc'), "tok_desc_cont");
|
||||
createHint("intro", $.i18n('conf_general_inst_desc'), "inst_desc_cont");
|
||||
}
|
||||
|
||||
removeOverlay();
|
||||
removeOverlay();
|
||||
});
|
||||
|
1055
assets/webconfig/js/content_grabber.js
Normal file → Executable file
1055
assets/webconfig/js/content_grabber.js
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
@@ -307,12 +307,17 @@ $(document).ready(function () {
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
|
||||
$(window).scroll(function(){
|
||||
$(window).scroll(function() {
|
||||
if ($(window).scrollTop() > 65)
|
||||
$("#navbar_brand_logo").css("display", "none");
|
||||
else
|
||||
$("#navbar_brand_logo").css("display", "");
|
||||
});
|
||||
});
|
||||
|
||||
$('#side-menu li a, #side-menu li ul li a').click(function() {
|
||||
$('#side-menu').find('.active').toggleClass('inactive'); // find all active classes and set inactive;
|
||||
$(this).addClass('active');
|
||||
});
|
||||
});
|
||||
|
||||
function suppressDefaultPwWarning() {
|
||||
@@ -349,7 +354,7 @@ $("#btn_darkmode").off().on("click", function (e) {
|
||||
});
|
||||
|
||||
// Menuitem toggle;
|
||||
function SwitchToMenuItem(target) {
|
||||
function SwitchToMenuItem(target, item) {
|
||||
document.getElementById(target).click(); // Get <a href menu item;
|
||||
let sidebar = $('#side-menu'); // Get sidebar menu;
|
||||
sidebar.find('.active').toggleClass('inactive'); // find all active classes and set inactive;
|
||||
@@ -357,6 +362,21 @@ function SwitchToMenuItem(target) {
|
||||
$('#' + target).removeClass('inactive'); // Remove inactive state by classname;
|
||||
$('#' + target).addClass('active'); // Add active state by classname;
|
||||
let cl_object = $('#' + target).closest('ul'); // Find closest ul sidemenu header;
|
||||
cl_object.addClass('in'); // add class "in" to expand header in sidebar menu;
|
||||
cl_object.addClass('in'); // Add class "in" to expand header in sidebar menu;
|
||||
if (item) { // Jump to div "item" if available. Time limit 3 seconds
|
||||
function scrollTo(counter) {
|
||||
if(counter < 30) {
|
||||
setTimeout(function() {
|
||||
counter++;
|
||||
if ($('#' + item).length)
|
||||
$('#' + item)[0].scrollIntoView();
|
||||
else
|
||||
scrollTo(counter);
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
||||
scrollTo(0);
|
||||
}
|
||||
};
|
||||
|
||||
|
99
assets/webconfig/js/content_instcapture.js
Normal file
99
assets/webconfig/js/content_instcapture.js
Normal file
@@ -0,0 +1,99 @@
|
||||
$(document).ready(function () {
|
||||
performTranslation();
|
||||
|
||||
// update instance listing
|
||||
updateHyperionInstanceListing();
|
||||
|
||||
var conf_editor_instCapt = null;
|
||||
|
||||
// Instance Capture
|
||||
$('#conf_cont').append(createRow('conf_cont_instCapt'));
|
||||
$('#conf_cont_instCapt').append(createOptPanel('fa-camera', $.i18n("edt_conf_instCapture_heading_title"), 'editor_container_instCapt', 'btn_submit_instCapt', ''));
|
||||
if (window.showOptHelp) {
|
||||
$('#conf_cont_instCapt').append(createHelpTable(window.schema.instCapture.properties, $.i18n("edt_conf_instCapture_heading_title")));
|
||||
}
|
||||
|
||||
// Instance Capture
|
||||
conf_editor_instCapt = createJsonEditor('editor_container_instCapt', {
|
||||
instCapture: window.schema.instCapture
|
||||
}, true, true);
|
||||
|
||||
var grabber_config_info_html = '<div class="bs-callout bs-callout-info" style="margin-top:0px"><h4>' + $.i18n('dashboard_infobox_label_title') + '</h4 >';
|
||||
grabber_config_info_html += '<span>' + $.i18n('conf_grabber_inst_grabber_config_info') + '</span>';
|
||||
grabber_config_info_html += '<a class="fa fa-cog fa-fw" onclick="SwitchToMenuItem(\'MenuItemGrabber\')" style="text-decoration:none;cursor:pointer"></a>';
|
||||
grabber_config_info_html += '</div>';
|
||||
$('#editor_container_instCapt').append(grabber_config_info_html);
|
||||
|
||||
conf_editor_instCapt.on('ready', function () {
|
||||
|
||||
if (!window.serverConfig.framegrabber.enable) {
|
||||
conf_editor_instCapt.getEditor("root.instCapture.systemEnable").setValue(false);
|
||||
conf_editor_instCapt.getEditor("root.instCapture.systemEnable").disable();
|
||||
}
|
||||
else {
|
||||
conf_editor_instCapt.getEditor("root.instCapture.systemEnable").setValue(window.serverConfig.instCapture.systemEnable);
|
||||
}
|
||||
|
||||
if (!window.serverConfig.grabberV4L2.enable) {
|
||||
conf_editor_instCapt.getEditor("root.instCapture.v4lEnable").setValue(false);
|
||||
conf_editor_instCapt.getEditor("root.instCapture.v4lEnable").disable();
|
||||
}
|
||||
else {
|
||||
conf_editor_instCapt.getEditor("root.instCapture.v4lEnable").setValue(window.serverConfig.instCapture.v4lEnable);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
conf_editor_instCapt.on('change', function () {
|
||||
|
||||
if (!conf_editor_instCapt.validate().length) {
|
||||
if (!window.serverConfig.framegrabber.enable && !window.serverConfig.grabberV4L2.enable) {
|
||||
$('#btn_submit_instCapt').attr('disabled', true);
|
||||
} else {
|
||||
window.readOnlyMode ? $('#btn_submit_instCapt').attr('disabled', true) : $('#btn_submit_instCapt').attr('disabled', false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$('#btn_submit_instCapt').attr('disabled', true);
|
||||
}
|
||||
});
|
||||
|
||||
conf_editor_instCapt.watch('root.instCapture.systemEnable', () => {
|
||||
|
||||
var screenEnable = conf_editor_instCapt.getEditor("root.instCapture.systemEnable").getValue();
|
||||
if (screenEnable) {
|
||||
conf_editor_instCapt.getEditor("root.instCapture.systemGrabberDevice").setValue(window.serverConfig.framegrabber.available_devices);
|
||||
conf_editor_instCapt.getEditor("root.instCapture.systemGrabberDevice").disable();
|
||||
showInputOptions("instCapture", ["systemGrabberDevice"], true);
|
||||
showInputOptions("instCapture", ["systemPriority"], true);
|
||||
|
||||
} else {
|
||||
showInputOptions("instCapture", ["systemGrabberDevice"], false);
|
||||
showInputOptions("instCapture", ["systemPriority"], false);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
conf_editor_instCapt.watch('root.instCapture.v4lEnable', () => {
|
||||
var videoEnable = conf_editor_instCapt.getEditor("root.instCapture.v4lEnable").getValue();
|
||||
if (videoEnable) {
|
||||
conf_editor_instCapt.getEditor("root.instCapture.v4lGrabberDevice").setValue(window.serverConfig.grabberV4L2.available_devices);
|
||||
conf_editor_instCapt.getEditor("root.instCapture.v4lGrabberDevice").disable();
|
||||
showInputOptions("instCapture", ["v4lGrabberDevice"], true);
|
||||
showInputOptions("instCapture", ["v4lPriority"], true);
|
||||
}
|
||||
else {
|
||||
if (!window.serverConfig.grabberV4L2.enable) {
|
||||
conf_editor_instCapt.getEditor("root.instCapture.v4lEnable").disable();
|
||||
}
|
||||
showInputOptions("instCapture", ["v4lGrabberDevice"], false);
|
||||
showInputOptions("instCapture", ["v4lPriority"], false);
|
||||
}
|
||||
});
|
||||
|
||||
$('#btn_submit_instCapt').off().on('click', function () {
|
||||
requestWriteConfig(conf_editor_instCapt.getValue());
|
||||
});
|
||||
|
||||
removeOverlay();
|
||||
});
|
@@ -701,6 +701,8 @@ $(document).ready(function () {
|
||||
var hwLedCountDefault = 1;
|
||||
var colorOrderDefault = "rgb";
|
||||
|
||||
$('#btn_test_controller').hide();
|
||||
|
||||
switch (ledType) {
|
||||
case "cololight":
|
||||
case "wled":
|
||||
@@ -769,11 +771,38 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
conf_editor.on('change', function () {
|
||||
//Check, if device can be identified/tested and/or saved
|
||||
// //Check, if device can be identified/tested and/or saved
|
||||
var canIdentify = false;
|
||||
var canSave = false;
|
||||
|
||||
switch (ledType) {
|
||||
|
||||
case "atmoorb":
|
||||
case "fadecandy":
|
||||
case "tinkerforge":
|
||||
case "tpm2net":
|
||||
case "udpe131":
|
||||
case "udpartnet":
|
||||
case "udph801":
|
||||
case "udpraw":
|
||||
var host = conf_editor.getEditor("root.specificOptions.host").getValue();
|
||||
if (host !== "") {
|
||||
canSave = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case "philipshue":
|
||||
var host = conf_editor.getEditor("root.specificOptions.host").getValue();
|
||||
var username = conf_editor.getEditor("root.specificOptions.username").getValue();
|
||||
if (host !== "" && username != "") {
|
||||
var useEntertainmentAPI = conf_editor.getEditor("root.specificOptions.useEntertainmentAPI").getValue();
|
||||
var clientkey = conf_editor.getEditor("root.specificOptions.clientkey").getValue();
|
||||
if (!useEntertainmentAPI || clientkey !== "") {
|
||||
canSave = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "cololight":
|
||||
case "wled":
|
||||
var hostList = conf_editor.getEditor("root.specificOptions.hostList").getValue();
|
||||
@@ -797,48 +826,20 @@ $(document).ready(function () {
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "adalight":
|
||||
var output = conf_editor.getEditor("root.specificOptions.output").getValue();
|
||||
if (output !== "NONE" && output !== "SELECT" && output !== "") {
|
||||
canIdentify = true;
|
||||
}
|
||||
case "atmo":
|
||||
case "dmx":
|
||||
case "karate":
|
||||
case "sedu":
|
||||
case "tpm2":
|
||||
case "apa102":
|
||||
case "apa104":
|
||||
case "ws2801":
|
||||
case "lpd6803":
|
||||
case "lpd8806":
|
||||
case "p9813":
|
||||
case "sk6812spi":
|
||||
case "sk6822spi":
|
||||
case "sk9822":
|
||||
case "ws2812spi":
|
||||
case "piblaster":
|
||||
var output = conf_editor.getEditor("root.specificOptions.output").getValue();
|
||||
if (output !== "NONE" && output !== "SELECT" && output !== "") {
|
||||
canSave = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
canIdentify = false;
|
||||
canSave = true;
|
||||
}
|
||||
|
||||
if (canIdentify) {
|
||||
$("#btn_test_controller").removeClass('hidden');
|
||||
$('#btn_test_controller').attr('disabled', false);
|
||||
}
|
||||
else {
|
||||
$('#btn_test_controller').attr('disabled', true);
|
||||
}
|
||||
|
||||
var hardwareLedCount = conf_editor.getEditor("root.generalOptions.hardwareLedCount").getValue();
|
||||
if (hardwareLedCount < 1) {
|
||||
if (!conf_editor.validate().length) {
|
||||
if (canIdentify) {
|
||||
$("#btn_test_controller").show();
|
||||
$('#btn_test_controller').attr('disabled', false);
|
||||
} else {
|
||||
$('#btn_test_controller').hide();
|
||||
$('#btn_test_controller').attr('disabled', true);
|
||||
}
|
||||
} else {
|
||||
canSave = false;
|
||||
}
|
||||
|
||||
@@ -886,9 +887,9 @@ $(document).ready(function () {
|
||||
conf_editor.getEditor(specOptPath + "host").setValue(val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
showAllDeviceInputOptions("hostList", showOptions);
|
||||
showAllDeviceInputOptions("hostList", showOptions);
|
||||
}
|
||||
});
|
||||
|
||||
conf_editor.watch('root.specificOptions.host', () => {
|
||||
@@ -900,8 +901,10 @@ $(document).ready(function () {
|
||||
else {
|
||||
let params = {};
|
||||
switch (ledType) {
|
||||
|
||||
case "cololight":
|
||||
params = { host: host };
|
||||
getProperties_device(ledType, host, params);
|
||||
break;
|
||||
|
||||
case "nanoleaf":
|
||||
@@ -910,33 +913,70 @@ $(document).ready(function () {
|
||||
return;
|
||||
}
|
||||
params = { host: host, token: token };
|
||||
getProperties_device(ledType, host, params);
|
||||
break;
|
||||
|
||||
case "wled":
|
||||
params = { host: host, filter: "info" };
|
||||
getProperties_device(ledType, host, params);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
getProperties_device(ledType, host, params);
|
||||
}
|
||||
});
|
||||
|
||||
conf_editor.watch('root.specificOptions.output', () => {
|
||||
var output = conf_editor.getEditor("root.specificOptions.output").getValue();
|
||||
if (output === "NONE" || output === "SELECT" || output === "") {
|
||||
|
||||
$('#btn_submit_controller').attr('disabled', true);
|
||||
$('#btn_test_controller').attr('disabled', true);
|
||||
$('#btn_test_controller').hide();
|
||||
|
||||
conf_editor.getEditor("root.generalOptions.hardwareLedCount").setValue(1);
|
||||
showAllDeviceInputOptions("output", false);
|
||||
}
|
||||
else {
|
||||
showAllDeviceInputOptions("output", true);
|
||||
let params = {};
|
||||
var canIdentify = false;
|
||||
switch (ledType) {
|
||||
case "adalight":
|
||||
canIdentify = true;
|
||||
break;
|
||||
case "atmo":
|
||||
case "karate":
|
||||
params = { serialPort: output };
|
||||
getProperties_device(ledType, output, params);
|
||||
break;
|
||||
case "dmx":
|
||||
case "sedu":
|
||||
case "tpm2":
|
||||
case "apa102":
|
||||
case "apa104":
|
||||
case "ws2801":
|
||||
case "lpd6803":
|
||||
case "lpd8806":
|
||||
case "p9813":
|
||||
case "sk6812spi":
|
||||
case "sk6822spi":
|
||||
case "sk9822":
|
||||
case "ws2812spi":
|
||||
case "piblaster":
|
||||
default:
|
||||
}
|
||||
|
||||
if (!conf_editor.validate().length) {
|
||||
if (canIdentify) {
|
||||
$("#btn_test_controller").show();
|
||||
$('#btn_test_controller').attr('disabled', false);
|
||||
} else {
|
||||
$('#btn_test_controller').hide();
|
||||
$('#btn_test_controller').attr('disabled', true);
|
||||
}
|
||||
if (!window.readOnlyMode) {
|
||||
$('#btn_submit_controller').attr('disabled', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1229,6 +1269,8 @@ function saveLedConfig(genDefLayout = false) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Rewrite whole LED & Layout configuration, in case changes were done accross tabs and no default layout
|
||||
if (genDefLayout !== true) {
|
||||
result.ledConfig = getLedConfig();
|
||||
@@ -1269,8 +1311,6 @@ var updateSelectList = function (ledType, discoveryInfo) {
|
||||
ledTypeGroup = "devRPiGPIO";
|
||||
}
|
||||
|
||||
var specOpt = conf_editor.getEditor('root.specificOptions'); // get specificOptions of the editor
|
||||
|
||||
switch (ledTypeGroup) {
|
||||
case "devNET":
|
||||
key = "hostList";
|
||||
@@ -1434,11 +1474,14 @@ var updateSelectList = function (ledType, discoveryInfo) {
|
||||
}
|
||||
|
||||
if (enumVals.length > 0) {
|
||||
updateJsonEditorSelection(specOpt, key, addSchemaElements, enumVals, enumTitelVals, enumDefaultVal, addSelect, addCustom);
|
||||
updateJsonEditorSelection(conf_editor, 'root.specificOptions', key, addSchemaElements, enumVals, enumTitelVals, enumDefaultVal, addSelect, addCustom);
|
||||
}
|
||||
};
|
||||
|
||||
async function discover_device(ledType, params) {
|
||||
|
||||
$('#btn_submit_controller').attr('disabled', true);
|
||||
|
||||
const result = await requestLedDeviceDiscovery(ledType, params);
|
||||
|
||||
var discoveryResult;
|
||||
@@ -1479,6 +1522,7 @@ async function getProperties_device(ledType, key, params) {
|
||||
}
|
||||
else {
|
||||
$('#btn_submit_controller').attr('disabled', true);
|
||||
$('#btn_test_controller').attr('disabled', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1544,8 +1588,7 @@ function updateElements(ledType, key) {
|
||||
if (ledProperties && ledProperties.ledCount) {
|
||||
if (ledProperties.ledCount.length > 0) {
|
||||
var configuredLedCount = window.serverConfig.device.hardwareLedCount;
|
||||
var generalOpt = conf_editor.getEditor('root.generalOptions');
|
||||
updateJsonEditorSelection(generalOpt, "hardwareLedCount", {}, ledProperties.ledCount, [], configuredLedCount);
|
||||
updateJsonEditorSelection(conf_editor, 'root.generalOptions', "hardwareLedCount", {}, ledProperties.ledCount, [], configuredLedCount);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@@ -25,7 +25,7 @@ $(document).ready(function () {
|
||||
$('#btn_submit').off().on('click', function () {
|
||||
|
||||
var displayedLogLevel = conf_editor.getEditor("root.logger.level").getValue();
|
||||
var newLogLevel = {logger:{}};
|
||||
var newLogLevel = { logger: {} };
|
||||
newLogLevel.logger.level = displayedLogLevel;
|
||||
|
||||
requestWriteConfig(newLogLevel);
|
||||
@@ -103,7 +103,7 @@ $(document).ready(function () {
|
||||
}
|
||||
});
|
||||
|
||||
$('#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>');
|
||||
$('#log_footer').append('<button class="btn btn-primary pull-right" id="btn_clipboard"><i class="fa fa-fw fa-clipboard"></i>' + $.i18n("conf_logging_btn_clipboard") + '</button>');
|
||||
|
||||
$('#btn_clipboard').off().on('click', function () {
|
||||
const temp = document.createElement('textarea');
|
||||
@@ -153,7 +153,7 @@ $(document).ready(function () {
|
||||
|
||||
$(window.hyperion).on("cmd-logging-update", function (event) {
|
||||
|
||||
var messages = (event.response.result.messages);
|
||||
var messages = (event.response.result.messages);
|
||||
|
||||
if (messages.length != 0) {
|
||||
if (!createdCont) {
|
||||
|
@@ -7,7 +7,7 @@ $(document).ready(function () {
|
||||
var oldEffects = [];
|
||||
var cpcolor = '#B500FF';
|
||||
var mappingList = window.serverSchema.properties.color.properties.imageToLedMappingType.enum;
|
||||
var duration = 0;
|
||||
var duration = ENDLESS;
|
||||
var rgb = { r: 255, g: 0, b: 0 };
|
||||
var lastImgData = "";
|
||||
var lastFileName = "";
|
||||
@@ -201,7 +201,9 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
for (const comp of components) {
|
||||
if (comp.name === "ALL")
|
||||
if (comp.name === "ALL" || (comp.name === "FORWARDER" && window.currentHyperionInstance != 0) ||
|
||||
(comp.name === "GRABBER" && !window.serverConfig.framegrabber.enable) ||
|
||||
(comp.name === "V4L" && !window.serverConfig.grabberV4L2.enable))
|
||||
continue;
|
||||
|
||||
const enable_style = (comp.enabled ? "checked" : "");
|
||||
|
@@ -33,37 +33,39 @@ window.comps = [];
|
||||
window.defaultPasswordIsSet = null;
|
||||
tokenList = {};
|
||||
|
||||
const ENDLESS = -1;
|
||||
|
||||
function initRestart()
|
||||
{
|
||||
$(window.hyperion).off();
|
||||
requestServerConfigReload();
|
||||
window.watchdog = 10;
|
||||
connectionLostDetection('restart');
|
||||
$(window.hyperion).off();
|
||||
requestServerConfigReload();
|
||||
window.watchdog = 10;
|
||||
connectionLostDetection('restart');
|
||||
}
|
||||
|
||||
function connectionLostDetection(type)
|
||||
{
|
||||
if ( window.watchdog > 2 )
|
||||
{
|
||||
var interval_id = window.setInterval(function(){clearInterval(interval_id);}, 9999); // Get a reference to the last
|
||||
for (var i = 1; i < interval_id; i++)
|
||||
window.clearInterval(i);
|
||||
if(type == 'restart')
|
||||
{
|
||||
$("body").html($("#container_restart").html());
|
||||
// setTimeout delay for probably slower systems, some browser don't execute THIS action
|
||||
setTimeout(restartAction,250);
|
||||
}
|
||||
else
|
||||
{
|
||||
$("body").html($("#container_connection_lost").html());
|
||||
connectionLostAction();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$.get( "/cgi/cfg_jsonserver", function() {window.watchdog=0}).fail(function() {window.watchdog++;});
|
||||
}
|
||||
if ( window.watchdog > 2 )
|
||||
{
|
||||
var interval_id = window.setInterval(function(){clearInterval(interval_id);}, 9999); // Get a reference to the last
|
||||
for (var i = 1; i < interval_id; i++)
|
||||
window.clearInterval(i);
|
||||
if(type == 'restart')
|
||||
{
|
||||
$("body").html($("#container_restart").html());
|
||||
// setTimeout delay for probably slower systems, some browser don't execute THIS action
|
||||
setTimeout(restartAction,250);
|
||||
}
|
||||
else
|
||||
{
|
||||
$("body").html($("#container_connection_lost").html());
|
||||
connectionLostAction();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$.get( "/cgi/cfg_jsonserver", function() {window.watchdog=0}).fail(function() {window.watchdog++;});
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(connectionLostDetection, 3000);
|
||||
@@ -72,107 +74,107 @@ setInterval(connectionLostDetection, 3000);
|
||||
|
||||
function initWebSocket()
|
||||
{
|
||||
if ("WebSocket" in window)
|
||||
{
|
||||
if (window.websocket == null)
|
||||
{
|
||||
window.jsonPort = '';
|
||||
if(document.location.port == '' && document.location.protocol == "http:")
|
||||
window.jsonPort = '80';
|
||||
else if (document.location.port == '' && document.location.protocol == "https:")
|
||||
window.jsonPort = '443';
|
||||
else
|
||||
window.jsonPort = document.location.port;
|
||||
window.websocket = (document.location.protocol == "https:") ? new WebSocket('wss://'+document.location.hostname+":"+window.jsonPort) : new WebSocket('ws://'+document.location.hostname+":"+window.jsonPort);
|
||||
if ("WebSocket" in window)
|
||||
{
|
||||
if (window.websocket == null)
|
||||
{
|
||||
window.jsonPort = '';
|
||||
if(document.location.port == '' && document.location.protocol == "http:")
|
||||
window.jsonPort = '80';
|
||||
else if (document.location.port == '' && document.location.protocol == "https:")
|
||||
window.jsonPort = '443';
|
||||
else
|
||||
window.jsonPort = document.location.port;
|
||||
window.websocket = (document.location.protocol == "https:") ? new WebSocket('wss://'+document.location.hostname+":"+window.jsonPort) : new WebSocket('ws://'+document.location.hostname+":"+window.jsonPort);
|
||||
|
||||
window.websocket.onopen = function (event) {
|
||||
$(window.hyperion).trigger({type:"open"});
|
||||
window.websocket.onopen = function (event) {
|
||||
$(window.hyperion).trigger({type:"open"});
|
||||
|
||||
$(window.hyperion).on("cmd-serverinfo", function(event) {
|
||||
window.watchdog = 0;
|
||||
});
|
||||
};
|
||||
$(window.hyperion).on("cmd-serverinfo", function(event) {
|
||||
window.watchdog = 0;
|
||||
});
|
||||
};
|
||||
|
||||
window.websocket.onclose = function (event) {
|
||||
// See http://tools.ietf.org/html/rfc6455#section-7.4.1
|
||||
var reason;
|
||||
switch(event.code)
|
||||
{
|
||||
case 1000: reason = "Normal closure, meaning that the purpose for which the connection was established has been fulfilled."; break;
|
||||
case 1001: reason = "An endpoint is \"going away\", such as a server going down or a browser having navigated away from a page."; break;
|
||||
case 1002: reason = "An endpoint is terminating the connection due to a protocol error"; break;
|
||||
case 1003: reason = "An endpoint is terminating the connection because it has received a type of data it cannot accept (e.g., an endpoint that understands only text data MAY send this if it receives a binary message)."; break;
|
||||
case 1004: reason = "Reserved. The specific meaning might be defined in the future."; break;
|
||||
case 1005: reason = "No status code was actually present."; break;
|
||||
case 1006: reason = "The connection was closed abnormally, e.g., without sending or receiving a Close control frame"; break;
|
||||
case 1007: reason = "An endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [http://tools.ietf.org/html/rfc3629] data within a text message)."; break;
|
||||
case 1008: reason = "An endpoint is terminating the connection because it has received a message that \"violates its policy\". This reason is given either if there is no other sutible reason, or if there is a need to hide specific details about the policy."; break;
|
||||
case 1009: reason = "An endpoint is terminating the connection because it has received a message that is too big for it to process."; break;
|
||||
case 1010: reason = "An endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake. <br /> Specifically, the extensions that are needed are: " + event.reason; break;
|
||||
case 1011: reason = "A server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."; break;
|
||||
case 1015: reason = "The connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."; break;
|
||||
default: reason = "Unknown reason";
|
||||
}
|
||||
$(window.hyperion).trigger({type:"close", reason:reason});
|
||||
window.watchdog = 10;
|
||||
connectionLostDetection();
|
||||
};
|
||||
window.websocket.onclose = function (event) {
|
||||
// See http://tools.ietf.org/html/rfc6455#section-7.4.1
|
||||
var reason;
|
||||
switch(event.code)
|
||||
{
|
||||
case 1000: reason = "Normal closure, meaning that the purpose for which the connection was established has been fulfilled."; break;
|
||||
case 1001: reason = "An endpoint is \"going away\", such as a server going down or a browser having navigated away from a page."; break;
|
||||
case 1002: reason = "An endpoint is terminating the connection due to a protocol error"; break;
|
||||
case 1003: reason = "An endpoint is terminating the connection because it has received a type of data it cannot accept (e.g., an endpoint that understands only text data MAY send this if it receives a binary message)."; break;
|
||||
case 1004: reason = "Reserved. The specific meaning might be defined in the future."; break;
|
||||
case 1005: reason = "No status code was actually present."; break;
|
||||
case 1006: reason = "The connection was closed abnormally, e.g., without sending or receiving a Close control frame"; break;
|
||||
case 1007: reason = "An endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [http://tools.ietf.org/html/rfc3629] data within a text message)."; break;
|
||||
case 1008: reason = "An endpoint is terminating the connection because it has received a message that \"violates its policy\". This reason is given either if there is no other sutible reason, or if there is a need to hide specific details about the policy."; break;
|
||||
case 1009: reason = "An endpoint is terminating the connection because it has received a message that is too big for it to process."; break;
|
||||
case 1010: reason = "An endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake. <br /> Specifically, the extensions that are needed are: " + event.reason; break;
|
||||
case 1011: reason = "A server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."; break;
|
||||
case 1015: reason = "The connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."; break;
|
||||
default: reason = "Unknown reason";
|
||||
}
|
||||
$(window.hyperion).trigger({type:"close", reason:reason});
|
||||
window.watchdog = 10;
|
||||
connectionLostDetection();
|
||||
};
|
||||
|
||||
window.websocket.onmessage = function (event) {
|
||||
try
|
||||
{
|
||||
var response = JSON.parse(event.data);
|
||||
var success = response.success;
|
||||
var cmd = response.command;
|
||||
var tan = response.tan
|
||||
if (success || typeof(success) == "undefined")
|
||||
{
|
||||
$(window.hyperion).trigger({type:"cmd-"+cmd, response:response});
|
||||
}
|
||||
else
|
||||
{
|
||||
// skip tan -1 error handling
|
||||
if(tan != -1){
|
||||
var error = response.hasOwnProperty("error")? response.error : "unknown";
|
||||
$(window.hyperion).trigger({type:"error",reason:error});
|
||||
console.log("[window.websocket::onmessage] ",error)
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(exception_error)
|
||||
{
|
||||
$(window.hyperion).trigger({type:"error",reason:exception_error});
|
||||
console.log("[window.websocket::onmessage] ",exception_error)
|
||||
}
|
||||
};
|
||||
window.websocket.onmessage = function (event) {
|
||||
try
|
||||
{
|
||||
var response = JSON.parse(event.data);
|
||||
var success = response.success;
|
||||
var cmd = response.command;
|
||||
var tan = response.tan
|
||||
if (success || typeof(success) == "undefined")
|
||||
{
|
||||
$(window.hyperion).trigger({type:"cmd-"+cmd, response:response});
|
||||
}
|
||||
else
|
||||
{
|
||||
// skip tan -1 error handling
|
||||
if(tan != -1){
|
||||
var error = response.hasOwnProperty("error")? response.error : "unknown";
|
||||
$(window.hyperion).trigger({type:"error",reason:error});
|
||||
console.log("[window.websocket::onmessage] ",error)
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(exception_error)
|
||||
{
|
||||
$(window.hyperion).trigger({type:"error",reason:exception_error});
|
||||
console.log("[window.websocket::onmessage] ",exception_error)
|
||||
}
|
||||
};
|
||||
|
||||
window.websocket.onerror = function (error) {
|
||||
$(window.hyperion).trigger({type:"error",reason:error});
|
||||
console.log("[window.websocket::onerror] ",error)
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$(window.hyperion).trigger("error");
|
||||
alert("Websocket is not supported by your browser");
|
||||
return;
|
||||
}
|
||||
window.websocket.onerror = function (error) {
|
||||
$(window.hyperion).trigger({type:"error",reason:error});
|
||||
console.log("[window.websocket::onerror] ",error)
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$(window.hyperion).trigger("error");
|
||||
alert("Websocket is not supported by your browser");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function sendToHyperion(command, subcommand, msg)
|
||||
{
|
||||
if (typeof subcommand != 'undefined' && subcommand.length > 0)
|
||||
subcommand = ',"subcommand":"'+subcommand+'"';
|
||||
else
|
||||
subcommand = "";
|
||||
if (typeof subcommand != 'undefined' && subcommand.length > 0)
|
||||
subcommand = ',"subcommand":"'+subcommand+'"';
|
||||
else
|
||||
subcommand = "";
|
||||
|
||||
if (typeof msg != 'undefined' && msg.length > 0)
|
||||
msg = ","+msg;
|
||||
else
|
||||
msg = "";
|
||||
if (typeof msg != 'undefined' && msg.length > 0)
|
||||
msg = ","+msg;
|
||||
else
|
||||
msg = "";
|
||||
|
||||
window.websocket.send('{"command":"'+command+'", "tan":'+window.wsTan+subcommand+msg+'}');
|
||||
window.websocket.send('{"command":"'+command+'", "tan":'+window.wsTan+subcommand+msg+'}');
|
||||
}
|
||||
|
||||
// Send a json message to Hyperion and wait for a matching response
|
||||
@@ -228,250 +230,256 @@ async function __sendAsync (data) {
|
||||
// Test if admin requires authentication
|
||||
function requestRequiresAdminAuth()
|
||||
{
|
||||
sendToHyperion("authorize","adminRequired");
|
||||
sendToHyperion("authorize","adminRequired");
|
||||
}
|
||||
// Test if the default password needs to be changed
|
||||
function requestRequiresDefaultPasswortChange()
|
||||
{
|
||||
sendToHyperion("authorize","newPasswordRequired");
|
||||
sendToHyperion("authorize","newPasswordRequired");
|
||||
}
|
||||
// Change password
|
||||
function requestChangePassword(oldPw, newPw)
|
||||
{
|
||||
sendToHyperion("authorize","newPassword",'"password": "'+oldPw+'", "newPassword":"'+newPw+'"');
|
||||
sendToHyperion("authorize","newPassword",'"password": "'+oldPw+'", "newPassword":"'+newPw+'"');
|
||||
}
|
||||
|
||||
function requestAuthorization(password)
|
||||
{
|
||||
sendToHyperion("authorize","login",'"password": "' + password + '"');
|
||||
sendToHyperion("authorize","login",'"password": "' + password + '"');
|
||||
}
|
||||
|
||||
function requestTokenAuthorization(token)
|
||||
{
|
||||
sendToHyperion("authorize","login",'"token": "' + token + '"');
|
||||
sendToHyperion("authorize","login",'"token": "' + token + '"');
|
||||
}
|
||||
|
||||
function requestToken(comment)
|
||||
{
|
||||
sendToHyperion("authorize","createToken",'"comment": "'+comment+'"');
|
||||
sendToHyperion("authorize","createToken",'"comment": "'+comment+'"');
|
||||
}
|
||||
|
||||
function requestTokenInfo()
|
||||
{
|
||||
sendToHyperion("authorize","getTokenList","");
|
||||
sendToHyperion("authorize","getTokenList","");
|
||||
}
|
||||
|
||||
function requestGetPendingTokenRequests (id, state) {
|
||||
sendToHyperion("authorize", "getPendingTokenRequests", "");
|
||||
sendToHyperion("authorize", "getPendingTokenRequests", "");
|
||||
}
|
||||
|
||||
function requestHandleTokenRequest(id, state)
|
||||
{
|
||||
sendToHyperion("authorize","answerRequest",'"id":"'+id+'", "accept":'+state);
|
||||
sendToHyperion("authorize","answerRequest",'"id":"'+id+'", "accept":'+state);
|
||||
}
|
||||
|
||||
function requestTokenDelete(id)
|
||||
{
|
||||
sendToHyperion("authorize","deleteToken",'"id":"'+id+'"');
|
||||
sendToHyperion("authorize","deleteToken",'"id":"'+id+'"');
|
||||
}
|
||||
|
||||
function requestInstanceRename(inst, name)
|
||||
{
|
||||
sendToHyperion("instance", "saveName",'"instance": '+inst+', "name": "'+name+'"');
|
||||
sendToHyperion("instance", "saveName",'"instance": '+inst+', "name": "'+name+'"');
|
||||
}
|
||||
|
||||
function requestInstanceStartStop(inst, start)
|
||||
{
|
||||
if(start)
|
||||
sendToHyperion("instance","startInstance",'"instance": '+inst);
|
||||
else
|
||||
sendToHyperion("instance","stopInstance",'"instance": '+inst);
|
||||
if(start)
|
||||
sendToHyperion("instance","startInstance",'"instance": '+inst);
|
||||
else
|
||||
sendToHyperion("instance","stopInstance",'"instance": '+inst);
|
||||
}
|
||||
|
||||
function requestInstanceDelete(inst)
|
||||
{
|
||||
sendToHyperion("instance","deleteInstance",'"instance": '+inst);
|
||||
sendToHyperion("instance","deleteInstance",'"instance": '+inst);
|
||||
}
|
||||
|
||||
function requestInstanceCreate(name)
|
||||
{
|
||||
sendToHyperion("instance","createInstance",'"name": "'+name+'"');
|
||||
sendToHyperion("instance","createInstance",'"name": "'+name+'"');
|
||||
}
|
||||
|
||||
function requestInstanceSwitch(inst)
|
||||
{
|
||||
sendToHyperion("instance","switchTo",'"instance": '+inst);
|
||||
sendToHyperion("instance","switchTo",'"instance": '+inst);
|
||||
}
|
||||
|
||||
function requestServerInfo()
|
||||
{
|
||||
sendToHyperion("serverinfo","",'"subscribe":["components-update","sessions-update","priorities-update", "imageToLedMapping-update", "adjustment-update", "videomode-update", "effects-update", "settings-update", "instance-update"]');
|
||||
sendToHyperion("serverinfo","",'"subscribe":["components-update","sessions-update","priorities-update", "imageToLedMapping-update", "adjustment-update", "videomode-update", "effects-update", "settings-update", "instance-update"]');
|
||||
}
|
||||
|
||||
function requestSysInfo()
|
||||
{
|
||||
sendToHyperion("sysinfo");
|
||||
sendToHyperion("sysinfo");
|
||||
}
|
||||
|
||||
function requestServerConfigSchema()
|
||||
{
|
||||
sendToHyperion("config","getschema");
|
||||
sendToHyperion("config","getschema");
|
||||
}
|
||||
|
||||
function requestServerConfig()
|
||||
{
|
||||
sendToHyperion("config", "getconfig");
|
||||
sendToHyperion("config", "getconfig");
|
||||
}
|
||||
|
||||
function requestServerConfigReload()
|
||||
{
|
||||
sendToHyperion("config", "reload");
|
||||
sendToHyperion("config", "reload");
|
||||
}
|
||||
|
||||
function requestLedColorsStart()
|
||||
{
|
||||
window.ledStreamActive=true;
|
||||
sendToHyperion("ledcolors", "ledstream-start");
|
||||
window.ledStreamActive=true;
|
||||
sendToHyperion("ledcolors", "ledstream-start");
|
||||
}
|
||||
|
||||
function requestLedColorsStop()
|
||||
{
|
||||
window.ledStreamActive=false;
|
||||
sendToHyperion("ledcolors", "ledstream-stop");
|
||||
window.ledStreamActive=false;
|
||||
sendToHyperion("ledcolors", "ledstream-stop");
|
||||
}
|
||||
|
||||
function requestLedImageStart()
|
||||
{
|
||||
window.imageStreamActive=true;
|
||||
sendToHyperion("ledcolors", "imagestream-start");
|
||||
window.imageStreamActive=true;
|
||||
sendToHyperion("ledcolors", "imagestream-start");
|
||||
}
|
||||
|
||||
function requestLedImageStop()
|
||||
{
|
||||
window.imageStreamActive=false;
|
||||
sendToHyperion("ledcolors", "imagestream-stop");
|
||||
window.imageStreamActive=false;
|
||||
sendToHyperion("ledcolors", "imagestream-stop");
|
||||
}
|
||||
|
||||
function requestPriorityClear(prio)
|
||||
{
|
||||
if(typeof prio !== 'number')
|
||||
prio = window.webPrio;
|
||||
if(typeof prio !== 'number')
|
||||
prio = window.webPrio;
|
||||
|
||||
sendToHyperion("clear", "", '"priority":'+prio+'');
|
||||
sendToHyperion("clear", "", '"priority":'+prio+'');
|
||||
}
|
||||
|
||||
function requestClearAll()
|
||||
{
|
||||
requestPriorityClear(-1)
|
||||
requestPriorityClear(-1)
|
||||
}
|
||||
|
||||
function requestPlayEffect(effectName, duration)
|
||||
{
|
||||
sendToHyperion("effect", "", '"effect":{"name":"'+effectName+'"},"priority":'+window.webPrio+',"duration":'+validateDuration(duration)+',"origin":"'+window.webOrigin+'"');
|
||||
sendToHyperion("effect", "", '"effect":{"name":"'+effectName+'"},"priority":'+window.webPrio+',"duration":'+validateDuration(duration)+',"origin":"'+window.webOrigin+'"');
|
||||
}
|
||||
|
||||
function requestSetColor(r,g,b,duration)
|
||||
{
|
||||
sendToHyperion("color", "", '"color":['+r+','+g+','+b+'], "priority":'+window.webPrio+',"duration":'+validateDuration(duration)+',"origin":"'+window.webOrigin+'"');
|
||||
sendToHyperion("color", "", '"color":['+r+','+g+','+b+'], "priority":'+window.webPrio+',"duration":'+validateDuration(duration)+',"origin":"'+window.webOrigin+'"');
|
||||
}
|
||||
|
||||
function requestSetImage(data,duration,name)
|
||||
{
|
||||
sendToHyperion("image", "", '"imagedata":"'+data+'", "priority":'+window.webPrio+',"duration":'+validateDuration(duration)+', "format":"auto", "origin":"'+window.webOrigin+'", "name":"'+name+'"');
|
||||
sendToHyperion("image", "", '"imagedata":"'+data+'", "priority":'+window.webPrio+',"duration":'+validateDuration(duration)+', "format":"auto", "origin":"'+window.webOrigin+'", "name":"'+name+'"');
|
||||
}
|
||||
|
||||
function requestSetComponentState(comp, state)
|
||||
{
|
||||
var state_str = state ? "true" : "false";
|
||||
sendToHyperion("componentstate", "", '"componentstate":{"component":"'+comp+'","state":'+state_str+'}');
|
||||
var state_str = state ? "true" : "false";
|
||||
sendToHyperion("componentstate", "", '"componentstate":{"component":"'+comp+'","state":'+state_str+'}');
|
||||
}
|
||||
|
||||
function requestSetSource(prio)
|
||||
{
|
||||
if ( prio == "auto" )
|
||||
sendToHyperion("sourceselect", "", '"auto":true');
|
||||
else
|
||||
sendToHyperion("sourceselect", "", '"priority":'+prio);
|
||||
if ( prio == "auto" )
|
||||
sendToHyperion("sourceselect", "", '"auto":true');
|
||||
else
|
||||
sendToHyperion("sourceselect", "", '"priority":'+prio);
|
||||
}
|
||||
|
||||
function requestWriteConfig(config, full)
|
||||
{
|
||||
if(full === true)
|
||||
window.serverConfig = config;
|
||||
else
|
||||
{
|
||||
jQuery.each(config, function(i, val) {
|
||||
window.serverConfig[i] = val;
|
||||
});
|
||||
}
|
||||
if(full === true)
|
||||
window.serverConfig = config;
|
||||
else
|
||||
{
|
||||
jQuery.each(config, function(i, val) {
|
||||
window.serverConfig[i] = val;
|
||||
});
|
||||
}
|
||||
|
||||
sendToHyperion("config","setconfig", '"config":'+JSON.stringify(window.serverConfig));
|
||||
sendToHyperion("config","setconfig", '"config":'+JSON.stringify(window.serverConfig));
|
||||
}
|
||||
|
||||
function requestWriteEffect(effectName,effectPy,effectArgs,data)
|
||||
{
|
||||
var cutArgs = effectArgs.slice(1, -1);
|
||||
sendToHyperion("create-effect", "", '"name":"'+effectName+'", "script":"'+effectPy+'", '+cutArgs+',"imageData":"'+data+'"');
|
||||
var cutArgs = effectArgs.slice(1, -1);
|
||||
sendToHyperion("create-effect", "", '"name":"'+effectName+'", "script":"'+effectPy+'", '+cutArgs+',"imageData":"'+data+'"');
|
||||
}
|
||||
|
||||
function requestTestEffect(effectName,effectPy,effectArgs,data)
|
||||
{
|
||||
sendToHyperion("effect", "", '"effect":{"name":"'+effectName+'", "args":'+effectArgs+'}, "priority":'+window.webPrio+', "origin":"'+window.webOrigin+'", "pythonScript":"'+effectPy+'", "imageData":"'+data+'"');
|
||||
sendToHyperion("effect", "", '"effect":{"name":"'+effectName+'", "args":'+effectArgs+'}, "priority":'+window.webPrio+', "origin":"'+window.webOrigin+'", "pythonScript":"'+effectPy+'", "imageData":"'+data+'"');
|
||||
}
|
||||
|
||||
function requestDeleteEffect(effectName)
|
||||
{
|
||||
sendToHyperion("delete-effect", "", '"name":"'+effectName+'"');
|
||||
sendToHyperion("delete-effect", "", '"name":"'+effectName+'"');
|
||||
}
|
||||
|
||||
function requestLoggingStart()
|
||||
{
|
||||
window.loggingStreamActive=true;
|
||||
sendToHyperion("logging", "start");
|
||||
window.loggingStreamActive=true;
|
||||
sendToHyperion("logging", "start");
|
||||
}
|
||||
|
||||
function requestLoggingStop()
|
||||
{
|
||||
window.loggingStreamActive=false;
|
||||
sendToHyperion("logging", "stop");
|
||||
window.loggingStreamActive=false;
|
||||
sendToHyperion("logging", "stop");
|
||||
}
|
||||
|
||||
function requestMappingType(type)
|
||||
{
|
||||
sendToHyperion("processing", "", '"mappingType": "'+type+'"');
|
||||
sendToHyperion("processing", "", '"mappingType": "'+type+'"');
|
||||
}
|
||||
|
||||
function requestVideoMode(newMode)
|
||||
{
|
||||
sendToHyperion("videomode", "", '"videoMode": "'+newMode+'"');
|
||||
sendToHyperion("videomode", "", '"videoMode": "'+newMode+'"');
|
||||
}
|
||||
|
||||
function requestAdjustment(type, value, complete)
|
||||
{
|
||||
if(complete === true)
|
||||
sendToHyperion("adjustment", "", '"adjustment": '+type+'');
|
||||
else
|
||||
sendToHyperion("adjustment", "", '"adjustment": {"'+type+'": '+value+'}');
|
||||
if(complete === true)
|
||||
sendToHyperion("adjustment", "", '"adjustment": '+type+'');
|
||||
else
|
||||
sendToHyperion("adjustment", "", '"adjustment": {"'+type+'": '+value+'}');
|
||||
}
|
||||
|
||||
async function requestLedDeviceDiscovery(type, params)
|
||||
{
|
||||
let data = { ledDeviceType: type, params: params };
|
||||
let data = { ledDeviceType: type, params: params };
|
||||
|
||||
return sendAsyncToHyperion("leddevice", "discover", data, Math.floor(Math.random() * 1000) );
|
||||
return sendAsyncToHyperion("leddevice", "discover", data, Math.floor(Math.random() * 1000) );
|
||||
}
|
||||
|
||||
async function requestLedDeviceProperties(type, params)
|
||||
{
|
||||
let data = { ledDeviceType: type, params: params };
|
||||
let data = { ledDeviceType: type, params: params };
|
||||
|
||||
return sendAsyncToHyperion("leddevice", "getProperties", data, Math.floor(Math.random() * 1000));
|
||||
return sendAsyncToHyperion("leddevice", "getProperties", data, Math.floor(Math.random() * 1000));
|
||||
}
|
||||
|
||||
function requestLedDeviceIdentification(type, params)
|
||||
{
|
||||
//sendToHyperion("leddevice", "identify", '"ledDeviceType": "'+type+'","params": '+JSON.stringify(params)+'');
|
||||
let data = { ledDeviceType: type, params: params };
|
||||
return sendAsyncToHyperion("leddevice", "identify", data, Math.floor(Math.random() * 1000));
|
||||
|
||||
return sendAsyncToHyperion("leddevice", "identify", data, Math.floor(Math.random() * 1000));
|
||||
}
|
||||
|
||||
async function requestInputSourcesDiscovery(type, params) {
|
||||
let data = { sourceType: type, params: params };
|
||||
|
||||
return sendAsyncToHyperion("inputsource", "discover", data, Math.floor(Math.random() * 1000));
|
||||
}
|
||||
|
||||
|
33
assets/webconfig/js/languages.js
Normal file
33
assets/webconfig/js/languages.js
Normal file
@@ -0,0 +1,33 @@
|
||||
var storedLang;
|
||||
var availLang = ['cs', 'de', 'en', 'es', 'fr', 'it', 'nl', 'nb', 'pl', 'pt', 'ro', 'sv', 'vi', 'ru', 'tr', 'zh-CN'];
|
||||
var availLangText = ['Čeština', 'Deutsch', 'English', 'Español', 'Français', 'Italiano', 'Nederlands', 'Norsk Bokmål', 'Polski', 'Português', 'Română', 'Svenska', 'Tiếng Việt', 'русский', 'Türkçe', '汉语'];
|
||||
|
||||
//$.i18n.debug = true;
|
||||
|
||||
//i18n
|
||||
function initTrans(lc) {
|
||||
$.i18n().load("i18n", lc).done(
|
||||
function () {
|
||||
$.i18n().locale = lc;
|
||||
performTranslation();
|
||||
});
|
||||
}
|
||||
|
||||
storedLang = getStorage("langcode");
|
||||
if (storedLang == null || storedLang === "undefined") {
|
||||
|
||||
var langLocale = $.i18n().locale.substring(0, 2);
|
||||
//Test, if language is supported by hyperion
|
||||
var langIdx = availLang.indexOf(langLocale);
|
||||
if (langIdx === -1) {
|
||||
// If language is not supported by hyperion, try fallback language
|
||||
langLocale = $.i18n().options.fallbackLocale.substring(0, 2);
|
||||
langIdx = availLang.indexOf(langLocale);
|
||||
if (langIdx === -1) {
|
||||
langLocale = 'en';
|
||||
}
|
||||
}
|
||||
storedLang = langLocale;
|
||||
setStorage("langcode", storedLang);
|
||||
}
|
||||
initTrans(storedLang);
|
@@ -1,279 +1,329 @@
|
||||
$(document).ready(function() {
|
||||
var modalOpened = false;
|
||||
var ledsim_width = 540;
|
||||
var ledsim_height = 489;
|
||||
var dialog;
|
||||
var leds;
|
||||
var lC = false;
|
||||
var imageCanvasNodeCtx;
|
||||
var ledsCanvasNodeCtx;
|
||||
var canvas_height;
|
||||
var canvas_width;
|
||||
var twoDPaths = [];
|
||||
var toggleLeds, toggleLedsNum = false;
|
||||
$(document).ready(function () {
|
||||
var modalOpened = false;
|
||||
var ledsim_width = 540;
|
||||
var ledsim_height = 489;
|
||||
var dialog;
|
||||
var leds;
|
||||
var grabberConfig;
|
||||
var lC = false;
|
||||
var imageCanvasNodeCtx;
|
||||
var ledsCanvasNodeCtx;
|
||||
var canvas_height;
|
||||
var canvas_width;
|
||||
var twoDPaths = [];
|
||||
var toggleLeds = false;
|
||||
var toggleLedsNum = false;
|
||||
var toggleSigDetectArea = false;
|
||||
|
||||
/// add prototype for simple canvas clear() method
|
||||
CanvasRenderingContext2D.prototype.clear = function(){
|
||||
this.clearRect(0, 0, this.canvas.width, this.canvas.height)
|
||||
};
|
||||
var activeComponent = "";
|
||||
|
||||
function create2dPaths(){
|
||||
twoDPaths = [];
|
||||
for(var idx=0; idx<leds.length; idx++)
|
||||
{
|
||||
var led = leds[idx];
|
||||
twoDPaths.push( build2DPath(led.hmin * canvas_width, led.vmin * canvas_height, (led.hmax-led.hmin) * canvas_width, (led.vmax-led.vmin) * canvas_height, 5) );
|
||||
}
|
||||
}
|
||||
const image = new Image()
|
||||
image.src = "img/hyperion/logo_negativ.png",
|
||||
|
||||
/**
|
||||
* Draws a rounded rectangle into a new Path2D object, returns the created path.
|
||||
* If you omit the last three params, it will draw a rectangle
|
||||
* outline with a 5 pixel border radius
|
||||
* @param {Number} x The top left x coordinate
|
||||
* @param {Number} y The top left y coordinate
|
||||
* @param {Number} width The width of the rectangle
|
||||
* @param {Number} height The height of the rectangle
|
||||
* @param {Number} [radius = 5] The corner radius; It can also be an object
|
||||
* to specify different radii for corners
|
||||
* @param {Number} [radius.tl = 0] Top left
|
||||
* @param {Number} [radius.tr = 0] Top right
|
||||
* @param {Number} [radius.br = 0] Bottom right
|
||||
* @param {Number} [radius.bl = 0] Bottom left
|
||||
* @return {Path2D} The final path
|
||||
*/
|
||||
function build2DPath(x, y, width, height, radius) {
|
||||
if (typeof radius == 'number') {
|
||||
radius = {tl: radius, tr: radius, br: radius, bl: radius};
|
||||
} else {
|
||||
var defaultRadius = {tl: 0, tr: 0, br: 0, bl: 0};
|
||||
for (var side in defaultRadius) {
|
||||
radius[side] = radius[side] || defaultRadius[side];
|
||||
}
|
||||
}
|
||||
/// add prototype for simple canvas clear() method
|
||||
CanvasRenderingContext2D.prototype.clear = function () {
|
||||
this.clearRect(0, 0, this.canvas.width, this.canvas.height)
|
||||
};
|
||||
|
||||
var path = new Path2D();
|
||||
function create2dPaths() {
|
||||
twoDPaths = [];
|
||||
for (var idx = 0; idx < leds.length; idx++) {
|
||||
var led = leds[idx];
|
||||
twoDPaths.push(build2DPath(led.hmin * canvas_width, led.vmin * canvas_height, (led.hmax - led.hmin) * canvas_width, (led.vmax - led.vmin) * canvas_height, 5));
|
||||
}
|
||||
}
|
||||
|
||||
path.moveTo(x + radius.tl, y);
|
||||
path.lineTo(x + width - radius.tr, y);
|
||||
path.quadraticCurveTo(x + width, y, x + width, y + radius.tr);
|
||||
path.lineTo(x + width, y + height - radius.br);
|
||||
path.quadraticCurveTo(x + width, y + height, x + width - radius.br, y + height);
|
||||
path.lineTo(x + radius.bl, y + height);
|
||||
path.quadraticCurveTo(x, y + height, x, y + height - radius.bl);
|
||||
path.lineTo(x, y + radius.tl);
|
||||
path.quadraticCurveTo(x, y, x + radius.tl, y);
|
||||
/**
|
||||
* Draws a rounded rectangle into a new Path2D object, returns the created path.
|
||||
* If you omit the last three params, it will draw a rectangle
|
||||
* outline with a 5 pixel border radius
|
||||
* @param {Number} x The top left x coordinate
|
||||
* @param {Number} y The top left y coordinate
|
||||
* @param {Number} width The width of the rectangle
|
||||
* @param {Number} height The height of the rectangle
|
||||
* @param {Number} [radius = 5] The corner radius; It can also be an object
|
||||
* to specify different radii for corners
|
||||
* @param {Number} [radius.tl = 0] Top left
|
||||
* @param {Number} [radius.tr = 0] Top right
|
||||
* @param {Number} [radius.br = 0] Bottom right
|
||||
* @param {Number} [radius.bl = 0] Bottom left
|
||||
* @return {Path2D} The final path
|
||||
*/
|
||||
function build2DPath(x, y, width, height, radius) {
|
||||
if (typeof radius == 'number') {
|
||||
radius = { tl: radius, tr: radius, br: radius, bl: radius };
|
||||
} else {
|
||||
var defaultRadius = { tl: 0, tr: 0, br: 0, bl: 0 };
|
||||
for (var side in defaultRadius) {
|
||||
radius[side] = radius[side] || defaultRadius[side];
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
var path = new Path2D();
|
||||
|
||||
$(window.hyperion).one("ready",function(){
|
||||
leds = window.serverConfig.leds;
|
||||
path.moveTo(x + radius.tl, y);
|
||||
path.lineTo(x + width - radius.tr, y);
|
||||
path.quadraticCurveTo(x + width, y, x + width, y + radius.tr);
|
||||
path.lineTo(x + width, y + height - radius.br);
|
||||
path.quadraticCurveTo(x + width, y + height, x + width - radius.br, y + height);
|
||||
path.lineTo(x + radius.bl, y + height);
|
||||
path.quadraticCurveTo(x, y + height, x, y + height - radius.bl);
|
||||
path.lineTo(x, y + radius.tl);
|
||||
path.quadraticCurveTo(x, y, x + radius.tl, y);
|
||||
|
||||
if(window.showOptHelp)
|
||||
{
|
||||
createHint('intro', $.i18n('main_ledsim_text'), 'ledsim_text');
|
||||
$('#ledsim_text').css({'margin':'10px 15px 0px 15px'});
|
||||
$('#ledsim_text .bs-callout').css("margin","0px")
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
if(getStorage('ledsim_width') != null)
|
||||
{
|
||||
ledsim_width = getStorage('ledsim_width');
|
||||
ledsim_height = getStorage('ledsim_height');
|
||||
}
|
||||
$(window.hyperion).one("ready", function () {
|
||||
leds = window.serverConfig.leds;
|
||||
grabberConfig = window.serverConfig.grabberV4L2;
|
||||
|
||||
dialog = $("#ledsim_dialog").dialog({
|
||||
uiLibrary: 'bootstrap',
|
||||
resizable: true,
|
||||
modal: false,
|
||||
minWidth: 250,
|
||||
width: ledsim_width,
|
||||
minHeight: 350,
|
||||
height: ledsim_height,
|
||||
closeOnEscape: true,
|
||||
autoOpen: false,
|
||||
title: $.i18n('main_ledsim_title'),
|
||||
resize: function (e) {
|
||||
updateLedLayout();
|
||||
},
|
||||
opened: function (e) {
|
||||
if(!lC)
|
||||
{
|
||||
updateLedLayout();
|
||||
lC = true;
|
||||
}
|
||||
modalOpened = true;
|
||||
requestLedColorsStart();
|
||||
if (window.showOptHelp) {
|
||||
createHint('intro', $.i18n('main_ledsim_text'), 'ledsim_text');
|
||||
$('#ledsim_text').css({ 'margin': '10px 15px 0px 15px' });
|
||||
$('#ledsim_text .bs-callout').css("margin", "0px")
|
||||
}
|
||||
|
||||
setClassByBool('#leds_toggle_live_video', window.imageStreamActive, "btn-danger", "btn-success");
|
||||
if($('#leds_toggle_live_video').hasClass('btn-success'))
|
||||
requestLedImageStart();
|
||||
},
|
||||
closed: function (e) {
|
||||
modalOpened = false;
|
||||
},
|
||||
resizeStop: function (e) {
|
||||
setStorage("ledsim_width", $("#ledsim_dialog").outerWidth());
|
||||
setStorage("ledsim_height", $("#ledsim_dialog").outerHeight());
|
||||
}
|
||||
});
|
||||
// apply new serverinfos
|
||||
$(window.hyperion).on("cmd-config-getconfig",function(event){
|
||||
leds = event.response.info.leds;
|
||||
updateLedLayout();
|
||||
});
|
||||
});
|
||||
if (getStorage('ledsim_width') != null) {
|
||||
ledsim_width = getStorage('ledsim_width');
|
||||
ledsim_height = getStorage('ledsim_height');
|
||||
}
|
||||
|
||||
function printLedsToCanvas(colors)
|
||||
{
|
||||
// toggle leds, do not print
|
||||
if(toggleLeds)
|
||||
return;
|
||||
dialog = $("#ledsim_dialog").dialog({
|
||||
uiLibrary: 'bootstrap',
|
||||
resizable: true,
|
||||
modal: false,
|
||||
minWidth: 250,
|
||||
width: ledsim_width,
|
||||
minHeight: 350,
|
||||
height: ledsim_height,
|
||||
closeOnEscape: true,
|
||||
autoOpen: false,
|
||||
title: $.i18n('main_ledsim_title'),
|
||||
resize: function (e) {
|
||||
updateLedLayout();
|
||||
},
|
||||
opened: function (e) {
|
||||
if (!lC) {
|
||||
updateLedLayout();
|
||||
lC = true;
|
||||
}
|
||||
modalOpened = true;
|
||||
requestLedColorsStart();
|
||||
|
||||
var useColor = false;
|
||||
var cPos = 0;
|
||||
ledsCanvasNodeCtx.clear();
|
||||
if(typeof colors != "undefined")
|
||||
useColor = true;
|
||||
setClassByBool('#leds_toggle_live_video', window.imageStreamActive, "btn-danger", "btn-success");
|
||||
if ($('#leds_toggle_live_video').hasClass('btn-success'))
|
||||
requestLedImageStart();
|
||||
},
|
||||
closed: function (e) {
|
||||
modalOpened = false;
|
||||
lC = false;
|
||||
},
|
||||
resizeStop: function (e) {
|
||||
setStorage("ledsim_width", $("#ledsim_dialog").outerWidth());
|
||||
setStorage("ledsim_height", $("#ledsim_dialog").outerHeight());
|
||||
}
|
||||
});
|
||||
// apply new serverinfos
|
||||
$(window.hyperion).on("cmd-config-getconfig", function (event) {
|
||||
leds = event.response.info.leds;
|
||||
grabberConfig = event.response.info.grabberV4L2;
|
||||
updateLedLayout();
|
||||
});
|
||||
});
|
||||
|
||||
// check size of ledcolors with leds length
|
||||
if(colors && colors.length/3 < leds.length)
|
||||
return;
|
||||
function printLedsToCanvas(colors) {
|
||||
|
||||
for(var idx=0; idx<leds.length; idx++)
|
||||
{
|
||||
var led = leds[idx];
|
||||
// can be used as fallback when Path2D is not available
|
||||
//roundRect(ledsCanvasNodeCtx, led.hmin * canvas_width, led.vmin * canvas_height, (led.hmax-led.hmin) * canvas_width, (led.vmax-led.vmin) * canvas_height, 4, true, colors[idx])
|
||||
//ledsCanvasNodeCtx.fillRect(led.hmin * canvas_width, led.vmin * canvas_height, (led.hmax-led.hmin) * canvas_width, (led.vmax-led.vmin) * canvas_height);
|
||||
if (grabberConfig.enable && grabberConfig.signalDetection && toggleSigDetectArea && storedAccess === 'expert') {
|
||||
|
||||
ledsCanvasNodeCtx.fillStyle = (useColor) ? "rgba("+colors[cPos]+","+colors[cPos+1]+","+colors[cPos+2]+",0.75)" : "hsla("+(idx*360/leds.length)+",100%,50%,0.75)";
|
||||
ledsCanvasNodeCtx.fill(twoDPaths[idx]);
|
||||
ledsCanvasNodeCtx.stroke(twoDPaths[idx]);
|
||||
sigDetectAreaCanvasNodeCtx.setLineDash([5, 5]);
|
||||
sigDetectAreaCanvasNodeCtx.stroke(build2DPath(grabberConfig.sDHOffsetMin * canvas_width,
|
||||
grabberConfig.sDVOffsetMin * canvas_height,
|
||||
(grabberConfig.sDHOffsetMax - grabberConfig.sDHOffsetMin) * canvas_width,
|
||||
(grabberConfig.sDVOffsetMax - grabberConfig.sDVOffsetMin) * canvas_height,
|
||||
5));
|
||||
}
|
||||
|
||||
if(toggleLedsNum)
|
||||
{
|
||||
//ledsCanvasNodeCtx.shadowOffsetX = 1;
|
||||
//ledsCanvasNodeCtx.shadowOffsetY = 1;
|
||||
//ledsCanvasNodeCtx.shadowColor = "black";
|
||||
//ledsCanvasNodeCtx.shadowBlur = 4;
|
||||
ledsCanvasNodeCtx.fillStyle = "white";
|
||||
ledsCanvasNodeCtx.textAlign = "center";
|
||||
ledsCanvasNodeCtx.fillText(((led.name) ? led.name : idx), (led.hmin * canvas_width) + ( ((led.hmax-led.hmin) * canvas_width) / 2), (led.vmin * canvas_height) + ( ((led.vmax-led.vmin) * canvas_height) / 2));
|
||||
}
|
||||
// toggle leds, do not print
|
||||
if (toggleLeds)
|
||||
return;
|
||||
|
||||
// increment colorsPosition
|
||||
cPos += 3;
|
||||
}
|
||||
}
|
||||
var useColor = false;
|
||||
var cPos = 0;
|
||||
ledsCanvasNodeCtx.clear();
|
||||
if (typeof colors != "undefined")
|
||||
useColor = true;
|
||||
|
||||
function updateLedLayout()
|
||||
{
|
||||
//calculate body size
|
||||
canvas_height = $('#ledsim_dialog').outerHeight()-$('#ledsim_text').outerHeight()-$('[data-role=footer]').outerHeight()-$('[data-role=header]').outerHeight()-40;
|
||||
canvas_width = $('#ledsim_dialog').outerWidth()-30;
|
||||
// check size of ledcolors with leds length
|
||||
if (colors && colors.length / 3 < leds.length)
|
||||
return;
|
||||
|
||||
$('#leds_canvas').html("");
|
||||
var leds_html = '<canvas id="image_preview_canv" width="'+canvas_width+'" height="'+canvas_height+'" style="position: absolute; left: 0; top: 0; z-index: 99998;"></canvas>';
|
||||
leds_html += '<canvas id="leds_preview_canv" width="'+canvas_width+'" height="'+canvas_height+'" style="position: absolute; left: 0; top: 0; z-index: 99999;"></canvas>';
|
||||
for (var idx = 0; idx < leds.length; idx++) {
|
||||
var led = leds[idx];
|
||||
// can be used as fallback when Path2D is not available
|
||||
//roundRect(ledsCanvasNodeCtx, led.hmin * canvas_width, led.vmin * canvas_height, (led.hmax-led.hmin) * canvas_width, (led.vmax-led.vmin) * canvas_height, 4, true, colors[idx])
|
||||
//ledsCanvasNodeCtx.fillRect(led.hmin * canvas_width, led.vmin * canvas_height, (led.hmax-led.hmin) * canvas_width, (led.vmax-led.vmin) * canvas_height);
|
||||
|
||||
$('#leds_canvas').html(leds_html);
|
||||
ledsCanvasNodeCtx.fillStyle = (useColor) ? "rgba(" + colors[cPos] + "," + colors[cPos + 1] + "," + colors[cPos + 2] + ",0.75)" : "hsla(" + (idx * 360 / leds.length) + ",100%,50%,0.75)";
|
||||
ledsCanvasNodeCtx.fill(twoDPaths[idx]);
|
||||
ledsCanvasNodeCtx.strokeStyle = '#323232';
|
||||
ledsCanvasNodeCtx.stroke(twoDPaths[idx]);
|
||||
|
||||
imageCanvasNodeCtx = document.getElementById("image_preview_canv").getContext("2d");
|
||||
ledsCanvasNodeCtx = document.getElementById("leds_preview_canv").getContext("2d");
|
||||
create2dPaths();
|
||||
printLedsToCanvas();
|
||||
resetImage();
|
||||
}
|
||||
if (toggleLedsNum) {
|
||||
//ledsCanvasNodeCtx.shadowOffsetX = 1;
|
||||
//ledsCanvasNodeCtx.shadowOffsetY = 1;
|
||||
//ledsCanvasNodeCtx.shadowColor = "black";
|
||||
//ledsCanvasNodeCtx.shadowBlur = 4;
|
||||
ledsCanvasNodeCtx.fillStyle = "white";
|
||||
ledsCanvasNodeCtx.textAlign = "center";
|
||||
ledsCanvasNodeCtx.fillText(((led.name) ? led.name : idx), (led.hmin * canvas_width) + (((led.hmax - led.hmin) * canvas_width) / 2), (led.vmin * canvas_height) + (((led.vmax - led.vmin) * canvas_height) / 2));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
$('#leds_toggle_num').off().on("click", function() {
|
||||
toggleLedsNum = !toggleLedsNum
|
||||
toggleClass('#leds_toggle_num', "btn-danger", "btn-success");
|
||||
});
|
||||
// ------------------------------------------------------------------
|
||||
// increment colorsPosition
|
||||
cPos += 3;
|
||||
}
|
||||
}
|
||||
|
||||
$('#leds_toggle').off().on("click", function() {
|
||||
toggleLeds = !toggleLeds
|
||||
ledsCanvasNodeCtx.clear();
|
||||
toggleClass('#leds_toggle', "btn-success", "btn-danger");
|
||||
});
|
||||
function updateLedLayout() {
|
||||
if (grabberConfig.enable && grabberConfig.signalDetection && storedAccess === 'expert') {
|
||||
$("#sigDetectArea_toggle").show();
|
||||
} else {
|
||||
$("#sigDetectArea_toggle").hide();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
$('#leds_toggle_live_video').off().on("click", function() {
|
||||
setClassByBool('#leds_toggle_live_video',window.imageStreamActive,"btn-success","btn-danger");
|
||||
if ( window.imageStreamActive )
|
||||
{
|
||||
requestLedImageStop();
|
||||
resetImage();
|
||||
}
|
||||
else
|
||||
{
|
||||
requestLedImageStart();
|
||||
}
|
||||
});
|
||||
//calculate body size
|
||||
canvas_height = $('#ledsim_dialog').outerHeight() - $('#ledsim_text').outerHeight() - $('[data-role=footer]').outerHeight() - $('[data-role=header]').outerHeight() - 40;
|
||||
canvas_width = $('#ledsim_dialog').outerWidth() - 30;
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
$(window.hyperion).on("cmd-ledcolors-ledstream-update",function(event){
|
||||
if (!modalOpened)
|
||||
{
|
||||
requestLedColorsStop();
|
||||
}
|
||||
else
|
||||
{
|
||||
printLedsToCanvas(event.response.result.leds)
|
||||
}
|
||||
});
|
||||
$('#leds_canvas').html("");
|
||||
var leds_html = '<canvas id="image_preview_canv" width="' + canvas_width + '" height="' + canvas_height + '" style="position: absolute; left: 0; top: 0; z-index: 99998;"></canvas>';
|
||||
leds_html += '<canvas id="leds_preview_canv" width="' + canvas_width + '" height="' + canvas_height + '" style="position: absolute; left: 0; top: 0; z-index: 99999;"></canvas>';
|
||||
leds_html += '<canvas id="grab_preview_canv" width="' + canvas_width + '" height="' + canvas_height + '" style="position: absolute; left: 0; top: 0; z-index: 99999;"></canvas>';
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
$(window.hyperion).on("cmd-ledcolors-imagestream-update",function(event){
|
||||
setClassByBool('#leds_toggle_live_video', window.imageStreamActive, "btn-danger", "btn-success");
|
||||
if (!modalOpened)
|
||||
{
|
||||
if ($('#leds_prev_toggle_live_video').length > 0)
|
||||
return;
|
||||
requestLedImageStop();
|
||||
}
|
||||
else
|
||||
{
|
||||
var imageData = (event.response.result.image);
|
||||
$('#leds_canvas').html(leds_html);
|
||||
|
||||
var image = new Image();
|
||||
image.onload = function() {
|
||||
imageCanvasNodeCtx.drawImage(image, 0, 0, canvas_width, canvas_height);
|
||||
};
|
||||
image.src = imageData;
|
||||
}
|
||||
});
|
||||
imageCanvasNodeCtx = document.getElementById("image_preview_canv").getContext("2d");
|
||||
ledsCanvasNodeCtx = document.getElementById("leds_preview_canv").getContext("2d");
|
||||
sigDetectAreaCanvasNodeCtx = document.getElementById("grab_preview_canv").getContext("2d");
|
||||
create2dPaths();
|
||||
printLedsToCanvas();
|
||||
resetImage();
|
||||
|
||||
$("#btn_open_ledsim").off().on("click", function(event) {
|
||||
dialog.open();
|
||||
});
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
$(window.hyperion).on("cmd-settings-update",function(event){
|
||||
// ------------------------------------------------------------------
|
||||
$('#leds_toggle_num').off().on("click", function () {
|
||||
toggleLedsNum = !toggleLedsNum
|
||||
toggleClass('#leds_toggle_num', "btn-danger", "btn-success");
|
||||
});
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
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();
|
||||
}
|
||||
});
|
||||
$('#leds_toggle').off().on("click", function () {
|
||||
toggleLeds = !toggleLeds
|
||||
ledsCanvasNodeCtx.clear();
|
||||
toggleClass('#leds_toggle', "btn-success", "btn-danger");
|
||||
|
||||
function resetImage(){
|
||||
if (getStorage("darkMode", false) == "on") {
|
||||
imageCanvasNodeCtx.clear();
|
||||
} else {
|
||||
imageCanvasNodeCtx.fillStyle = "rgb(225,225,225)"
|
||||
imageCanvasNodeCtx.fillRect(0, 0, canvas_width, canvas_height);
|
||||
}
|
||||
if (!toggleLeds) {
|
||||
$("#leds_toggle_num").show();
|
||||
} else {
|
||||
$("#leds_toggle_num").hide();
|
||||
}
|
||||
});
|
||||
|
||||
var image = document.getElementById('navbar_brand_logo');
|
||||
imageCanvasNodeCtx.drawImage(image, canvas_width / 2 - image.width / 2, canvas_height / 2 - image.height / 2, image.width, image.height);
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
$('#leds_toggle_live_video').off().on("click", function () {
|
||||
setClassByBool('#leds_toggle_live_video', window.imageStreamActive, "btn-success", "btn-danger");
|
||||
if (window.imageStreamActive) {
|
||||
requestLedImageStop();
|
||||
resetImage();
|
||||
}
|
||||
else {
|
||||
requestLedImageStart();
|
||||
}
|
||||
});
|
||||
|
||||
$('#sigDetectArea_toggle').off().on("click", function () {
|
||||
toggleSigDetectArea = !toggleSigDetectArea
|
||||
sigDetectAreaCanvasNodeCtx.clear();
|
||||
toggleClass('#sigDetectArea_toggle', "btn-success", "btn-danger");
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
$(window.hyperion).on("cmd-ledcolors-ledstream-update", function (event) {
|
||||
if (!modalOpened) {
|
||||
requestLedColorsStop();
|
||||
}
|
||||
else {
|
||||
printLedsToCanvas(event.response.result.leds)
|
||||
}
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
$(window.hyperion).on("cmd-ledcolors-imagestream-update", function (event) {
|
||||
//console.log("cmd-ledcolors-imagestream-update", event.response);
|
||||
setClassByBool('#leds_toggle_live_video', window.imageStreamActive, "btn-danger", "btn-success");
|
||||
if (!modalOpened) {
|
||||
if ($('#leds_prev_toggle_live_video').length > 0)
|
||||
return;
|
||||
requestLedImageStop();
|
||||
}
|
||||
else {
|
||||
var imageData = (event.response.result.image);
|
||||
|
||||
var image = new Image();
|
||||
image.onload = function () {
|
||||
imageCanvasNodeCtx.drawImage(image, 0, 0, canvas_width, canvas_height);
|
||||
};
|
||||
image.src = imageData;
|
||||
}
|
||||
});
|
||||
|
||||
$("#btn_open_ledsim").off().on("click", function (event) {
|
||||
dialog.open();
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
$(window.hyperion).on("cmd-settings-update", function (event) {
|
||||
|
||||
var obj = event.response.data
|
||||
if (obj.leds || obj.grabberV4L2) {
|
||||
//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;
|
||||
grabberConfig = window.serverConfig.grabberV4L2;
|
||||
updateLedLayout();
|
||||
}
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-priorities-update", function (event) {
|
||||
//console.log("cmd-priorities-update", event.response.data);
|
||||
|
||||
var prios = event.response.data.priorities;
|
||||
if (prios.length > 0)
|
||||
{
|
||||
//Clear image when new input
|
||||
if (prios[0].componentId !== activeComponent) {
|
||||
resetImage();
|
||||
activeComponent = prios[0].componentId;
|
||||
}
|
||||
else if (!prios[0].active) {
|
||||
resetImage();
|
||||
}
|
||||
}
|
||||
else {
|
||||
resetImage();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function resetImage() {
|
||||
if (typeof imageCanvasNodeCtx !== "undefined") {
|
||||
|
||||
imageCanvasNodeCtx.fillStyle = "#1c1c1c"; //90% gray
|
||||
imageCanvasNodeCtx.fillRect(0, 0, canvas_width, canvas_height);
|
||||
imageCanvasNodeCtx.drawImage(image, canvas_width / 2 - image.width / 2, canvas_height / 2 - image.height / 2, image.width, image.height);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@@ -1839,7 +1839,14 @@ JSONEditor.AbstractEditor = Class.extend({
|
||||
this.parent = null;
|
||||
},
|
||||
getDefault: function() {
|
||||
if(this.schema["default"]) return this.schema["default"];
|
||||
var def = this.schema["default"];
|
||||
if(def) {
|
||||
if (typeof def === "string") {
|
||||
return $.i18n(def);
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
if(this.schema["enum"]) return this.schema["enum"][0];
|
||||
|
||||
var type = this.schema.type || this.schema.oneOf;
|
||||
|
@@ -1,149 +1,111 @@
|
||||
var storedAccess;
|
||||
var storedLang;
|
||||
var availLang = ['cs', 'de', 'en', 'es', 'fr', 'it', 'nl', 'nb', 'pl', 'pt', 'ro', 'sv', 'vi', 'ru', 'tr', 'zh-CN'];
|
||||
var availLangText = ['Čeština', 'Deutsch', 'English', 'Español', 'Français', 'Italiano', 'Nederlands', 'Norsk Bokmål', 'Polski', 'Português', 'Română', 'Svenska', 'Tiếng Việt', 'русский', 'Türkçe', '汉语'];
|
||||
var availAccess = ['default', 'advanced', 'expert'];
|
||||
|
||||
//$.i18n.debug = true;
|
||||
var storedAccess;
|
||||
|
||||
//Change Password
|
||||
function changePassword(){
|
||||
showInfoDialog('changePassword', $.i18n('InfoDialog_changePassword_title'));
|
||||
showInfoDialog('changePassword', $.i18n('InfoDialog_changePassword_title'));
|
||||
|
||||
// fill default pw if default is set
|
||||
if(window.defaultPasswordIsSet)
|
||||
$('#oldPw').val('hyperion')
|
||||
// fill default pw if default is set
|
||||
if(window.defaultPasswordIsSet)
|
||||
$('#oldPw').val('hyperion')
|
||||
|
||||
$('#id_btn_ok').off().on('click',function() {
|
||||
var oldPw = $('#oldPw').val();
|
||||
var newPw = $('#newPw').val();
|
||||
$('#id_btn_ok').off().on('click',function() {
|
||||
var oldPw = $('#oldPw').val();
|
||||
var newPw = $('#newPw').val();
|
||||
|
||||
requestChangePassword(oldPw, newPw)
|
||||
});
|
||||
requestChangePassword(oldPw, newPw)
|
||||
});
|
||||
|
||||
$('#newPw, #oldPw').off().on('input',function(e) {
|
||||
($('#oldPw').val().length >= 8 && $('#newPw').val().length >= 8) && !window.readOnlyMode ? $('#id_btn_ok').attr('disabled', false) : $('#id_btn_ok').attr('disabled', true);
|
||||
});
|
||||
$('#newPw, #oldPw').off().on('input',function(e) {
|
||||
($('#oldPw').val().length >= 8 && $('#newPw').val().length >= 8) && !window.readOnlyMode ? $('#id_btn_ok').attr('disabled', false) : $('#id_btn_ok').attr('disabled', true);
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready( function() {
|
||||
$(document).ready(function () {
|
||||
|
||||
//i18n
|
||||
function initTrans(lc){
|
||||
if (lc == 'auto')
|
||||
{
|
||||
$.i18n().load().done(
|
||||
function() {
|
||||
performTranslation();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$.i18n().locale = lc;
|
||||
$.i18n().load( "i18n", lc ).done(
|
||||
function() {
|
||||
performTranslation();
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!storageComp()) {
|
||||
showInfoDialog('warning', "Can't store settings", "Your browser doesn't support localStorage. You can't save a specific language setting (fallback to 'auto detection') and access level (fallback to 'default'). Some wizards may be hidden. You could still use the webinterface without further issues");
|
||||
$('#language-select').attr("disabled", true);
|
||||
$('#btn_setaccess').attr("disabled", true);
|
||||
}
|
||||
|
||||
if (storageComp())
|
||||
{
|
||||
storedLang = getStorage("langcode");
|
||||
if (storedLang == null)
|
||||
{
|
||||
setStorage("langcode", 'auto');
|
||||
storedLang = 'auto';
|
||||
initTrans(storedLang);
|
||||
}
|
||||
else
|
||||
{
|
||||
initTrans(storedLang);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
showInfoDialog('warning', "Can't store settings", "Your browser doesn't support localStorage. You can't save a specific language setting (fallback to 'auto detection') and access level (fallback to 'default'). Some wizards may be hidden. You could still use the webinterface without further issues");
|
||||
initTrans('auto');
|
||||
storedLang = 'auto';
|
||||
storedAccess = "default";
|
||||
$('#btn_setlang').attr("disabled", true);
|
||||
$('#btn_setaccess').attr("disabled", true);
|
||||
}
|
||||
initLanguageSelection();
|
||||
|
||||
initLanguageSelection();
|
||||
//access
|
||||
storedAccess = getStorage("accesslevel");
|
||||
if (storedAccess == null) {
|
||||
storedAccess = "default";
|
||||
setStorage("accesslevel", storedAccess);
|
||||
}
|
||||
|
||||
//access
|
||||
storedAccess = getStorage("accesslevel");
|
||||
if (storedAccess == null)
|
||||
{
|
||||
setStorage("accesslevel", "default");
|
||||
storedAccess = "default";
|
||||
}
|
||||
if (!storageComp()) {
|
||||
showInfoDialog('warning', $.i18n('InfoDialog_nostorage_title'), $.i18n('InfoDialog_nostorage_text'));
|
||||
$('#btn_setlang').attr("disabled", true);
|
||||
}
|
||||
|
||||
$('#btn_setaccess').off().on('click',function() {
|
||||
var newAccess;
|
||||
showInfoDialog('select', $.i18n('InfoDialog_access_title'), $.i18n('InfoDialog_access_text'));
|
||||
$('#btn_setaccess').off().on('click',function() {
|
||||
var newAccess;
|
||||
showInfoDialog('select', $.i18n('InfoDialog_access_title'), $.i18n('InfoDialog_access_text'));
|
||||
|
||||
for (var lcx = 0; lcx<availAccess.length; lcx++)
|
||||
{
|
||||
$('#id_select').append(createSelOpt(availAccess[lcx], $.i18n('general_access_'+availAccess[lcx])));
|
||||
}
|
||||
for (var lcx = 0; lcx<availAccess.length; lcx++)
|
||||
{
|
||||
$('#id_select').append(createSelOpt(availAccess[lcx], $.i18n('general_access_'+availAccess[lcx])));
|
||||
}
|
||||
|
||||
$('#id_select').val(storedAccess);
|
||||
$('#id_select').val(storedAccess);
|
||||
|
||||
$('#id_select').off().on('change',function() {
|
||||
newAccess = $('#id_select').val();
|
||||
if (newAccess == storedAccess)
|
||||
$('#id_btn_saveset').attr('disabled', true);
|
||||
else
|
||||
$('#id_btn_saveset').attr('disabled', false);
|
||||
});
|
||||
$('#id_select').off().on('change',function() {
|
||||
newAccess = $('#id_select').val();
|
||||
if (newAccess == storedAccess)
|
||||
$('#id_btn_saveset').attr('disabled', true);
|
||||
else
|
||||
$('#id_btn_saveset').attr('disabled', false);
|
||||
});
|
||||
|
||||
$('#id_btn_saveset').off().on('click',function() {
|
||||
setStorage("accesslevel", newAccess);
|
||||
reload();
|
||||
});
|
||||
$('#id_btn_saveset').off().on('click',function() {
|
||||
setStorage("accesslevel", newAccess);
|
||||
reload();
|
||||
});
|
||||
|
||||
$('#id_select').trigger('change');
|
||||
});
|
||||
$('#id_select').trigger('change');
|
||||
});
|
||||
|
||||
// change pw btn
|
||||
$('#btn_changePassword').off().on('click',function() {
|
||||
changePassword();
|
||||
});
|
||||
// change pw btn
|
||||
$('#btn_changePassword').off().on('click',function() {
|
||||
changePassword();
|
||||
});
|
||||
|
||||
//Lock Ui
|
||||
$('#btn_lock_ui').off().on('click',function() {
|
||||
removeStorage('loginToken', true);
|
||||
location.replace('/');
|
||||
});
|
||||
//Lock Ui
|
||||
$('#btn_lock_ui').off().on('click',function() {
|
||||
removeStorage('loginToken', true);
|
||||
location.replace('/');
|
||||
});
|
||||
|
||||
//hide menu elements
|
||||
if (storedAccess != 'expert')
|
||||
$('#load_webconfig').toggle(false);
|
||||
//hide menu elements
|
||||
if (storedAccess != 'expert')
|
||||
$('#load_webconfig').toggle(false);
|
||||
|
||||
|
||||
// instance switcher
|
||||
$('#btn_instanceswitch').off().on('click',function() {
|
||||
var lsys = window.sysInfo.system.hostName+':'+window.serverConfig.webConfig.port;
|
||||
showInfoDialog('iswitch', $.i18n('InfoDialog_iswitch_title'), $.i18n('InfoDialog_iswitch_text'));
|
||||
// instance switcher
|
||||
$('#btn_instanceswitch').off().on('click',function() {
|
||||
var lsys = window.sysInfo.system.hostName+':'+window.serverConfig.webConfig.port;
|
||||
showInfoDialog('iswitch', $.i18n('InfoDialog_iswitch_title'), $.i18n('InfoDialog_iswitch_text'));
|
||||
|
||||
for (var i = 0; i<window.wSess.length; i++)
|
||||
{
|
||||
if(lsys != window.wSess[i].host+':'+window.wSess[i].port)
|
||||
{
|
||||
var hyperionAddress = window.wSess[i].address;
|
||||
if(hyperionAddress.indexOf(':') > -1 && hyperionAddress.length == 36) hyperionAddress = '['+hyperionAddress+']';
|
||||
hyperionAddress = 'http://'+hyperionAddress+':'+window.wSess[i].port;
|
||||
$('#id_select').append(createSelOpt(hyperionAddress, window.wSess[i].name));
|
||||
}
|
||||
}
|
||||
for (var i = 0; i<window.wSess.length; i++)
|
||||
{
|
||||
if(lsys != window.wSess[i].host+':'+window.wSess[i].port)
|
||||
{
|
||||
var hyperionAddress = window.wSess[i].address;
|
||||
if(hyperionAddress.indexOf(':') > -1 && hyperionAddress.length == 36) hyperionAddress = '['+hyperionAddress+']';
|
||||
hyperionAddress = 'http://'+hyperionAddress+':'+window.wSess[i].port;
|
||||
$('#id_select').append(createSelOpt(hyperionAddress, window.wSess[i].name));
|
||||
}
|
||||
}
|
||||
|
||||
$('#id_btn_saveset').off().on('click',function() {
|
||||
$("#loading_overlay").addClass("overlay");
|
||||
window.location.href = $('#id_select').val();
|
||||
});
|
||||
$('#id_btn_saveset').off().on('click',function() {
|
||||
$("#loading_overlay").addClass("overlay");
|
||||
window.location.href = $('#id_select').val();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
100
assets/webconfig/js/ui_utils.js
Executable file → Normal file
100
assets/webconfig/js/ui_utils.js
Executable file → Normal file
@@ -67,7 +67,7 @@ function updateSessions() {
|
||||
|
||||
function validateDuration(d) {
|
||||
if (typeof d === "undefined" || d < 0)
|
||||
return 0;
|
||||
return ENDLESS;
|
||||
else
|
||||
return d *= 1000;
|
||||
}
|
||||
@@ -162,25 +162,22 @@ function initLanguageSelection() {
|
||||
|
||||
var langLocale = storedLang;
|
||||
|
||||
// If no language has been set, resolve browser locale
|
||||
if (langLocale === 'auto') {
|
||||
langLocale = $.i18n().locale.substring(0, 2);
|
||||
}
|
||||
|
||||
// Resolve text for language code
|
||||
var langText = 'Please Select';
|
||||
|
||||
//Test, if language is supported by hyperion
|
||||
var langIdx = availLang.indexOf(langLocale);
|
||||
if (langIdx > -1) {
|
||||
langText = availLangText[langIdx];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// If language is not supported by hyperion, try fallback language
|
||||
langLocale = $.i18n().options.fallbackLocale.substring(0, 2);
|
||||
langIdx = availLang.indexOf(langLocale);
|
||||
if (langIdx > -1) {
|
||||
langText = availLangText[langIdx];
|
||||
} else {
|
||||
langLocale = 'en';
|
||||
langIdx = availLang.indexOf(langLocale);
|
||||
if (langIdx > -1) {
|
||||
langText = availLangText[langIdx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,10 +192,12 @@ function updateUiOnInstance(inst) {
|
||||
$('#btn_hypinstanceswitch').toggle(true);
|
||||
$('#active_instance_dropdown').prop('disabled', false);
|
||||
$('#active_instance_dropdown').css('cursor', 'pointer');
|
||||
$("#active_instance_dropdown").css("pointer-events", "auto");
|
||||
} else {
|
||||
$('#btn_hypinstanceswitch').toggle(false);
|
||||
$('#active_instance_dropdown').prop('disabled', true);
|
||||
$("#active_instance_dropdown").css('cursor', 'default');
|
||||
$("#active_instance_dropdown").css("pointer-events", "none");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,10 +287,12 @@ function showInfoDialog(type, header, message) {
|
||||
}
|
||||
else if (type == "changePassword") {
|
||||
$('#id_body_rename').html('<i style="margin-bottom:20px" class="fa fa-key modal-icon-edit"><br>');
|
||||
$('#id_body_rename').append('<h4>' + header + '</h4>');
|
||||
$('#id_body_rename').append('<input class="form-control" id="oldPw" placeholder="Old" type="text"> <br />');
|
||||
$('#id_body_rename').append('<input class="form-control" id="newPw" placeholder="New" type="password">');
|
||||
$('#id_footer_rename').html('<button type="button" id="id_btn_ok" class="btn btn-success" data-dismiss-modal="#modal_dialog_rename" disabled><i class="fa fa-fw fa-save"></i>' + $.i18n('general_btn_ok') + '</button>');
|
||||
$('#id_body_rename').append('<h4>' + header + '</h4><br>');
|
||||
$('#id_body_rename').append('<div class="row"><div class="col-md-3"><p class="text-left">' + $.i18n('infoDialog_password_current_text') +
|
||||
'</p></div><div class="col-md-8"><input class="form-control" id="oldPw" placeholder="Old" type="password"></div></div><br>');
|
||||
$('#id_body_rename').append('<div class="row"><div class="col-md-3"><p class="text-left">' + $.i18n('infoDialog_password_new_text')+
|
||||
'</p></div><div class="col-md-8"><input class="form-control" id="newPw" placeholder="New" type="password"></div></div>');
|
||||
$('#id_footer_rename').html('<button type="button" id="id_btn_ok" class="btn btn-success" data-dismiss-modal="#modal_dialog_rename" disabled><i class="fa fa-fw fa-save"></ul>' + $.i18n('general_btn_ok') + '</button>');
|
||||
$('#id_footer_rename').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>' + $.i18n('general_btn_cancel') + '</button>');
|
||||
}
|
||||
else if (type == "checklist") {
|
||||
@@ -461,7 +462,8 @@ function createJsonEditor(container, schema, setconfig, usePanel, arrayre) {
|
||||
return editor;
|
||||
}
|
||||
|
||||
function updateJsonEditorSelection(editor, key, addElements, newEnumVals, newTitelVals, newDefaultVal, addSelect, addCustom, addCustomAsFirst, customText) {
|
||||
function updateJsonEditorSelection(rootEditor, path, key, addElements, newEnumVals, newTitelVals, newDefaultVal, addSelect, addCustom, addCustomAsFirst, customText) {
|
||||
var editor = rootEditor.getEditor(path);
|
||||
var orginalProperties = editor.schema.properties[key];
|
||||
|
||||
var newSchema = [];
|
||||
@@ -536,13 +538,15 @@ function updateJsonEditorSelection(editor, key, addElements, newEnumVals, newTit
|
||||
|
||||
editor.original_schema.properties[key] = orginalProperties;
|
||||
editor.schema.properties[key] = newSchema[key];
|
||||
rootEditor.validator.schema.properties[editor.key].properties[key] = newSchema[key];
|
||||
|
||||
editor.removeObjectProperty(key);
|
||||
delete editor.cached_editors[key];
|
||||
editor.addObjectProperty(key);
|
||||
}
|
||||
|
||||
function updateJsonEditorMultiSelection(editor, key, addElements, newEnumVals, newTitelVals, newDefaultVal) {
|
||||
function updateJsonEditorMultiSelection(rootEditor, path, key, addElements, newEnumVals, newTitelVals, newDefaultVal) {
|
||||
var editor = rootEditor.getEditor(path);
|
||||
var orginalProperties = editor.schema.properties[key];
|
||||
|
||||
var newSchema = [];
|
||||
@@ -593,36 +597,55 @@ function updateJsonEditorMultiSelection(editor, key, addElements, newEnumVals, n
|
||||
|
||||
editor.original_schema.properties[key] = orginalProperties;
|
||||
editor.schema.properties[key] = newSchema[key];
|
||||
rootEditor.validator.schema.properties[editor.key].properties[key] = newSchema[key];
|
||||
|
||||
editor.removeObjectProperty(key);
|
||||
delete editor.cached_editors[key];
|
||||
editor.addObjectProperty(key);
|
||||
}
|
||||
|
||||
function updateJsonEditorRange(editor, key, minimum, maximum, defaultValue, step) {
|
||||
function updateJsonEditorRange(rootEditor, path, key, minimum, maximum, defaultValue, step, clear) {
|
||||
var editor = rootEditor.getEditor(path);
|
||||
|
||||
//Preserve current value when updating range
|
||||
var currentValue = rootEditor.getEditor(path + "." + key).getValue();
|
||||
|
||||
var orginalProperties = editor.schema.properties[key];
|
||||
var newSchema = [];
|
||||
newSchema[key] = orginalProperties;
|
||||
|
||||
if (minimum) {
|
||||
if (clear) {
|
||||
delete newSchema[key]["minimum"];
|
||||
delete newSchema[key]["maximum"];
|
||||
delete newSchema[key]["default"];
|
||||
delete newSchema[key]["step"];
|
||||
}
|
||||
|
||||
if (typeof minimum !== "undefined") {
|
||||
newSchema[key]["minimum"] = minimum;
|
||||
}
|
||||
if (maximum) {
|
||||
if (typeof maximum !== "undefined") {
|
||||
newSchema[key]["maximum"] = maximum;
|
||||
}
|
||||
if (defaultValue) {
|
||||
if (typeof defaultValue !== "undefined") {
|
||||
newSchema[key]["default"] = defaultValue;
|
||||
currentValue = defaultValue;
|
||||
}
|
||||
if (step) {
|
||||
|
||||
if (typeof step !== "undefined") {
|
||||
newSchema[key]["step"] = step;
|
||||
}
|
||||
|
||||
editor.original_schema.properties[key] = orginalProperties;
|
||||
editor.schema.properties[key] = newSchema[key];
|
||||
rootEditor.validator.schema.properties[editor.key].properties[key] = newSchema[key];
|
||||
|
||||
editor.removeObjectProperty(key);
|
||||
delete editor.cached_editors[key];
|
||||
editor.addObjectProperty(key);
|
||||
|
||||
// Restore current (new default) value for new range
|
||||
rootEditor.getEditor(path + "." + key).setValue(currentValue);
|
||||
}
|
||||
|
||||
function buildWL(link, linkt, cl) {
|
||||
@@ -807,14 +830,15 @@ function createRow(id) {
|
||||
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;
|
||||
|
||||
var pfooter = document.createElement('button');
|
||||
pfooter.className = "btn btn-primary";
|
||||
pfooter.setAttribute("id", footerid);
|
||||
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') {
|
||||
@@ -1141,14 +1165,34 @@ function isAccessLevelCompliant(accessLevel) {
|
||||
|
||||
function showInputOptions(path, elements, state) {
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
$('[data-schemapath="' + path + '.' + elements[i] + '"]').toggle(state);
|
||||
$('[data-schemapath="root.' + path + '.' + elements[i] + '"]').toggle(state);
|
||||
}
|
||||
}
|
||||
|
||||
function showInputOptionsForKey(editor, item, showForKey, state) {
|
||||
function showInputOptionForItem(editor, path, item, state) {
|
||||
var accessLevel = editor.schema.properties[path].properties[item].access;
|
||||
// Enable element only, if access level compliant
|
||||
if (!state || isAccessLevelCompliant(accessLevel)) {
|
||||
showInputOptions(path, [item], state);
|
||||
}
|
||||
}
|
||||
|
||||
function showInputOptionsForKey(editor, item, showForKeys, state) {
|
||||
var elements = [];
|
||||
var keysToshow = [];
|
||||
|
||||
if (Array.isArray(showForKeys)) {
|
||||
keysToshow = showForKeys;
|
||||
} else {
|
||||
if (typeof showForKeys === 'string') {
|
||||
keysToshow.push(showForKeys);
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for (var key in editor.schema.properties[item].properties) {
|
||||
if (showForKey !== key) {
|
||||
if ($.inArray(key, keysToshow) === -1) {
|
||||
var accessLevel = editor.schema.properties[item].properties[key].access;
|
||||
|
||||
//Always disable all elements, but only enable elements, if access level compliant
|
||||
@@ -1157,5 +1201,5 @@ function showInputOptionsForKey(editor, item, showForKey, state) {
|
||||
}
|
||||
}
|
||||
}
|
||||
showInputOptions("root." + item, elements, state);
|
||||
showInputOptions(item, elements, state);
|
||||
}
|
||||
|
Reference in New Issue
Block a user