Small Hue improvements (#235)

* Small Hue Bridge improvements

* Small Lang fixing
This commit is contained in:
b1rdhous3
2016-09-11 22:20:57 +02:00
committed by redPanther
parent 0b8d41ed69
commit d097995a74
5 changed files with 60 additions and 52 deletions

View File

@@ -1,9 +1,5 @@
$(document).ready( function() {
if($("#ip").val() != '' && $("#user").val() != '') {
get_hue_lights();
}
$("#create_user").on("click", function() {
var connectionRetries = 15;
var data = {"devicetype":"hyperion#"+Date.now()};
@@ -32,6 +28,8 @@ $(document).ready( function() {
if (typeof r[0].success != 'undefined') {
$('#pairmodal').modal('hide');
$('#user').val(r[0].success.username);
$( "#hue_lights" ).empty();
get_hue_lights();
clearInterval(UserInterval);
}
@@ -51,19 +49,4 @@ function abortConnection(UserInterval){
$('#pairmodal').modal('hide');
}
function get_hue_lights(){
$.ajax({
type: "GET",
url: 'http://'+$("#ip").val()+'/api/'+$("#user").val()+'/lights',
processData: false,
contentType: 'application/json',
success: function(r) {
for(var lightid in r){
//console.log(r[lightid].name);
$('#hue_lights').append('ID: '+lightid+' Name: '+r[lightid].name+'<br />');
}
}
});
}
});

View File

@@ -96,16 +96,16 @@ $(document).ready(function() {
// ------------------------------------------------------------------
$("#leds_custom_check").off().on("click", function() {
e = isJsonString($("#ledconfig").val());
if (e.length == 0)
showErrorDialog("Validation success", "Your config is valid!");
else
showErrorDialog("Validation failed!", e);
});
// ------------------------------------------------------------------
$("#leds_custom_save").off().on("click", function() {
});
$('#leds_cfg_nav a[data-toggle="tab"]').off().on('shown.bs.tab', function (e) {
@@ -127,7 +127,7 @@ $(document).ready(function() {
$('#editor_container').off();
$('#editor_container').html("");
var element = document.getElementById('editor_container');
var grabber_conf_editor = new JSONEditor(element,{
theme: 'bootstrap3',
iconlib: "fontawesome4",
@@ -154,7 +154,7 @@ $(document).ready(function() {
values_general[key] = parsedConfJSON.device[key];
};
grabber_conf_editor.getEditor("root.generalOptions").setValue( values_general );
if (isCurrentDevice)
{
for(var key in parsedConfJSON.device){
@@ -163,23 +163,30 @@ $(document).ready(function() {
};
grabber_conf_editor.getEditor("root.specificOptions").setValue( values_specific );
};
$('#editor_container .well').css("background-color","white");
$('#editor_container .well').css("border","none");
$('#editor_container .well').css("box-shadow","none");
$('#editor_container .btn').addClass("btn-primary");
$('#editor_container h3').first().remove();
if ($(this).val() == "philipshue")
{
$("#huebridge").show();
$("#ip").attr('value', values_specific.output);
$("#user").attr('value', values_specific.username);
if($("#ip").val() != '' && $("#user").val() != '') {
get_hue_lights();
}
}
else
{
$("#huebridge").hide();
}
});
requestServerConfig();
});

View File

@@ -197,3 +197,18 @@ function requestWriteConfig(config, create, overwrite)
var overwrite = (typeof overwrite !== 'undefined') ? overwrite : false;
websocket.send('{"command":"config","subcommand":"setconfig", "tan":'+wsTan+', "config":'+JSON.stringify(config)+',"create":'+create+', "overwrite":'+overwrite+'}');
}
function get_hue_lights(){
$.ajax({
type: "GET",
url: 'http://'+$("#ip").val()+'/api/'+$("#user").val()+'/lights',
processData: false,
contentType: 'application/json',
success: function(r) {
for(var lightid in r){
//console.log(r[lightid].name);
$('#hue_lights').append('ID: '+lightid+' Name: '+r[lightid].name+'<br />');
}
}
});
}