Web: Centralize websocket, add json port changer and led schemas (#209)

* add comp test

* update web

* .

* typo

[skip ci]
This commit is contained in:
brindosch 2016-08-30 23:25:27 +02:00 committed by GitHub
parent 02ee557300
commit 0603fadd21
26 changed files with 397 additions and 86 deletions

View File

@ -17,28 +17,13 @@
$(document).ready( function() {
webSocket = new WebSocket('ws://'+document.location.hostname+':19444');
var serverInfo;
webSocket.onerror = function(event) {
alert(event.data);
};
webSocket.onopen = function(event) {
webSocket.send('{"command":"serverinfo"}');
};
webSocket.onmessage = function(response){
responseJSON = JSON.parse(response.data );
//console.log(response.data);
for(i = 0; i < responseJSON.info.effects.length; i++) {
//console.log(responseJSON.info.effects[i].name);
var effectName = responseJSON.info.effects[i].name;
for(i = 0; i < parsedServerInfoJSON.info.effects.length; i++) {
//console.log(parsedServerInfoJSON.info.effects[i].name);
var effectName = parsedServerInfoJSON.info.effects[i].name;
$('#buttondiv').append('<button type="button" class="btn btn-success" onclick="playEffect(\''+effectName+'\')"><i class="fa fa-play"></i></button> '+effectName+'<br />');
}
}
$("#effect_stop").on("click", function() {
webSocket.send('{"command":"clear", "priority":1}');

View File

@ -28,15 +28,21 @@
<div class="modal fade bs-pair-modal-lg" id="pairmodal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Hue Bridge</h4>
</div>
<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 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>
</div>
<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>
<script>

View File

@ -346,6 +346,8 @@
<div class="introd">
<h4 lang="en" data-lang-token="dashboard_label_intro">The dashboard give you a quick overview about the status of Hyperion and show you the latest news of the Hyperion Blog.</h4>
</div>
<hr>
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#myModal">Change JSON port</button>
<hr>
<div class="col-lg-4">
<div class="panel panel-default">
@ -358,15 +360,19 @@
<tbody>
<tr>
<td lang="en" data-lang-token="dashboard_label_infobox_currenthyp">Your Hyperion version:</td>
<td id="currentversion"></td>
<td id="currentversion">unknown</td>
</tr>
<tr>
<td lang="en" data-lang-token="dashboard_label_infobox_latesthyp">Latest version:</td>
<td id="latestversion"></td>
<td id="latestversion">unknown</td>
</tr>
<tr>
<td lang="en" data-lang-token="dashboard_label_infobox_leddevice">LED type:</td>
<td id="dash_leddevice">unknown</td>
</tr>
<tr>
<td lang="en" data-lang-token="dashboard_label_infobox_device">Device:</td>
<td></td>
<td id="dash_systeminfo"></td>
</tr>
</tbody>
</table>
@ -431,7 +437,49 @@
</div>
<!-- /#wrapper -->
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Modal Test and port changer</h4>
</div>
<div class="modal-body">
<p>Input the JSON port you want to connect and press reload</p>
<form class="form-inline">
<div class="form-group">
<label for="port">Your JSON Port:</label>
<input type="number" min="100" max="65535" value="19444" class="form-control" id="json_port">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" onclick="button_reloaddata()" class="btn btn-primary" data-dismiss="modal">Reload!</button>
</div>
</div>
</div>
</div>
<div id="con_error_modal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content" id="con_error_modal">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Oh noes! Something went wrong!</h4>
</div>
<div class="modal-body">
<p>We are sorry, the json port was not found. Just try another one!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Okay!</button>
</div>
</div>
</div>
</div>
<!-- Bootstrap Core JavaScript -->
<script src="js/lib/bootstrap.min.js"></script>
@ -479,46 +527,7 @@
//Change all Checkboxes to Switches
$("[type='checkbox']").bootstrapSwitch();
// vesion check
var currentVersion;
var cleanCurrentVersion;
var latestVersion;
var cleanLatestVersion;
webSocket = new WebSocket('ws://'+document.location.hostname+':19444');
var serverInfo;
webSocket.onerror = function(event) {
alert(event.data);
};
webSocket.onopen = function(event) {
webSocket.send('{"command":"serverinfo"}');
};
webSocket.onmessage = function(response){
responseJSON = JSON.parse(response.data );
currentVersion = responseJSON.info.hyperion[0].version;
cleanCurrentVersion = currentVersion.replace(/\./g, '');
$.get( "https://raw.githubusercontent.com/hyperion-project/hyperion.ng/master/version.json", function( data ) {
var responseJSON = JSON.parse(data);
latestVersion = responseJSON[0].versionnr;
cleanLatestVersion = latestVersion.replace(/\./g, '');
$('#currentversion').append(' V'+currentVersion);
$('#latestversion').append(' V'+latestVersion);
if ( cleanCurrentVersion < cleanLatestVersion ) {
$('#versioninforesult').append('<div lang="en" data-lang-token="dashboard_message_infobox_updatewarning" style="margin:0px;" class="alert alert-warning">A newer version of Hyperion is available!</div>');
}
else{
$('#versioninforesult').append('<div lang="en" data-lang-token="dashboard_message_infobox_updatesuccess" style="margin:0px;" class="alert alert-success">You run the latest version of Hyperion.</div>');
}
});
};
loaddata();
});
$(function(){

View File

@ -20,3 +20,59 @@ $inputs.each(function() {
$("label[for='" + $(this).attr('id') + "']").html('<span lang="en" data-lang-token="' + tokenPrefix + "_" + $(this).attr('id') + '">' + oldtext + '</span>');
});
}
// global vars
var currentVersion;
var cleanCurrentVersion;
var latestVersion;
var cleanLatestVersion;
var parsedServerInfoJSON;
var parsedUpdateJSON;
var hyperionport = 19444;
function button_reloaddata(){
hyperionport = $("#json_port").val();
loaddata();
};
function loaddata() {
webSocket = new WebSocket('ws://'+document.location.hostname+':'+hyperionport);
webSocket.onerror = function(event) {
$('#con_error_modal').modal('show');
};
webSocket.onopen = function(event) {
webSocket.send('{"command":"serverinfo"}');
};
webSocket.onmessage = function(response){
parsedServerInfoJSON = JSON.parse(response.data );
currentVersion = parsedServerInfoJSON.info.hyperion[0].version;
cleanCurrentVersion = currentVersion.replace(/\./g, '');
// get active led device
var leddevice = parsedServerInfoJSON.info.ledDevices.active;
$('#dash_leddevice').html(leddevice);
// get host
var hostname = parsedServerInfoJSON.info.hostname;
$('#dash_systeminfo').html(hostname+':'+hyperionport);
$.get( "https://raw.githubusercontent.com/hyperion-project/hyperion.ng/master/version.json", function( data ) {
parsedUpdateJSON = JSON.parse(data);
latestVersion = parsedUpdateJSON[0].versionnr;
cleanLatestVersion = latestVersion.replace(/\./g, '');
$('#currentversion').html(' V'+currentVersion);
$('#latestversion').html(' V'+latestVersion);
if ( cleanCurrentVersion < cleanLatestVersion ) {
$('#versioninforesult').html('<div lang="en" data-lang-token="dashboard_message_infobox_updatewarning" style="margin:0px;" class="alert alert-warning">A newer version of Hyperion is available!</div>');
}
else{
$('#versioninforesult').html('<div lang="en" data-lang-token="dashboard_message_infobox_updatesuccess" style="margin:0px;" class="alert alert-success">You run the latest version of Hyperion.</div>');
}
});
};
};

View File

@ -13,7 +13,8 @@
"dashboard_label_infobox_title" : "Informationen",
"dashboard_label_infobox_currenthyp" : "Deine Hyperion Version:",
"dashboard_label_infobox_latesthyp" : "Aktuellste Hyperion Version:",
"dashboard_label_infobox_device" : "Geräteinformation:",
"dashboard_label_infobox_leddevice" : "LED Typ:",
"dashboard_label_infobox_device" : "Systeminformation:",
"dashboard_label_componentbox_title" : "Komponenten Status",
"dashboard_label_newsbox_title" : "Die letzten Blogposts",
"dashboard_message_infobox_updatewarning" : "Eine aktuellere Version von Hyperion ist verfügbar!",

View File

@ -21,14 +21,6 @@
<script>
var webSocket = new WebSocket('ws://'+document.location.hostname+':19444');
webSocket.onerror = function(event) {
alert(event.data);
};
webSocket.onopen = function(event) {
$(function() {
$('#cp2').colorpicker({
format: 'rgb',
@ -66,7 +58,7 @@
webSocket.send('{"command":"clear", "priority":1}');
});
};
webSocket.onmessage = function(event){
console.log(event.data);

View File

@ -14,8 +14,6 @@
<script>
webSocket = new WebSocket('ws://'+document.location.hostname+':19444');
new Enum('SMOOTHING', 'BLACKBORDER', 'KODICHECKER', 'FORWARDER', 'UDPLISTENER', 'BOBLIGHT_SERVER','GRABBER');
function Enum() {

View File

@ -6,6 +6,8 @@
<h4 lang="en" data-lang-token="update_label_intro">This page gives you an overview of all Hyperion versions available. On top you could update or downgrade your version of Hyperion whenever you want. Sorted from newest to oldest</h4>
</div>
<hr>
<h4 id="update_currver"></h4>
<hr>
<div class="col-lg-12" id="versionlist">
</div>
</div>
@ -14,13 +16,11 @@
<script type="text/javascript">
$.get( "https://raw.githubusercontent.com/hyperion-project/hyperion.ng/master/version.json", function( data ) {
var vlist = JSON.parse(data);
for (key in vlist)
for (key in parsedUpdateJSON)
{
$('#versionlist').append('<div class="col-lg-6"><div class="panel panel-default"><div class="panel-heading"><i class="fa fa-television fa-fw"></i>Hyperion V'+vlist[key].versionnr+'</div><div class="panel-body"><p><span style="font-weight:bold;" lang="en" data-lang-token="update_label_type">Type:</span> '+ vlist[key].channel +'</p><p><span style="font-weight:bold;" lang="en" data-lang-token="update_label_description">Description:</span> '+vlist[key].versiondesc+'</p><hr><a class="btn btn-primary" href="'+ vlist[key].versionchangelog +'" target="_blank"><i class="fa fa-list fa-fw"></i><span style="font-weight:bold;" lang="en" data-lang-token="update_button_changelog">Full changelog</span></a><button type="button" class="btn btn-warning pull-right"><i class="fa fa-download fa-fw"></i><span lang="en" data-lang-token="update_button_install">Install</span></button></div></div></div>');
$('#versionlist').append('<div class="col-lg-6"><div class="panel panel-default"><div class="panel-heading"><i class="fa fa-television fa-fw"></i>Hyperion V'+parsedUpdateJSON[key].versionnr+'</div><div class="panel-body"><p><span style="font-weight:bold;" lang="en" data-lang-token="update_label_type">Type:</span> '+ parsedUpdateJSON[key].channel +'</p><p><span style="font-weight:bold;" lang="en" data-lang-token="update_label_description">Description:</span> '+parsedUpdateJSON[key].versiondesc+'</p><hr><a class="btn btn-primary" href="'+ parsedUpdateJSON[key].versionchangelog +'" target="_blank"><i class="fa fa-list fa-fw"></i><span style="font-weight:bold;" lang="en" data-lang-token="update_button_changelog">Full changelog</span></a><button type="button" class="btn btn-warning pull-right"><i class="fa fa-download fa-fw"></i><span lang="en" data-lang-token="update_button_install">Install</span></button></div></div></div>');
}
$('#update_currver').append(currentVersion);
});
</script>

View File

@ -2,6 +2,20 @@
"type":"object",
"required":true,
"properties":{
"output": {
"type": "string",
"title":"Output path"
},
"rate": {
"type": "integer",
"title":"Baudrate",
"default": 1000000
},
"delayAfterConnect": {
"type": "integer",
"title":"Delay after connect",
"default": 250
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,20 @@
"type":"object",
"required":true,
"properties":{
"output": {
"type": "string",
"title":"Output path"
},
"rate": {
"type": "integer",
"title":"Baudrate",
"default": 1000000
},
"delayAfterConnect": {
"type": "integer",
"title":"Delay after connect",
"default": 250
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,21 @@
"type":"object",
"required":true,
"properties":{
"output": {
"type": "string",
"title":"SPI path",
"enum" : ["/dev/spidev0.0","/dev/spidev0.1"]
},
"rate": {
"type": "integer",
"title":"Baudrate",
"default": 1000000
},
"invert": {
"type": "boolean",
"title":"Invert signal",
"default": false
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,20 @@
"type":"object",
"required":true,
"properties":{
"output": {
"type": "string",
"title":"Output path"
},
"rate": {
"type": "integer",
"title":"Baudrate",
"default": 1000000
},
"delayAfterConnect": {
"type": "integer",
"title":"Delay after connect",
"default": 250
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,33 @@
"type":"object",
"required":true,
"properties":{
"output": {
"type": "string",
"title":"Multicast group",
"default" : "239.15.18.2"
},
"orbIds": {
"type": "string",
"title":"Baudrate",
"default": "1"
},
"numLeds": {
"type": "integer",
"title":"Number of LEDs",
"default": 24
},
"port": {
"type": "integer",
"title":"Port",
"minimum" : 0,
"maximum" : 65535,
"default": 24
},
"useOrbSmoothing": {
"type": "boolean",
"title":"Use orb smoothing",
"default": true
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,20 @@
"type":"object",
"required":true,
"properties":{
"universe": {
"type": "integer",
"title":"Universe",
"default": 1
},
"latchtinme": {
"type": "integer",
"title":"Latchtime",
"default": 104000
},
"cid": {
"type": "string",
"title":"CID",
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,11 @@
"type":"object",
"required":true,
"properties":{
"output": {
"type": "string",
"title":"Output",
"default" : "/dev/null",
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,10 @@
"type":"object",
"required":true,
"properties":{
"output": {
"type": "string",
"title":"Serial number"
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,21 @@
"type":"object",
"required":true,
"properties":{
"output": {
"type": "string",
"title":"SPI path",
"enum" : ["/dev/spidev0.0","/dev/spidev0.1"]
},
"rate": {
"type": "integer",
"title":"Baudrate",
"default": 1000000
},
"invert": {
"type": "boolean",
"title":"Invert signal",
"default": false
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,21 @@
"type":"object",
"required":true,
"properties":{
"output": {
"type": "string",
"title":"SPI path",
"enum" : ["/dev/spidev0.0","/dev/spidev0.1"]
},
"rate": {
"type": "integer",
"title":"Baudrate",
"default": 1000000
},
"invert": {
"type": "boolean",
"title":"Invert signal",
"default": false
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,21 @@
"type":"object",
"required":true,
"properties":{
"output": {
"type": "string",
"title":"SPI path",
"enum" : ["/dev/spidev0.0","/dev/spidev0.1"]
},
"rate": {
"type": "integer",
"title":"Baudrate",
"default": 1000000
},
"invert": {
"type": "boolean",
"title":"Invert signal",
"default": false
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,21 @@
"type":"object",
"required":true,
"properties":{
"VID": {
"type": "string",
"title":"VID",
"default" : "0x2341"
},
"PID": {
"type": "string",
"title":"PID",
"default" : "0x8036"
},
"delayAfterConnect": {
"type": "integer",
"title":"Delay after connect",
"default": 0
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,29 @@
"type":"object",
"required":true,
"properties":{
"output": {
"type": "string",
"title":"Target IP"
},
"username": {
"type": "string",
"title":"Username",
"default": "newdeveloper"
},
"lightIds": {
"type": "integer",
"title":"Light ids"
},
"transitiontime": {
"type": "integer",
"title":"Transistion time (x100ms)",
"default" : 1,
},
"switchOffOnBlack": {
"type": "boolean",
"title":"Switch off on black",
"default" : true
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,21 @@
"type":"object",
"required":true,
"properties":{
"VID": {
"type": "string",
"title":"VID",
"default" : "0x2341"
},
"PID": {
"type": "string",
"title":"PID",
"default" : "0x8036"
},
"delayAfterConnect": {
"type": "integer",
"title":"Delay after connect",
"default": 0
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,20 @@
"type":"object",
"required":true,
"properties":{
"output": {
"type": "string",
"title":"Output path"
},
"rate": {
"type": "integer",
"title":"Baudrate",
"default": 1000000
},
"delayAfterConnect": {
"type": "integer",
"title":"Delay after connect",
"default": 250
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,21 @@
"type":"object",
"required":true,
"properties":{
"output": {
"type": "string",
"title":"SPI path",
"enum" : ["/dev/spidev0.0","/dev/spidev0.1"]
},
"rate": {
"type": "integer",
"title":"Baudrate",
"default": 1000000
},
"invert": {
"type": "boolean",
"title":"Invert signal",
"default": false
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,21 @@
"type":"object",
"required":true,
"properties":{
"output": {
"type": "string",
"title":"SPI path",
"enum" : ["/dev/spidev0.0","/dev/spidev0.1"]
},
"rate": {
"type": "integer",
"title":"Baudrate",
"default": 1000000
},
"invert": {
"type": "boolean",
"title":"Invert signal",
"default": false
}
},
"additionalProperties": true
}

View File

@ -2,6 +2,21 @@
"type":"object",
"required":true,
"properties":{
"output": {
"type": "string",
"title":"SPI path",
"enum" : ["/dev/spidev0.0","/dev/spidev0.1"]
},
"rate": {
"type": "integer",
"title":"Baudrate",
"default": 1000000
},
"invert": {
"type": "boolean",
"title":"Invert signal",
"default": false
}
},
"additionalProperties": true
}