mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
* Handle Arrays & Objects differently * Fix UI error, if "last instance used" does not longer exist
This commit is contained in:
parent
77262adf3b
commit
9e281b2347
@ -1,26 +1,21 @@
|
|||||||
var prevTag;
|
var prevTag;
|
||||||
|
|
||||||
function removeOverlay()
|
function removeOverlay() {
|
||||||
{
|
|
||||||
$("#loading_overlay").removeClass("overlay");
|
$("#loading_overlay").removeClass("overlay");
|
||||||
}
|
}
|
||||||
|
|
||||||
function reload()
|
function reload() {
|
||||||
{
|
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
function storageComp()
|
function storageComp() {
|
||||||
{
|
|
||||||
if (typeof (Storage) !== "undefined")
|
if (typeof (Storage) !== "undefined")
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStorage(item, session)
|
function getStorage(item, session) {
|
||||||
{
|
if (storageComp()) {
|
||||||
if(storageComp())
|
|
||||||
{
|
|
||||||
if (session === true)
|
if (session === true)
|
||||||
return sessionStorage.getItem(item);
|
return sessionStorage.getItem(item);
|
||||||
else
|
else
|
||||||
@ -29,10 +24,8 @@ function getStorage(item, session)
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStorage(item, value, session)
|
function setStorage(item, value, session) {
|
||||||
{
|
if (storageComp()) {
|
||||||
if(storageComp())
|
|
||||||
{
|
|
||||||
if (session === true)
|
if (session === true)
|
||||||
sessionStorage.setItem(item, value);
|
sessionStorage.setItem(item, value);
|
||||||
else
|
else
|
||||||
@ -40,10 +33,8 @@ function setStorage(item, value, session)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeStorage(item, session)
|
function removeStorage(item, session) {
|
||||||
{
|
if (storageComp()) {
|
||||||
if(storageComp())
|
|
||||||
{
|
|
||||||
if (session === true)
|
if (session === true)
|
||||||
sessionStorage.removeItem(item);
|
sessionStorage.removeItem(item);
|
||||||
else
|
else
|
||||||
@ -51,24 +42,18 @@ function removeStorage(item, session)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function debugMessage(msg)
|
function debugMessage(msg) {
|
||||||
{
|
if (window.debugMessagesActive) {
|
||||||
if (window.debugMessagesActive)
|
|
||||||
{
|
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSessions()
|
function updateSessions() {
|
||||||
{
|
|
||||||
var sess = window.serverInfo.sessions;
|
var sess = window.serverInfo.sessions;
|
||||||
if (sess && sess.length)
|
if (sess && sess.length) {
|
||||||
{
|
|
||||||
window.wSess = [];
|
window.wSess = [];
|
||||||
for(var i = 0; i<sess.length; i++)
|
for (var i = 0; i < sess.length; i++) {
|
||||||
{
|
if (sess[i].type == "_hyperiond-http._tcp.") {
|
||||||
if(sess[i].type == "_hyperiond-http._tcp.")
|
|
||||||
{
|
|
||||||
window.wSess.push(sess[i]);
|
window.wSess.push(sess[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,20 +65,17 @@ function updateSessions()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateDuration(d)
|
function validateDuration(d) {
|
||||||
{
|
|
||||||
if (typeof d === "undefined" || d < 0)
|
if (typeof d === "undefined" || d < 0)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return d *= 1000;
|
return d *= 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHashtag()
|
function getHashtag() {
|
||||||
{
|
|
||||||
if (getStorage('lasthashtag', true) != null)
|
if (getStorage('lasthashtag', true) != null)
|
||||||
return getStorage('lasthashtag', true);
|
return getStorage('lasthashtag', true);
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
var tag = document.URL;
|
var tag = document.URL;
|
||||||
tag = tag.substr(tag.indexOf("#") + 1);
|
tag = tag.substr(tag.indexOf("#") + 1);
|
||||||
if (tag == "" || typeof tag === "undefined" || tag.startsWith("http"))
|
if (tag == "" || typeof tag === "undefined" || tag.startsWith("http"))
|
||||||
@ -102,20 +84,20 @@ function getHashtag()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadContent(event, forceRefresh)
|
function loadContent(event, forceRefresh) {
|
||||||
{
|
|
||||||
var tag;
|
var tag;
|
||||||
|
|
||||||
var lastSelectedInstance = getStorage('lastSelectedInstance', false);
|
var lastSelectedInstance = getStorage('lastSelectedInstance', false);
|
||||||
|
|
||||||
if (lastSelectedInstance && (lastSelectedInstance != window.currentHyperionInstance))
|
if (lastSelectedInstance && (lastSelectedInstance != window.currentHyperionInstance)) {
|
||||||
if (typeof(window.serverInfo.instance[lastSelectedInstance].running) !== 'undefined' && window.serverInfo.instance[lastSelectedInstance].running)
|
if (window.serverInfo.instance[lastSelectedInstance] && window.serverInfo.instance[lastSelectedInstance].running) {
|
||||||
instanceSwitch(lastSelectedInstance);
|
instanceSwitch(lastSelectedInstance);
|
||||||
else
|
} else {
|
||||||
removeStorage('lastSelectedInstance', false);
|
removeStorage('lastSelectedInstance', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(typeof event != "undefined")
|
if (typeof event != "undefined") {
|
||||||
{
|
|
||||||
tag = event.currentTarget.hash;
|
tag = event.currentTarget.hash;
|
||||||
tag = tag.substr(tag.indexOf("#") + 1);
|
tag = tag.substr(tag.indexOf("#") + 1);
|
||||||
setStorage('lasthashtag', tag, true);
|
setStorage('lasthashtag', tag, true);
|
||||||
@ -123,13 +105,11 @@ function loadContent(event, forceRefresh)
|
|||||||
else
|
else
|
||||||
tag = getHashtag();
|
tag = getHashtag();
|
||||||
|
|
||||||
if(forceRefresh || prevTag != tag)
|
if (forceRefresh || prevTag != tag) {
|
||||||
{
|
|
||||||
prevTag = tag;
|
prevTag = tag;
|
||||||
$("#page-content").off();
|
$("#page-content").off();
|
||||||
$("#page-content").load("/content/" + tag + ".html", function (response, status, xhr) {
|
$("#page-content").load("/content/" + tag + ".html", function (response, status, xhr) {
|
||||||
if(status == "error")
|
if (status == "error") {
|
||||||
{
|
|
||||||
$("#page-content").html('<h3>' + $.i18n('info_404') + '</h3>');
|
$("#page-content").html('<h3>' + $.i18n('info_404') + '</h3>');
|
||||||
removeOverlay();
|
removeOverlay();
|
||||||
}
|
}
|
||||||
@ -138,23 +118,19 @@ function loadContent(event, forceRefresh)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInstanceNameByIndex(index)
|
function getInstanceNameByIndex(index) {
|
||||||
{
|
|
||||||
var instData = window.serverInfo.instance
|
var instData = window.serverInfo.instance
|
||||||
for(var key in instData)
|
for (var key in instData) {
|
||||||
{
|
|
||||||
if (instData[key].instance == index)
|
if (instData[key].instance == index)
|
||||||
return instData[key].friendly_name;
|
return instData[key].friendly_name;
|
||||||
}
|
}
|
||||||
return "unknown"
|
return "unknown"
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateHyperionInstanceListing()
|
function updateHyperionInstanceListing() {
|
||||||
{
|
|
||||||
var data = window.serverInfo.instance.filter(entry => entry.running);
|
var data = window.serverInfo.instance.filter(entry => entry.running);
|
||||||
$('#hyp_inst_listing').html("");
|
$('#hyp_inst_listing').html("");
|
||||||
for(var key in data)
|
for (var key in data) {
|
||||||
{
|
|
||||||
var currInstMarker = (data[key].instance == window.currentHyperionInstance) ? "component-on" : "";
|
var currInstMarker = (data[key].instance == window.currentHyperionInstance) ? "component-on" : "";
|
||||||
|
|
||||||
var html = '<li id="hyperioninstance_' + data[key].instance + '"> \
|
var html = '<li id="hyperioninstance_' + data[key].instance + '"> \
|
||||||
@ -178,19 +154,16 @@ function updateHyperionInstanceListing()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initLanguageSelection()
|
function initLanguageSelection() {
|
||||||
{
|
|
||||||
// Initialise language selection list with languages supported
|
// Initialise language selection list with languages supported
|
||||||
for (var i = 0; i < availLang.length; i++)
|
for (var i = 0; i < availLang.length; i++) {
|
||||||
{
|
|
||||||
$("#language-select").append('<option value="' + i + '" selected="">' + availLangText[i] + '</option>');
|
$("#language-select").append('<option value="' + i + '" selected="">' + availLangText[i] + '</option>');
|
||||||
}
|
}
|
||||||
|
|
||||||
var langLocale = storedLang;
|
var langLocale = storedLang;
|
||||||
|
|
||||||
// If no language has been set, resolve browser locale
|
// If no language has been set, resolve browser locale
|
||||||
if ( langLocale === 'auto' )
|
if (langLocale === 'auto') {
|
||||||
{
|
|
||||||
langLocale = $.i18n().locale.substring(0, 2);
|
langLocale = $.i18n().locale.substring(0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,17 +172,14 @@ function initLanguageSelection()
|
|||||||
|
|
||||||
//Test, if language is supported by hyperion
|
//Test, if language is supported by hyperion
|
||||||
var langIdx = availLang.indexOf(langLocale);
|
var langIdx = availLang.indexOf(langLocale);
|
||||||
if ( langIdx > -1 )
|
if (langIdx > -1) {
|
||||||
{
|
|
||||||
langText = availLangText[langIdx];
|
langText = availLangText[langIdx];
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
// If language is not supported by hyperion, try fallback language
|
// If language is not supported by hyperion, try fallback language
|
||||||
langLocale = $.i18n().options.fallbackLocale.substring(0, 2);
|
langLocale = $.i18n().options.fallbackLocale.substring(0, 2);
|
||||||
langIdx = availLang.indexOf(langLocale);
|
langIdx = availLang.indexOf(langLocale);
|
||||||
if ( langIdx > -1 )
|
if (langIdx > -1) {
|
||||||
{
|
|
||||||
langText = availLangText[langIdx];
|
langText = availLangText[langIdx];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,10 +190,8 @@ function initLanguageSelection()
|
|||||||
$("#language-select").selectpicker("refresh");
|
$("#language-select").selectpicker("refresh");
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateUiOnInstance(inst)
|
function updateUiOnInstance(inst) {
|
||||||
{
|
if (inst != 0) {
|
||||||
if(inst != 0)
|
|
||||||
{
|
|
||||||
var currentURL = $(location).attr("href");
|
var currentURL = $(location).attr("href");
|
||||||
if (currentURL.indexOf('#conf_network') != -1 || currentURL.indexOf('#update') != -1 || currentURL.indexOf('#conf_webconfig') != -1 || currentURL.indexOf('#conf_grabber') != -1 || currentURL.indexOf('#conf_logging') != -1)
|
if (currentURL.indexOf('#conf_network') != -1 || currentURL.indexOf('#update') != -1 || currentURL.indexOf('#conf_webconfig') != -1 || currentURL.indexOf('#conf_grabber') != -1 || currentURL.indexOf('#conf_logging') != -1)
|
||||||
$("#hyperion_global_setting_notify").fadeIn("fast");
|
$("#hyperion_global_setting_notify").fadeIn("fast");
|
||||||
@ -233,15 +201,13 @@ function updateUiOnInstance(inst)
|
|||||||
$("#dashboard_active_instance_friendly_name").html($.i18n('dashboard_active_instance') + ': ' + window.serverInfo.instance[inst].friendly_name);
|
$("#dashboard_active_instance_friendly_name").html($.i18n('dashboard_active_instance') + ': ' + window.serverInfo.instance[inst].friendly_name);
|
||||||
$("#dashboard_active_instance").removeAttr("style");
|
$("#dashboard_active_instance").removeAttr("style");
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$("#hyperion_global_setting_notify").fadeOut("fast");
|
$("#hyperion_global_setting_notify").fadeOut("fast");
|
||||||
$("#dashboard_active_instance").attr("style", "display:none");
|
$("#dashboard_active_instance").attr("style", "display:none");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function instanceSwitch(inst)
|
function instanceSwitch(inst) {
|
||||||
{
|
|
||||||
requestInstanceSwitch(inst)
|
requestInstanceSwitch(inst)
|
||||||
window.currentHyperionInstance = inst;
|
window.currentHyperionInstance = inst;
|
||||||
window.currentHyperionInstanceName = getInstanceNameByIndex(inst);
|
window.currentHyperionInstanceName = getInstanceNameByIndex(inst);
|
||||||
@ -249,102 +215,83 @@ function instanceSwitch(inst)
|
|||||||
updateHyperionInstanceListing()
|
updateHyperionInstanceListing()
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadContentTo(containerId, fileName)
|
function loadContentTo(containerId, fileName) {
|
||||||
{
|
|
||||||
$(containerId).load("/content/" + fileName + ".html");
|
$(containerId).load("/content/" + fileName + ".html");
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleClass(obj,class1,class2)
|
function toggleClass(obj, class1, class2) {
|
||||||
{
|
if ($(obj).hasClass(class1)) {
|
||||||
if ( $(obj).hasClass(class1))
|
|
||||||
{
|
|
||||||
$(obj).removeClass(class1);
|
$(obj).removeClass(class1);
|
||||||
$(obj).addClass(class2);
|
$(obj).addClass(class2);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$(obj).removeClass(class2);
|
$(obj).removeClass(class2);
|
||||||
$(obj).addClass(class1);
|
$(obj).addClass(class1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setClassByBool(obj, enable, class1, class2) {
|
||||||
function setClassByBool(obj,enable,class1,class2)
|
if (enable) {
|
||||||
{
|
|
||||||
if (enable)
|
|
||||||
{
|
|
||||||
$(obj).removeClass(class1);
|
$(obj).removeClass(class1);
|
||||||
$(obj).addClass(class2);
|
$(obj).addClass(class2);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$(obj).removeClass(class2);
|
$(obj).removeClass(class2);
|
||||||
$(obj).addClass(class1);
|
$(obj).addClass(class1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showInfoDialog(type,header,message)
|
function showInfoDialog(type, header, message) {
|
||||||
{
|
if (type == "success") {
|
||||||
if (type=="success")
|
|
||||||
{
|
|
||||||
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-check modal-icon-check">');
|
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-check modal-icon-check">');
|
||||||
if (header == "")
|
if (header == "")
|
||||||
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n('infoDialog_general_success_title') + '</h4>');
|
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n('infoDialog_general_success_title') + '</h4>');
|
||||||
$('#id_footer').html('<button type="button" class="btn btn-success" data-dismiss="modal">' + $.i18n('general_btn_ok') + '</button>');
|
$('#id_footer').html('<button type="button" class="btn btn-success" data-dismiss="modal">' + $.i18n('general_btn_ok') + '</button>');
|
||||||
}
|
}
|
||||||
else if (type=="warning")
|
else if (type == "warning") {
|
||||||
{
|
|
||||||
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-warning">');
|
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-warning">');
|
||||||
if (header == "")
|
if (header == "")
|
||||||
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n('infoDialog_general_warning_title') + '</h4>');
|
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n('infoDialog_general_warning_title') + '</h4>');
|
||||||
$('#id_footer').html('<button type="button" class="btn btn-warning" data-dismiss="modal">' + $.i18n('general_btn_ok') + '</button>');
|
$('#id_footer').html('<button type="button" class="btn btn-warning" data-dismiss="modal">' + $.i18n('general_btn_ok') + '</button>');
|
||||||
}
|
}
|
||||||
else if (type=="error")
|
else if (type == "error") {
|
||||||
{
|
|
||||||
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-error">');
|
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-error">');
|
||||||
if (header == "")
|
if (header == "")
|
||||||
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n('infoDialog_general_error_title') + '</h4>');
|
$('#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">' + $.i18n('general_btn_ok') + '</button>');
|
||||||
}
|
}
|
||||||
else if (type == "select")
|
else if (type == "select") {
|
||||||
{
|
|
||||||
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
||||||
$('#id_footer').html('<button type="button" id="id_btn_saveset" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-fw fa-save"></i>' + $.i18n('general_btn_saveandreload') + '</button>');
|
$('#id_footer').html('<button type="button" id="id_btn_saveset" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-fw fa-save"></i>' + $.i18n('general_btn_saveandreload') + '</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_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>');
|
||||||
}
|
}
|
||||||
else if (type == "iswitch")
|
else if (type == "iswitch") {
|
||||||
{
|
|
||||||
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
||||||
$('#id_footer').html('<button type="button" id="id_btn_saveset" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-fw fa-exchange"></i>' + $.i18n('general_btn_iswitch') + '</button>');
|
$('#id_footer').html('<button type="button" id="id_btn_saveset" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-fw fa-exchange"></i>' + $.i18n('general_btn_iswitch') + '</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_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>');
|
||||||
}
|
}
|
||||||
else if (type == "uilock")
|
else if (type == "uilock") {
|
||||||
{
|
|
||||||
$('#id_body').html('<img src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
$('#id_body').html('<img src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
||||||
$('#id_footer').html('<b>' + $.i18n('InfoDialog_nowrite_foottext') + '</b>');
|
$('#id_footer').html('<b>' + $.i18n('InfoDialog_nowrite_foottext') + '</b>');
|
||||||
}
|
}
|
||||||
else if (type == "import")
|
else if (type == "import") {
|
||||||
{
|
|
||||||
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-warning">');
|
$('#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').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_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>');
|
||||||
}
|
}
|
||||||
else if (type == "delInst")
|
else if (type == "delInst") {
|
||||||
{
|
|
||||||
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-remove modal-icon-warning">');
|
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-remove modal-icon-warning">');
|
||||||
$('#id_footer').html('<button type="button" id="id_btn_yes" class="btn btn-warning" data-dismiss="modal"><i class="fa fa-fw fa-trash"></i>' + $.i18n('general_btn_yes') + '</button>');
|
$('#id_footer').html('<button type="button" id="id_btn_yes" class="btn btn-warning" data-dismiss="modal"><i class="fa fa-fw fa-trash"></i>' + $.i18n('general_btn_yes') + '</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_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>');
|
||||||
}
|
}
|
||||||
else if (type == "renInst")
|
else if (type == "renInst") {
|
||||||
{
|
|
||||||
$('#id_body_rename').html('<i style="margin-bottom:20px" class="fa fa-pencil modal-icon-edit"><br>');
|
$('#id_body_rename').html('<i style="margin-bottom:20px" class="fa fa-pencil modal-icon-edit"><br>');
|
||||||
$('#id_body_rename').append('<h4>' + header + '</h4>');
|
$('#id_body_rename').append('<h4>' + header + '</h4>');
|
||||||
$('#id_body_rename').append('<input class="form-control" id="renInst_name" type="text" value="' + message + '">');
|
$('#id_body_rename').append('<input class="form-control" id="renInst_name" type="text" value="' + message + '">');
|
||||||
$('#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_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_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>');
|
$('#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 == "changePassword")
|
else if (type == "changePassword") {
|
||||||
{
|
|
||||||
$('#id_body_rename').html('<i style="margin-bottom:20px" class="fa fa-key modal-icon-edit"><br>');
|
$('#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('<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="oldPw" placeholder="Old" type="text"> <br />');
|
||||||
@ -352,27 +299,23 @@ function showInfoDialog(type,header,message)
|
|||||||
$('#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_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_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>');
|
$('#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")
|
else if (type == "checklist") {
|
||||||
{
|
|
||||||
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
||||||
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n('infoDialog_checklist_title') + '</h4>');
|
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n('infoDialog_checklist_title') + '</h4>');
|
||||||
$('#id_body').append(header);
|
$('#id_body').append(header);
|
||||||
$('#id_footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">' + $.i18n('general_btn_ok') + '</button>');
|
$('#id_footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">' + $.i18n('general_btn_ok') + '</button>');
|
||||||
}
|
}
|
||||||
else if (type == "newToken")
|
else if (type == "newToken") {
|
||||||
{
|
|
||||||
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
||||||
$('#id_footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">' + $.i18n('general_btn_ok') + '</button>');
|
$('#id_footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">' + $.i18n('general_btn_ok') + '</button>');
|
||||||
}
|
}
|
||||||
else if (type == "grantToken")
|
else if (type == "grantToken") {
|
||||||
{
|
|
||||||
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
||||||
$('#id_footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal" id="tok_grant_acc">' + $.i18n('general_btn_grantAccess') + '</button>');
|
$('#id_footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal" id="tok_grant_acc">' + $.i18n('general_btn_grantAccess') + '</button>');
|
||||||
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal" id="tok_deny_acc">' + $.i18n('general_btn_denyAccess') + '</button>');
|
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal" id="tok_deny_acc">' + $.i18n('general_btn_denyAccess') + '</button>');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type != "renInst")
|
if (type != "renInst") {
|
||||||
{
|
|
||||||
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">' + header + '</h4>');
|
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">' + header + '</h4>');
|
||||||
$('#id_body').append(message);
|
$('#id_body').append(message);
|
||||||
}
|
}
|
||||||
@ -380,7 +323,6 @@ function showInfoDialog(type,header,message)
|
|||||||
if (type == "select" || type == "iswitch")
|
if (type == "select" || type == "iswitch")
|
||||||
$('#id_body').append('<select id="id_select" class="form-control" style="margin-top:10px;width:auto;"></select>');
|
$('#id_body').append('<select id="id_select" class="form-control" style="margin-top:10px;width:auto;"></select>');
|
||||||
|
|
||||||
|
|
||||||
$(type == "renInst" || type == "changePassword" ? "#modal_dialog_rename" : "#modal_dialog").modal({
|
$(type == "renInst" || type == "changePassword" ? "#modal_dialog_rename" : "#modal_dialog").modal({
|
||||||
backdrop: "static",
|
backdrop: "static",
|
||||||
keyboard: false,
|
keyboard: false,
|
||||||
@ -393,8 +335,7 @@ function showInfoDialog(type,header,message)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createHintH(type, text, container)
|
function createHintH(type, text, container) {
|
||||||
{
|
|
||||||
type = String(type);
|
type = String(type);
|
||||||
if (type == "intro")
|
if (type == "intro")
|
||||||
tclass = "introd";
|
tclass = "introd";
|
||||||
@ -402,27 +343,22 @@ function createHintH(type, text, container)
|
|||||||
$('#' + container).prepend('<div class="' + tclass + '"><h4 style="font-size:16px">' + text + '</h4><hr/></div>');
|
$('#' + container).prepend('<div class="' + tclass + '"><h4 style="font-size:16px">' + text + '</h4><hr/></div>');
|
||||||
}
|
}
|
||||||
|
|
||||||
function createHint(type, text, container, buttonid, buttontxt)
|
function createHint(type, text, container, buttonid, buttontxt) {
|
||||||
{
|
|
||||||
var fe, tclass;
|
var fe, tclass;
|
||||||
|
|
||||||
if(type == "intro")
|
if (type == "intro") {
|
||||||
{
|
|
||||||
fe = '';
|
fe = '';
|
||||||
tclass = "intro-hint";
|
tclass = "intro-hint";
|
||||||
}
|
}
|
||||||
else if(type == "info")
|
else if (type == "info") {
|
||||||
{
|
|
||||||
fe = '<div style="font-size:25px;text-align:center"><i class="fa fa-info"></i></div><div style="text-align:center;font-size:13px">Information</div>';
|
fe = '<div style="font-size:25px;text-align:center"><i class="fa fa-info"></i></div><div style="text-align:center;font-size:13px">Information</div>';
|
||||||
tclass = "info-hint";
|
tclass = "info-hint";
|
||||||
}
|
}
|
||||||
else if(type == "wizard")
|
else if (type == "wizard") {
|
||||||
{
|
|
||||||
fe = '<div style="font-size:25px;text-align:center"><i class="fa fa-magic"></i></div><div style="text-align:center;font-size:13px">Information</div>';
|
fe = '<div style="font-size:25px;text-align:center"><i class="fa fa-magic"></i></div><div style="text-align:center;font-size:13px">Information</div>';
|
||||||
tclass = "wizard-hint";
|
tclass = "wizard-hint";
|
||||||
}
|
}
|
||||||
else if(type == "warning")
|
else if (type == "warning") {
|
||||||
{
|
|
||||||
fe = '<div style="font-size:25px;text-align:center"><i class="fa fa-info"></i></div><div style="text-align:center;font-size:13px">Information</div>';
|
fe = '<div style="font-size:25px;text-align:center"><i class="fa fa-info"></i></div><div style="text-align:center;font-size:13px">Information</div>';
|
||||||
tclass = "warning-hint";
|
tclass = "warning-hint";
|
||||||
}
|
}
|
||||||
@ -436,31 +372,26 @@ function createHint(type, text, container, buttonid, buttontxt)
|
|||||||
$('#' + container).prepend('<div class="bs-callout bs-callout-primary" style="margin-top:0px"><h4>' + $.i18n("conf_helptable_expl") + '</h4>' + text + '</div>');
|
$('#' + container).prepend('<div class="bs-callout bs-callout-primary" style="margin-top:0px"><h4>' + $.i18n("conf_helptable_expl") + '</h4>' + text + '</div>');
|
||||||
else if (type == "wizard")
|
else if (type == "wizard")
|
||||||
$('#' + container).prepend('<div class="bs-callout bs-callout-wizard" style="margin-top:0px"><h4>' + $.i18n("wiz_wizavail") + '</h4>' + $.i18n('wiz_guideyou', text) + buttonid + '</div>');
|
$('#' + container).prepend('<div class="bs-callout bs-callout-wizard" style="margin-top:0px"><h4>' + $.i18n("wiz_wizavail") + '</h4>' + $.i18n('wiz_guideyou', text) + buttonid + '</div>');
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
createTable('', 'htb', container, true, tclass);
|
createTable('', 'htb', container, true, tclass);
|
||||||
$('#' + container + ' .htb').append(createTableRow([fe, text], false, true));
|
$('#' + container + ' .htb').append(createTableRow([fe, text], false, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createEffHint(title, text)
|
function createEffHint(title, text) {
|
||||||
{
|
|
||||||
return '<div class="bs-callout bs-callout-primary" style="margin-top:0px"><h4>' + title + '</h4>' + text + '</div>';
|
return '<div class="bs-callout bs-callout-primary" style="margin-top:0px"><h4>' + title + '</h4>' + text + '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function valValue(id,value,min,max)
|
function valValue(id, value, min, max) {
|
||||||
{
|
|
||||||
if (typeof max === 'undefined' || max == "")
|
if (typeof max === 'undefined' || max == "")
|
||||||
max = 999999;
|
max = 999999;
|
||||||
|
|
||||||
if(Number(value) > Number(max))
|
if (Number(value) > Number(max)) {
|
||||||
{
|
|
||||||
$('#' + id).val(max);
|
$('#' + id).val(max);
|
||||||
showInfoDialog("warning", "", $.i18n('edt_msg_error_maximum_incl', max));
|
showInfoDialog("warning", "", $.i18n('edt_msg_error_maximum_incl', max));
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
else if(Number(value) < Number(min))
|
else if (Number(value) < Number(min)) {
|
||||||
{
|
|
||||||
$('#' + id).val(min);
|
$('#' + id).val(min);
|
||||||
showInfoDialog("warning", "", $.i18n('edt_msg_error_minimum_incl', min));
|
showInfoDialog("warning", "", $.i18n('edt_msg_error_minimum_incl', min));
|
||||||
return min;
|
return min;
|
||||||
@ -468,8 +399,7 @@ function valValue(id,value,min,max)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function readImg(input,cb)
|
function readImg(input, cb) {
|
||||||
{
|
|
||||||
if (input.files && input.files[0]) {
|
if (input.files && input.files[0]) {
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
// inject fileName property
|
// inject fileName property
|
||||||
@ -482,21 +412,17 @@ function readImg(input,cb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isJsonString(str)
|
function isJsonString(str) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
JSON.parse(str);
|
JSON.parse(str);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e) {
|
||||||
{
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function createJsonEditor(container,schema,setconfig,usePanel,arrayre)
|
function createJsonEditor(container, schema, setconfig, usePanel, arrayre) {
|
||||||
{
|
|
||||||
$('#' + container).off();
|
$('#' + container).off();
|
||||||
$('#' + container).html("");
|
$('#' + container).html("");
|
||||||
|
|
||||||
@ -522,17 +448,14 @@ function createJsonEditor(container,schema,setconfig,usePanel,arrayre)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(usePanel)
|
if (usePanel) {
|
||||||
{
|
|
||||||
$('#' + container + ' .well').first().removeClass('well well-sm');
|
$('#' + container + ' .well').first().removeClass('well well-sm');
|
||||||
$('#' + container + ' h4').first().remove();
|
$('#' + container + ' h4').first().remove();
|
||||||
$('#' + container + ' .well').first().removeClass('well well-sm');
|
$('#' + container + ' .well').first().removeClass('well well-sm');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setconfig)
|
if (setconfig) {
|
||||||
{
|
for (var key in editor.root.editors) {
|
||||||
for(var key in editor.root.editors)
|
|
||||||
{
|
|
||||||
editor.getEditor("root." + key).setValue(Object.assign({}, editor.getEditor("root." + key).value, window.serverConfig[key]));
|
editor.getEditor("root." + key).setValue(Object.assign({}, editor.getEditor("root." + key).value, window.serverConfig[key]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -540,8 +463,7 @@ function createJsonEditor(container,schema,setconfig,usePanel,arrayre)
|
|||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildWL(link,linkt,cl)
|
function buildWL(link, linkt, cl) {
|
||||||
{
|
|
||||||
var baseLink = "https://docs.hyperion-project.org/";
|
var baseLink = "https://docs.hyperion-project.org/";
|
||||||
var lang;
|
var lang;
|
||||||
|
|
||||||
@ -553,8 +475,7 @@ function buildWL(link,linkt,cl)
|
|||||||
else
|
else
|
||||||
lang = "en";
|
lang = "en";
|
||||||
|
|
||||||
if(cl === true)
|
if (cl === true) {
|
||||||
{
|
|
||||||
linkt = $.i18n(linkt);
|
linkt = $.i18n(linkt);
|
||||||
return '<div class="bs-callout bs-callout-primary"><h4>' + linkt + '</h4>' + $.i18n('general_wiki_moreto', linkt) + ': <a href="' + baseLink + lang + '/' + link + '" target="_blank">' + linkt + '<a></div>'
|
return '<div class="bs-callout bs-callout-primary"><h4>' + linkt + '</h4>' + $.i18n('general_wiki_moreto', linkt) + ': <a href="' + baseLink + lang + '/' + link + '" target="_blank">' + linkt + '<a></div>'
|
||||||
}
|
}
|
||||||
@ -562,10 +483,8 @@ function buildWL(link,linkt,cl)
|
|||||||
return ': <a href="' + baseLink + lang + '/' + link + '" target="_blank">' + linkt + '<a>';
|
return ': <a href="' + baseLink + lang + '/' + link + '" target="_blank">' + linkt + '<a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function rgbToHex(rgb)
|
function rgbToHex(rgb) {
|
||||||
{
|
if (rgb.length == 3) {
|
||||||
if(rgb.length == 3)
|
|
||||||
{
|
|
||||||
return "#" +
|
return "#" +
|
||||||
("0" + parseInt(rgb[0], 10).toString(16)).slice(-2) +
|
("0" + parseInt(rgb[0], 10).toString(16)).slice(-2) +
|
||||||
("0" + parseInt(rgb[1], 10).toString(16)).slice(-2) +
|
("0" + parseInt(rgb[1], 10).toString(16)).slice(-2) +
|
||||||
@ -591,12 +510,9 @@ function hexToRgb(hex) {
|
|||||||
@param title A title (optional)
|
@param title A title (optional)
|
||||||
@param addhtml Add custom html to the notification end
|
@param addhtml Add custom html to the notification end
|
||||||
*/
|
*/
|
||||||
function showNotification(type, message, title="", addhtml="")
|
function showNotification(type, message, title = "", addhtml = "") {
|
||||||
{
|
if (title == "") {
|
||||||
if(title == "")
|
switch (type) {
|
||||||
{
|
|
||||||
switch(type)
|
|
||||||
{
|
|
||||||
case "info":
|
case "info":
|
||||||
title = $.i18n('infoDialog_general_info_title');
|
title = $.i18n('infoDialog_general_info_title');
|
||||||
break;
|
break;
|
||||||
@ -641,15 +557,13 @@ function showNotification(type, message, title="", addhtml="")
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createCP(id, color, cb)
|
function createCP(id, color, cb) {
|
||||||
{
|
|
||||||
if (Array.isArray(color))
|
if (Array.isArray(color))
|
||||||
color = rgbToHex(color);
|
color = rgbToHex(color);
|
||||||
else if (color == "undefined")
|
else if (color == "undefined")
|
||||||
color = "#AA3399";
|
color = "#AA3399";
|
||||||
|
|
||||||
if(color.startsWith("#"))
|
if (color.startsWith("#")) {
|
||||||
{
|
|
||||||
$('#' + id).colorpicker({
|
$('#' + id).colorpicker({
|
||||||
format: 'rgb',
|
format: 'rgb',
|
||||||
customClass: 'colorpicker-2x',
|
customClass: 'colorpicker-2x',
|
||||||
@ -679,8 +593,7 @@ function createCP(id, color, cb)
|
|||||||
// @param string bid : a class for tbody
|
// @param string bid : a class for tbody
|
||||||
// @param string cont : a container id to html() the table
|
// @param string cont : a container id to html() the table
|
||||||
// @param string bless: if true the table is borderless
|
// @param string bless: if true the table is borderless
|
||||||
function createTable(hid, bid, cont, bless, tclass)
|
function createTable(hid, bid, cont, bless, tclass) {
|
||||||
{
|
|
||||||
var table = document.createElement('table');
|
var table = document.createElement('table');
|
||||||
var thead = document.createElement('thead');
|
var thead = document.createElement('thead');
|
||||||
var tbody = document.createElement('tbody');
|
var tbody = document.createElement('tbody');
|
||||||
@ -707,12 +620,10 @@ function createTable(hid, bid, cont, bless, tclass)
|
|||||||
// @param bool align :if null or false no alignment
|
// @param bool align :if null or false no alignment
|
||||||
//
|
//
|
||||||
// @return : <tr> with <td> or <th> as child(s)
|
// @return : <tr> with <td> or <th> as child(s)
|
||||||
function createTableRow(list, head, align)
|
function createTableRow(list, head, align) {
|
||||||
{
|
|
||||||
var row = document.createElement('tr');
|
var row = document.createElement('tr');
|
||||||
|
|
||||||
for(var i = 0; i < list.length; i++)
|
for (var i = 0; i < list.length; i++) {
|
||||||
{
|
|
||||||
if (head === true)
|
if (head === true)
|
||||||
var el = document.createElement('th');
|
var el = document.createElement('th');
|
||||||
else
|
else
|
||||||
@ -727,16 +638,14 @@ function createTableRow(list, head, align)
|
|||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRow(id)
|
function createRow(id) {
|
||||||
{
|
|
||||||
var el = document.createElement('div');
|
var el = document.createElement('div');
|
||||||
el.className = "row";
|
el.className = "row";
|
||||||
el.setAttribute('id', id);
|
el.setAttribute('id', id);
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createOptPanel(phicon, phead, bodyid, footerid)
|
function createOptPanel(phicon, phead, bodyid, footerid) {
|
||||||
{
|
|
||||||
phead = '<i class="fa ' + phicon + ' fa-fw"></i>' + phead;
|
phead = '<i class="fa ' + phicon + ' fa-fw"></i>' + phead;
|
||||||
var pfooter = document.createElement('button');
|
var pfooter = document.createElement('button');
|
||||||
pfooter.className = "btn btn-primary";
|
pfooter.className = "btn btn-primary";
|
||||||
@ -746,10 +655,8 @@ function createOptPanel(phicon, phead, bodyid, footerid)
|
|||||||
return createPanel(phead, "", pfooter, "panel-default", bodyid);
|
return createPanel(phead, "", pfooter, "panel-default", bodyid);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortProperties(list)
|
function sortProperties(list) {
|
||||||
{
|
for (var key in list) {
|
||||||
for(var key in list)
|
|
||||||
{
|
|
||||||
list[key].key = key;
|
list[key].key = key;
|
||||||
}
|
}
|
||||||
list = $.map(list, function (value, index) {
|
list = $.map(list, function (value, index) {
|
||||||
@ -772,10 +679,8 @@ function createHelpTable(list, phead){
|
|||||||
|
|
||||||
thead.appendChild(createTableRow([$.i18n('conf_helptable_option'), $.i18n('conf_helptable_expl')], true, false));
|
thead.appendChild(createTableRow([$.i18n('conf_helptable_option'), $.i18n('conf_helptable_expl')], true, false));
|
||||||
|
|
||||||
for (var key in list)
|
for (var key in list) {
|
||||||
{
|
if (list[key].access != 'system') {
|
||||||
if(list[key].access != 'system')
|
|
||||||
{
|
|
||||||
// break one iteration (in the loop), if the schema has the entry hidden=true
|
// break one iteration (in the loop), if the schema has the entry hidden=true
|
||||||
if ("options" in list[key] && "hidden" in list[key].options && (list[key].options.hidden))
|
if ("options" in list[key] && "hidden" in list[key].options && (list[key].options.hidden))
|
||||||
continue;
|
continue;
|
||||||
@ -784,11 +689,9 @@ function createHelpTable(list, phead){
|
|||||||
var text = list[key].title.replace('title', 'expl');
|
var text = list[key].title.replace('title', 'expl');
|
||||||
tbody.appendChild(createTableRow([$.i18n(list[key].title), $.i18n(text)], false, false));
|
tbody.appendChild(createTableRow([$.i18n(list[key].title), $.i18n(text)], false, false));
|
||||||
|
|
||||||
if(list[key].items && list[key].items.properties)
|
if (list[key].items && list[key].items.properties) {
|
||||||
{
|
|
||||||
var ilist = sortProperties(list[key].items.properties);
|
var ilist = sortProperties(list[key].items.properties);
|
||||||
for (var ikey in ilist)
|
for (var ikey in ilist) {
|
||||||
{
|
|
||||||
// break one iteration (in the loop), if the schema has the entry hidden=true
|
// break one iteration (in the loop), if the schema has the entry hidden=true
|
||||||
if ("options" in ilist[ikey] && "hidden" in ilist[ikey].options && (ilist[ikey].options.hidden))
|
if ("options" in ilist[ikey] && "hidden" in ilist[ikey].options && (ilist[ikey].options.hidden))
|
||||||
continue;
|
continue;
|
||||||
@ -825,8 +728,7 @@ function createPanel(head, body, footer, type, bodyid){
|
|||||||
|
|
||||||
phead.innerHTML = head;
|
phead.innerHTML = head;
|
||||||
|
|
||||||
if(typeof bodyid != 'undefined')
|
if (typeof bodyid != 'undefined') {
|
||||||
{
|
|
||||||
pfooter.style.textAlign = 'right';
|
pfooter.style.textAlign = 'right';
|
||||||
pbody.setAttribute("id", bodyid);
|
pbody.setAttribute("id", bodyid);
|
||||||
}
|
}
|
||||||
@ -840,8 +742,7 @@ function createPanel(head, body, footer, type, bodyid){
|
|||||||
p.appendChild(phead);
|
p.appendChild(phead);
|
||||||
p.appendChild(pbody);
|
p.appendChild(pbody);
|
||||||
|
|
||||||
if(typeof footer != 'undefined')
|
if (typeof footer != 'undefined') {
|
||||||
{
|
|
||||||
pfooter.style.textAlign = "right";
|
pfooter.style.textAlign = "right";
|
||||||
p.appendChild(pfooter);
|
p.appendChild(pfooter);
|
||||||
}
|
}
|
||||||
@ -851,15 +752,13 @@ function createPanel(head, body, footer, type, bodyid){
|
|||||||
return cont;
|
return cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSelGroup(group)
|
function createSelGroup(group) {
|
||||||
{
|
|
||||||
var el = document.createElement('optgroup');
|
var el = document.createElement('optgroup');
|
||||||
el.setAttribute('label', group);
|
el.setAttribute('label', group);
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSelOpt(opt, title)
|
function createSelOpt(opt, title) {
|
||||||
{
|
|
||||||
var el = document.createElement('option');
|
var el = document.createElement('option');
|
||||||
el.setAttribute('value', opt);
|
el.setAttribute('value', opt);
|
||||||
if (typeof title == 'undefined')
|
if (typeof title == 'undefined')
|
||||||
@ -869,16 +768,12 @@ function createSelOpt(opt, title)
|
|||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSel(array, group, split)
|
function createSel(array, group, split) {
|
||||||
{
|
if (array.length != 0) {
|
||||||
if (array.length != 0)
|
|
||||||
{
|
|
||||||
var el = createSelGroup(group);
|
var el = createSelGroup(group);
|
||||||
for(var i=0; i<array.length; i++)
|
for (var i = 0; i < array.length; i++) {
|
||||||
{
|
|
||||||
var opt;
|
var opt;
|
||||||
if(split)
|
if (split) {
|
||||||
{
|
|
||||||
opt = array[i].split(":")
|
opt = array[i].split(":")
|
||||||
opt = createSelOpt(opt[0], opt[1])
|
opt = createSelOpt(opt[0], opt[1])
|
||||||
}
|
}
|
||||||
@ -890,27 +785,22 @@ function createSel(array, group, split)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function performTranslation()
|
function performTranslation() {
|
||||||
{
|
|
||||||
$('[data-i18n]').i18n();
|
$('[data-i18n]').i18n();
|
||||||
}
|
}
|
||||||
|
|
||||||
function encode_utf8(s)
|
function encode_utf8(s) {
|
||||||
{
|
|
||||||
return unescape(encodeURIComponent(s));
|
return unescape(encodeURIComponent(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getReleases(callback)
|
function getReleases(callback) {
|
||||||
{
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: window.gitHubReleaseApiUrl,
|
url: window.gitHubReleaseApiUrl,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
error: function(XMLHttpRequest, textStatus, errorThrown)
|
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
||||||
{
|
|
||||||
callback(false);
|
callback(false);
|
||||||
},
|
},
|
||||||
success: function(releases)
|
success: function (releases) {
|
||||||
{
|
|
||||||
window.gitHubVersionList = releases;
|
window.gitHubVersionList = releases;
|
||||||
var highestRelease = {
|
var highestRelease = {
|
||||||
tag_name: '0.0.0'
|
tag_name: '0.0.0'
|
||||||
@ -926,28 +816,23 @@ function getReleases(callback)
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (var i in releases) {
|
for (var i in releases) {
|
||||||
|
|
||||||
//drafts will be ignored
|
//drafts will be ignored
|
||||||
if (releases[i].draft)
|
if (releases[i].draft)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(releases[i].tag_name.includes('alpha'))
|
if (releases[i].tag_name.includes('alpha')) {
|
||||||
{
|
|
||||||
if (sem = semverLite.gt(releases[i].tag_name, highestAlphaRelease.tag_name))
|
if (sem = semverLite.gt(releases[i].tag_name, highestAlphaRelease.tag_name))
|
||||||
highestAlphaRelease = releases[i];
|
highestAlphaRelease = releases[i];
|
||||||
}
|
}
|
||||||
else if (releases[i].tag_name.includes('beta'))
|
else if (releases[i].tag_name.includes('beta')) {
|
||||||
{
|
|
||||||
if (sem = semverLite.gt(releases[i].tag_name, highestBetaRelease.tag_name))
|
if (sem = semverLite.gt(releases[i].tag_name, highestBetaRelease.tag_name))
|
||||||
highestBetaRelease = releases[i];
|
highestBetaRelease = releases[i];
|
||||||
}
|
}
|
||||||
else if (releases[i].tag_name.includes('rc'))
|
else if (releases[i].tag_name.includes('rc')) {
|
||||||
{
|
|
||||||
if (semverLite.gt(releases[i].tag_name, highestRcRelease.tag_name))
|
if (semverLite.gt(releases[i].tag_name, highestRcRelease.tag_name))
|
||||||
highestRcRelease = releases[i];
|
highestRcRelease = releases[i];
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
if (semverLite.gt(releases[i].tag_name, highestRelease.tag_name))
|
if (semverLite.gt(releases[i].tag_name, highestRelease.tag_name))
|
||||||
highestRelease = releases[i];
|
highestRelease = releases[i];
|
||||||
}
|
}
|
||||||
@ -957,7 +842,6 @@ function getReleases(callback)
|
|||||||
window.latestAlphaVersion = highestAlphaRelease;
|
window.latestAlphaVersion = highestAlphaRelease;
|
||||||
window.latestRcVersion = highestRcRelease;
|
window.latestRcVersion = highestRcRelease;
|
||||||
|
|
||||||
|
|
||||||
if (window.serverConfig.general.watchedVersionBranch == "Beta" && semverLite.gt(highestBetaRelease.tag_name, highestRelease.tag_name))
|
if (window.serverConfig.general.watchedVersionBranch == "Beta" && semverLite.gt(highestBetaRelease.tag_name, highestRelease.tag_name))
|
||||||
window.latestVersion = highestBetaRelease;
|
window.latestVersion = highestBetaRelease;
|
||||||
else
|
else
|
||||||
@ -977,13 +861,11 @@ function getReleases(callback)
|
|||||||
window.latestVersion = highestAlphaRelease;
|
window.latestVersion = highestAlphaRelease;
|
||||||
|
|
||||||
callback(true);
|
callback(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDarkMode()
|
function handleDarkMode() {
|
||||||
{
|
|
||||||
$("<link/>", {
|
$("<link/>", {
|
||||||
rel: "stylesheet",
|
rel: "stylesheet",
|
||||||
type: "text/css",
|
type: "text/css",
|
||||||
|
@ -120,7 +120,15 @@ QJsonObject SettingsManager::getSettings() const
|
|||||||
for(const auto & key : _qconfig.keys())
|
for(const auto & key : _qconfig.keys())
|
||||||
{
|
{
|
||||||
//Read all records from database to ensure that global settings are read across instances
|
//Read all records from database to ensure that global settings are read across instances
|
||||||
config.insert(key, _sTable->getSettingsRecord(key).object());
|
QJsonDocument doc = _sTable->getSettingsRecord(key);
|
||||||
|
if(doc.isArray())
|
||||||
|
{
|
||||||
|
config.insert(key, doc.array());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
config.insert(key, doc.object());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
@ -245,5 +253,18 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
|
|||||||
Debug(_log,"LED Layout migrated");
|
Debug(_log,"LED Layout migrated");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.contains("grabberV4L2"))
|
||||||
|
{
|
||||||
|
QJsonObject newGrabberV4L2Config = config["grabberV4L2"].toObject();
|
||||||
|
|
||||||
|
if (newGrabberV4L2Config.contains("encoding_format"))
|
||||||
|
{
|
||||||
|
newGrabberV4L2Config.remove("encoding_format");
|
||||||
|
config["grabberV4L2"] = newGrabberV4L2Config;
|
||||||
|
migrated = true;
|
||||||
|
Debug(_log, "GrabberV4L2 Layout migrated");
|
||||||
|
}
|
||||||
|
}
|
||||||
return migrated;
|
return migrated;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user