mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Refactor Settings DB and Handling (#1786)
* Refactor config API
* Corrections
* Test Qt 6.8
* Revert "Test Qt 6.8"
This reverts commit eceebec49e
.
* Corrections 2
* Update Changelog
* Add configFilter element for getconfig call
* Do not create errors for DB updates when in read-only mode
* Have configuration migration and validation before Hyperion starts
* Correct Tests
* Corrections
* Add migration items
* Correct windows build
* Ensure that first instance as default one exists
* Remove dependency between AuthManager and SSDPHandler
* Correct typos
* Address CodeQL findings
* Replace CamkeSettings by Presets and provide debug scenarios
This commit is contained in:
@@ -28,11 +28,6 @@ $(document).ready(function () {
|
||||
// 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));
|
||||
|
||||
@@ -119,14 +114,14 @@ $(document).ready(function () {
|
||||
//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 {
|
||||
@@ -143,10 +138,10 @@ $(document).ready(function () {
|
||||
$('#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) {
|
||||
@@ -157,18 +152,17 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
//export
|
||||
$('#btn_export_conf').off().on('click', function () {
|
||||
var name = window.serverConfig.general.name;
|
||||
$('#btn_export_conf').off().on('click', async () =>
|
||||
{
|
||||
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}`;
|
||||
|
||||
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");
|
||||
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
|
||||
@@ -180,3 +174,8 @@ $(document).ready(function () {
|
||||
|
||||
removeOverlay();
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-config-restoreconfig", function (event) {
|
||||
setTimeout(initRestart, 100);
|
||||
});
|
||||
|
||||
|
@@ -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;
|
||||
@@ -278,7 +278,7 @@ $(document).ready(function () {
|
||||
window.currentHyperionInstance = 0;
|
||||
window.currentHyperionInstanceName = getInstanceNameByIndex(0);
|
||||
|
||||
requestServerConfig();
|
||||
requestServerConfigOld();
|
||||
setTimeout(requestServerInfo, 100)
|
||||
setTimeout(requestTokenInfo, 200)
|
||||
}
|
||||
@@ -296,7 +296,7 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-instance-switchTo", function (event) {
|
||||
requestServerConfig();
|
||||
requestServerConfigOld();
|
||||
setTimeout(requestServerInfo, 200)
|
||||
setTimeout(requestTokenInfo, 400)
|
||||
});
|
||||
@@ -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") {
|
||||
|
@@ -37,9 +37,8 @@ const ENDLESS = -1;
|
||||
function initRestart()
|
||||
{
|
||||
$(window.hyperion).off();
|
||||
requestServerConfigReload();
|
||||
window.watchdog = 10;
|
||||
connectionLostDetection('restart');
|
||||
connectionLostDetection('restart');
|
||||
}
|
||||
|
||||
function connectionLostDetection(type)
|
||||
@@ -138,9 +137,10 @@ function initWebSocket()
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -344,6 +344,11 @@ function requestServerConfig()
|
||||
sendToHyperion("config", "getconfig");
|
||||
}
|
||||
|
||||
function requestServerConfigOld()
|
||||
{
|
||||
sendToHyperion("config", "getconfig-old");
|
||||
}
|
||||
|
||||
function requestServerConfigReload()
|
||||
{
|
||||
sendToHyperion("config", "reload");
|
||||
@@ -522,3 +527,12 @@ async function requestServiceDiscovery(type, params) {
|
||||
return sendAsyncToHyperion("service", "discover", data);
|
||||
}
|
||||
|
||||
async function requestConfig(globalTypes, instances, instanceTypes) {
|
||||
let globalFilter = { "global": { "types": globalTypes } };
|
||||
let instanceFilter = { "instances": { "ids": instances, "types": instanceTypes } };
|
||||
let filter = { "configFilter" : globalFilter, instanceFilter };
|
||||
|
||||
return sendAsyncToHyperion("config", "getconfig", filter);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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();
|
||||
|
@@ -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!">');
|
||||
@@ -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">');
|
||||
@@ -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';
|
||||
|
||||
|
Reference in New Issue
Block a user