mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Simplified Hue Connection (#225)
This commit is contained in:
parent
bbffa078fd
commit
ffafe7e306
@ -5,13 +5,14 @@
|
|||||||
<div class="col-lg-12" >
|
<div class="col-lg-12" >
|
||||||
<div class="col-lg-6" >
|
<div class="col-lg-6" >
|
||||||
<span id="ip_alert" style="display:none; color:red; font-weight: bold;" lang="en" data-lang-token="hue_failure_ip_token">Please check your IP Address.</span>
|
<span id="ip_alert" style="display:none; color:red; font-weight: bold;" lang="en" data-lang-token="hue_failure_ip_token">Please check your IP Address.</span>
|
||||||
|
<span id="abortConnection" style="display:none; color:red; font-weight: bold;" lang="en" data-lang-token="hue_failure_connection_token">Connection Timeout. Please press the button in time.</span>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="ip">IP:</label>
|
<label for="ip">IP:</label>
|
||||||
<input type="text" class="form-control" id="ip">
|
<input type="text" class="form-control" id="ip">
|
||||||
<label for="user" lang="en" data-lang-token="hue_label_username">Username:</label>
|
<label for="user" lang="en" data-lang-token="hue_label_username">Username:</label>
|
||||||
<input type="text" class="form-control" id="user" disabled>
|
<input type="text" class="form-control" id="user" disabled>
|
||||||
<br />
|
<br />
|
||||||
<button type="button" class="btn btn-success" id="create_user_first"> <i class="fa fa-floppy-o"></i><span lang="en" data-lang-token="hue_button_create_user_token"> Create User</span></button>
|
<button type="button" class="btn btn-success" id="create_user"> <i class="fa fa-floppy-o"></i><span lang="en" data-lang-token="hue_button_create_user_token"> Create User</span></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -32,13 +33,13 @@
|
|||||||
<h4 class="modal-title">Hue Bridge</h4>
|
<h4 class="modal-title">Hue Bridge</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<span lang="en" data-lang-token="hue_press_link_modal">Press link button on the Hue Bridge now and confirm with the "Pair" button.</span> <br /><br />
|
<span lang="en" data-lang-token="hue_press_link_modal">Please press link button on the Hue Bridge.</span> <br /><br />
|
||||||
<span id="link_not_pressed" style="display:none; color: red" lang="en" data-lang-token="hue_press_link_modal_failure">Please press link button on your Hue Bridge.</span>
|
<center>
|
||||||
|
<span id="connectionTime"></span><br />
|
||||||
|
<img src="/img/hyperion/ring-alt.svg">
|
||||||
|
<center>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<center>
|
|
||||||
<button type="button" class="btn btn-success" id="create_user_second"> <i class="fa fa-floppy-o"></i><span lang="en" data-lang-token="hue_button_pair"> Pair</span>
|
|
||||||
</center>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -53,9 +54,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$("#create_user_first").on("click", function() {
|
$("#create_user").on("click", function() {
|
||||||
|
var connectionRetries = 15;
|
||||||
var data = {"devicetype":"hyperion#"+Date.now()};
|
var data = {"devicetype":"hyperion#"+Date.now()};
|
||||||
$.ajax({
|
var UserInterval = setInterval(function(){
|
||||||
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: 'http://'+$("#ip").val()+'/api',
|
url: 'http://'+$("#ip").val()+'/api',
|
||||||
processData: false,
|
processData: false,
|
||||||
@ -63,42 +66,39 @@
|
|||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
data: JSON.stringify(data),
|
data: JSON.stringify(data),
|
||||||
success: function(r) {
|
success: function(r) {
|
||||||
$("#ip_alert").hide();
|
connectionRetries--;
|
||||||
if (typeof r[0].error != 'undefined') {
|
$("#connectionTime").html(connectionRetries);
|
||||||
if (r[0].error.description == "link button not pressed"){
|
if(connectionRetries == 0) {
|
||||||
$('#pairmodal').modal('show')
|
abortConnection(UserInterval);
|
||||||
}
|
}
|
||||||
}
|
else{
|
||||||
},
|
$("#abortConnection").hide();
|
||||||
|
$('#pairmodal').modal('show');
|
||||||
|
$("#ip_alert").hide();
|
||||||
|
if (typeof r[0].error != 'undefined') {
|
||||||
|
console.log("link not pressed");
|
||||||
|
}
|
||||||
|
if (typeof r[0].success != 'undefined') {
|
||||||
|
$('#pairmodal').modal('hide');
|
||||||
|
$('#user').val(r[0].success.username);
|
||||||
|
get_hue_lights();
|
||||||
|
clearInterval(UserInterval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||||
$("#ip_alert").show();
|
$("#ip_alert").show();
|
||||||
|
clearInterval(UserInterval);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function abortConnection(UserInterval){
|
||||||
$("#create_user_second").on("click", function() {
|
clearInterval(UserInterval);
|
||||||
var data = {"devicetype":"my_hue_app#iphone pet2er"};
|
$("#abortConnection").show();
|
||||||
$.ajax({
|
$('#pairmodal').modal('hide');
|
||||||
type: "POST",
|
}
|
||||||
url: 'http://'+$("#ip").val()+'/api',
|
|
||||||
processData: false,
|
|
||||||
contentType: 'application/json',
|
|
||||||
data: JSON.stringify(data),
|
|
||||||
success: function(r) {
|
|
||||||
if (typeof r[0].error != 'undefined') {
|
|
||||||
$("#link_not_pressed").show();
|
|
||||||
}
|
|
||||||
if (typeof r[0].success != 'undefined') {
|
|
||||||
$('#pairmodal').modal('hide');
|
|
||||||
$('#user').val(r[0].success.username);
|
|
||||||
$("#link_not_pressed").hide();
|
|
||||||
get_hue_lights();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
function get_hue_lights(){
|
function get_hue_lights(){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
1
assets/webconfig/img/hyperion/ring-alt.svg
Normal file
1
assets/webconfig/img/hyperion/ring-alt.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><svg width='120px' height='120px' xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" class="uil-ring-alt"><rect x="0" y="0" width="100" height="100" fill="none" class="bk"></rect><circle cx="50" cy="50" r="40" stroke="#afafb7" fill="none" stroke-width="10" stroke-linecap="round"></circle><circle cx="50" cy="50" r="40" stroke="#5cffd6" fill="none" stroke-width="6" stroke-linecap="round"><animate attributeName="stroke-dashoffset" dur="2s" repeatCount="indefinite" from="0" to="502"></animate><animate attributeName="stroke-dasharray" dur="2s" repeatCount="indefinite" values="150.6 100.4;1 250;150.6 100.4"></animate></circle></svg>
|
After Width: | Height: | Size: 709 B |
@ -32,6 +32,7 @@
|
|||||||
"main_menu_system_token" : "System",
|
"main_menu_system_token" : "System",
|
||||||
"main_menu_input_selection_token" : "Eingabeauswahl",
|
"main_menu_input_selection_token" : "Eingabeauswahl",
|
||||||
"main_menu_general_conf_token":"Allgemein",
|
"main_menu_general_conf_token":"Allgemein",
|
||||||
|
"main_menu_leds_conf_token":"LEDs",
|
||||||
"remote_colors_label_color":"Farbe: ",
|
"remote_colors_label_color":"Farbe: ",
|
||||||
"remote_colors_button_reset":"Farbe zurücksetzen",
|
"remote_colors_button_reset":"Farbe zurücksetzen",
|
||||||
"remote_effects_intro" : "Die Effekt-Fernbedienung ermöglicht es dir Effekte zu starten für Demonstrations- oder Testzwecke. Vergessse nicht den Effekt wieder zu stoppen, wenn du fertig bist.",
|
"remote_effects_intro" : "Die Effekt-Fernbedienung ermöglicht es dir Effekte zu starten für Demonstrations- oder Testzwecke. Vergessse nicht den Effekt wieder zu stoppen, wenn du fertig bist.",
|
||||||
@ -39,8 +40,8 @@
|
|||||||
"remote_effects_label_stopeffect":"Stoppe Effekte",
|
"remote_effects_label_stopeffect":"Stoppe Effekte",
|
||||||
"remote_components_intro" : "Die Komponenten-Fenbedienung ermöglicht es dir Komponenten von Hyperion zu starten und stoppen. Beachte: Dies ist nur temporär und geht nach einem Neustart verloren. Möchtest du dauerhaft Komponenten aktivieren/deaktivieren benutze die Konfigurationsseiten.",
|
"remote_components_intro" : "Die Komponenten-Fenbedienung ermöglicht es dir Komponenten von Hyperion zu starten und stoppen. Beachte: Dies ist nur temporär und geht nach einem Neustart verloren. Möchtest du dauerhaft Komponenten aktivieren/deaktivieren benutze die Konfigurationsseiten.",
|
||||||
"hue_button_create_user_token":"Benutzer anlegen",
|
"hue_button_create_user_token":"Benutzer anlegen",
|
||||||
"hue_press_link_modal":"Link Taste auf der Hue Bridge drücken und mit Button bestätigen.",
|
"hue_press_link_modal":"Bitte Link Taste auf der Hue Bridge drücken.",
|
||||||
"hue_press_link_modal_failure":"Bitte drücke die Link Taste auf deiner Hue Bridge.",
|
"hue_failure_connection_token":"Connection Timeout. Bitte drücke die Taste rechtzeitig.",
|
||||||
"hue_button_pair":"Verbinden",
|
"hue_button_pair":"Verbinden",
|
||||||
"hue_failure_ip_token":"Bitte überprüfe deine IP Adresse.",
|
"hue_failure_ip_token":"Bitte überprüfe deine IP Adresse.",
|
||||||
"hue_label_username":"Benutzername:",
|
"hue_label_username":"Benutzername:",
|
||||||
|
Loading…
Reference in New Issue
Block a user