Refactor event handling incl.CEC

This commit is contained in:
LordGrey
2023-11-06 21:40:12 +01:00
parent b1c8534cb7
commit 0d9a8b8a3a
39 changed files with 1306 additions and 1158 deletions

View File

@@ -192,8 +192,8 @@
"conf_network_tok_intro": "Here you can create and delete tokens for API authentication. Created tokens will only be displayed once.",
"conf_network_tok_lastuse": "Last use",
"conf_network_tok_title": "Token Management",
"conf_system_events_heading_title": "System Events",
"conf_system_events_intro": "Settings related to diffent Operating System events Hyperion can handle",
"conf_os_events_heading_title": "Operating System Events",
"conf_os_events_intro": "Settings related to diffent Operating System events Hyperion can handle",
"conf_webconfig_label_intro": "Webconfiguration settings. Edit wisely.",
"dashboard_active_instance": "Selected instance",
"dashboard_alert_message_confedit": "Your Hyperion configuration has been modified. To apply it, restart Hyperion.",
@@ -457,6 +457,12 @@
"edt_conf_net_localApiAuth_title": "Local API Authentication",
"edt_conf_net_restirctedInternetAccessAPI_expl": "You can restrict the access to the API through the internet to certain IP's.",
"edt_conf_net_restirctedInternetAccessAPI_title": "Restrict to IP's",
"edt_conf_os_events_lockEnable_title": "Listen to lock events",
"edt_conf_os_events_lockEnable_expl": "Listen to screen lock/unlock events",
"edt_conf_os_events_suspendEnable_title": "Listen to suspend events",
"edt_conf_os_events_suspendEnable_expl": "Listen to operating system suspend/resume events",
"edt_conf_os_events_suspendOnLockEnable_title": "Suspend when locked",
"edt_conf_os_events_suspendOnLockEnable_expl": "Suspend when the screen is locked, otherwise go into idle mode",
"edt_conf_pbs_heading_title": "Protocol Buffers Server",
"edt_conf_pbs_timeout_expl": "If no data are received for the given period, the component will be (soft) disabled.",
"edt_conf_pbs_timeout_title": "Timeout",
@@ -477,12 +483,6 @@
"edt_conf_smooth_updateDelay_title": "Output delay",
"edt_conf_smooth_updateFrequency_expl": "The output speed to your LED controller.",
"edt_conf_smooth_updateFrequency_title": "Update frequency",
"edt_conf_system_events_lockEnable_title": "Listen to lock events",
"edt_conf_system_events_lockEnable_expl": "Listen to screen lock/unlock events",
"edt_conf_system_events_suspendEnable_title": "Listen to suspend events",
"edt_conf_system_events_suspendEnable_expl": "Listen to system suspend/resume events",
"edt_conf_system_events_suspendOnLockEnable_title": "Suspend when locked",
"edt_conf_system_events_suspendOnLockEnable_expl": "Suspend when the screen is locked, otherwise go into idle mode",
"edt_conf_v4l2_blueSignalThreshold_expl": "Darkens low blue values (recognized as black)",
"edt_conf_v4l2_blueSignalThreshold_title": "Blue signal threshold",
"edt_conf_v4l2_cecDetection_expl": "If enabled, USB capture will be temporarily disabled when CEC standby event received from HDMI bus.",

View File

@@ -1,35 +1,75 @@
$(document).ready(function () {
performTranslation();
var conf_editor_systemEvents = null;
var CEC_ENABLED = (jQuery.inArray("cec", window.serverInfo.services) !== -1);
var conf_editor_osEvents = null;
var conf_editor_cecEvents = null;
if (window.showOptHelp) {
//System Events
$('#conf_cont').append(createRow('conf_cont_system_events'));
$('#conf_cont_system_events').append(createOptPanel('fa-laptop', $.i18n("conf_system_events_heading_title"), 'editor_container_system_events', 'btn_submit_system_events', 'panel-system'));
$('#conf_cont_system_events').append(createHelpTable(window.schema.systemEvents.properties, $.i18n("conf_system_events_heading_title")));
//Operating System Events
$('#conf_cont').append(createRow('conf_cont_os_events'));
$('#conf_cont_os_events').append(createOptPanel('fa-laptop', $.i18n("conf_os_events_heading_title"), 'editor_container_os_events', 'btn_submit_os_events', 'panel-system'));
$('#conf_cont_os_events').append(createHelpTable(window.schema.osEvents.properties, $.i18n("conf_os_events_heading_title")));
//CEC Events
if (CEC_ENABLED) {
$('#conf_cont').append(createRow('conf_cont_event_cec'));
$('#conf_cont_event_cec').append(createOptPanel('fa-tv', $.i18n("conf_cec_events_heading_title"), 'editor_container_cec_events', 'btn_submit_cec_events', 'panel-system'));
$('#conf_cont_event_cec').append(createHelpTable(window.schema.cecEvents.properties, $.i18n("conf_cec_events_heading_title"), "cecEventsHelpPanelId"));
}
}
else {
$('#conf_cont').addClass('row');
$('#conf_cont').append(createOptPanel('fa-laptop', $.i18n("conf_system_events_heading_title"), 'editor_container_system_events', 'btn_submit_system_events'));
$('#conf_cont').append(createOptPanel('fa-laptop', $.i18n("conf_os_events_heading_title"), 'editor_container_os_events', 'btn_submit_os_events'));
if (CEC_ENABLED) {
$('#conf_cont').append(createOptPanel('fa-tv', $.i18n("conf_cec_events_heading_title"), 'editor_container_cec_events', 'btn_submit_cec_events'));
}
}
//System Events
conf_editor_systemEvents = createJsonEditor('editor_container_system_events', {
systemEvents: window.schema.systemEvents
//Operating System Events
conf_editor_osEvents = createJsonEditor('editor_container_os_events', {
osEvents: window.schema.osEvents
}, true, true);
conf_editor_systemEvents.on('change', function () {
conf_editor_systemEvents.validate().length || window.readOnlyMode ? $('#btn_submit_system_events').prop('disabled', true) : $('#btn_submit_system_events').prop('disabled', false);
conf_editor_osEvents.on('change', function () {
conf_editor_osEvents.validate().length || window.readOnlyMode ? $('#btn_submit_os_events').prop('disabled', true) : $('#btn_submit_os_events').prop('disabled', false);
});
$('#btn_submit_system_events').off().on('click', function () {
requestWriteConfig(conf_editor_systemEvents.getValue());
$('#btn_submit_os_events').off().on('click', function () {
requestWriteConfig(conf_editor_osEvents.getValue());
});
//CEC Events
if (CEC_ENABLED) {
conf_editor_cecEvents = createJsonEditor('editor_container_cec_events', {
cecEvents: window.schema.cecEvents
}, true, true);
conf_editor_cecEvents.on('change', function () {
var cecEventsEnable = conf_editor_cecEvents.getEditor("root.cecEvents.enable").getValue();
if (cecEventsEnable) {
showInputOptionsForKey(conf_editor_cecEvents, "cecEvents", "enable", true);
$('#cecEventsHelpPanelId').show();
} else {
showInputOptionsForKey(conf_editor_cecEvents, "cecEvents", "enable", false);
$('#cecEventsHelpPanelId').hide();
}
conf_editor_cecEvents.validate().length || window.readOnlyMode ? $('#btn_submit_cec_events').prop('disabled', true) : $('#btn_submit_cec_events').prop('disabled', false);
});
$('#btn_submit_cec_events').off().on('click', function () {
requestWriteConfig(conf_editor_cecEvents.getValue());
});
}
//create introduction
if (window.showOptHelp) {
createHint("intro", $.i18n('conf_system_events_intro'), "editor_container_system_events");
createHint("intro", $.i18n('conf_os_events_intro'), "editor_container_os_events");
if (CEC_ENABLED) {
createHint("intro", $.i18n('conf_cec_events_intro'), "editor_container_cec_events");
}
}
removeOverlay();