2017-02-08 14:36:28 +01:00
|
|
|
$(document).ready( function() {
|
|
|
|
performTranslation();
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
var importedConf;
|
|
|
|
var confName;
|
|
|
|
var conf_editor = null;
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
$('#conf_cont').append(createOptPanel('fa-wrench', $.i18n("edt_conf_gen_heading_title"), 'editor_container', 'btn_submit'));
|
2019-06-05 18:19:08 +02:00
|
|
|
if(window.showOptHelp)
|
2017-01-17 21:53:35 +01:00
|
|
|
{
|
2019-06-05 18:19:08 +02:00
|
|
|
$('#conf_cont').append(createHelpTable(window.schema.general.properties, $.i18n("edt_conf_gen_heading_title")));
|
2017-01-17 21:53:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
$('#conf_imp').appendTo('#conf_cont');
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2016-12-23 19:37:35 +01:00
|
|
|
conf_editor = createJsonEditor('editor_container', {
|
2019-06-05 18:19:08 +02:00
|
|
|
general: window.schema.general
|
2017-01-04 10:55:10 +01:00
|
|
|
}, true, true);
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
conf_editor.on('change',function() {
|
|
|
|
conf_editor.validate().length ? $('#btn_submit').attr('disabled', true) : $('#btn_submit').attr('disabled', false);
|
|
|
|
});
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2016-12-23 19:37:35 +01:00
|
|
|
$('#btn_submit').off().on('click',function() {
|
|
|
|
requestWriteConfig(conf_editor.getValue());
|
|
|
|
});
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
// Instance handling
|
2019-08-04 20:19:33 +02:00
|
|
|
function handleInstanceRename(e)
|
|
|
|
{
|
|
|
|
var inst = e.currentTarget.id.split("_")[1];
|
|
|
|
showInfoDialog('renInst', $.i18n('conf_general_inst_renreq_t'), getInstanceNameByIndex(inst));
|
|
|
|
|
|
|
|
$("#id_btn_ok").off().on('click', function(){
|
|
|
|
requestInstanceRename(inst, $('#renInst_name').val())
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#renInst_name').off().on('input',function(e) {
|
|
|
|
(e.currentTarget.value.length >= 5 && e.currentTarget.value != getInstanceNameByIndex(inst)) ? $('#id_btn_ok').attr('disabled', false) : $('#id_btn_ok').attr('disabled', true);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
function handleInstanceStartStop(e)
|
|
|
|
{
|
|
|
|
var inst = e.currentTarget.id.split("_")[1];
|
|
|
|
var start = (e.currentTarget.className == "btn btn-danger")
|
|
|
|
requestInstanceStartStop(inst, start)
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleInstanceDelete(e)
|
|
|
|
{
|
|
|
|
var inst = e.currentTarget.id.split("_")[1];
|
2019-08-04 20:19:33 +02:00
|
|
|
showInfoDialog('delInst',$.i18n('conf_general_inst_delreq_h'),$.i18n('conf_general_inst_delreq_t',getInstanceNameByIndex(inst)));
|
2019-07-14 22:43:22 +02:00
|
|
|
$("#id_btn_yes").off().on('click', function(){
|
|
|
|
requestInstanceDelete(inst)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function buildInstanceList()
|
|
|
|
{
|
|
|
|
var inst = serverInfo.instance
|
|
|
|
$('.itbody').html("");
|
|
|
|
for(var key in inst)
|
|
|
|
{
|
|
|
|
var startBtnColor = inst[key].running ? "success" : "danger";
|
2019-08-04 20:19:33 +02:00
|
|
|
var startBtnIcon = inst[key].running ? "stop" : "play";
|
2019-07-14 22:43:22 +02:00
|
|
|
var startBtnText = inst[key].running ? $.i18n('general_btn_stop') : $.i18n('general_btn_start');
|
2019-08-13 23:22:06 +02:00
|
|
|
var renameBtn = '<button id="instren_'+inst[key].instance+'" type="button" class="btn btn-primary"><i class="fa fa-fw fa-pencil"></i>'+$.i18n('general_btn_rename')+'</button>';
|
2019-08-04 20:19:33 +02:00
|
|
|
var startBtn = ""
|
|
|
|
var delBtn = "";
|
2019-07-14 22:43:22 +02:00
|
|
|
if(inst[key].instance > 0)
|
|
|
|
{
|
2019-08-13 23:22:06 +02:00
|
|
|
delBtn = '<button id="instdel_'+inst[key].instance+'" type="button" class="btn btn-warning"><i class="fa fa-fw fa-remove"></i>'+$.i18n('general_btn_delete')+'</button>';
|
|
|
|
startBtn = '<button id="inst_'+inst[key].instance+'" type="button" class="btn btn-'+startBtnColor+'"><i class="fa fa-fw fa-'+startBtnIcon+'"></i>'+startBtnText+'</button>';
|
2019-07-14 22:43:22 +02:00
|
|
|
}
|
2019-08-04 20:19:33 +02:00
|
|
|
$('.itbody').append(createTableRow([inst[key].friendly_name, renameBtn, startBtn, delBtn], false, true));
|
|
|
|
$('#instren_'+inst[key].instance).off().on('click', handleInstanceRename);
|
2019-07-14 22:43:22 +02:00
|
|
|
$('#inst_'+inst[key].instance).off().on('click', handleInstanceStartStop);
|
|
|
|
$('#instdel_'+inst[key].instance).off().on('click', handleInstanceDelete);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
createTable('ithead', 'itbody', 'itable');
|
2019-08-04 20:19:33 +02:00
|
|
|
$('.ithead').html(createTableRow([$.i18n('conf_general_inst_namehead'), "", $.i18n('conf_general_inst_actionhead'), ""], true, true));
|
2019-07-14 22:43:22 +02:00
|
|
|
buildInstanceList();
|
|
|
|
|
|
|
|
$('#inst_name').off().on('input',function(e) {
|
|
|
|
(e.currentTarget.value.length >= 5) ? $('#btn_create_inst').attr('disabled', false) : $('#btn_create_inst').attr('disabled', true);
|
2019-08-15 23:48:13 +02:00
|
|
|
if(5-e.currentTarget.value.length >= 1 && 5-e.currentTarget.value.length <= 4)
|
|
|
|
$('#inst_chars_needed').html(5-e.currentTarget.value.length + " " + $.i18n('general_chars_needed'))
|
|
|
|
else
|
|
|
|
$('#inst_chars_needed').html("<br />")
|
2019-07-14 22:43:22 +02:00
|
|
|
});
|
2019-08-04 20:19:33 +02:00
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
$('#btn_create_inst').off().on('click',function(e) {
|
|
|
|
requestInstanceCreate($('#inst_name').val());
|
2019-08-04 20:19:33 +02:00
|
|
|
$('#inst_name').val("");
|
|
|
|
$('#btn_create_inst').attr('disabled', true)
|
2019-07-14 22:43:22 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
$(hyperion).off("instance-updated").on("instance-updated", function(event) {
|
|
|
|
buildInstanceList()
|
|
|
|
});
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
//import
|
2017-01-17 21:53:35 +01:00
|
|
|
function dis_imp_btn(state)
|
|
|
|
{
|
|
|
|
state ? $('#btn_import_conf').attr('disabled', true) : $('#btn_import_conf').attr('disabled', false);
|
|
|
|
}
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
function readFile(evt)
|
|
|
|
{
|
|
|
|
var f = evt.target.files[0];
|
|
|
|
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
var r = new FileReader();
|
|
|
|
r.onload = function(e)
|
|
|
|
{
|
2017-07-30 13:32:10 +02:00
|
|
|
var content = e.target.result.replace(/[^:]?\/\/.*/g, ''); //remove Comments
|
2017-01-17 21:53:35 +01:00
|
|
|
|
|
|
|
//check file is json
|
|
|
|
var check = isJsonString(content);
|
|
|
|
if(check.length != 0)
|
|
|
|
{
|
|
|
|
showInfoDialog('error', "", $.i18n('infoDialog_import_jsonerror_text', f.name, JSON.stringify(check)));
|
|
|
|
dis_imp_btn(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
content = JSON.parse(content);
|
|
|
|
//check for hyperion json
|
|
|
|
if(typeof content.leds === 'undefined' || typeof content.general === 'undefined')
|
|
|
|
{
|
|
|
|
showInfoDialog('error', "", $.i18n('infoDialog_import_hyperror_text', f.name));
|
2017-07-30 13:32:10 +02:00
|
|
|
dis_imp_btn(true);
|
2017-01-17 21:53:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-04 23:12:59 +02:00
|
|
|
dis_imp_btn(false);
|
|
|
|
importedConf = content;
|
|
|
|
confName = f.name;
|
2017-01-17 21:53:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
r.readAsText(f);
|
|
|
|
}
|
|
|
|
}
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
$('#btn_import_conf').off().on('click', function(){
|
|
|
|
showInfoDialog('import', $.i18n('infoDialog_import_confirm_title'), $.i18n('infoDialog_import_confirm_text', confName));
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
$('#id_btn_import').off().on('click', function(){
|
|
|
|
requestWriteConfig(importedConf, true);
|
|
|
|
setTimeout(initRestart, 100);
|
|
|
|
});
|
|
|
|
});
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
$('#select_import_conf').off().on('change', function(e){
|
|
|
|
if (window.File && window.FileReader && window.FileList && window.Blob)
|
|
|
|
readFile(e);
|
|
|
|
else
|
|
|
|
showInfoDialog('error', "", $.i18n('infoDialog_import_comperror_text'));
|
|
|
|
});
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
//export
|
|
|
|
$('#btn_export_conf').off().on('click', function(){
|
2019-06-05 18:19:08 +02:00
|
|
|
var name = window.serverConfig.general.name;
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
var d = new Date();
|
|
|
|
var month = d.getMonth()+1;
|
|
|
|
var day = d.getDate();
|
|
|
|
|
|
|
|
var timestamp = d.getFullYear() + '.' +
|
|
|
|
(month<10 ? '0' : '') + month + '.' +
|
|
|
|
(day<10 ? '0' : '') + day;
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
download(JSON.stringify(window.serverConfig, null, "\t"), 'Hyperion-'+window.currentVersion+'-Backup ('+name+') '+timestamp+'.json', "application/json");
|
2017-02-08 14:36:28 +01:00
|
|
|
});
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
//create introduction
|
2019-06-05 18:19:08 +02:00
|
|
|
if(window.showOptHelp)
|
add Hue EntertainmentAPI + Forwarder & other Fixes (#592)
* whitespaces + typo fixes
* JS / LGTM fixes
* SSDP Handler crash fix
* MessageForwarder handlePriorityChanges Slave fixes
* use aboutToQuit Signal
* complete rewriten Hue Entertainment API structure
combined Philips Hue and Entertainment API
with new MbedTLS based SSL UDP Provider
* add required cross-compile submodules
* logical rebuild fn: initLeds, setLights + new logs
-more detailed checks and error handling inside iniLeds and setLights
- logical script procedure before ProviderUdpSSL init
- first steps for multiple ProviderUdpSSL usage
- better fallback support to old RestAPI, if entertainment api is not supported
- just 4 u LordGrey: new log fn for cosmetic config outputs ;)
* add OSX CompileHowTo - undo from CrossCompileHowTo
* whitespace fixes
* lightID toString fix
* fix unsigned int E-API + debug output
* bugfixes, reworked black signal detection, wizard:
- change device config field light-ids from int to string -> real unsigned int fix
- add signal detection brightness minimum threshold value
0.0 for 0% brightness - 1.0 for 100% brightness to count for blacklight signal detection
reason: input may not 100% black, like mine - i have a deep dark gray input signal
-> my threshold value is set to 0.005 for 0.5% minimum brightness = 1 (from max 255) to count as black
- wizard optimations, with fallback without entertainment support (beta state)
- whitespace fixes
* cleanup + minor fixes
* change fixed Hue UPD SSL config to _devConfig paras
* Hotfix SSL Connection, new light models, wizard:
- Fix UPD SSL Connection failed Problems
- add new supported gamut C light models: LCG002, LCA001, LCA002, LCA003
- wizard: extend fallback support to classic mode + hints
* whitespace, typo fix
* uncheck useEntertainmentAPI, if noAPISupport detected + hint
* coredump fix -> add _blackLightsTimer nullptr init
* code cleanup / remove old debugs + whitespacefixes
* add gamut C LCP001, LCP002
* SSL UDP config made more flexible + remove qDebug
-> switch to hyerion.ng _log
-> replace logCommand with verbose
-> code cleanups etc...
* extended mbedtls debugging infos
* add adjustable ssl timeout settings
* error handling
* streamdebugger bugfixes
* UPDSSL psk / psk_identity bugfixes! + hue wizard fn typo fix +
- verbose option available without dependencies
- whitespace fixes
* Philips Hue Assistant now recognizes non-original bridges better...
+ Added note if no clientkey is set when using the entertainment API
+ User creation (+ clientkey) for non-original bridges can now also be used
+ Minor changes and bug fixes
* CMAKE mbedTLS detection
* minor bug fixes + code cleanups
* FindMbedTLS.cmake remove Path-Hints + wizard.js: ajax timeout handling
Test - content_grabber.js: run relevant code only, if V4L2_AVAIL is true:
conf_grabber don't displays other devices, if V4L2 is not available
* compile mbedtls via cmake as static lib
* remove libmbedtls-dev from compileHowto / scripts
* Fix Windows build
* Fix windows build (part 2)
* removed unnecessary osx x11 include directory path
* QTimer Shutdown bugfix
* cmake win32 fix + minor bugfixes
* cmake debug msg used mbedtls libs
* Bugfix: noSignalDetection wasn't switchedOn again
if no signal was previously detected
* Some code fixes based on alerts from lgtm.com
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
2020-05-22 19:40:50 +02:00
|
|
|
{
|
2017-02-08 14:36:28 +01:00
|
|
|
createHint("intro", $.i18n('conf_general_intro'), "editor_container");
|
2019-07-12 16:54:26 +02:00
|
|
|
createHint("intro", $.i18n('conf_general_tok_desc'), "tok_desc_cont");
|
2019-07-14 22:43:22 +02:00
|
|
|
createHint("intro", $.i18n('conf_general_inst_desc'), "inst_desc_cont");
|
add Hue EntertainmentAPI + Forwarder & other Fixes (#592)
* whitespaces + typo fixes
* JS / LGTM fixes
* SSDP Handler crash fix
* MessageForwarder handlePriorityChanges Slave fixes
* use aboutToQuit Signal
* complete rewriten Hue Entertainment API structure
combined Philips Hue and Entertainment API
with new MbedTLS based SSL UDP Provider
* add required cross-compile submodules
* logical rebuild fn: initLeds, setLights + new logs
-more detailed checks and error handling inside iniLeds and setLights
- logical script procedure before ProviderUdpSSL init
- first steps for multiple ProviderUdpSSL usage
- better fallback support to old RestAPI, if entertainment api is not supported
- just 4 u LordGrey: new log fn for cosmetic config outputs ;)
* add OSX CompileHowTo - undo from CrossCompileHowTo
* whitespace fixes
* lightID toString fix
* fix unsigned int E-API + debug output
* bugfixes, reworked black signal detection, wizard:
- change device config field light-ids from int to string -> real unsigned int fix
- add signal detection brightness minimum threshold value
0.0 for 0% brightness - 1.0 for 100% brightness to count for blacklight signal detection
reason: input may not 100% black, like mine - i have a deep dark gray input signal
-> my threshold value is set to 0.005 for 0.5% minimum brightness = 1 (from max 255) to count as black
- wizard optimations, with fallback without entertainment support (beta state)
- whitespace fixes
* cleanup + minor fixes
* change fixed Hue UPD SSL config to _devConfig paras
* Hotfix SSL Connection, new light models, wizard:
- Fix UPD SSL Connection failed Problems
- add new supported gamut C light models: LCG002, LCA001, LCA002, LCA003
- wizard: extend fallback support to classic mode + hints
* whitespace, typo fix
* uncheck useEntertainmentAPI, if noAPISupport detected + hint
* coredump fix -> add _blackLightsTimer nullptr init
* code cleanup / remove old debugs + whitespacefixes
* add gamut C LCP001, LCP002
* SSL UDP config made more flexible + remove qDebug
-> switch to hyerion.ng _log
-> replace logCommand with verbose
-> code cleanups etc...
* extended mbedtls debugging infos
* add adjustable ssl timeout settings
* error handling
* streamdebugger bugfixes
* UPDSSL psk / psk_identity bugfixes! + hue wizard fn typo fix +
- verbose option available without dependencies
- whitespace fixes
* Philips Hue Assistant now recognizes non-original bridges better...
+ Added note if no clientkey is set when using the entertainment API
+ User creation (+ clientkey) for non-original bridges can now also be used
+ Minor changes and bug fixes
* CMAKE mbedTLS detection
* minor bug fixes + code cleanups
* FindMbedTLS.cmake remove Path-Hints + wizard.js: ajax timeout handling
Test - content_grabber.js: run relevant code only, if V4L2_AVAIL is true:
conf_grabber don't displays other devices, if V4L2 is not available
* compile mbedtls via cmake as static lib
* remove libmbedtls-dev from compileHowto / scripts
* Fix Windows build
* Fix windows build (part 2)
* removed unnecessary osx x11 include directory path
* QTimer Shutdown bugfix
* cmake win32 fix + minor bugfixes
* cmake debug msg used mbedtls libs
* Bugfix: noSignalDetection wasn't switchedOn again
if no signal was previously detected
* Some code fixes based on alerts from lgtm.com
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
2020-05-22 19:40:50 +02:00
|
|
|
}
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
removeOverlay();
|
2016-12-23 19:37:35 +01:00
|
|
|
});
|