Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Settings DB and Handling #1786

Merged
merged 20 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.17-beta.1
2.0.17-beta.2
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

**JSON-API**
- Align JSON subscription update elements. `ledcolors-imagestream-update, ledcolors-ledstream-update, logmsg-update` now return data via `data` and not `result
- Gloabl global configuration elements are now separated form instance specific ones

### Added

Expand All @@ -18,6 +19,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support gaps on Matrix Layout (#1696)
- Windows: Added a new grabber that uses the DXGI DDA (Desktop Duplication API). This has much better performance than the DX grabber as it does more of its work on the GPU.

- Support to import, export and backup Hyperion's full configuration via the UI, JSON-API and commandline (`--importConfig, --exportConfig`) (#804)
- Allow to force starting Hyperion in read-only mode (`--readonlyMode`)
- JSON-API: Support to query for a dedicated set of configuration items for a set of instances
- JSON-API: Support to save a dedicated set of configuration items for a set of instances

**JSON-API**
- New subscription support for event updates, i.e. `Suspend, Resume, Idle, idleResume, Restart, Quit`.
- Support direct or multiple instance addressing via single requests (#809)
Expand All @@ -33,12 +39,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed: Kodi Color Calibration, Refactor Wizards (#1674)
- Fixed: Token Dialog not closing
- Fixed: Philip Hue APIv2 support without Entertainment group defined (#1742)
- Refactored: Database access layer
- Refactored: Hyperion's configuration database is validated before start-up (and migrated, if required)

**JSON-API**
- Refactored JSON-API to ensure consistent authorization behaviour across sessions and single requests with token authorization.
- Provide additional error details with API responses, esp. on JSON parsing, validation or token errors.
- Generate random TANs for every API request from the Hyperion UI
- Fixed: Handling of IP4 addresses wrapped in IPv6 for external network connections-
- fixed: Local Admin API Authentication rejects valid tokens (#1251)

### Removed

Expand Down
42 changes: 28 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ PROJECT(hyperion)
include (${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.cmake)
file (STRINGS ".version" HYPERION_VERSION)
SetVersionNumber(HYPERION ${HYPERION_VERSION})
set(DEFAULT_JSON_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/config/hyperion.config.json.default)
set(DEFAULT_JSON_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/settings/hyperion.settings.json.default)
file(READ ${DEFAULT_JSON_CONFIG_FILE} DEFAULT_JSON_CONFIG_VAR)
string(REPLACE "configVersionValue" ${HYPERION_VERSION} DEFAULT_JSON_CONFIG_VAR "${DEFAULT_JSON_CONFIG_VAR}")
string(REPLACE "previousVersionValue" ${HYPERION_VERSION} DEFAULT_JSON_CONFIG_VAR "${DEFAULT_JSON_CONFIG_VAR}")
file(WRITE ${CMAKE_BINARY_DIR}/config/hyperion.config.json.default "${DEFAULT_JSON_CONFIG_VAR}")
file(WRITE ${CMAKE_BINARY_DIR}/settings/hyperion.settings.json.default "${DEFAULT_JSON_CONFIG_VAR}")

# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
Expand Down Expand Up @@ -227,7 +226,7 @@ message(STATUS "HYPERION_LIGHT = ${HYPERION_LIGHT}")

if(HYPERION_LIGHT)
message(STATUS "HYPERION_LIGHT: Hyperion is build with a reduced set of functionality.")
# Disable Grabbers
# Disable Screen/Video Grabbers
SET ( DEFAULT_AMLOGIC OFF )
SET ( DEFAULT_DISPMANX OFF )
SET ( DEFAULT_DX OFF )
Expand All @@ -240,22 +239,37 @@ if(HYPERION_LIGHT)
SET ( DEFAULT_X11 OFF )
SET ( DEFAULT_XCB OFF )

# Disable Audio Grabbers
SET ( DEFAULT_AUDIO OFF )

# LED-Devices
#SET ( DEFAULT_DEV_NETWORK OFF )
#SET ( DEFAULT_DEV_FTDI OFF )
#SET ( DEFAULT_DEV_SERIAL OFF )
#SET ( DEFAULT_DEV_SPI OFF )
#SET ( DEFAULT_DEV_TINKERFORGE OFF )
#SET ( DEFAULT_DEV_USB_HID OFF )
#SET ( DEFAULT_DEV_WS281XPWM OFF )

# Disable Input Servers
set(DEFAULT_BOBLIGHT_SERVER OFF)
set(DEFAULT_CEC OFF)
set(DEFAULT_FLATBUF_SERVER OFF)
set(DEFAULT_PROTOBUF_SERVER OFF)
SET ( DEFAULT_BOBLIGHT_SERVER OFF )
SET ( DEFAULT_CEC OFF )
SET ( DEFAULT_FLATBUF_SERVER OFF )
SET ( DEFAULT_PROTOBUF_SERVER OFF )

# Disable Output Connectors
set(DEFAULT_FORWARDER OFF)
set(DEFAULT_FLATBUF_CONNECT OFF)
SET ( DEFAULT_FORWARDER OFF )
SET ( DEFAULT_FLATBUF_CONNECT OFF )

# Disable Services
set(DEFAULT_EFFECTENGINE OFF)
SET ( DEFAULT_EFFECTENGINE OFF )
#SET ( DEFAULT_EXPERIMENTAL OFF )
#SET ( DEFAULT_MDNS OFF )
#SET ( DEFAULT_REMOTE_CTL OFF )

#SET ( ENABLE_JSONCHECKS OFF )
#SET ( ENABLE_DEPLOY_DEPENDENCIES OFF )
endif()

message(STATUS "Grabber options:")

addIndent(" - ")
Expand Down Expand Up @@ -430,7 +444,7 @@ endif()
if(ENABLE_JSONCHECKS)
# check all json files
file (GLOB_RECURSE HYPERION_SCHEMAS RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/libsrc/*schema*.json)
set(JSON_FILES ${CMAKE_BINARY_DIR}/config/hyperion.config.json.default ${HYPERION_SCHEMAS})
set(JSON_FILES ${CMAKE_BINARY_DIR}/settings/hyperion.settings.json.default ${HYPERION_SCHEMAS})

execute_process (
COMMAND ${PYTHON_EXECUTABLE} test/jsonchecks/checkjson.py ${JSON_FILES}
Expand All @@ -453,7 +467,7 @@ if(ENABLE_JSONCHECKS)
endif()

execute_process (
COMMAND ${PYTHON_EXECUTABLE} test/jsonchecks/checkschema.py ${CMAKE_BINARY_DIR}/config/hyperion.config.json.default libsrc/hyperion/hyperion.schema.json
COMMAND ${PYTHON_EXECUTABLE} test/jsonchecks/checkschema.py ${CMAKE_BINARY_DIR}/settings/hyperion.settings.json.default libsrc/hyperion/schema/schema-settings-default.json
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE CHECK_CONFIG_FAILED
)
Expand Down
2 changes: 1 addition & 1 deletion assets/webconfig/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1014,8 +1014,8 @@
"infoDialog_import_comperror_text": "Sad! Your browser doesn't support importing. Please try again with another browser.",
"infoDialog_import_confirm_text": "Are you sure to import \"$1\"? This process can't be reverted!",
"infoDialog_import_confirm_title": "Confirm import",
"infoDialog_import_hyperror_text": "The selected configuration file \"$1\" can't be imported. It's not compatible with Hyperion 2.0 and higher!",
"infoDialog_import_jsonerror_text": "The selected configuration file \"$1\" is not a .json file, or it's corrupted. Error message: ($2)",
"infoDialog_import_version_error_text": "The selected configuration file \"$1\" can not be imported. It's not compatible with Hyperion 2.0.17 and higher!",
"infoDialog_wizrgb_text": "Your RGB Byte Order is already well adjusted.",
"infoDialog_writeconf_error_text": "Saving your configuration failed.",
"infoDialog_writeimage_error_text": "The selected file \"$1\" is not an image file, or it's corrupted! Please select another image file.",
Expand Down
45 changes: 23 additions & 22 deletions assets/webconfig/js/content_general.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
// Instance handling
function handleInstanceRename(e) {

conf_editor.on('change', function () {
window.readOnlyMode ? $('#btn_cl_save').prop('disabled', true) : $('#btn_submit').prop('disabled', false);
window.readOnlyMode ? $('#btn_ma_save').prop('disabled', true) : $('#btn_submit').prop('disabled', false);
});

var inst = e.currentTarget.id.split("_")[1];
showInfoDialog('renInst', $.i18n('conf_general_inst_renreq_t'), getInstanceNameByIndex(inst));

Expand Down Expand Up @@ -119,14 +114,14 @@
//check file is json
var check = isJsonString(content);
if (check.length != 0) {
showInfoDialog('error', "", $.i18n('infoDialog_import_jsonerror_text', f.name, JSON.stringify(check)));
showInfoDialog('error', "", $.i18n('infoDialog_import_jsonerror_text', f.name, JSON.stringify(check.message)));
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));
if (typeof content.global === 'undefined' || typeof content.instances === 'undefined') {
showInfoDialog('error', "", $.i18n('infoDialog_import_version_error_text', f.name));
dis_imp_btn(true);
}
else {
Expand All @@ -143,10 +138,10 @@
$('#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 () {
$('#id_btn_import').off().on('click', function () {
requestRestoreConfig(importedConf);
setTimeout(initRestart, 100);
});

});

$('#select_import_conf').off().on('change', function (e) {
Expand All @@ -157,18 +152,19 @@
});

//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 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");
$('#btn_export_conf').off().on('click', async () =>
{
const name = window.serverConfig.general.name;
Fixed Show fixed Hide fixed

const d = new Date();
const month = String(d.getMonth() + 1).padStart(2, '0');
const day = String(d.getDate()).padStart(2, '0');
const timestamp = `${d.getFullYear()}-${month}-${day}`;

const configBackup = await requestConfig();
if (configBackup.success === true) {
download(JSON.stringify(configBackup.info, null, "\t"), 'HyperionBackup-' + timestamp + '_v' + window.currentVersion + '.json', "application/json");
}
});

//create introduction
Expand All @@ -180,3 +176,8 @@

removeOverlay();
});

$(window.hyperion).on("cmd-config-restoreconfig", function (event) {
setTimeout(initRestart, 100);
});

11 changes: 3 additions & 8 deletions assets/webconfig/js/content_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ $(document).ready(function () {
requestSysInfo();
});

$(window.hyperion).on("cmd-config-getconfig", function (event) {
$(window.hyperion).on("cmd-config-getconfig-old", function (event) {
window.serverConfig = event.response.info;

window.showOptHelp = window.serverConfig.general.showOptHelp;
Expand Down Expand Up @@ -278,7 +278,7 @@ $(document).ready(function () {
window.currentHyperionInstance = 0;
window.currentHyperionInstanceName = getInstanceNameByIndex(0);

requestServerConfig();
requestServerConfigOld();
setTimeout(requestServerInfo, 100)
setTimeout(requestTokenInfo, 200)
}
Expand All @@ -296,7 +296,7 @@ $(document).ready(function () {
});

$(window.hyperion).on("cmd-instance-switchTo", function (event) {
requestServerConfig();
requestServerConfigOld();
setTimeout(requestServerInfo, 200)
setTimeout(requestTokenInfo, 400)
});
Expand Down Expand Up @@ -338,11 +338,6 @@ $(function () {
});
});

// hotfix body padding when bs modals overlap
$(document.body).on('hide.bs.modal,hidden.bs.modal', function () {
$('body').css('padding-right', '0');
});

//Dark Mode
$("#btn_darkmode").off().on("click", function (e) {
if (getStorage("darkMode") != "on") {
Expand Down
24 changes: 20 additions & 4 deletions assets/webconfig/js/hyperion.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@
function initRestart()
{
$(window.hyperion).off();
requestServerConfigReload();
window.watchdog = 10;
connectionLostDetection('restart');
connectionLostDetection('restart');
}

function connectionLostDetection(type)
Expand Down Expand Up @@ -138,9 +137,10 @@
if (error == "Service Unavailable") {
window.location.reload();
} else {
$(window.hyperion).trigger({type:"error",reason:error});
$(window.hyperion).trigger({type:"error", reason:error});
}
console.log("[window.websocket::onmessage] ",error)
let errorData = response.hasOwnProperty("errorData")? response.errorData : "";
console.log("[window.websocket::onmessage] ",error, ", Description:", errorData);
}
}
}
Expand Down Expand Up @@ -344,6 +344,11 @@
sendToHyperion("config", "getconfig");
}

function requestServerConfigOld()
{
sendToHyperion("config", "getconfig-old");
}

function requestServerConfigReload()
{
sendToHyperion("config", "reload");
Expand Down Expand Up @@ -522,3 +527,14 @@
return sendAsyncToHyperion("service", "discover", data);
}

async function requestConfig(globalTypes, instances, instanceTypes) {
let globalFilter = { "global": { "types": globalTypes } };
Fixed Show fixed Hide fixed
let instanceFilter = { "instances": { "ids": instances, "types": instanceTypes } };
Fixed Show fixed Hide fixed

//todo create filter
let filter;

return sendAsyncToHyperion("config", "getconfig", filter);
}


2 changes: 1 addition & 1 deletion assets/webconfig/js/ledsim.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ $(document).ready(function () {
}
});
// apply new serverinfos
$(window.hyperion).on("cmd-config-getconfig", function (event) {
$(window.hyperion).on("cmd-config-getconfig-old", function (event) {
leds = event.response.info.leds;
grabberConfig = event.response.info.grabberV4L2;
updateLedLayout();
Expand Down
10 changes: 5 additions & 5 deletions assets/webconfig/js/ui_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ function showInfoDialog(type, header, message) {
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-error">');
if (header == "")
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n('infoDialog_general_error_title') + '</h4>');
$('#id_footer').html('<button type="button" class="btn btn-danger" data-dismiss="modal">' + $.i18n('general_btn_ok') + '</button>');
$('#id_footer').html('<button type="button" class="btn btn-danger" data-dismiss-modal="#modal_dialog">' + $.i18n('general_btn_ok') + '</button>');
}
else if (type == "select") {
$('#id_body').html('<img style="margin-bottom:20px" id="id_logo" src="img/hyperion/logo_positiv.png" alt="Redefine ambient light!">');
Expand All @@ -256,9 +256,9 @@ function showInfoDialog(type, header, message) {
$('#id_footer').html('<b>' + $.i18n('InfoDialog_nowrite_foottext') + '</b>');
}
else if (type == "import") {
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-warning">');
$('#id_footer').html('<button type="button" id="id_btn_import" class="btn btn-warning" data-dismiss="modal"><i class="fa fa-fw fa-save"></i>' + $.i18n('general_btn_saverestart') + '</button>');
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>' + $.i18n('general_btn_cancel') + '</button>');
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-warning"></i>');
$('#id_footer').html('<button type="button" id="id_btn_import" class="btn btn-warning"><i class="fa fa-fw fa-save"></i>' + $.i18n('general_btn_saverestart') + '</button>');
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss-modal="#modal_dialog"><i class="fa fa-fw fa-close"></i>' + $.i18n('general_btn_cancel') + '</button>');
}
else if (type == "delInst") {
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-remove modal-icon-warning">');
Expand Down Expand Up @@ -1222,7 +1222,7 @@ function getSystemInfo() {
info += '- Avail Video Cap.: ' + window.serverInfo.grabbers.video.available + '\n';
info += '- Avail Audio Cap.: ' + window.serverInfo.grabbers.audio.available + '\n';
info += '- Avail Services: ' + window.serverInfo.services + '\n';
info += '- Config path: ' + shy.rootPath + '\n';
info += '- Config database: ' + shy.configDatabaseFile + '\n';
info += '- Database: ' + (shy.readOnlyMode ? "ready-only" : "read/write") + '\n';
info += '- Mode: ' + (shy.isGuiMode ? "GUI" : "Non-GUI") + '\n';

Expand Down
Loading