From 184cfb1e72afcb205a503622bd0cdd27bdc7c502 Mon Sep 17 00:00:00 2001 From: Lord-Grey Date: Wed, 5 May 2021 10:44:53 +0200 Subject: [PATCH] Allow editor-validation for enum-lists --- assets/webconfig/js/content_leds.js | 70 ++++++++++--------- assets/webconfig/js/lib/jsoneditor.js | 2 +- .../hyperion/schema/schema-framegrabber.json | 2 +- .../hyperion/schema/schema-grabberV4L2.json | 2 +- .../leddevice/schemas/schema-cololight.json | 3 +- libsrc/leddevice/schemas/schema-nanoleaf.json | 3 +- libsrc/leddevice/schemas/schema-wled.json | 3 +- 7 files changed, 42 insertions(+), 43 deletions(-) diff --git a/assets/webconfig/js/content_leds.js b/assets/webconfig/js/content_leds.js index a8718284..391ec320 100755 --- a/assets/webconfig/js/content_leds.js +++ b/assets/webconfig/js/content_leds.js @@ -421,8 +421,8 @@ $(document).ready(function () { // translate performTranslation(); - // update instance listing - updateHyperionInstanceListing(); + // update instance listing + updateHyperionInstanceListing(); //add intros if (window.showOptHelp) { @@ -561,21 +561,21 @@ $(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(); + // 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(); - } - }); + } + else + { + requestLedImageStart(); + } + }); - $(window.hyperion).on("cmd-ledcolors-imagestream-update",function(event){ + $(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); @@ -584,7 +584,7 @@ $(document).ready(function () { imageCanvasNodeCtx.drawImage(image, 0, 0, imageCanvasNodeCtx.canvas.width, imageCanvasNodeCtx.canvas.height); }; image.src = imageData; - }); + }); // open checklist $('#leds_prev_checklist').off().on("click", function () { @@ -831,28 +831,30 @@ $(document).ready(function () { canSave = true; } - if (canIdentify) { - $("#btn_test_controller").removeClass('hidden'); - $('#btn_test_controller').attr('disabled', false); - } - else { - $('#btn_test_controller').attr('disabled', true); - } + if (!conf_editor.validate().length) { - var hardwareLedCount = conf_editor.getEditor("root.generalOptions.hardwareLedCount").getValue(); - if (hardwareLedCount < 1) { - canSave = false; - } + if (canIdentify) { + $("#btn_test_controller").removeClass('hidden'); + $('#btn_test_controller').attr('disabled', false); + } + else { + $('#btn_test_controller').attr('disabled', true); + } - if (canSave) { - if (!window.readOnlyMode) { - $('#btn_submit_controller').attr('disabled', false); + var hardwareLedCount = conf_editor.getEditor("root.generalOptions.hardwareLedCount").getValue(); + if (hardwareLedCount < 1) { + canSave = false; + } + + if (canSave) { + if (!window.readOnlyMode) { + $('#btn_submit_controller').attr('disabled', false); + } + } + else { + $('#btn_submit_controller').attr('disabled', true); } } - else { - $('#btn_submit_controller').attr('disabled', true); - } - window.readOnlyMode ? $('#btn_cl_save').attr('disabled', true) : $('#btn_submit').attr('disabled', false); window.readOnlyMode ? $('#btn_ma_save').attr('disabled', true) : $('#btn_submit').attr('disabled', false); window.readOnlyMode ? $('#leds_custom_save').attr('disabled', true) : $('#btn_submit').attr('disabled', false); diff --git a/assets/webconfig/js/lib/jsoneditor.js b/assets/webconfig/js/lib/jsoneditor.js index 8b1c93dd..fd21cbea 100755 --- a/assets/webconfig/js/lib/jsoneditor.js +++ b/assets/webconfig/js/lib/jsoneditor.js @@ -1839,7 +1839,7 @@ JSONEditor.AbstractEditor = Class.extend({ this.parent = null; }, getDefault: function() { - if(this.schema["default"]) return this.schema["default"]; + if(this.schema["default"]) return $.i18n(this.schema["default"]); if(this.schema["enum"]) return this.schema["enum"][0]; var type = this.schema.type || this.schema.oneOf; diff --git a/libsrc/hyperion/schema/schema-framegrabber.json b/libsrc/hyperion/schema/schema-framegrabber.json index 6661bd41..a829c98d 100644 --- a/libsrc/hyperion/schema/schema-framegrabber.json +++ b/libsrc/hyperion/schema/schema-framegrabber.json @@ -5,7 +5,7 @@ "available_devices": { "type": "string", "title": "edt_conf_grabber_discovered_title", - "default": "NONE", + "default": "edt_conf_grabber_discovery_inprogress", "options": { "infoText": "edt_conf_grabber_discovered_title_info" }, diff --git a/libsrc/hyperion/schema/schema-grabberV4L2.json b/libsrc/hyperion/schema/schema-grabberV4L2.json index 3a88d27e..3be66dc0 100644 --- a/libsrc/hyperion/schema/schema-grabberV4L2.json +++ b/libsrc/hyperion/schema/schema-grabberV4L2.json @@ -6,7 +6,7 @@ "available_devices": { "type": "string", "title": "edt_conf_grabber_discovered_title", - "default": "NONE", + "default": "edt_conf_grabber_discovery_inprogress", "options": { "infoText": "edt_conf_grabber_discovered_title_info" }, diff --git a/libsrc/leddevice/schemas/schema-cololight.json b/libsrc/leddevice/schemas/schema-cololight.json index 11942ed2..58db7c61 100644 --- a/libsrc/leddevice/schemas/schema-cololight.json +++ b/libsrc/leddevice/schemas/schema-cololight.json @@ -5,9 +5,8 @@ "hostList": { "type": "string", "title": "edt_dev_spec_devices_discovered_title", - "enum": [ "NONE" ], + "default": "edt_dev_spec_devices_discovery_inprogress", "options": { - "enum_titles": [ "edt_dev_spec_devices_discovery_inprogress" ], "infoText": "edt_dev_spec_devices_discovered_title_info" }, "required": true, diff --git a/libsrc/leddevice/schemas/schema-nanoleaf.json b/libsrc/leddevice/schemas/schema-nanoleaf.json index ec3a81d3..08a33e94 100644 --- a/libsrc/leddevice/schemas/schema-nanoleaf.json +++ b/libsrc/leddevice/schemas/schema-nanoleaf.json @@ -5,9 +5,8 @@ "hostList": { "type": "string", "title": "edt_dev_spec_devices_discovered_title", - "enum": [ "NONE" ], + "default": "edt_dev_spec_devices_discovery_inprogress", "options": { - "enum_titles": [ "edt_dev_spec_devices_discovery_inprogress" ], "infoText": "edt_dev_spec_devices_discovered_title_info" }, "required": true, diff --git a/libsrc/leddevice/schemas/schema-wled.json b/libsrc/leddevice/schemas/schema-wled.json index 881220c8..75cec45b 100644 --- a/libsrc/leddevice/schemas/schema-wled.json +++ b/libsrc/leddevice/schemas/schema-wled.json @@ -6,9 +6,8 @@ "hostList": { "type": "string", "title": "edt_dev_spec_devices_discovered_title", - "enum": [ "NONE" ], + "default": "edt_dev_spec_devices_discovery_inprogress", "options": { - "enum_titles": [ "edt_dev_spec_devices_discovery_inprogress" ], "infoText": "edt_dev_spec_devices_discovered_title_info" }, "required": true,