mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
webui: enhance led config (#224)
* split content and js tune leds config * implement connection lost page * split js/html in huebridge * add js action for connection lost
This commit is contained in:
@@ -8,118 +8,50 @@
|
||||
#leds_controls {white-space:nowrap; margin-top:530px;}
|
||||
</style>
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<h1 class="page-header" lang="en" data-lang-token="main_menu_leds_conf_token">Led Configuration</h1>
|
||||
<!-- <div class="introd">
|
||||
<h4 lang="en" data-lang-token="remote_effects_intro"></h4>
|
||||
</div>-->
|
||||
|
||||
<div id="leds_canvas"/>
|
||||
<ul id="leds_cfg_nav" class="nav nav-tabs">
|
||||
<li class="active"><a data-toggle="tab" href="#menu_display">Display LEDs</a></li>
|
||||
<li><a data-toggle="tab" href="#menu_gencfg">Generate Config</a></li>
|
||||
<li><a data-toggle="tab" href="#menu_customcfg">Custom Config</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
|
||||
<div id="menu_display" class="tab-pane fade in active">
|
||||
<div class="container-fluid">
|
||||
<div id="leds_canvas"/>
|
||||
|
||||
<div id="leds_controls">
|
||||
<button lang="en" type="button" class="btn btn-success" id="leds_toggle">toggle leds</button>
|
||||
<button lang="en" type="button" class="btn btn-danger" id="leds_toggle_num">toggle led numbers</button>
|
||||
<button lang="en" type="button" class="btn btn-success" id="leds_toggle_live">toggle live leds</button>
|
||||
<div id="leds_controls">
|
||||
<button lang="en" type="button" class="btn btn-success" id="leds_toggle">toggle leds</button>
|
||||
<button lang="en" type="button" class="btn btn-danger" id="leds_toggle_num">toggle led numbers</button>
|
||||
<button lang="en" type="button" class="btn btn-danger" id="leds_toggle_live">toggle live leds</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<div id="menu_gencfg" class="tab-pane fade">
|
||||
<h3>coming soon</h3>
|
||||
<p>led config generator ...</p>
|
||||
</div>
|
||||
|
||||
function updateLedColors()
|
||||
{
|
||||
if($("#leds_canvas").length > 0 && ledStreamActive)
|
||||
{
|
||||
requestLedColorsStart();
|
||||
}
|
||||
else
|
||||
{
|
||||
ledStreamActivate(false);
|
||||
}
|
||||
}
|
||||
<div id="menu_customcfg" class="tab-pane fade">
|
||||
<p>
|
||||
<div class="form-group">
|
||||
<div style="margin-bottom:5px">
|
||||
<button lang="en" type="button" class="btn btn-success" id="leds_custom_check">check config</button>
|
||||
<button lang="en" type="button" class="btn btn-success" id="leds_custom_save">save config</button>
|
||||
</div>
|
||||
<textarea rows="20" id="ledconfig" style="width:90%"></textarea>
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
function ledStreamActivate(enable)
|
||||
{
|
||||
$(hyperion).off("cron", updateLedColors );
|
||||
if ( enable && ! ledStreamActive )
|
||||
{
|
||||
$(hyperion).on("cron", updateLedColors );
|
||||
}
|
||||
</div> <!-- tab content -->
|
||||
|
||||
ledStreamActive=enable;
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
$(hyperion).on("cmd-ledcolors",function(event){
|
||||
ledColors = (event.response.result);
|
||||
for(var idx=0; idx<ledColors.length; idx++)
|
||||
{
|
||||
led = ledColors[idx]
|
||||
$("#led_"+led.index).css("background","rgb("+led.red+","+led.green+","+led.blue+")");
|
||||
}
|
||||
});
|
||||
<script src="/js/content_leds.js"></script>
|
||||
|
||||
$(hyperion).on("cmd-ledcolors-ledstream-update",function(event){
|
||||
ledColors = (event.response.result);
|
||||
for(var idx=0; idx<ledColors.length; idx++)
|
||||
{
|
||||
led = ledColors[idx]
|
||||
$("#led_"+led.index).css("background","rgb("+led.red+","+led.green+","+led.blue+")");
|
||||
}
|
||||
});
|
||||
|
||||
$(hyperion).on("cmd-config-getconfig",function(event){
|
||||
parsedConfJSON = event.response.result;
|
||||
leds = parsedConfJSON.leds;
|
||||
canvas_height = $('#leds_canvas').innerHeight();
|
||||
canvas_width = $('#leds_canvas').innerWidth();
|
||||
|
||||
leds_html = "";
|
||||
for(var idx=0; idx<leds.length; idx++)
|
||||
{
|
||||
led = leds[idx];
|
||||
led_id='led_'+led.index;
|
||||
bgcolor = "background-color:hsl("+(idx*360/leds.length)+",100%,50%);";
|
||||
pos = "left:"+(led.hscan.minimum * canvas_width)+"px;"+
|
||||
"top:"+(led.vscan.minimum * canvas_height)+"px;"+
|
||||
"width:"+((led.hscan.maximum-led.hscan.minimum) * canvas_width-1)+"px;"+
|
||||
"height:"+((led.vscan.maximum-led.vscan.minimum) * canvas_height-1)+"px;";
|
||||
leds_html += '<div id="'+led_id+'" class="led" style="'+bgcolor+pos+'" title="'+led.index+'"><span id="'+led_id+'_num" class="led_num">'+led.index+'</span></div>';
|
||||
}
|
||||
$('#leds_canvas').html(leds_html);
|
||||
$('#led_0').css("border","2px dotted red");
|
||||
ledStreamActivate(true)
|
||||
});
|
||||
|
||||
$('#leds_toggle_num').on("click", function() {
|
||||
$('.led_num').toggle();
|
||||
toggleClass('#leds_toggle_num', "btn-danger", "btn-success");
|
||||
});
|
||||
|
||||
$('#leds_toggle').on("click", function() {
|
||||
$('.led').toggle();
|
||||
toggleClass('#leds_toggle', "btn-success", "btn-danger");
|
||||
});
|
||||
|
||||
$('#leds_toggle_live').on("click", function() {
|
||||
setClassByBool('#leds_toggle_live',ledStreamActive,"btn-success","btn-danger");
|
||||
if ( ledStreamActive )
|
||||
{
|
||||
ledStreamActivate(false);
|
||||
|
||||
led_count = $(".led").length;
|
||||
for(var idx=0; idx<led_count; idx++)
|
||||
{
|
||||
$('#led_'+idx).css("background-color","hsl("+(idx*360/led_count)+",100%,50%)");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ledStreamActivate(true);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
requestServerConfig();
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user