mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
update (#431)
This commit is contained in:
@@ -68,6 +68,9 @@ $(document).ready( function() {
|
||||
requestWriteConfig(editor_blackborder.getValue());
|
||||
});
|
||||
|
||||
//wiki links
|
||||
$('#editor_container_blackborder').append(buildWL("user/moretopics/bbmode","edt_conf_bb_mode_title",true));
|
||||
|
||||
//create introduction
|
||||
if(showOptHelp)
|
||||
{
|
||||
|
@@ -75,12 +75,12 @@ $(document).ready( function() {
|
||||
var cleanLatestVersion = latestVersion.replace(/\./g, '');
|
||||
var cleanCurrentVersion = currentVersion.replace(/\./g, '');
|
||||
|
||||
$('#dash_latev').html(latestVersion);
|
||||
// $('#dash_latev').html(latestVersion);
|
||||
|
||||
if ( cleanCurrentVersion < cleanLatestVersion )
|
||||
$('#versioninforesult').html('<div style="margin:0px;" class="alert alert-warning">'+$.i18n('dashboard_infobox_message_updatewarning', latestVersion)+'</div>');
|
||||
else
|
||||
$('#versioninforesult').html('<div style="margin:0px;" class="alert alert-success">'+$.i18n('dashboard_infobox_message_updatesuccess')+'</div>');
|
||||
// if ( cleanCurrentVersion < cleanLatestVersion )
|
||||
// $('#versioninforesult').html('<div class="bs-callout bs-callout-warning" style="margin:0px">'+$.i18n('dashboard_infobox_message_updatewarning', latestVersion)+'</div>');
|
||||
// else
|
||||
$('#versioninforesult').html('<div class="bs-callout bs-callout-success" style="margin:0px">'+$.i18n('dashboard_infobox_message_updatesuccess')+'</div>');
|
||||
});
|
||||
|
||||
//determine platform
|
||||
|
@@ -15,6 +15,10 @@ $(document).ready( function() {
|
||||
else
|
||||
$("#hyperion_reload_notify").fadeOut("fast");
|
||||
|
||||
if (serverInfo.hyperion.off)
|
||||
$("#hyperion_disabled_notify").fadeIn("fast");
|
||||
else
|
||||
$("#hyperion_disabled_notify").fadeOut("fast");
|
||||
|
||||
if ($("#logmessages").length == 0 && loggingStreamActive)
|
||||
{
|
||||
@@ -54,12 +58,12 @@ $(document).ready( function() {
|
||||
$('#btn_instanceswitch').toggle(false);
|
||||
}
|
||||
|
||||
|
||||
}); // end cmd-serverinfo
|
||||
|
||||
$(hyperion).one("cmd-sysinfo", function(event) {
|
||||
requestServerInfo();
|
||||
sysInfo = event.response.info;
|
||||
|
||||
currentVersion = sysInfo.hyperion.version;
|
||||
});
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
|
||||
var ledsCustomCfgInitialized = false;
|
||||
var finalLedArray = [];
|
||||
var conf_editor = null;
|
||||
|
||||
function round(number) {
|
||||
var factor = Math.pow(10, 4);
|
||||
@@ -354,6 +355,9 @@ $(document).ready(function() {
|
||||
$('#btn_cl_save').toggle(false);
|
||||
}
|
||||
|
||||
//Wiki link
|
||||
$('#leds_wl').append('<p style="font-weight:bold">'+$.i18n('general_wiki_moreto',$.i18n('conf_leds_nav_label_ledlayout'))+buildWL("user/moretopics/ledarea","Wiki")+'</p>');
|
||||
|
||||
// bind change event to all inputs
|
||||
$('.ledCLconstr').bind("change", function() {
|
||||
valValue(this.id,this.value,this.min,this.max);
|
||||
@@ -421,7 +425,6 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
// create and update editor
|
||||
var conf_editor = null;
|
||||
$("#leddevices").off().on("change", function() {
|
||||
generalOptions = serverSchema.properties.device;
|
||||
specificOptions = serverSchema.properties.alldevices[$(this).val()];
|
||||
@@ -452,6 +455,18 @@ $(document).ready(function() {
|
||||
|
||||
// change save button state based on validation result
|
||||
conf_editor.validate().length ? $('#btn_submit_controller').attr('disabled', true) : $('#btn_submit_controller').attr('disabled', false);
|
||||
|
||||
// led controller sepecific wizards
|
||||
if($(this).val() == "philipshue")
|
||||
{
|
||||
createHint("wizard", $.i18n('wiz_hue_title'), "btn_wiz_holder","btn_led_device_wiz");
|
||||
$('#btn_led_device_wiz').off().on('click',startWizardPhilipsHue);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#btn_wiz_holder').html("")
|
||||
$('#btn_led_device_wiz').off();
|
||||
}
|
||||
});
|
||||
|
||||
// create led device selection
|
||||
|
@@ -14,6 +14,7 @@ $(document).ready(function() {
|
||||
$('#conf_cont').append(createHelpTable(schema.logger.properties, $.i18n("edt_conf_log_heading_title")));
|
||||
createHintH("intro", $.i18n('conf_logging_label_intro'), "log_head");
|
||||
}
|
||||
$("#log_upl_pol").append('<span style="color:grey;font-size:80%">'+$.i18n("conf_logging_uplpolicy")+' '+buildWL("user/support#report_privacy_policy",$.i18n("conf_logging_contpolicy")));
|
||||
|
||||
conf_editor = createJsonEditor('editor_container', {
|
||||
logger : schema.logger
|
||||
@@ -27,13 +28,19 @@ $(document).ready(function() {
|
||||
requestWriteConfig(conf_editor.getValue());
|
||||
});
|
||||
|
||||
$('#btn_logupload').off().on('click',function() {
|
||||
uploadLog();
|
||||
$(this).attr("disabled", true);
|
||||
$('#upl_link').html($.i18n('conf_logging_uploading'))
|
||||
});
|
||||
|
||||
//show prev uploads
|
||||
var ent;
|
||||
|
||||
if(getStorage("prev_reports"))
|
||||
{
|
||||
ent = JSON.parse(getStorage("prev_reports"));
|
||||
$('#prev_reports').append('<hr><h4>'+$.i18n('conf_logging_lastreports')+'</h4>');
|
||||
$('#prev_reports').append('<h4 style="margin-top:30px">'+$.i18n('conf_logging_lastreports')+'</h4>');
|
||||
for(var i = 0; i<ent.length; i++)
|
||||
{
|
||||
$('#prev_reports').append('<p><a href="'+reportUrl+ent[i].id+'" target="_blank">'+ent[i].title+'('+ent[i].time+')</a></p>');
|
||||
@@ -61,23 +68,29 @@ $(document).ready(function() {
|
||||
var info;
|
||||
|
||||
//create log
|
||||
for(var i = 0; i<messages.length; i++)
|
||||
if(messages)
|
||||
{
|
||||
app_name = messages[i].appName;
|
||||
logger_name = messages[i].loggerName;
|
||||
function_ = messages[i].function;
|
||||
line = messages[i].line;
|
||||
file_name = messages[i].fileName;
|
||||
msg = messages[i].message;
|
||||
level_string = messages[i].levelString;
|
||||
debug = "";
|
||||
for(var i = 0; i<messages.length; i++)
|
||||
{
|
||||
app_name = messages[i].appName;
|
||||
logger_name = messages[i].loggerName;
|
||||
function_ = messages[i].function;
|
||||
line = messages[i].line;
|
||||
file_name = messages[i].fileName;
|
||||
msg = messages[i].message;
|
||||
level_string = messages[i].levelString;
|
||||
debug = "";
|
||||
|
||||
if(level_string == "DEBUG") {
|
||||
debug = "<"+file_name+":"+line+":"+function_+"()> ";
|
||||
}
|
||||
if(level_string == "DEBUG") {
|
||||
debug = "<"+file_name+":"+line+":"+function_+"()> ";
|
||||
}
|
||||
|
||||
log += "["+app_name+" "+logger_name+"] <"+level_string+"> "+debug+msg+"\n";
|
||||
log += "["+app_name+" "+logger_name+"] <"+level_string+"> "+debug+msg+"\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
log = "Log was empty!";
|
||||
|
||||
//create general info
|
||||
info = "### GENERAL ### \n";
|
||||
info += 'Build: '+shy.build+'\n';
|
||||
@@ -154,17 +167,12 @@ $(document).ready(function() {
|
||||
messages = (event.response.result.messages);
|
||||
if(messages.length != 0 && !createdCont)
|
||||
{
|
||||
$('#log_content').html('<pre><div id="logmessages" style="overflow:scroll;max-height:400px"></div></pre><button class="btn btn-primary" id="btn_logupload">'+$.i18n('conf_logging_btn_pbupload')+'</button><button class="btn btn-success" id="btn_autoscroll" style="margin-left:10px;">'+$.i18n('conf_logging_btn_autoscroll')+'</button><div id="upl_link" style="margin-top:10px;font-weight:bold;"></div>');
|
||||
$('#log_content').html('<pre><div id="logmessages" style="overflow:scroll;max-height:400px"></div></pre><button class="btn btn-success" id="btn_autoscroll"><i class="fa fa-long-arrow-down fa-fw"></i>'+$.i18n('conf_logging_btn_autoscroll')+'</button>');
|
||||
createdCont = true;
|
||||
|
||||
$('#btn_autoscroll').off().on('click',function() {
|
||||
toggleClass('#btn_autoscroll', "btn-success", "btn-danger");
|
||||
});
|
||||
$('#btn_logupload').off().on('click',function() {
|
||||
uploadLog();
|
||||
$(this).attr("disabled", true);
|
||||
$('#upl_link').html($.i18n('conf_logging_uploading'))
|
||||
});
|
||||
}
|
||||
for(var idx=0; idx<messages.length; idx++)
|
||||
{
|
||||
|
@@ -5,6 +5,7 @@ $(document).ready(function() {
|
||||
var cpcolor = '#B500FF';
|
||||
var mappingList = serverSchema.properties.color.properties.imageToLedMappingType.enum;
|
||||
var duration = 0;
|
||||
var rgb = {r:255,g:0,b:0};
|
||||
|
||||
//create html
|
||||
createTable('ssthead', 'sstbody', 'sstcont');
|
||||
@@ -53,8 +54,8 @@ $(document).ready(function() {
|
||||
}
|
||||
else
|
||||
{
|
||||
if(sColor[key].key == "backlightThreshold" || sColor[key].key == "brightness" || sColor[key].key == "brightnessCompensation")
|
||||
property = '<input id="cr_'+sColor[key].key+'" type="number" class="form-control" min="0" max="100" step="10" value="'+value+'"/>';
|
||||
if(sColor[key].key == "brightness" || sColor[key].key == "brightnessCompensation" || sColor[key].key == "backlightThreshold")
|
||||
property = '<div class="input-group"><input id="cr_'+sColor[key].key+'" type="number" class="form-control" min="0" max="100" step="10" value="'+value+'"/><span class="input-group-addon">'+$.i18n("edt_append_percent")+'</span></div>';
|
||||
else
|
||||
property = '<input id="cr_'+sColor[key].key+'" type="number" class="form-control" min="0.1" max="4.0" step="0.1" value="'+value+'"/>';
|
||||
|
||||
@@ -67,6 +68,23 @@ $(document).ready(function() {
|
||||
}
|
||||
}
|
||||
|
||||
function sendEffect()
|
||||
{
|
||||
efx = $("#effect_select").val();
|
||||
if(efx != "__none__")
|
||||
{
|
||||
requestPriorityClear();
|
||||
$(hyperion).one("cmd-clear", function(event) {
|
||||
setTimeout(function() {requestPlayEffect(efx,duration)}, 100);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function sendColor()
|
||||
{
|
||||
requestSetColor(rgb.r, rgb.g, rgb.b,duration);
|
||||
}
|
||||
|
||||
function updateRemote()
|
||||
{
|
||||
if ($('#componentsbutton').length == 0)
|
||||
@@ -245,7 +263,10 @@ $(document).ready(function() {
|
||||
|
||||
// colorpicker and effect
|
||||
if (getStorage('rmcpcolor') != null)
|
||||
{
|
||||
cpcolor = getStorage('rmcpcolor');
|
||||
rgb = hexToRgb(cpcolor);
|
||||
}
|
||||
|
||||
if (getStorage('rmduration') != null)
|
||||
{
|
||||
@@ -253,8 +274,9 @@ $(document).ready(function() {
|
||||
duration = getStorage('rmduration');
|
||||
}
|
||||
|
||||
createCP('cp2', cpcolor, function(rgb,hex){
|
||||
requestSetColor(rgb.r, rgb.g, rgb.b,duration);
|
||||
createCP('cp2', cpcolor, function(rgbT,hex){
|
||||
rgb = rgbT;
|
||||
sendColor()
|
||||
$("#effect_select").val("__none__");
|
||||
setStorage('rmcpcolor', hex);
|
||||
});
|
||||
@@ -270,14 +292,14 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
$("#effect_select").off().on("change", function(event) {
|
||||
efx = $(this).val();
|
||||
if(efx != "__none__")
|
||||
{
|
||||
requestPriorityClear();
|
||||
$(hyperion).one("cmd-clear", function(event) {
|
||||
setTimeout(function() {requestPlayEffect(efx,duration)}, 100);
|
||||
});
|
||||
}
|
||||
sendEffect();
|
||||
});
|
||||
|
||||
$("#remote_input_reseff, #remote_input_rescol").off().on("click", function(){
|
||||
if(this.id == "remote_input_rescol")
|
||||
sendColor();
|
||||
else
|
||||
sendEffect();
|
||||
});
|
||||
|
||||
$("#remote_input_img").change(function(){
|
||||
|
@@ -6690,7 +6690,10 @@ JSONEditor.defaults.themes.bootstrap3 = JSONEditor.AbstractTheme.extend({
|
||||
},
|
||||
getButton: function(text, icon, title) {
|
||||
var el = this._super(text, icon, title);
|
||||
el.className += 'btn btn-sm btn-primary';
|
||||
if(icon.className.includes("fa-times"))
|
||||
el.className += 'btn btn-sm btn-danger';
|
||||
else
|
||||
el.className += 'btn btn-sm btn-primary';
|
||||
return el;
|
||||
},
|
||||
getTable: function() {
|
||||
|
@@ -197,7 +197,7 @@ function createHintH(type, text, container)
|
||||
$('#'+container).prepend('<div class="'+tclass+'"><h4 style="font-size:16px">'+text+'</h4><hr/></div>');
|
||||
}
|
||||
|
||||
function createHint(type, text, container)
|
||||
function createHint(type, text, container, buttonid, buttontxt)
|
||||
{
|
||||
var fe, tclass;
|
||||
|
||||
@@ -222,8 +222,15 @@ function createHint(type, text, container)
|
||||
tclass = "warning-hint";
|
||||
}
|
||||
|
||||
if(fe == "")
|
||||
$('#'+container).prepend('<div class="'+tclass+'">'+text+'</div>');
|
||||
if(buttonid)
|
||||
buttonid = '<p><button id="'+buttonid+'" class="btn btn-wizard" style="margin-top:15px;">'+text+'</button></p>';
|
||||
else
|
||||
buttonid = "";
|
||||
|
||||
if(type == "intro")
|
||||
$('#'+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")
|
||||
$('#'+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
|
||||
{
|
||||
createTable('','htb',container, true, tclass);
|
||||
@@ -235,7 +242,7 @@ function valValue(id,value,min,max)
|
||||
{
|
||||
if(typeof max === 'undefined' || max == "")
|
||||
max = 999999;
|
||||
|
||||
|
||||
if(Number(value) > Number(max))
|
||||
{
|
||||
$('#'+id).val(max);
|
||||
@@ -320,6 +327,28 @@ function createJsonEditor(container,schema,setconfig,usePanel)
|
||||
return editor;
|
||||
}
|
||||
|
||||
function buildWL(link,linkt,cl)
|
||||
{
|
||||
var baseLink = "https://docs.hyperion-project.org/";
|
||||
var lang;
|
||||
|
||||
if(typeof linkt == "undefined")
|
||||
linkt = "Placeholder";
|
||||
|
||||
if(storedLang == "de" || navigator.locale == "de")
|
||||
lang = "de";
|
||||
else
|
||||
lang = "en";
|
||||
|
||||
if(cl === true)
|
||||
{
|
||||
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>'
|
||||
}
|
||||
else
|
||||
return ': <a href="'+baseLink+lang+'/'+link+'" target="_blank">'+linkt+'<a>';
|
||||
}
|
||||
|
||||
function rgbToHex(rgb)
|
||||
{
|
||||
if(rgb.length == 3)
|
||||
@@ -333,6 +362,16 @@ function rgbToHex(rgb)
|
||||
debugMessage('rgbToHex: Given rgb is no array or has wrong length');
|
||||
}
|
||||
|
||||
function hexToRgb(hex) {
|
||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||
return result ? {
|
||||
r: parseInt(result[1], 16),
|
||||
g: parseInt(result[2], 16),
|
||||
b: parseInt(result[3], 16)
|
||||
} : null;
|
||||
}
|
||||
|
||||
|
||||
function createCP(id, color, cb)
|
||||
{
|
||||
if(Array.isArray(color))
|
||||
|
@@ -1,4 +1,4 @@
|
||||
$(document).ready( function() {
|
||||
|
||||
//clear priority and other tasks if people reload the page or lost connection while a wizard was active
|
||||
$(hyperion).one("ready", function(event) {
|
||||
if(getStorage("wizardactive") === 'true')
|
||||
@@ -517,21 +517,29 @@ $(document).ready( function() {
|
||||
$('#btn_wizard_colorcalibration').off().on('click', startWizardCC);
|
||||
|
||||
//hue wizard
|
||||
var hueIPs = [];
|
||||
var hueIPsinc = 0;
|
||||
var lightIDs = null;
|
||||
var huePosTop = {hscan: {maximum: 0.85,minimum: 0.15},index: 0,vscan: {maximum: 0.2,minimum: 0}};
|
||||
var huePosBottom = {hscan: {maximum: 0.85,minimum: 0.15},index: 2,vscan: {maximum: 1,minimum: 0.8}};
|
||||
var huePosLeft = {hscan: {maximum: 0.15,minimum: 0},index: 1,vscan: {maximum: 0.85,minimum: 0.15}};
|
||||
var huePosRight = {hscan: {maximum: 1,minimum: 0.85},index: 3,vscan: {maximum: 0.85,minimum: 0.15}};
|
||||
var huePosEntire = {hscan: {maximum: 1.0,minimum: 0.0},index: 0,vscan: {maximum: 1.0,minimum: 0.0}};
|
||||
|
||||
function startWizardPhilipsHue()
|
||||
{
|
||||
//create html
|
||||
$('#wiz_header').html('<i class="fa fa-magic fa-fw"></i>'+$.i18n('wiz_hue_title'));
|
||||
$('#wizp1_body').html('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('wiz_hue_title')+'</h4><p>'+$.i18n('wiz_hue_intro1')+'</p><p style="font-weight:bold;">'+$.i18n('wiz_hue_intro2')+'</p>');
|
||||
$('#wizp1_body').html('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('wiz_hue_title')+'</h4><p>'+$.i18n('wiz_hue_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').append('<span id="ip_alert" style="display:none; color:red; font-weight: bold;">'+$.i18n('wiz_hue_failure_ip')+'</span>');
|
||||
$('#wizp2_body').append('<span id="abortConnection" style="display:none; color:red; font-weight: bold;">'+$.i18n('wiz_hue_failure_connection')+'</span><br />');
|
||||
$('#wizp2_body').append('<div class="form-group"><label>'+$.i18n('wiz_hue_ip')+'</label><div class="input-group" style="width:150px"><input type="text" class="input-group" id="ip"></div></div>');
|
||||
$('#wizp2_body').append('<div class="form-group"><label>'+$.i18n('wiz_hue_username')+'</label<div class="input-group" style="width:150px"><input type="text" class="input-group" id="user" readonly="readonly"></div></div>');
|
||||
$('#wizp2_body').append('<div id="hue_lights" class="row"><table></table></div>');
|
||||
$('#wizp2_footer').html('<button type="button" class="btn btn-success" id="wiz_hue_create_user"> <i class="fa fa-floppy-o"></i>'+$.i18n('wiz_hue_create_user')+'</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>');
|
||||
$('#wizp3_body').html('<span>'+$.i18n('wiz_hue_press_link')+'</span> <br /><br /><center><span id="connectionTime"></span><br /><img src="/img/hyperion/ring-alt.svg" /><center>');
|
||||
|
||||
|
||||
$('#wizp2_body').html('<div id="wh_topcontainer"></div>');
|
||||
$('#wh_topcontainer').append('<p style="font-weight:bold">'+$.i18n('wiz_hue_desc1')+'</p><div class="form-group"><label>'+$.i18n('wiz_hue_ip')+'</label><div class="input-group" style="width:175px"><input type="text" class="input-group form-control" id="ip"><span class="input-group-addon" id="retry_bridge" style="cursor:pointer"><i class="fa fa-refresh"></i></span></div></div><span style="font-weight:bold;color:red" id="wiz_hue_ipstate"></span>');
|
||||
$('#wh_topcontainer').append('<div class="form-group" id="usrcont" style="display:none"><label>'+$.i18n('wiz_hue_username')+'</label><div class="input-group" style="width:250px"><input type="text" class="form-control" id="user"><span class="input-group-addon" id="retry_usr" style="cursor:pointer"><i class="fa fa-refresh"></i></span></div><span style="font-weight:bold;color:red" id="wiz_hue_usrstate"></span><br><button type="button" class="btn btn-primary" style="display:none" id="wiz_hue_create_user"> <i class="fa fa-fw fa-plus"></i>'+$.i18n('wiz_hue_create_user')+'</button></div>');
|
||||
$('#wizp2_body').append('<div id="hue_ids_t" style="display:none"><p style="font-weight:bold">'+$.i18n('wiz_hue_desc2')+'</p></div>');
|
||||
createTable("lidsh", "lidsb", "hue_ids_t");
|
||||
$('.lidsh').append(createTableRow([$.i18n('edt_dev_spec_lightid_title'),$.i18n('wiz_hue_pos'),$.i18n('wiz_hue_ident')], 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_saverestart')+'</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>');
|
||||
$('#wizp3_body').html('<span>'+$.i18n('wiz_hue_press_link')+'</span> <br /><br /><center><span id="connectionTime"></span><br /><i class="fa fa-cog fa-spin" style="font-size:100px"></i></center>');
|
||||
|
||||
//open modal
|
||||
$("#wizard_modal").modal({
|
||||
@@ -548,17 +556,207 @@ $(document).ready( function() {
|
||||
});
|
||||
}
|
||||
|
||||
function checkHueBridge(cb,hueUser){
|
||||
var usr = "";
|
||||
|
||||
if(typeof hueUser != "undefined")
|
||||
usr = hueUser;
|
||||
|
||||
$.ajax({
|
||||
url: 'http://'+hueIPs[hueIPsinc].internalipaddress+'/api/'+usr,
|
||||
contentType: 'application/json',
|
||||
type: 'GET',
|
||||
timeout: 2000
|
||||
})
|
||||
.done( function( data, textStatus, jqXHR ) {
|
||||
if(Array.isArray(data) && data[0].error && data[0].error.type == 4)
|
||||
cb(true);
|
||||
else if(Array.isArray(data) && data[0].error)
|
||||
cb(false);
|
||||
else
|
||||
cb(true);
|
||||
})
|
||||
.fail( function( jqXHR, textStatus ) {
|
||||
cb(false);
|
||||
});
|
||||
}
|
||||
|
||||
function checkUserResult(reply){
|
||||
if(reply)
|
||||
{
|
||||
$('#wiz_hue_usrstate').html("");
|
||||
$('#wiz_hue_create_user').toggle(false);
|
||||
get_hue_lights();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#wiz_hue_usrstate').html($.i18n('wiz_hue_failure_user'));
|
||||
$('#wiz_hue_create_user').toggle(true);
|
||||
}
|
||||
};
|
||||
|
||||
function checkBridgeResult(reply){
|
||||
if(reply)
|
||||
{
|
||||
//abort checking, first reachable result is used
|
||||
$('#wiz_hue_ipstate').html("");
|
||||
$('#ip').val(hueIPs[hueIPsinc].internalipaddress)
|
||||
|
||||
//now check hue user on this bridge
|
||||
$('#usrcont').toggle(true);
|
||||
checkHueBridge(checkUserResult,$('#user').val() ? $('#user').val() : "newdeveloper");
|
||||
}
|
||||
else
|
||||
{
|
||||
//increment and check again
|
||||
if(hueIPs.length-1 > hueIPsinc)
|
||||
{
|
||||
hueIPsinc++;
|
||||
checkHueBridge(checkBridgeResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#usrcont').toggle(false);
|
||||
$('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function assignHuePos(id, pos, inc)
|
||||
{
|
||||
var i = null;
|
||||
|
||||
if(pos == "top")
|
||||
i = huePosTop;
|
||||
else if(pos == "bottom")
|
||||
i = huePosBottom;
|
||||
else if(pos == "left")
|
||||
i = huePosLeft;
|
||||
else if(pos == "right")
|
||||
i = huePosRight;
|
||||
else
|
||||
i = huePosEntire;
|
||||
|
||||
i.index = inc;
|
||||
return i;
|
||||
}
|
||||
|
||||
function identHueId(id, off)
|
||||
{
|
||||
var on = true;
|
||||
if(off !== true)
|
||||
setTimeout(identHueId,1500,id,true);
|
||||
else
|
||||
on = false;
|
||||
|
||||
$.ajax({
|
||||
url: 'http://'+$('#ip').val()+'/api/'+$('#user').val()+'/lights/'+id+'/state',
|
||||
type: 'PUT',
|
||||
timeout: 2000,
|
||||
data: ' {"on":'+on+', "sat":254, "bri":254,"hue":47000}'
|
||||
})
|
||||
}
|
||||
|
||||
function getHueIPs(){
|
||||
$('#wiz_hue_ipstate').html($.i18n('wiz_hue_searchb'));
|
||||
$.ajax({
|
||||
url: 'https://www.meethue.com/api/nupnp',
|
||||
crossDomain: true,
|
||||
type: 'GET',
|
||||
timeout: 3000
|
||||
})
|
||||
.done( function( data, textStatus, jqXHR ) {
|
||||
if(data.length == 0)
|
||||
$('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
|
||||
else
|
||||
{
|
||||
hueIPs = data;
|
||||
checkHueBridge(checkBridgeResult);
|
||||
}
|
||||
})
|
||||
.fail( function( jqXHR, textStatus ) {
|
||||
$('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
|
||||
});
|
||||
};
|
||||
|
||||
function beginWizardHue()
|
||||
{
|
||||
//listen for continue
|
||||
$('#wiz_hue_create_user').off().on('click',function() {
|
||||
doWizardHue();
|
||||
//check if ip is empty/reachable/search for bridge
|
||||
if(conf_editor.getEditor("root.specificOptions.output").getValue() == "")
|
||||
getHueIPs();
|
||||
else
|
||||
{
|
||||
var ip = conf_editor.getEditor("root.specificOptions.output").getValue();
|
||||
$('#ip').val(ip);
|
||||
hueIPs.push({internalipaddress : ip});
|
||||
checkHueBridge(checkBridgeResult);
|
||||
|
||||
var usr = conf_editor.getEditor("root.specificOptions.username").getValue();
|
||||
$('#user').val(usr);
|
||||
}
|
||||
|
||||
$('#retry_bridge').off().on('click', function(){
|
||||
hueIPs[0].internalipaddress = $('#ip').val();
|
||||
hueIPsinc = 0;
|
||||
checkHueBridge(checkBridgeResult);
|
||||
});
|
||||
|
||||
$('#retry_usr').off().on('click', function(){
|
||||
checkHueBridge(checkUserResult,$('#user').val() ? $('#user').val() : "newdeveloper");
|
||||
});
|
||||
|
||||
$('#wiz_hue_create_user').off().on('click',function() {
|
||||
createHueUser();
|
||||
});
|
||||
|
||||
$('#btn_wiz_save').off().on("click", function(){
|
||||
var hueLedConfig = [];
|
||||
var finalLightIds = [];
|
||||
|
||||
//create hue led config
|
||||
var incC = 0;
|
||||
for(key in lightIDs)
|
||||
{
|
||||
if($('#hue_'+key).val() != "disabled")
|
||||
{
|
||||
hueLedConfig.push(assignHuePos(key, $('#hue_'+key).val(), incC));
|
||||
finalLightIds.push(parseInt(key));
|
||||
incC++;
|
||||
}
|
||||
}
|
||||
|
||||
serverConfig.leds = hueLedConfig;
|
||||
|
||||
//Adjust gamma, brightness and compensation
|
||||
var c = serverConfig.color.channelAdjustment[0];
|
||||
c.gammaBlue = 1.0;
|
||||
c.gammaRed = 1.0;
|
||||
c.gammaGreen = 1.0;
|
||||
c.brightness = 100;
|
||||
c.brightnessCompensation = 0;
|
||||
|
||||
//device config
|
||||
var d = serverConfig.device;
|
||||
d.output = $('#ip').val();
|
||||
d.lightIds = finalLightIds;
|
||||
d.username = $('#user').val();
|
||||
d.type = "philipshue";
|
||||
d.transitiontime = 1;
|
||||
d.switchOffOnBlack = true;
|
||||
|
||||
//smoothing off
|
||||
serverConfig.smoothing.enable = false;
|
||||
|
||||
requestWriteConfig(serverConfig, true);
|
||||
setTimeout(initRestart,200);
|
||||
});
|
||||
|
||||
$('#btn_wiz_abort').off().on('click', resetWizard);
|
||||
}
|
||||
|
||||
function doWizardHue()
|
||||
function createHueUser()
|
||||
{
|
||||
var connectionRetries = 15;
|
||||
var connectionRetries = 30;
|
||||
var data = {"devicetype":"hyperion#"+Date.now()};
|
||||
var UserInterval = setInterval(function(){
|
||||
$.ajax({
|
||||
@@ -580,8 +778,6 @@ $(document).ready( function() {
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#abortConnection").hide();
|
||||
$("#ip_alert").hide();
|
||||
if (typeof r[0].error != 'undefined') {
|
||||
console.log(connectionRetries+": link not pressed");
|
||||
}
|
||||
@@ -590,9 +786,7 @@ $(document).ready( function() {
|
||||
$('#wizp2').toggle(true);
|
||||
$('#wizp3').toggle(false);
|
||||
$('#user').val(r[0].success.username);
|
||||
|
||||
$( "#hue_lights" ).empty();
|
||||
get_hue_lights();
|
||||
checkHueBridge(checkUserResult,r[0].success.username);
|
||||
clearInterval(UserInterval);
|
||||
}
|
||||
}
|
||||
@@ -601,7 +795,6 @@ $(document).ready( function() {
|
||||
$('#wizp1').toggle(false);
|
||||
$('#wizp2').toggle(true);
|
||||
$('#wizp3').toggle(false);
|
||||
$("#ip_alert").show();
|
||||
clearInterval(UserInterval);
|
||||
}
|
||||
});
|
||||
@@ -615,8 +808,34 @@ $(document).ready( function() {
|
||||
processData: false,
|
||||
contentType: 'application/json',
|
||||
success: function(r) {
|
||||
for(var lightid in r){
|
||||
$('#hue_lights').append('<tr><td>ID: '+lightid+'</td><td>Name: '+r[lightid].name+'</td></tr>');
|
||||
if(Object.keys(r).length > 0)
|
||||
{
|
||||
$('#wh_topcontainer').toggle(false);
|
||||
$('#hue_ids_t, #btn_wiz_save').toggle(true);
|
||||
lightIDs = r;
|
||||
|
||||
for(var lightid in r)
|
||||
{
|
||||
$('.lidsb').append(createTableRow([lightid+' ('+r[lightid].name+')', '<select id="hue_'+lightid+'" class="hue_sel_watch form-control"><option value="disabled">'+$.i18n('wiz_hue_ids_disabled')+'</option><option value="top">'+$.i18n('conf_leds_layout_cl_top')+'</option><option value="bottom">'+$.i18n('conf_leds_layout_cl_bottom')+'</option><option value="left">'+$.i18n('conf_leds_layout_cl_left')+'</option><option value="right">'+$.i18n('conf_leds_layout_cl_right')+'</option><option value="entire">'+$.i18n('wiz_hue_ids_entire')+'</option></select>','<button class="btn btn-sm btn-primary" onClick=identHueId('+lightid+')>'+$.i18n('wiz_hue_blinkblue',lightid)+'</button>']));
|
||||
}
|
||||
|
||||
$('.hue_sel_watch').bind("change", function(){
|
||||
var cC = 0;
|
||||
for(key in lightIDs)
|
||||
{
|
||||
if($('#hue_'+key).val() != "disabled")
|
||||
{
|
||||
cC++;
|
||||
}
|
||||
}
|
||||
cC == 0 ? $('#btn_wiz_save').attr("disabled",true) : $('#btn_wiz_save').attr("disabled",false);
|
||||
});
|
||||
|
||||
$('.hue_sel_watch').trigger('change');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#wizp2_body').html('<h4>'+$.i18n('wiz_hue_noids')+'</h4>')
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -627,9 +846,5 @@ $(document).ready( function() {
|
||||
$('#wizp1').toggle(false);
|
||||
$('#wizp2').toggle(true);
|
||||
$('#wizp3').toggle(false);
|
||||
$("#abortConnection").show();
|
||||
|
||||
}
|
||||
|
||||
$('#btn_wizard_philipshue').off().on('click',startWizardPhilipsHue);
|
||||
});
|
||||
$("#wiz_hue_usrstate").html($.i18n('wiz_hue_failure_connection'));
|
||||
}
|
Reference in New Issue
Block a user