mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Dynamic Device Selection/Configuration (#1164)
This commit is contained in:
154
assets/webconfig/js/content_colors.js
Normal file → Executable file
154
assets/webconfig/js/content_colors.js
Normal file → Executable file
@@ -1,84 +1,80 @@
|
||||
$(document).ready( function() {
|
||||
performTranslation();
|
||||
var editor_color = null;
|
||||
var editor_smoothing = null;
|
||||
var editor_blackborder = null;
|
||||
|
||||
if(window.showOptHelp)
|
||||
{
|
||||
//color
|
||||
$('#conf_cont').append(createRow('conf_cont_color'));
|
||||
$('#conf_cont_color').append(createOptPanel('fa-photo', $.i18n("edt_conf_color_heading_title"), 'editor_container_color', 'btn_submit_color'));
|
||||
$('#conf_cont_color').append(createHelpTable(window.schema.color.properties, $.i18n("edt_conf_color_heading_title")));
|
||||
|
||||
//smoothing
|
||||
$('#conf_cont').append(createRow('conf_cont_smoothing'));
|
||||
$('#conf_cont_smoothing').append(createOptPanel('fa-photo', $.i18n("edt_conf_smooth_heading_title"), 'editor_container_smoothing', 'btn_submit_smoothing'));
|
||||
$('#conf_cont_smoothing').append(createHelpTable(window.schema.smoothing.properties, $.i18n("edt_conf_smooth_heading_title")));
|
||||
|
||||
//blackborder
|
||||
$('#conf_cont').append(createRow('conf_cont_blackborder'));
|
||||
$('#conf_cont_blackborder').append(createOptPanel('fa-photo', $.i18n("edt_conf_bb_heading_title"), 'editor_container_blackborder', 'btn_submit_blackborder'));
|
||||
$('#conf_cont_blackborder').append(createHelpTable(window.schema.blackborderdetector.properties, $.i18n("edt_conf_bb_heading_title")));
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#conf_cont').addClass('row');
|
||||
$('#conf_cont').append(createOptPanel('fa-photo', $.i18n("edt_conf_color_heading_title"), 'editor_container_color', 'btn_submit_color'));
|
||||
$('#conf_cont').append(createOptPanel('fa-photo', $.i18n("edt_conf_smooth_heading_title"), 'editor_container_smoothing', 'btn_submit_smoothing'));
|
||||
$('#conf_cont').append(createOptPanel('fa-photo', $.i18n("edt_conf_bb_heading_title"), 'editor_container_blackborder', 'btn_submit_blackborder'));
|
||||
}
|
||||
|
||||
//color
|
||||
editor_color = createJsonEditor('editor_container_color', {
|
||||
color : window.schema.color
|
||||
}, true, true);
|
||||
$(document).ready(function () {
|
||||
performTranslation();
|
||||
var editor_color = null;
|
||||
var editor_smoothing = null;
|
||||
var editor_blackborder = null;
|
||||
|
||||
editor_color.on('change',function() {
|
||||
editor_color.validate().length || window.readOnlyMode ? $('#btn_submit_color').attr('disabled', true) : $('#btn_submit_color').attr('disabled', false);
|
||||
});
|
||||
|
||||
$('#btn_submit_color').off().on('click',function() {
|
||||
requestWriteConfig(editor_color.getValue());
|
||||
});
|
||||
|
||||
//smoothing
|
||||
editor_smoothing = createJsonEditor('editor_container_smoothing', {
|
||||
smoothing : window.schema.smoothing
|
||||
}, true, true);
|
||||
if (window.showOptHelp) {
|
||||
//color
|
||||
$('#conf_cont').append(createRow('conf_cont_color'));
|
||||
$('#conf_cont_color').append(createOptPanel('fa-photo', $.i18n("edt_conf_color_heading_title"), 'editor_container_color', 'btn_submit_color'));
|
||||
$('#conf_cont_color').append(createHelpTable(window.schema.color.properties, $.i18n("edt_conf_color_heading_title")));
|
||||
|
||||
editor_smoothing.on('change',function() {
|
||||
editor_smoothing.validate().length || window.readOnlyMode ? $('#btn_submit_smoothing').attr('disabled', true) : $('#btn_submit_smoothing').attr('disabled', false);
|
||||
|
||||
});
|
||||
|
||||
$('#btn_submit_smoothing').off().on('click',function() {
|
||||
requestWriteConfig(editor_smoothing.getValue());
|
||||
});
|
||||
//smoothing
|
||||
$('#conf_cont').append(createRow('conf_cont_smoothing'));
|
||||
$('#conf_cont_smoothing').append(createOptPanel('fa-photo', $.i18n("edt_conf_smooth_heading_title"), 'editor_container_smoothing', 'btn_submit_smoothing'));
|
||||
$('#conf_cont_smoothing').append(createHelpTable(window.schema.smoothing.properties, $.i18n("edt_conf_smooth_heading_title")));
|
||||
|
||||
//blackborder
|
||||
editor_blackborder = createJsonEditor('editor_container_blackborder', {
|
||||
blackborderdetector: window.schema.blackborderdetector
|
||||
}, true, true);
|
||||
//blackborder
|
||||
$('#conf_cont').append(createRow('conf_cont_blackborder'));
|
||||
$('#conf_cont_blackborder').append(createOptPanel('fa-photo', $.i18n("edt_conf_bb_heading_title"), 'editor_container_blackborder', 'btn_submit_blackborder'));
|
||||
$('#conf_cont_blackborder').append(createHelpTable(window.schema.blackborderdetector.properties, $.i18n("edt_conf_bb_heading_title")));
|
||||
}
|
||||
else {
|
||||
$('#conf_cont').addClass('row');
|
||||
$('#conf_cont').append(createOptPanel('fa-photo', $.i18n("edt_conf_color_heading_title"), 'editor_container_color', 'btn_submit_color'));
|
||||
$('#conf_cont').append(createOptPanel('fa-photo', $.i18n("edt_conf_smooth_heading_title"), 'editor_container_smoothing', 'btn_submit_smoothing'));
|
||||
$('#conf_cont').append(createOptPanel('fa-photo', $.i18n("edt_conf_bb_heading_title"), 'editor_container_blackborder', 'btn_submit_blackborder'));
|
||||
}
|
||||
|
||||
editor_blackborder.on('change',function() {
|
||||
editor_blackborder.validate().length || window.readOnlyMode ? $('#btn_submit_blackborder').attr('disabled', true) : $('#btn_submit_blackborder').attr('disabled', false);
|
||||
});
|
||||
|
||||
$('#btn_submit_blackborder').off().on('click',function() {
|
||||
requestWriteConfig(editor_blackborder.getValue());
|
||||
});
|
||||
|
||||
//wiki links
|
||||
$('#editor_container_blackborder').append(buildWL("user/moretopics/bbmode","edt_conf_bb_mode_title",true));
|
||||
|
||||
//create introduction
|
||||
if(window.showOptHelp)
|
||||
{
|
||||
createHint("intro", $.i18n('conf_colors_color_intro'), "editor_container_color");
|
||||
createHint("intro", $.i18n('conf_colors_smoothing_intro'), "editor_container_smoothing");
|
||||
createHint("intro", $.i18n('conf_colors_blackborder_intro'), "editor_container_blackborder");
|
||||
}
|
||||
|
||||
removeOverlay();
|
||||
//color
|
||||
editor_color = createJsonEditor('editor_container_color', {
|
||||
color: window.schema.color
|
||||
}, true, true);
|
||||
|
||||
editor_color.on('change', function () {
|
||||
editor_color.validate().length || window.readOnlyMode ? $('#btn_submit_color').attr('disabled', true) : $('#btn_submit_color').attr('disabled', false);
|
||||
});
|
||||
|
||||
$('#btn_submit_color').off().on('click', function () {
|
||||
requestWriteConfig(editor_color.getValue());
|
||||
});
|
||||
|
||||
//smoothing
|
||||
editor_smoothing = createJsonEditor('editor_container_smoothing', {
|
||||
smoothing: window.schema.smoothing
|
||||
}, true, true);
|
||||
|
||||
editor_smoothing.on('change', function () {
|
||||
editor_smoothing.validate().length || window.readOnlyMode ? $('#btn_submit_smoothing').attr('disabled', true) : $('#btn_submit_smoothing').attr('disabled', false);
|
||||
});
|
||||
|
||||
$('#btn_submit_smoothing').off().on('click', function () {
|
||||
requestWriteConfig(editor_smoothing.getValue());
|
||||
});
|
||||
|
||||
//blackborder
|
||||
editor_blackborder = createJsonEditor('editor_container_blackborder', {
|
||||
blackborderdetector: window.schema.blackborderdetector
|
||||
}, true, true);
|
||||
|
||||
editor_blackborder.on('change', function () {
|
||||
editor_blackborder.validate().length || window.readOnlyMode ? $('#btn_submit_blackborder').attr('disabled', true) : $('#btn_submit_blackborder').attr('disabled', false);
|
||||
});
|
||||
|
||||
$('#btn_submit_blackborder').off().on('click', function () {
|
||||
requestWriteConfig(editor_blackborder.getValue());
|
||||
});
|
||||
|
||||
//wiki links
|
||||
$('#editor_container_blackborder').append(buildWL("user/advanced/Advanced.html#blackbar-detection", "edt_conf_bb_mode_title", true));
|
||||
|
||||
//create introduction
|
||||
if (window.showOptHelp) {
|
||||
createHint("intro", $.i18n('conf_colors_color_intro'), "editor_container_color");
|
||||
createHint("intro", $.i18n('conf_colors_smoothing_intro'), "editor_container_smoothing");
|
||||
createHint("intro", $.i18n('conf_colors_blackborder_intro'), "editor_container_blackborder");
|
||||
}
|
||||
|
||||
removeOverlay();
|
||||
});
|
||||
|
575
assets/webconfig/js/content_index.js
Normal file → Executable file
575
assets/webconfig/js/content_index.js
Normal file → Executable file
@@ -1,354 +1,357 @@
|
||||
var instNameInit = false
|
||||
|
||||
$(document).ready(function () {
|
||||
var darkModeOverwrite = getStorage("darkModeOverwrite", true);
|
||||
|
||||
var darkModeOverwrite = getStorage("darkModeOverwrite", true);
|
||||
if (darkModeOverwrite == "false" || darkModeOverwrite == null) {
|
||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
handleDarkMode();
|
||||
}
|
||||
|
||||
if(darkModeOverwrite == "false" || darkModeOverwrite == null)
|
||||
{
|
||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
handleDarkMode();
|
||||
}
|
||||
|
||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
|
||||
setStorage("darkMode", "off", false);
|
||||
}
|
||||
}
|
||||
|
||||
if(getStorage("darkMode", false) == "on")
|
||||
{
|
||||
handleDarkMode();
|
||||
}
|
||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
|
||||
setStorage("darkMode", "off", false);
|
||||
}
|
||||
}
|
||||
|
||||
loadContentTo("#container_connection_lost", "connection_lost");
|
||||
loadContentTo("#container_restart", "restart");
|
||||
initWebSocket();
|
||||
if (getStorage("darkMode", false) == "on") {
|
||||
handleDarkMode();
|
||||
}
|
||||
|
||||
$(window.hyperion).on("cmd-serverinfo", function (event) {
|
||||
window.serverInfo = event.response.info;
|
||||
|
||||
window.readOnlyMode = window.sysInfo.hyperion.readOnlyMode;
|
||||
|
||||
// comps
|
||||
window.comps = event.response.info.components
|
||||
loadContentTo("#container_connection_lost", "connection_lost");
|
||||
loadContentTo("#container_restart", "restart");
|
||||
initWebSocket();
|
||||
|
||||
$(window.hyperion).trigger("ready");
|
||||
$(window.hyperion).on("cmd-serverinfo", function (event) {
|
||||
window.serverInfo = event.response.info;
|
||||
|
||||
window.comps.forEach(function (obj) {
|
||||
if (obj.name == "ALL") {
|
||||
if (obj.enabled)
|
||||
$("#hyperion_disabled_notify").fadeOut("fast");
|
||||
else
|
||||
$("#hyperion_disabled_notify").fadeIn("fast");
|
||||
}
|
||||
});
|
||||
window.readOnlyMode = window.sysInfo.hyperion.readOnlyMode;
|
||||
|
||||
// determine button visibility
|
||||
var running = window.serverInfo.instance.filter(entry => entry.running);
|
||||
if (running.length > 1)
|
||||
$('#btn_hypinstanceswitch').toggle(true)
|
||||
else
|
||||
$('#btn_hypinstanceswitch').toggle(false)
|
||||
// update listing at button
|
||||
updateHyperionInstanceListing()
|
||||
if (!instNameInit) {
|
||||
window.currentHyperionInstanceName = getInstanceNameByIndex(0);
|
||||
instNameInit = true;
|
||||
}
|
||||
// comps
|
||||
window.comps = event.response.info.components
|
||||
|
||||
updateSessions();
|
||||
}); // end cmd-serverinfo
|
||||
$(window.hyperion).trigger("ready");
|
||||
|
||||
// Update language selection
|
||||
$("#language-select").on('changed.bs.select',function (e, clickedIndex, isSelected, previousValue){
|
||||
var newLang = availLang[clickedIndex-1];
|
||||
if (newLang !== storedLang)
|
||||
{
|
||||
setStorage("langcode", newLang);
|
||||
reload();
|
||||
}
|
||||
});
|
||||
window.comps.forEach(function (obj) {
|
||||
if (obj.name == "ALL") {
|
||||
if (obj.enabled)
|
||||
$("#hyperion_disabled_notify").fadeOut("fast");
|
||||
else
|
||||
$("#hyperion_disabled_notify").fadeIn("fast");
|
||||
}
|
||||
});
|
||||
|
||||
$("#language-select").selectpicker(
|
||||
{
|
||||
container: 'body'
|
||||
});
|
||||
// determine button visibility
|
||||
var running = window.serverInfo.instance.filter(entry => entry.running);
|
||||
if (running.length > 1)
|
||||
$('#btn_hypinstanceswitch').toggle(true)
|
||||
else
|
||||
$('#btn_hypinstanceswitch').toggle(false)
|
||||
// update listing at button
|
||||
updateHyperionInstanceListing()
|
||||
if (!instNameInit) {
|
||||
window.currentHyperionInstanceName = getInstanceNameByIndex(0);
|
||||
instNameInit = true;
|
||||
}
|
||||
|
||||
$(".bootstrap-select").click(function () {
|
||||
$(this).addClass("open");
|
||||
});
|
||||
updateSessions();
|
||||
}); // end cmd-serverinfo
|
||||
|
||||
$(document).click(function(){
|
||||
$(".bootstrap-select").removeClass("open");
|
||||
});
|
||||
// Update language selection
|
||||
$("#language-select").on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
|
||||
var newLang = availLang[clickedIndex - 1];
|
||||
if (newLang !== storedLang) {
|
||||
setStorage("langcode", newLang);
|
||||
reload();
|
||||
}
|
||||
});
|
||||
|
||||
$(".bootstrap-select").click(function(e){
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
//End language selection
|
||||
|
||||
$(window.hyperion).on("cmd-sessions-update", function (event) {
|
||||
window.serverInfo.sessions = event.response.data;
|
||||
updateSessions();
|
||||
});
|
||||
$("#language-select").selectpicker(
|
||||
{
|
||||
container: 'body'
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-authorize-tokenRequest cmd-authorize-getPendingTokenRequests", function (event) {
|
||||
var val = event.response.info;
|
||||
if (Array.isArray(event.response.info)) {
|
||||
if (event.response.info.length == 0) {
|
||||
return
|
||||
}
|
||||
val = event.response.info[0]
|
||||
if (val.comment == '')
|
||||
$('#modal_dialog').modal('hide');
|
||||
}
|
||||
$(".bootstrap-select").click(function () {
|
||||
$(this).addClass("open");
|
||||
});
|
||||
|
||||
showInfoDialog("grantToken", $.i18n('conf_network_tok_grantT'), $.i18n('conf_network_tok_grantMsg') + '<br><span style="font-weight:bold">App: ' + val.comment + '</span><br><span style="font-weight:bold">Code: ' + val.id + '</span>')
|
||||
$("#tok_grant_acc").off().on('click', function () {
|
||||
tokenList.push(val)
|
||||
// forward event, in case we need to rebuild the list now
|
||||
$(window.hyperion).trigger({ type: "build-token-list" });
|
||||
requestHandleTokenRequest(val.id, true)
|
||||
});
|
||||
$("#tok_deny_acc").off().on('click', function () {
|
||||
requestHandleTokenRequest(val.id, false)
|
||||
});
|
||||
});
|
||||
$(document).click(function () {
|
||||
$(".bootstrap-select").removeClass("open");
|
||||
});
|
||||
|
||||
$(window.hyperion).one("cmd-authorize-getTokenList", function (event) {
|
||||
tokenList = event.response.info;
|
||||
requestServerInfo();
|
||||
});
|
||||
$(".bootstrap-select").click(function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-sysinfo", function (event) {
|
||||
requestServerInfo();
|
||||
window.sysInfo = event.response.info;
|
||||
//End language selection
|
||||
|
||||
window.currentVersion = window.sysInfo.hyperion.version;
|
||||
window.currentChannel = window.sysInfo.hyperion.channel;
|
||||
});
|
||||
$(window.hyperion).on("cmd-sessions-update", function (event) {
|
||||
window.serverInfo.sessions = event.response.data;
|
||||
updateSessions();
|
||||
});
|
||||
|
||||
$(window.hyperion).one("cmd-config-getschema", function (event) {
|
||||
window.serverSchema = event.response.info;
|
||||
requestServerConfig();
|
||||
$(window.hyperion).on("cmd-authorize-tokenRequest cmd-authorize-getPendingTokenRequests", function (event) {
|
||||
var val = event.response.info;
|
||||
if (Array.isArray(event.response.info)) {
|
||||
if (event.response.info.length == 0) {
|
||||
return
|
||||
}
|
||||
val = event.response.info[0]
|
||||
if (val.comment == '')
|
||||
$('#modal_dialog').modal('hide');
|
||||
}
|
||||
|
||||
showInfoDialog("grantToken", $.i18n('conf_network_tok_grantT'), $.i18n('conf_network_tok_grantMsg') + '<br><span style="font-weight:bold">App: ' + val.comment + '</span><br><span style="font-weight:bold">Code: ' + val.id + '</span>')
|
||||
$("#tok_grant_acc").off().on('click', function () {
|
||||
tokenList.push(val)
|
||||
// forward event, in case we need to rebuild the list now
|
||||
$(window.hyperion).trigger({ type: "build-token-list" });
|
||||
requestHandleTokenRequest(val.id, true)
|
||||
});
|
||||
$("#tok_deny_acc").off().on('click', function () {
|
||||
requestHandleTokenRequest(val.id, false)
|
||||
});
|
||||
});
|
||||
|
||||
$(window.hyperion).one("cmd-authorize-getTokenList", function (event) {
|
||||
tokenList = event.response.info;
|
||||
requestServerInfo();
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-sysinfo", function (event) {
|
||||
requestServerInfo();
|
||||
window.sysInfo = event.response.info;
|
||||
|
||||
window.currentVersion = window.sysInfo.hyperion.version;
|
||||
window.currentChannel = window.sysInfo.hyperion.channel;
|
||||
});
|
||||
|
||||
$(window.hyperion).one("cmd-config-getschema", function (event) {
|
||||
window.serverSchema = event.response.info;
|
||||
requestServerConfig();
|
||||
requestTokenInfo();
|
||||
requestGetPendingTokenRequests();
|
||||
|
||||
window.schema = window.serverSchema.properties;
|
||||
});
|
||||
window.schema = window.serverSchema.properties;
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-config-getconfig", function (event) {
|
||||
window.serverConfig = event.response.info;
|
||||
requestSysInfo();
|
||||
$(window.hyperion).on("cmd-config-getconfig", function (event) {
|
||||
window.serverConfig = event.response.info;
|
||||
requestSysInfo();
|
||||
|
||||
window.showOptHelp = window.serverConfig.general.showOptHelp;
|
||||
});
|
||||
window.showOptHelp = window.serverConfig.general.showOptHelp;
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-config-setconfig", function (event) {
|
||||
if (event.response.success === true) {
|
||||
showNotification('success', $.i18n('dashboard_alert_message_confsave_success'), $.i18n('dashboard_alert_message_confsave_success_t'))
|
||||
}
|
||||
});
|
||||
$(window.hyperion).on("cmd-config-setconfig", function (event) {
|
||||
if (event.response.success === true) {
|
||||
showNotification('success', $.i18n('dashboard_alert_message_confsave_success'), $.i18n('dashboard_alert_message_confsave_success_t'))
|
||||
}
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-authorize-login", function (event) {
|
||||
$("#main-nav").removeAttr('style')
|
||||
$("#top-navbar").removeAttr('style')
|
||||
$(window.hyperion).on("cmd-authorize-login", function (event) {
|
||||
$("#main-nav").removeAttr('style')
|
||||
$("#top-navbar").removeAttr('style')
|
||||
|
||||
if (window.defaultPasswordIsSet === true && getStorage("suppressDefaultPwWarning") !== "true" )
|
||||
{
|
||||
var supprPwWarnCheckbox = '<div class="text-right">'+$.i18n('dashboard_message_do_not_show_again')
|
||||
+ ' <input id="chk_suppressDefaultPw" type="checkbox" onChange="suppressDefaultPwWarning()"> </div>'
|
||||
showNotification('warning', $.i18n('dashboard_message_default_password'), $.i18n('dashboard_message_default_password_t'), '<a style="cursor:pointer" onClick="changePassword()">'
|
||||
+ $.i18n('InfoDialog_changePassword_title') + '</a>' + supprPwWarnCheckbox)
|
||||
}
|
||||
else
|
||||
//if logged on and pw != default show option to lock ui
|
||||
$("#btn_lock_ui").removeAttr('style')
|
||||
if (window.defaultPasswordIsSet === true && getStorage("suppressDefaultPwWarning") !== "true") {
|
||||
var supprPwWarnCheckbox = '<div class="text-right">' + $.i18n('dashboard_message_do_not_show_again')
|
||||
+ ' <input id="chk_suppressDefaultPw" type="checkbox" onChange="suppressDefaultPwWarning()"> </div>'
|
||||
showNotification('warning', $.i18n('dashboard_message_default_password'), $.i18n('dashboard_message_default_password_t'), '<a style="cursor:pointer" onClick="changePassword()">'
|
||||
+ $.i18n('InfoDialog_changePassword_title') + '</a>' + supprPwWarnCheckbox)
|
||||
}
|
||||
else
|
||||
//if logged on and pw != default show option to lock ui
|
||||
$("#btn_lock_ui").removeAttr('style')
|
||||
|
||||
if (event.response.hasOwnProperty('info'))
|
||||
setStorage("loginToken", event.response.info.token, true);
|
||||
|
||||
if (event.response.hasOwnProperty('info'))
|
||||
setStorage("loginToken", event.response.info.token, true);
|
||||
requestServerConfigSchema();
|
||||
});
|
||||
|
||||
requestServerConfigSchema();
|
||||
});
|
||||
$(window.hyperion).on("cmd-authorize-newPassword", function (event) {
|
||||
if (event.response.success === true) {
|
||||
showInfoDialog("success", $.i18n('InfoDialog_changePassword_success'));
|
||||
// not necessarily true, but better than nothing
|
||||
window.defaultPasswordIsSet = false;
|
||||
}
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-authorize-newPassword", function (event) {
|
||||
if (event.response.success === true) {
|
||||
showInfoDialog("success", $.i18n('InfoDialog_changePassword_success'));
|
||||
// not necessarily true, but better than nothing
|
||||
window.defaultPasswordIsSet = false;
|
||||
}
|
||||
});
|
||||
$(window.hyperion).on("cmd-authorize-newPasswordRequired", function (event) {
|
||||
var loginToken = getStorage("loginToken", true)
|
||||
|
||||
$(window.hyperion).on("cmd-authorize-newPasswordRequired", function (event) {
|
||||
var loginToken = getStorage("loginToken", true)
|
||||
if (event.response.info.newPasswordRequired == true) {
|
||||
window.defaultPasswordIsSet = true;
|
||||
|
||||
if (event.response.info.newPasswordRequired == true) {
|
||||
window.defaultPasswordIsSet = true;
|
||||
if (loginToken)
|
||||
requestTokenAuthorization(loginToken)
|
||||
else
|
||||
requestAuthorization('hyperion');
|
||||
}
|
||||
else {
|
||||
$("#main-nav").attr('style', 'display:none')
|
||||
$("#top-navbar").attr('style', 'display:none')
|
||||
|
||||
if (loginToken)
|
||||
requestTokenAuthorization(loginToken)
|
||||
else
|
||||
requestAuthorization('hyperion');
|
||||
}
|
||||
else {
|
||||
$("#main-nav").attr('style', 'display:none')
|
||||
$("#top-navbar").attr('style', 'display:none')
|
||||
if (loginToken)
|
||||
requestTokenAuthorization(loginToken)
|
||||
else
|
||||
loadContentTo("#page-content", "login")
|
||||
}
|
||||
});
|
||||
|
||||
if (loginToken)
|
||||
requestTokenAuthorization(loginToken)
|
||||
else
|
||||
loadContentTo("#page-content", "login")
|
||||
}
|
||||
});
|
||||
$(window.hyperion).on("cmd-authorize-adminRequired", function (event) {
|
||||
//Check if a admin login is required.
|
||||
//If yes: check if default pw is set. If no: go ahead to get server config and render page
|
||||
if (event.response.info.adminRequired === true)
|
||||
requestRequiresDefaultPasswortChange();
|
||||
else
|
||||
requestServerConfigSchema();
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-authorize-adminRequired", function (event) {
|
||||
//Check if a admin login is required.
|
||||
//If yes: check if default pw is set. If no: go ahead to get server config and render page
|
||||
if (event.response.info.adminRequired === true)
|
||||
requestRequiresDefaultPasswortChange();
|
||||
else
|
||||
requestServerConfigSchema();
|
||||
});
|
||||
$(window.hyperion).on("error", function (event) {
|
||||
//If we are getting an error "No Authorization" back with a set loginToken we will forward to new Login (Token is expired.
|
||||
//e.g.: hyperiond was started new in the meantime)
|
||||
if (event.reason == "No Authorization" && getStorage("loginToken", true)) {
|
||||
removeStorage("loginToken", true);
|
||||
requestRequiresAdminAuth();
|
||||
}
|
||||
else {
|
||||
showInfoDialog("error", "Error", event.reason);
|
||||
}
|
||||
});
|
||||
|
||||
$(window.hyperion).on("error", function (event) {
|
||||
//If we are getting an error "No Authorization" back with a set loginToken we will forward to new Login (Token is expired.
|
||||
//e.g.: hyperiond was started new in the meantime)
|
||||
if (event.reason == "No Authorization" && getStorage("loginToken", true)) {
|
||||
removeStorage("loginToken", true);
|
||||
requestRequiresAdminAuth();
|
||||
}
|
||||
else {
|
||||
showInfoDialog("error", "Error", event.reason);
|
||||
}
|
||||
});
|
||||
$(window.hyperion).on("open", function (event) {
|
||||
requestRequiresAdminAuth();
|
||||
});
|
||||
|
||||
$(window.hyperion).on("open", function (event) {
|
||||
requestRequiresAdminAuth();
|
||||
});
|
||||
$(window.hyperion).one("ready", function (event) {
|
||||
loadContent();
|
||||
});
|
||||
|
||||
$(window.hyperion).one("ready", function (event) {
|
||||
loadContent();
|
||||
});
|
||||
$(window.hyperion).on("cmd-adjustment-update", function (event) {
|
||||
window.serverInfo.adjustment = event.response.data
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-adjustment-update", function (event) {
|
||||
window.serverInfo.adjustment = event.response.data
|
||||
});
|
||||
$(window.hyperion).on("cmd-videomode-update", function (event) {
|
||||
window.serverInfo.videomode = event.response.data.videomode
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-videomode-update", function (event) {
|
||||
window.serverInfo.videomode = event.response.data.videomode
|
||||
});
|
||||
$(window.hyperion).on("cmd-components-update", function (event) {
|
||||
let obj = event.response.data
|
||||
|
||||
$(window.hyperion).on("cmd-components-update", function (event) {
|
||||
let obj = event.response.data
|
||||
// notfication in index
|
||||
if (obj.name == "ALL") {
|
||||
if (obj.enabled)
|
||||
$("#hyperion_disabled_notify").fadeOut("fast");
|
||||
else
|
||||
$("#hyperion_disabled_notify").fadeIn("fast");
|
||||
}
|
||||
|
||||
// notfication in index
|
||||
if (obj.name == "ALL") {
|
||||
if (obj.enabled)
|
||||
$("#hyperion_disabled_notify").fadeOut("fast");
|
||||
else
|
||||
$("#hyperion_disabled_notify").fadeIn("fast");
|
||||
}
|
||||
window.comps.forEach((entry, index) => {
|
||||
if (entry.name === obj.name) {
|
||||
window.comps[index] = obj;
|
||||
}
|
||||
});
|
||||
// notify the update
|
||||
$(window.hyperion).trigger("components-updated", event.response.data);
|
||||
});
|
||||
|
||||
window.comps.forEach((entry, index) => {
|
||||
if (entry.name === obj.name) {
|
||||
window.comps[index] = obj;
|
||||
}
|
||||
});
|
||||
// notify the update
|
||||
$(window.hyperion).trigger("components-updated", event.response.data);
|
||||
});
|
||||
$(window.hyperion).on("cmd-instance-update", function (event) {
|
||||
window.serverInfo.instance = event.response.data
|
||||
var avail = event.response.data;
|
||||
// notify the update
|
||||
$(window.hyperion).trigger("instance-updated");
|
||||
|
||||
$(window.hyperion).on("cmd-instance-update", function (event) {
|
||||
window.serverInfo.instance = event.response.data
|
||||
var avail = event.response.data;
|
||||
// notify the update
|
||||
$(window.hyperion).trigger("instance-updated");
|
||||
// if our current instance is no longer available we are at instance 0 again.
|
||||
var isInData = false;
|
||||
for (var key in avail) {
|
||||
if (avail[key].instance == currentHyperionInstance && avail[key].running) {
|
||||
isInData = true;
|
||||
}
|
||||
}
|
||||
|
||||
// if our current instance is no longer available we are at instance 0 again.
|
||||
var isInData = false;
|
||||
for (var key in avail) {
|
||||
if (avail[key].instance == currentHyperionInstance && avail[key].running) {
|
||||
isInData = true;
|
||||
}
|
||||
}
|
||||
if (!isInData) {
|
||||
//Delete Storage information about the last used but now stopped instance
|
||||
if (getStorage('lastSelectedInstance', false))
|
||||
removeStorage('lastSelectedInstance', false)
|
||||
|
||||
if (!isInData) {
|
||||
//Delete Storage information about the last used but now stopped instance
|
||||
if (getStorage('lastSelectedInstance', false))
|
||||
removeStorage('lastSelectedInstance', false)
|
||||
currentHyperionInstance = 0;
|
||||
currentHyperionInstanceName = getInstanceNameByIndex(0);
|
||||
requestServerConfig();
|
||||
setTimeout(requestServerInfo, 100)
|
||||
setTimeout(requestTokenInfo, 200)
|
||||
setTimeout(loadContent, 300, undefined, true)
|
||||
}
|
||||
|
||||
currentHyperionInstance = 0;
|
||||
currentHyperionInstanceName = getInstanceNameByIndex(0);
|
||||
requestServerConfig();
|
||||
setTimeout(requestServerInfo, 100)
|
||||
setTimeout(requestTokenInfo, 200)
|
||||
setTimeout(loadContent, 300, undefined, true)
|
||||
}
|
||||
// determine button visibility
|
||||
var running = serverInfo.instance.filter(entry => entry.running);
|
||||
if (running.length > 1)
|
||||
$('#btn_hypinstanceswitch').toggle(true)
|
||||
else
|
||||
$('#btn_hypinstanceswitch').toggle(false)
|
||||
|
||||
// determine button visibility
|
||||
var running = serverInfo.instance.filter(entry => entry.running);
|
||||
if (running.length > 1)
|
||||
$('#btn_hypinstanceswitch').toggle(true)
|
||||
else
|
||||
$('#btn_hypinstanceswitch').toggle(false)
|
||||
// update listing for button
|
||||
updateHyperionInstanceListing()
|
||||
});
|
||||
|
||||
// update listing for button
|
||||
updateHyperionInstanceListing()
|
||||
});
|
||||
$(window.hyperion).on("cmd-instance-switchTo", function (event) {
|
||||
requestServerConfig();
|
||||
setTimeout(requestServerInfo, 200)
|
||||
setTimeout(requestTokenInfo, 400)
|
||||
setTimeout(loadContent, 400, undefined, true)
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-instance-switchTo", function (event) {
|
||||
requestServerConfig();
|
||||
setTimeout(requestServerInfo, 200)
|
||||
setTimeout(requestTokenInfo, 400)
|
||||
setTimeout(loadContent, 400, undefined, true)
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-effects-update", function (event) {
|
||||
window.serverInfo.effects = event.response.data.effects
|
||||
});
|
||||
|
||||
$(".mnava").bind('click.menu', function (e) {
|
||||
loadContent(e);
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
$(window.hyperion).on("cmd-effects-update", function (event) {
|
||||
window.serverInfo.effects = event.response.data.effects
|
||||
});
|
||||
|
||||
$(".mnava").bind('click.menu', function (e) {
|
||||
loadContent(e);
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
});
|
||||
|
||||
function suppressDefaultPwWarning(){
|
||||
|
||||
if (document.getElementById('chk_suppressDefaultPw').checked)
|
||||
setStorage("suppressDefaultPwWarning", "true");
|
||||
else
|
||||
setStorage("suppressDefaultPwWarning", "false");
|
||||
function suppressDefaultPwWarning() {
|
||||
if (document.getElementById('chk_suppressDefaultPw').checked)
|
||||
setStorage("suppressDefaultPwWarning", "true");
|
||||
else
|
||||
setStorage("suppressDefaultPwWarning", "false");
|
||||
}
|
||||
|
||||
$(function () {
|
||||
var sidebar = $('#side-menu'); // cache sidebar to a variable for performance
|
||||
sidebar.delegate('a.inactive', 'click', function () {
|
||||
sidebar.find('.active').toggleClass('active inactive');
|
||||
$(this).toggleClass('active inactive');
|
||||
});
|
||||
var sidebar = $('#side-menu'); // cache sidebar to a variable for performance
|
||||
sidebar.delegate('a.inactive', 'click', function () {
|
||||
sidebar.find('.active').toggleClass('active inactive');
|
||||
$(this).toggleClass('active inactive');
|
||||
});
|
||||
});
|
||||
|
||||
// hotfix body padding when bs modals overlap
|
||||
$(document.body).on('hide.bs.modal,hidden.bs.modal', function () {
|
||||
$('body').css('padding-right', '0');
|
||||
$('body').css('padding-right', '0');
|
||||
});
|
||||
|
||||
//Dark Mode
|
||||
$("#btn_darkmode").off().on("click",function(e){
|
||||
|
||||
if(getStorage("darkMode", false) != "on")
|
||||
{
|
||||
handleDarkMode();
|
||||
setStorage("darkModeOverwrite", true, true);
|
||||
}
|
||||
else {
|
||||
setStorage("darkMode", "off", false);
|
||||
setStorage("darkModeOverwrite", true, true);
|
||||
location.reload();
|
||||
}
|
||||
|
||||
$("#btn_darkmode").off().on("click", function (e) {
|
||||
if (getStorage("darkMode", false) != "on") {
|
||||
handleDarkMode();
|
||||
setStorage("darkModeOverwrite", true, true);
|
||||
}
|
||||
else {
|
||||
setStorage("darkMode", "off", false);
|
||||
setStorage("darkModeOverwrite", true, true);
|
||||
location.reload();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Menuitem toggle;
|
||||
function SwitchToMenuItem(target) {
|
||||
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;
|
||||
sidebar.find('.in').removeClass("in"); // Find all collapsed menu items and close it by remove "in" class;
|
||||
$('#' + 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;
|
||||
};
|
||||
|
||||
|
2019
assets/webconfig/js/content_leds.js
Normal file → Executable file
2019
assets/webconfig/js/content_leds.js
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
239
assets/webconfig/js/ui_utils.js
Normal file → Executable file
239
assets/webconfig/js/ui_utils.js
Normal file → Executable file
@@ -53,7 +53,7 @@ function updateSessions() {
|
||||
if (sess && sess.length) {
|
||||
window.wSess = [];
|
||||
for (var i = 0; i < sess.length; i++) {
|
||||
if (sess[i].type == "_hyperiond-http._tcp.") {
|
||||
if (sess[i].type == "_http._tcp." || sess[i].type == "_https._tcp." || sess[i].type == "_hyperiond-http._tcp.") {
|
||||
window.wSess.push(sess[i]);
|
||||
}
|
||||
}
|
||||
@@ -134,13 +134,13 @@ function updateHyperionInstanceListing() {
|
||||
var currInstMarker = (data[key].instance == window.currentHyperionInstance) ? "component-on" : "";
|
||||
|
||||
var html = '<li id="hyperioninstance_' + data[key].instance + '"> \
|
||||
<a> \
|
||||
<div> \
|
||||
<i class="fa fa-circle fa-fw '+ currInstMarker + '"></i> \
|
||||
<span>'+ data[key].friendly_name + '</span> \
|
||||
</div> \
|
||||
</a> \
|
||||
</li> '
|
||||
<a> \
|
||||
<div> \
|
||||
<i class="fa fa-circle fa-fw '+ currInstMarker + '"></i> \
|
||||
<span>'+ data[key].friendly_name + '</span> \
|
||||
</div> \
|
||||
</a> \
|
||||
</li> '
|
||||
|
||||
if (data.length - 1 > key)
|
||||
html += '<li class="divider"></li>'
|
||||
@@ -183,7 +183,6 @@ function initLanguageSelection() {
|
||||
langText = availLangText[langIdx];
|
||||
}
|
||||
}
|
||||
//console.log("langLocale: ", langLocale, "langText: ", langText);
|
||||
|
||||
$('#language-select').prop('title', langText);
|
||||
$("#language-select").val(langIdx);
|
||||
@@ -463,6 +462,170 @@ function createJsonEditor(container, schema, setconfig, usePanel, arrayre) {
|
||||
return editor;
|
||||
}
|
||||
|
||||
function updateJsonEditorSelection(editor, key, addElements, newEnumVals, newTitelVals, newDefaultVal, addSelect, addCustom, addCustomAsFirst, customText) {
|
||||
var orginalProperties = editor.schema.properties[key];
|
||||
|
||||
var newSchema = [];
|
||||
newSchema[key] =
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [],
|
||||
"required": true,
|
||||
"options": { "enum_titles": [], "infoText": "" },
|
||||
"propertyOrder": 1
|
||||
};
|
||||
|
||||
//Add additional elements to overwrite defaults
|
||||
for (var item in addElements) {
|
||||
newSchema[key][item] = addElements[item];
|
||||
}
|
||||
|
||||
if (orginalProperties) {
|
||||
if (orginalProperties["title"]) {
|
||||
newSchema[key]["title"] = orginalProperties["title"];
|
||||
}
|
||||
|
||||
if (orginalProperties["options"] && orginalProperties["options"]["infoText"]) {
|
||||
newSchema[key]["options"]["infoText"] = orginalProperties["options"]["infoText"];
|
||||
}
|
||||
|
||||
if (orginalProperties["propertyOrder"]) {
|
||||
newSchema[key]["propertyOrder"] = orginalProperties["propertyOrder"];
|
||||
}
|
||||
}
|
||||
|
||||
if (addCustom) {
|
||||
|
||||
if (newTitelVals.length === 0) {
|
||||
newTitelVals = [...newEnumVals];
|
||||
}
|
||||
|
||||
if (!!!customText) {
|
||||
customText = "edt_conf_enum_custom";
|
||||
}
|
||||
|
||||
if (addCustomAsFirst) {
|
||||
newEnumVals.unshift("CUSTOM");
|
||||
newTitelVals.unshift(customText);
|
||||
} else {
|
||||
newEnumVals.push("CUSTOM");
|
||||
newTitelVals.push(customText);
|
||||
}
|
||||
|
||||
if (newSchema[key].options.infoText) {
|
||||
var customInfoText = newSchema[key].options.infoText + "_custom";
|
||||
newSchema[key].options.infoText = customInfoText;
|
||||
}
|
||||
}
|
||||
|
||||
if (addSelect) {
|
||||
newEnumVals.unshift("SELECT");
|
||||
newTitelVals.unshift("edt_conf_enum_please_select");
|
||||
newDefaultVal = "SELECT";
|
||||
}
|
||||
|
||||
if (newEnumVals) {
|
||||
newSchema[key]["enum"] = newEnumVals;
|
||||
}
|
||||
|
||||
if (newTitelVals) {
|
||||
newSchema[key]["options"]["enum_titles"] = newTitelVals;
|
||||
}
|
||||
if (newDefaultVal) {
|
||||
newSchema[key]["default"] = newDefaultVal;
|
||||
}
|
||||
|
||||
editor.original_schema.properties[key] = orginalProperties;
|
||||
editor.schema.properties[key] = newSchema[key];
|
||||
|
||||
editor.removeObjectProperty(key);
|
||||
delete editor.cached_editors[key];
|
||||
editor.addObjectProperty(key);
|
||||
}
|
||||
|
||||
function updateJsonEditorMultiSelection(editor, key, addElements, newEnumVals, newTitelVals, newDefaultVal) {
|
||||
var orginalProperties = editor.schema.properties[key];
|
||||
|
||||
var newSchema = [];
|
||||
newSchema[key] =
|
||||
{
|
||||
"type": "array",
|
||||
"format": "select",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [],
|
||||
"options": { "enum_titles": [] },
|
||||
},
|
||||
"options": { "infoText": "" },
|
||||
"default": [],
|
||||
"propertyOrder": 1
|
||||
};
|
||||
|
||||
//Add additional elements to overwrite defaults
|
||||
for (var item in addElements) {
|
||||
newSchema[key][item] = addElements[item];
|
||||
}
|
||||
|
||||
if (orginalProperties) {
|
||||
if (orginalProperties["title"]) {
|
||||
newSchema[key]["title"] = orginalProperties["title"];
|
||||
}
|
||||
|
||||
if (orginalProperties["options"] && orginalProperties["options"]["infoText"]) {
|
||||
newSchema[key]["options"]["infoText"] = orginalProperties["options"]["infoText"];
|
||||
}
|
||||
|
||||
if (orginalProperties["propertyOrder"]) {
|
||||
newSchema[key]["propertyOrder"] = orginalProperties["propertyOrder"];
|
||||
}
|
||||
}
|
||||
|
||||
if (newEnumVals) {
|
||||
newSchema[key]["items"]["enum"] = newEnumVals;
|
||||
}
|
||||
|
||||
if (newTitelVals) {
|
||||
newSchema[key]["items"]["options"]["enum_titles"] = newTitelVals;
|
||||
}
|
||||
|
||||
if (newDefaultVal) {
|
||||
newSchema[key]["default"] = newDefaultVal;
|
||||
}
|
||||
|
||||
editor.original_schema.properties[key] = orginalProperties;
|
||||
editor.schema.properties[key] = newSchema[key];
|
||||
|
||||
editor.removeObjectProperty(key);
|
||||
delete editor.cached_editors[key];
|
||||
editor.addObjectProperty(key);
|
||||
}
|
||||
|
||||
function updateJsonEditorRange(editor, key, minimum, maximum, defaultValue, step) {
|
||||
var orginalProperties = editor.schema.properties[key];
|
||||
var newSchema = [];
|
||||
newSchema[key] = orginalProperties;
|
||||
|
||||
if (minimum) {
|
||||
newSchema[key]["minimum"] = minimum;
|
||||
}
|
||||
if (maximum) {
|
||||
newSchema[key]["maximum"] = maximum;
|
||||
}
|
||||
if (defaultValue) {
|
||||
newSchema[key]["default"] = defaultValue;
|
||||
}
|
||||
if (step) {
|
||||
newSchema[key]["step"] = step;
|
||||
}
|
||||
|
||||
editor.original_schema.properties[key] = orginalProperties;
|
||||
editor.schema.properties[key] = newSchema[key];
|
||||
|
||||
editor.removeObjectProperty(key);
|
||||
delete editor.cached_editors[key];
|
||||
editor.addObjectProperty(key);
|
||||
}
|
||||
|
||||
function buildWL(link, linkt, cl) {
|
||||
var baseLink = "https://docs.hyperion-project.org/";
|
||||
var lang;
|
||||
@@ -655,6 +818,48 @@ function createOptPanel(phicon, phead, bodyid, footerid) {
|
||||
return createPanel(phead, "", pfooter, "panel-default", bodyid);
|
||||
}
|
||||
|
||||
function compareTwoValues(key1, key2, order = 'asc') {
|
||||
return function innerSort(a, b) {
|
||||
if (!a.hasOwnProperty(key1) || !b.hasOwnProperty(key1)) {
|
||||
// property key1 doesn't exist on either object
|
||||
return 0;
|
||||
}
|
||||
|
||||
const varA1 = (typeof a[key1] === 'string')
|
||||
? a[key1].toUpperCase() : a[key1];
|
||||
const varB1 = (typeof b[key1] === 'string')
|
||||
? b[key1].toUpperCase() : b[key1];
|
||||
|
||||
let comparison = 0;
|
||||
if (varA1 > varB1) {
|
||||
comparison = 1;
|
||||
} else {
|
||||
if (varA1 < varB1) {
|
||||
comparison = -1;
|
||||
} else {
|
||||
if (!a.hasOwnProperty(key2) || !b.hasOwnProperty(key2)) {
|
||||
// property key2 doesn't exist on either object
|
||||
return 0;
|
||||
}
|
||||
|
||||
const varA2 = (typeof a[key2] === 'string')
|
||||
? a[key2].toUpperCase() : a[key2];
|
||||
const varB2 = (typeof b[key1] === 'string')
|
||||
? b[key2].toUpperCase() : b[key2];
|
||||
|
||||
if (varA2 > varB2) {
|
||||
comparison = 1;
|
||||
} else {
|
||||
comparison = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (
|
||||
(order === 'desc') ? (comparison * -1) : comparison
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
function sortProperties(list) {
|
||||
for (var key in list) {
|
||||
list[key].key = key;
|
||||
@@ -876,3 +1081,19 @@ function handleDarkMode() {
|
||||
$('#btn_darkmode_icon').removeClass('fa fa-moon-o');
|
||||
$('#btn_darkmode_icon').addClass('fa fa-sun-o');
|
||||
}
|
||||
|
||||
function isAccessLevelCompliant(accessLevel) {
|
||||
var isOK = true;
|
||||
if (accessLevel) {
|
||||
if (accessLevel === 'system') {
|
||||
isOK = false;
|
||||
}
|
||||
else if (accessLevel === 'advanced' && storedAccess === 'default') {
|
||||
isOK = false;
|
||||
}
|
||||
else if (accessLevel === 'expert' && storedAccess !== 'expert') {
|
||||
isOK = false;
|
||||
}
|
||||
}
|
||||
return isOK
|
||||
}
|
||||
|
437
assets/webconfig/js/wizard.js
Normal file → Executable file
437
assets/webconfig/js/wizard.js
Normal file → Executable file
@@ -424,7 +424,7 @@ function startWizardCC() {
|
||||
}
|
||||
//create html
|
||||
$('#wiz_header').html('<i class="fa fa-magic fa-fw"></i>' + $.i18n('wiz_cc_title'));
|
||||
$('#wizp1_body').html('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n('wiz_cc_title') + '</h4><p>' + $.i18n('wiz_cc_intro1') + '</p><label>' + $.i18n('wiz_cc_kwebs') + '</label><input class="form-control" style="width:170px;margin:auto" id="wiz_cc_kodiip" type="text" placeholder="' + kodiAddress + '" value="' + kodiAddress + '" /><span id="kodi_status"></span><span id="multi_cali"></span>');
|
||||
$('#wizp1_body').html('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n('wiz_cc_title') + '</h4><p>' + $.i18n('wiz_cc_intro1') + '</p><label>' + $.i18n('wiz_cc_kwebs') + '</label><input class="form-control" style="width:170px;margin:auto" id="wiz_cc_kodiip" type="text" placeholder="' + kodiAddress + '" value="' + kodiAddress + '" /><span id="kodi_status"></span><span id="multi_cali"></span>');
|
||||
$('#wizp1_footer').html('<button type="button" class="btn btn-primary" id="btn_wiz_cont" disabled="disabled"><i class="fa fa-fw fa-check"></i>' + $.i18n('general_btn_continue') + '</button><button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>' + $.i18n('general_btn_cancel') + '</button>');
|
||||
$('#wizp2_body').html('<div id="wiz_cc_desc" style="font-weight:bold"></div><div id="editor_container_wiz"></div>');
|
||||
$('#wizp2_footer').html('<button type="button" class="btn btn-primary" id="btn_wiz_back"><i class="fa fa-fw fa-chevron-left"></i>' + $.i18n('general_btn_back') + '</button><button type="button" class="btn btn-primary" id="btn_wiz_next">' + $.i18n('general_btn_next') + '<i style="margin-left:4px;"class="fa fa-fw fa-chevron-right"></i></button><button type="button" class="btn btn-warning" id="btn_wiz_save" style="display:none"><i class="fa fa-fw fa-save"></i>' + $.i18n('general_btn_save') + '</button><button type="button" class="btn btn-danger" id="btn_wiz_abort"><i class="fa fa-fw fa-close"></i>' + $.i18n('general_btn_cancel') + '</button>');
|
||||
@@ -437,10 +437,9 @@ function startWizardCC() {
|
||||
});
|
||||
|
||||
$('#wiz_cc_kodiip').off().on('change', function () {
|
||||
|
||||
kodiAddress = $(this).val().trim();
|
||||
$('#wizp1_body').find("kodiAddress").val(kodiAddress);
|
||||
|
||||
|
||||
$('#kodi_status').html('');
|
||||
|
||||
// Remove Kodi's default Web-Socket port (9090) from display and ensure Kodi's default REST-API port (8080) is mapped to web-socket port to ease migration
|
||||
@@ -788,8 +787,6 @@ async function discover_hue_bridges() {
|
||||
const r = res.info;
|
||||
|
||||
// Process devices returned by discovery
|
||||
console.log(r);
|
||||
|
||||
if (r.devices.length == 0)
|
||||
$('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
|
||||
else {
|
||||
@@ -832,7 +829,7 @@ async function identify_hue_device(hostAddress, username, id) {
|
||||
$('#btn_wiz_save').attr('disabled', true);
|
||||
|
||||
let params = { host: hostAddress, user: username, lightId: id };
|
||||
const res = await requestLedDeviceIdentification('philipshue', params);
|
||||
await requestLedDeviceIdentification('philipshue', params);
|
||||
|
||||
if (!window.readOnlyMode) {
|
||||
$('#btn_wiz_save').attr('disabled', false);
|
||||
@@ -1187,7 +1184,6 @@ function get_hue_lights() {
|
||||
}
|
||||
|
||||
(cC == 0 || window.readOnlyMode) ? $('#btn_wiz_save').attr("disabled", true) : $('#btn_wiz_save').attr("disabled", false);
|
||||
|
||||
});
|
||||
}
|
||||
$('.hue_sel_watch').trigger('change');
|
||||
@@ -1208,108 +1204,6 @@ function abortConnection(UserInterval) {
|
||||
$("#wiz_hue_usrstate").html($.i18n('wiz_hue_failure_connection'));
|
||||
}
|
||||
|
||||
//****************************
|
||||
// Wizard WLED
|
||||
//****************************
|
||||
var lights = null;
|
||||
function startWizardWLED(e) {
|
||||
//create html
|
||||
|
||||
var wled_title = 'wiz_wled_title';
|
||||
var wled_intro1 = 'wiz_wled_intro1';
|
||||
|
||||
$('#wiz_header').html('<i class="fa fa-magic fa-fw"></i>' + $.i18n(wled_title));
|
||||
$('#wizp1_body').html('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n(wled_title) + '</h4><p>' + $.i18n(wled_intro1) + '</p>');
|
||||
$('#wizp1_footer').html('<button type="button" class="btn btn-primary" id="btn_wiz_cont"><i class="fa fa-fw fa-check"></i>' + $.i18n('general_btn_continue') + '</button><button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>' + $.i18n('general_btn_cancel') + '</button>');
|
||||
|
||||
/*$('#wizp2_body').html('<div id="wh_topcontainer"></div>');
|
||||
|
||||
$('#wh_topcontainer').append('<div class="form-group" id="usrcont" style="display:none"></div>');
|
||||
|
||||
$('#wizp2_body').append('<div id="hue_ids_t" style="display:none"><p style="font-weight:bold" id="hue_id_headline">'+$.i18n('wiz_wled_desc2')+'</p></div>');
|
||||
|
||||
createTable("lidsh", "lidsb", "hue_ids_t");
|
||||
$('.lidsh').append(createTableRow([$.i18n('edt_dev_spec_lights_title'),$.i18n('wiz_pos'),$.i18n('wiz_identify')], true));
|
||||
$('#wizp2_footer').html('<button type="button" class="btn btn-primary" id="btn_wiz_save" style="display:none"><i class="fa fa-fw fa-save"></i>'+$.i18n('general_btn_save')+'</button><button type="button" class="btn btn-danger" id="btn_wiz_abort"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
|
||||
*/
|
||||
//open modal
|
||||
$("#wizard_modal").modal({
|
||||
backdrop: "static",
|
||||
keyboard: false,
|
||||
show: true
|
||||
});
|
||||
|
||||
//listen for continue
|
||||
$('#btn_wiz_cont').off().on('click', function () {
|
||||
/* For testing only
|
||||
|
||||
discover_wled();
|
||||
|
||||
var hostAddress = conf_editor.getEditor("root.specificOptions.host").getValue();
|
||||
if(hostAddress != "")
|
||||
{
|
||||
getProperties_wled(hostAddress,"info");
|
||||
identify_wled(hostAddress)
|
||||
}
|
||||
|
||||
For testing only */
|
||||
});
|
||||
}
|
||||
|
||||
async function discover_wled() {
|
||||
const res = await requestLedDeviceDiscovery('wled');
|
||||
|
||||
// TODO: error case unhandled
|
||||
// res can be: false (timeout) or res.error (not found)
|
||||
if (res && !res.error) {
|
||||
const r = res.info
|
||||
|
||||
// Process devices returned by discovery
|
||||
console.log(r);
|
||||
|
||||
if (r.devices.length == 0)
|
||||
$('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
|
||||
else {
|
||||
for (const device of r.devices) {
|
||||
console.log("Device:", device);
|
||||
|
||||
var ip = device.hostname + ":" + device.port;
|
||||
console.log("Host:", ip);
|
||||
|
||||
//wledIPs.push({internalipaddress : ip});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function getProperties_wled(hostAddress, resourceFilter) {
|
||||
let params = { host: hostAddress, filter: resourceFilter };
|
||||
|
||||
const res = await requestLedDeviceProperties('wled', params);
|
||||
|
||||
// TODO: error case unhandled
|
||||
// res can be: false (timeout) or res.error (not found)
|
||||
if (res && !res.error) {
|
||||
const r = res.info
|
||||
|
||||
// Process properties returned
|
||||
console.log(r);
|
||||
}
|
||||
}
|
||||
|
||||
async function identify_wled(hostAddress) {
|
||||
|
||||
// Take care that new record cannot be save during background process
|
||||
$('#btn_wiz_save').attr('disabled', true);
|
||||
|
||||
let params = { host: hostAddress };
|
||||
const res = await requestLedDeviceIdentification('wled', params);
|
||||
|
||||
if (!window.readOnlyMode) {
|
||||
$('#btn_wiz_save').attr('disabled', false);
|
||||
}
|
||||
}
|
||||
|
||||
//****************************
|
||||
// Wizard Yeelight
|
||||
//****************************
|
||||
@@ -1438,8 +1332,17 @@ async function discover_yeelight_lights() {
|
||||
var light = {};
|
||||
light.host = device.hostname;
|
||||
light.port = device.port;
|
||||
light.name = device.other.name;
|
||||
light.model = device.other.model;
|
||||
|
||||
if (device.txt) {
|
||||
light.name = device.name;
|
||||
light.model = device.txt.md;
|
||||
//Yeelight does not provide correct API port with mDNS response, use default one
|
||||
light.port = 55443;
|
||||
}
|
||||
else {
|
||||
light.name = device.other.name;
|
||||
light.model = device.other.model;
|
||||
}
|
||||
lights.push(light);
|
||||
}
|
||||
}
|
||||
@@ -1469,7 +1372,8 @@ async function discover_yeelight_lights() {
|
||||
}
|
||||
|
||||
function assign_yeelight_lights() {
|
||||
var models = ['color', 'color1', 'color2', 'color4', 'stripe', 'strip1'];
|
||||
// Model mappings, see https://www.home-assistant.io/integrations/yeelight/
|
||||
var models = ['color', 'color1', 'YLDP02YL', 'YLDP02YL', 'color2', 'YLDP06YL', 'color4', 'YLDP13YL', 'stripe', 'YLDD04YL', 'strip1', 'YLDD01YL', 'YLDD02YL'];
|
||||
|
||||
// If records are left for configuration
|
||||
if (Object.keys(lights).length > 0) {
|
||||
@@ -1534,7 +1438,7 @@ function assign_yeelight_lights() {
|
||||
$('.yee_sel_watch').trigger('change');
|
||||
}
|
||||
else {
|
||||
var noLightsTxt = '<p style="font-weight:bold;color:red;">' + $.i18n('wiz_noLights','Yeelights') + '</p>';
|
||||
var noLightsTxt = '<p style="font-weight:bold;color:red;">' + $.i18n('wiz_noLights', 'Yeelights') + '</p>';
|
||||
$('#wizp2_body').append(noLightsTxt);
|
||||
}
|
||||
}
|
||||
@@ -1555,15 +1459,14 @@ async function getProperties_yeelight(hostname, port) {
|
||||
}
|
||||
|
||||
async function identify_yeelight_device(hostname, port) {
|
||||
|
||||
// Take care that new record cannot be save during background process
|
||||
$('#btn_wiz_save').attr('disabled', true);
|
||||
|
||||
let params = { hostname: hostname, port: port };
|
||||
const res = await requestLedDeviceIdentification("yeelight", params);
|
||||
await requestLedDeviceIdentification("yeelight", params);
|
||||
|
||||
if (!window.readOnlyMode) {
|
||||
$('#btn_wiz_save').attr('disabled', false);
|
||||
$('#btn_wiz_save').attr('disabled', false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1675,14 +1578,12 @@ async function discover_atmoorb_lights(multiCastGroup, multiCastPort) {
|
||||
var light = {};
|
||||
|
||||
var params = {};
|
||||
if (multiCastGroup !== "")
|
||||
{
|
||||
if (multiCastGroup !== "") {
|
||||
params.multiCastGroup = multiCastGroup;
|
||||
}
|
||||
|
||||
if (multiCastPort !== 0)
|
||||
{
|
||||
params.multiCastPort = multiCastPort;
|
||||
if (multiCastPort !== 0) {
|
||||
params.multiCastPort = multiCastPort;
|
||||
}
|
||||
|
||||
// Get discovered lights
|
||||
@@ -1692,7 +1593,7 @@ async function discover_atmoorb_lights(multiCastGroup, multiCastPort) {
|
||||
// res can be: false (timeout) or res.error (not found)
|
||||
if (res && !res.error) {
|
||||
const r = res.info;
|
||||
|
||||
|
||||
// Process devices returned by discovery
|
||||
for (const device of r.devices) {
|
||||
if (device.id !== "") {
|
||||
@@ -1774,7 +1675,7 @@ function assign_atmoorb_lights() {
|
||||
|
||||
$('.lidsb').append(createTableRow([orbId + lightAnnotation, '<select id="orb_' + lightid + '" ' + enabled + ' class="orb_sel_watch form-control">'
|
||||
+ options
|
||||
+ '</select>', '<button class="btn btn-sm btn-primary" ' + enabled + ' onClick=identify_atmoorb_device(' + orbId + ')>'
|
||||
+ '</select>', '<button class="btn btn-sm btn-primary" ' + enabled + ' onClick=identify_atmoorb_device("' + orbId + '")>'
|
||||
+ $.i18n('wiz_identify_light', orbId) + '</button>']));
|
||||
}
|
||||
|
||||
@@ -1793,303 +1694,19 @@ function assign_atmoorb_lights() {
|
||||
$('.orb_sel_watch').trigger('change');
|
||||
}
|
||||
else {
|
||||
var noLightsTxt = '<p style="font-weight:bold;color:red;">' + $.i18n('wiz_noLights','AtmoOrbs') + '</p>';
|
||||
var noLightsTxt = '<p style="font-weight:bold;color:red;">' + $.i18n('wiz_noLights', 'AtmoOrbs') + '</p>';
|
||||
$('#wizp2_body').append(noLightsTxt);
|
||||
}
|
||||
}
|
||||
|
||||
async function identify_atmoorb_device(orbId) {
|
||||
|
||||
// Take care that new record cannot be save during background process
|
||||
$('#btn_wiz_save').attr('disabled', true);
|
||||
|
||||
let params = { id: orbId };
|
||||
const res = await requestLedDeviceIdentification("atmoorb", params);
|
||||
await requestLedDeviceIdentification("atmoorb", params);
|
||||
|
||||
if (!window.readOnlyMode) {
|
||||
$('#btn_wiz_save').attr('disabled', false);
|
||||
}
|
||||
}
|
||||
|
||||
//****************************
|
||||
// Wizard/Routines Nanoleaf
|
||||
//****************************
|
||||
async function discover_nanoleaf() {
|
||||
const res = await requestLedDeviceDiscovery('nanoleaf');
|
||||
|
||||
// TODO: error case unhandled
|
||||
// res can be: false (timeout) or res.error (not found)
|
||||
if (res && !res.error) {
|
||||
const r = res.info
|
||||
|
||||
// Process devices returned by discovery
|
||||
console.log(r);
|
||||
|
||||
if (r.devices.length == 0)
|
||||
$('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
|
||||
else {
|
||||
for (const device of r.devices) {
|
||||
console.log("Device:", device);
|
||||
|
||||
var ip = device.hostname + ":" + device.port;
|
||||
console.log("Host:", ip);
|
||||
|
||||
//nanoleafIPs.push({internalipaddress : ip});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function getProperties_nanoleaf(hostAddress, authToken, resourceFilter) {
|
||||
let params = { host: hostAddress, token: authToken, filter: resourceFilter };
|
||||
|
||||
const res = await requestLedDeviceProperties('nanoleaf', params);
|
||||
|
||||
// TODO: error case unhandled
|
||||
// res can be: false (timeout) or res.error (not found)
|
||||
if (res && !res.error) {
|
||||
const r = res.info
|
||||
|
||||
// Process properties returned
|
||||
console.log(r);
|
||||
}
|
||||
}
|
||||
|
||||
async function identify_nanoleaf(hostAddress, authToken) {
|
||||
|
||||
// Take care that new record cannot be save during background process
|
||||
$('#btn_wiz_save').attr('disabled', true);
|
||||
|
||||
let params = { host: hostAddress, token: authToken };
|
||||
const res = await requestLedDeviceIdentification('nanoleaf', params);
|
||||
|
||||
if (!window.readOnlyMode) {
|
||||
$('#btn_wiz_save').attr('disabled', false);
|
||||
}
|
||||
}
|
||||
|
||||
//****************************
|
||||
// Wizard Cololight
|
||||
//****************************
|
||||
var lights = null;
|
||||
var selectedLightId = null;
|
||||
|
||||
function startWizardCololight(e) {
|
||||
//create html
|
||||
|
||||
var cololight_title = 'wiz_cololight_title';
|
||||
var cololight_intro1 = 'wiz_cololight_intro1';
|
||||
|
||||
$('#wiz_header').html('<i class="fa fa-magic fa-fw"></i>' + $.i18n(cololight_title));
|
||||
$('#wizp1_body').html('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n(cololight_title) + '</h4><p>' + $.i18n(cololight_intro1) + '</p>');
|
||||
$('#wizp1_footer').html('<button type="button" class="btn btn-primary" id="btn_wiz_cont"><i class="fa fa-fw fa-check"></i>' + $.i18n('general_btn_continue') + '</button><button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>' + $.i18n('general_btn_cancel') + '</button>');
|
||||
|
||||
$('#wizp2_body').html('<div id="wh_topcontainer"></div>');
|
||||
|
||||
$('#wh_topcontainer').append('<div class="form-group" id="usrcont" style="display:none"></div>');
|
||||
|
||||
$('#wizp2_body').append('<div id="colo_ids_t" style="display:none"><p style="font-weight:bold" id="colo_id_headline">' + $.i18n('wiz_cololight_desc2') + '</p></div>');
|
||||
|
||||
createTable("lidsh", "lidsb", "colo_ids_t");
|
||||
$('.lidsh').append(createTableRow([$.i18n('edt_dev_spec_lights_title'), $.i18n('wiz_identify')], true));
|
||||
$('#wizp2_footer').html('<button type="button" class="btn btn-primary" id="btn_wiz_save" style="display:none"><i class="fa fa-fw fa-save"></i>'
|
||||
+ $.i18n('general_btn_save') + '</button><buttowindow.serverConfig.device = d;n type="button" class="btn btn-danger" id="btn_wiz_abort"><i class="fa fa-fw fa-close"></i>'
|
||||
+ $.i18n('general_btn_cancel') + '</button>');
|
||||
|
||||
//open modal
|
||||
$("#wizard_modal").modal({
|
||||
backdrop: "static",
|
||||
keyboard: false,
|
||||
show: true
|
||||
});
|
||||
|
||||
//listen for continue
|
||||
$('#btn_wiz_cont').off().on('click', function () {
|
||||
beginWizardCololight();
|
||||
$('#wizp1').toggle(false);
|
||||
$('#wizp2').toggle(true);
|
||||
});
|
||||
}
|
||||
|
||||
function beginWizardCololight() {
|
||||
lights = [];
|
||||
|
||||
discover_cololights();
|
||||
|
||||
$('#btn_wiz_save').off().on("click", function () {
|
||||
//LED device config
|
||||
//Start with a clean configuration
|
||||
var d = {};
|
||||
|
||||
d.type = 'cololight';
|
||||
|
||||
//Cololight does not resolve into stable hostnames (as devices named the same), therefore use IP
|
||||
if (!lights[selectedLightId].ip) {
|
||||
d.host = lights[selectedLightId].host;
|
||||
} else {
|
||||
d.host = lights[selectedLightId].ip;
|
||||
}
|
||||
|
||||
var coloLightProperties = lights[selectedLightId].props.properties;
|
||||
if (Object.keys(coloLightProperties).length === 0) {
|
||||
alert($.i18n('wiz_cololight_noprops'));
|
||||
d.hardwareLedCount = 1;
|
||||
}
|
||||
else {
|
||||
d.hardwareLedCount = coloLightProperties.ledCount;
|
||||
}
|
||||
|
||||
d.colorOrder = conf_editor.getEditor("root.generalOptions.colorOrder").getValue();
|
||||
d.latchTime = parseInt(conf_editor.getEditor("root.specificOptions.latchTime").getValue());;
|
||||
|
||||
window.serverConfig.device = d;
|
||||
|
||||
//LED layout - have initial layout prepared matching the LED-count
|
||||
|
||||
var coloLightLedConfig = [];
|
||||
|
||||
if (coloLightProperties.modelType === "Strip") {
|
||||
coloLightLedConfig = createClassicLedLayoutSimple(d.hardwareLedCount / 2, d.hardwareLedCount / 4, d.hardwareLedCount / 4, 0, d.hardwareLedCount / 4 * 3, false);
|
||||
} else {
|
||||
coloLightLedConfig = createClassicLedLayoutSimple(0, 0, 0, d.hardwareLedCount, 0, true);
|
||||
}
|
||||
|
||||
window.serverConfig.leds = coloLightLedConfig;
|
||||
|
||||
//smoothing off
|
||||
window.serverConfig.smoothing.enable = false;
|
||||
|
||||
requestWriteConfig(window.serverConfig, true);
|
||||
|
||||
resetWizard();
|
||||
});
|
||||
|
||||
$('#btn_wiz_abort').off().on('click', resetWizard);
|
||||
}
|
||||
|
||||
async function discover_cololights() {
|
||||
const res = await requestLedDeviceDiscovery('cololight');
|
||||
|
||||
if (res && !res.error) {
|
||||
const r = res.info;
|
||||
|
||||
// Process devices returned by discovery
|
||||
for (const device of r.devices) {
|
||||
if (device.ip !== "") {
|
||||
if (getIpInLights(device.ip).length === 0) {
|
||||
var light = {};
|
||||
light.ip = device.ip;
|
||||
light.host = device.hostname;
|
||||
light.name = device.name;
|
||||
light.type = device.type;
|
||||
lights.push(light);
|
||||
}
|
||||
}
|
||||
}
|
||||
assign_cololight_lights();
|
||||
}
|
||||
}
|
||||
|
||||
function assign_cololight_lights() {
|
||||
// If records are left for configuration
|
||||
if (Object.keys(lights).length > 0) {
|
||||
$('#wh_topcontainer').toggle(false);
|
||||
$('#colo_ids_t, #btn_wiz_save').toggle(true);
|
||||
|
||||
$('.lidsb').html("");
|
||||
|
||||
var options = "";
|
||||
|
||||
for (var lightid in lights) {
|
||||
lights[lightid].id = lightid;
|
||||
|
||||
var lightHostname = lights[lightid].host;
|
||||
var lightIP = lights[lightid].ip;
|
||||
|
||||
var val = lightHostname + " (" + lightIP + ")";
|
||||
options += '<option value="' + lightid + '">' + val + '</option>';
|
||||
}
|
||||
|
||||
var enabled = 'enabled';
|
||||
|
||||
$('.lidsb').append(createTableRow(['<select id="colo_select_id" ' + enabled + ' class="colo_sel_watch form-control">'
|
||||
+ options
|
||||
+ '</select>', '<button id="wiz_identify_btn" class="btn btn-sm btn-primary">'
|
||||
+ $.i18n('wiz_identify') + '</button>']));
|
||||
|
||||
$('.colo_sel_watch').bind("change", function () {
|
||||
selectedLightId = $('#colo_select_id').val();
|
||||
var lightIP = lights[selectedLightId].ip;
|
||||
|
||||
$('#wiz_identify_btn').unbind().bind('click', function (event) { identify_cololight_device(lightIP); });
|
||||
|
||||
if (!lights[selectedLightId].props) {
|
||||
getProperties_cololight(lightIP);
|
||||
}
|
||||
});
|
||||
$('.colo_sel_watch').trigger('change');
|
||||
}
|
||||
else {
|
||||
var noLightsTxt = '<p style="font-weight:bold;color:red;">' + $.i18n('wiz_noLights','Cololights') + '</p>';
|
||||
$('#wizp2_body').append(noLightsTxt);
|
||||
}
|
||||
}
|
||||
|
||||
async function getProperties_cololight(ip) {
|
||||
let params = { host: ip };
|
||||
|
||||
const res = await requestLedDeviceProperties('cololight', params);
|
||||
|
||||
if (res && !res.error) {
|
||||
var coloLightProperties = res.info;
|
||||
|
||||
//Store properties along light with given IP-address
|
||||
var id = getIpInLights(ip)[0].id;
|
||||
lights[id].props = coloLightProperties;
|
||||
}
|
||||
}
|
||||
|
||||
async function identify_cololight_device(hostAddress) {
|
||||
|
||||
// Take care that new record cannot be save during background process
|
||||
$('#btn_wiz_save').attr('disabled', true);
|
||||
|
||||
let params = { host: hostAddress };
|
||||
const res = await requestLedDeviceIdentification('cololight', params);
|
||||
|
||||
if (!window.readOnlyMode) {
|
||||
$('#btn_wiz_save').attr('disabled', false);
|
||||
}
|
||||
}
|
||||
|
||||
//****************************
|
||||
// Wizard/Routines RS232-Devices
|
||||
//****************************
|
||||
async function discover_providerRs232(rs232Type) {
|
||||
const res = await requestLedDeviceDiscovery(rs232Type);
|
||||
|
||||
// TODO: error case unhandled
|
||||
// res can be: false (timeout) or res.error (not found)
|
||||
if (res && !res.error) {
|
||||
const r = res.info
|
||||
|
||||
// Process serialPorts returned by discover
|
||||
console.log(r);
|
||||
}
|
||||
}
|
||||
|
||||
//****************************
|
||||
// Wizard/Routines HID (USB)-Devices
|
||||
//****************************
|
||||
async function discover_providerHid(hidType) {
|
||||
const res = await requestLedDeviceDiscovery(hidType);
|
||||
|
||||
// TODO: error case unhandled
|
||||
// res can be: false (timeout) or res.error (not found)
|
||||
if (res && !res.error) {
|
||||
const r = res.info
|
||||
|
||||
// Process HID returned by discover
|
||||
console.log(r);
|
||||
$('#btn_wiz_save').attr('disabled', false);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user