mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
@@ -5,6 +5,9 @@ var finalLedArray = [];
|
||||
var conf_editor = null;
|
||||
var blacklist_editor = null;
|
||||
var aceEdt = null;
|
||||
var imageCanvasNodeCtx;
|
||||
var canvas_height;
|
||||
var canvas_width;
|
||||
|
||||
var devRPiSPI = ['apa102', 'apa104', 'ws2801', 'lpd6803', 'lpd8806', 'p9813', 'sk6812spi', 'sk6822spi', 'sk9822', 'ws2812spi'];
|
||||
var devRPiPWM = ['ws281x'];
|
||||
@@ -39,8 +42,11 @@ function createLedPreview(leds, origin) {
|
||||
|
||||
$('.st_helper').css("border", "8px solid grey");
|
||||
|
||||
var canvas_height = $('#leds_preview').innerHeight();
|
||||
var canvas_width = $('#leds_preview').innerWidth();
|
||||
canvas_height = $('#leds_preview').innerHeight();
|
||||
canvas_width = $('#leds_preview').innerWidth();
|
||||
|
||||
imageCanvasNodeCtx = document.getElementById("image_preview").getContext("2d");
|
||||
$('#image_preview').css({"width":canvas_width, "height":canvas_height});
|
||||
|
||||
var leds_html = "";
|
||||
for (var idx = 0; idx < leds.length; idx++) {
|
||||
@@ -415,6 +421,9 @@ $(document).ready(function () {
|
||||
// translate
|
||||
performTranslation();
|
||||
|
||||
// update instance listing
|
||||
updateHyperionInstanceListing();
|
||||
|
||||
//add intros
|
||||
if (window.showOptHelp) {
|
||||
createHintH("intro", $.i18n('conf_leds_device_intro'), "leddevice_intro");
|
||||
@@ -552,6 +561,31 @@ $(document).ready(function () {
|
||||
toggleClass('#leds_prev_toggle_num', "btn-danger", "btn-success");
|
||||
});
|
||||
|
||||
// toggle live video
|
||||
$('#leds_prev_toggle_live_video').off().on("click", function() {
|
||||
setClassByBool('#leds_prev_toggle_live_video', window.imageStreamActive, "btn-success", "btn-danger");
|
||||
if (window.imageStreamActive)
|
||||
{
|
||||
requestLedImageStop();
|
||||
imageCanvasNodeCtx.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
requestLedImageStart();
|
||||
}
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-ledcolors-imagestream-update",function(event){
|
||||
setClassByBool('#leds_prev_toggle_live_video', window.imageStreamActive, "btn-danger", "btn-success");
|
||||
var imageData = (event.response.result.image);
|
||||
|
||||
var image = new Image();
|
||||
image.onload = function() {
|
||||
imageCanvasNodeCtx.drawImage(image, 0, 0, imageCanvasNodeCtx.canvas.width, imageCanvasNodeCtx.canvas.height);
|
||||
};
|
||||
image.src = imageData;
|
||||
});
|
||||
|
||||
// open checklist
|
||||
$('#leds_prev_checklist').off().on("click", function () {
|
||||
var liList = [$.i18n('conf_leds_layout_checkp1'), $.i18n('conf_leds_layout_checkp3'), $.i18n('conf_leds_layout_checkp2'), $.i18n('conf_leds_layout_checkp4')];
|
||||
@@ -725,11 +759,11 @@ $(document).ready(function () {
|
||||
}
|
||||
|
||||
if (ledType !== window.serverConfig.device.type) {
|
||||
var hwLedCount = conf_editor.getEditor("root.generalOptions.hardwareLedCount")
|
||||
var hwLedCount = conf_editor.getEditor("root.generalOptions.hardwareLedCount");
|
||||
if (hwLedCount) {
|
||||
hwLedCount.setValue(hwLedCountDefault);
|
||||
}
|
||||
var colorOrder = conf_editor.getEditor("root.generalOptions.colorOrder")
|
||||
var colorOrder = conf_editor.getEditor("root.generalOptions.colorOrder");
|
||||
if (colorOrder) {
|
||||
colorOrder.setValue(colorOrderDefault);
|
||||
}
|
||||
@@ -830,7 +864,7 @@ $(document).ready(function () {
|
||||
//Disable General Options, as LED count will be resolved from device itself
|
||||
conf_editor.getEditor("root.generalOptions").disable();
|
||||
|
||||
var hostList = conf_editor.getEditor("root.specificOptions.hostList")
|
||||
var hostList = conf_editor.getEditor("root.specificOptions.hostList");
|
||||
if (hostList) {
|
||||
var val = hostList.getValue();
|
||||
var showOptions = true;
|
||||
@@ -875,7 +909,7 @@ $(document).ready(function () {
|
||||
case "nanoleaf":
|
||||
var token = conf_editor.getEditor("root.specificOptions.token").getValue();
|
||||
if (token === "") {
|
||||
return
|
||||
return;
|
||||
}
|
||||
params = { host: host, token: token };
|
||||
break;
|
||||
@@ -1400,7 +1434,7 @@ var updateSelectList = function (ledType, discoveryInfo) {
|
||||
if (enumVals.length > 0) {
|
||||
updateJsonEditorSelection(specOpt, key, addSchemaElements, enumVals, enumTitelVals, enumDefaultVal, addSelect, addCustom);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function discover_device(ledType, params) {
|
||||
const result = await requestLedDeviceDiscovery(ledType, params);
|
||||
@@ -1519,27 +1553,6 @@ function updateElements(ledType, key) {
|
||||
}
|
||||
}
|
||||
|
||||
function showInputOptions(path, elements, state) {
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
$('[data-schemapath="' + path + '.' + elements[i] + '"]').toggle(state);
|
||||
}
|
||||
}
|
||||
|
||||
function showInputOptionsForKey(editor, item, showForKey, state) {
|
||||
var elements = [];
|
||||
for (var key in editor.schema.properties[item].properties) {
|
||||
if (showForKey !== key) {
|
||||
var accessLevel = editor.schema.properties[item].properties[key].access;
|
||||
|
||||
//Only enable elements, if access level compliant
|
||||
if (state && isAccessLevelCompliant(accessLevel)) {
|
||||
elements.push(key);
|
||||
}
|
||||
}
|
||||
showInputOptions("root." + item, elements, state);
|
||||
}
|
||||
}
|
||||
|
||||
function showAllDeviceInputOptions(showForKey, state) {
|
||||
showInputOptionsForKey(conf_editor, "generalOptions", showForKey, state);
|
||||
showInputOptionsForKey(conf_editor, "specificOptions", showForKey, state);
|
||||
|
Reference in New Issue
Block a user