webui: add read/write for all editors (#268)

This commit is contained in:
redPanther 2016-10-10 23:15:50 +02:00 committed by GitHub
parent 37558a983f
commit 102fd611fa
13 changed files with 84 additions and 147 deletions

View File

@ -4,13 +4,12 @@
<div class="col-lg-12"> <div class="col-lg-12">
<h1 class="page-header" lang="en" data-lang-token="main_menu_grabber_conf_token">Image Processing</h1> <h1 class="page-header" lang="en" data-lang-token="main_menu_grabber_conf_token">Image Processing</h1>
<div class="introd"> <div class="introd">
<h4 lang="en" data-lang-token="remote_general_conf_intro">You can edit the general configuration here.</h4> <h4 lang="en" data-lang-token="remote_general_conf_intro">You can edit the image and color configuration here.</h4>
</div> </div>
<hr /> <hr />
<div class="col-lg-12"> <div class="col-lg-12">
<!-- <form id="grabberConfForm"></form>-->
<div id='editor_container'/> <div id='editor_container'/>
<button id='btn_submit'>Submit (console.log)</button> <button class="btn btn-success" id='btn_submit'>Save Settings</button>
</div> </div>
</div> </div>

View File

@ -3,12 +3,12 @@
<div class="col-lg-12"> <div class="col-lg-12">
<h1 class="page-header" lang="en" data-lang-token="main_menu_general_conf_token">Effects</h1> <h1 class="page-header" lang="en" data-lang-token="main_menu_general_conf_token">Effects</h1>
<div class="introd"> <div class="introd">
<h4 lang="en" data-lang-token="remote_general_conf_intro">You can edit the general configuration here.</h4> <h4 lang="en" data-lang-token="remote_general_conf_intro">You can edit the effect settings here.</h4>
</div> </div>
<hr> <hr>
<div class="col-lg-12"> <div class="col-lg-12">
<div id='editor_container'></div> <div id='editor_container'></div>
<button id='btn_submit' class="btn btn-danger">Submit - currently will destroy your config!</button> <button class="btn btn-success" id='btn_submit'>Save Settings</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -4,13 +4,12 @@
<div class="col-lg-12"> <div class="col-lg-12">
<h1 class="page-header" lang="en" data-lang-token="main_menu_grabber_conf_token">Capturing Hardware</h1> <h1 class="page-header" lang="en" data-lang-token="main_menu_grabber_conf_token">Capturing Hardware</h1>
<div class="introd"> <div class="introd">
<h4 lang="en" data-lang-token="remote_general_conf_intro">You can edit the general configuration here.</h4> <h4 lang="en" data-lang-token="remote_general_conf_intro">You can edit your capturing hardware configuration here.</h4>
</div> </div>
<hr /> <hr />
<div class="col-lg-12"> <div class="col-lg-12">
<!-- <form id="grabberConfForm"></form>-->
<div id='editor_container'/> <div id='editor_container'/>
<button id='btn_submit'>Submit (console.log)</button> <button class="btn btn-success" id='btn_submit'>Save Settings</button>
</div> </div>
</div> </div>

View File

@ -13,7 +13,7 @@
<div class="col-lg-12"> <div class="col-lg-12">
<div id='editor_container'/> <div id='editor_container'/>
<button id='btn_submit'>Submit (console.log)</button> <button class="btn btn-success" id='btn_submit'>Save Settings</button>
</div> </div>
</div> </div>

View File

@ -4,13 +4,13 @@
<div class="col-lg-12"> <div class="col-lg-12">
<h1 class="page-header" lang="en" data-lang-token="main_menu_grabber_conf_token">Network Services</h1> <h1 class="page-header" lang="en" data-lang-token="main_menu_grabber_conf_token">Network Services</h1>
<div class="introd"> <div class="introd">
<h4 lang="en" data-lang-token="remote_general_conf_intro">You can edit the general configuration here.</h4> <h4 lang="en" data-lang-token="remote_general_conf_intro">You can edit the network configuration here.</h4>
</div> </div>
<hr /> <hr />
<div class="col-lg-12"> <div class="col-lg-12">
<!-- <form id="grabberConfForm"></form>--> <!-- <form id="grabberConfForm"></form>-->
<div id='editor_container'/> <div id='editor_container'/>
<button id='btn_submit'>Submit (console.log)</button> <button class="btn btn-success" id='btn_submit'>Save Settings</button>
</div> </div>
</div> </div>

View File

@ -1,34 +1,20 @@
var conf_editor = null; var conf_editor = null;
$(hyperion).one("cmd-config-getschema", function(event) { $(hyperion).one("cmd-config-getschema", function(event) {
parsedConfSchemaJSON = event.response.result;
schema = parsedConfSchemaJSON.properties; schema = parsedConfSchemaJSON.properties;
conf_editor = createJsonEditor('editor_container', {
conf_editor = createJsonEditor('editor_container',
{
title:'',
properties: {
color : schema.color, color : schema.color,
smoothing : schema.smoothing, smoothing : schema.smoothing,
blackborderdetector: schema.blackborderdetector, blackborderdetector: schema.blackborderdetector,
} }, true);
$('#btn_submit').off().on('click',function() {
requestWriteConfig(conf_editor.getValue());
}); });
$('#editor_container .well').css("background-color","white");
$('#editor_container .well').css("border","none");
$('#editor_container .well').css("box-shadow","none");
$('#editor_container .btn').addClass("btn-primary");
$('#editor_container h3').first().remove();
}); });
$(document).ready( function() { $(document).ready( function() {
requestServerConfigSchema(); requestServerConfigSchema();
document.getElementById('btn_submit').addEventListener('click',function() {
// Get the value from the editor
console.log(conf_editor.getValue());
});
}); });

View File

@ -1,39 +1,14 @@
var conf_editor = null;
$(hyperion).one("cmd-config-getschema", function(event) { $(hyperion).one("cmd-config-getschema", function(event) {
parsedConfSchemaJSON = event.response.result;
schema = parsedConfSchemaJSON.properties; schema = parsedConfSchemaJSON.properties;
var general_conf_editor = createJsonEditor('editor_container', conf_editor = createJsonEditor('editor_container', {
{
title:'',
properties: {
effects : schema.effects, effects : schema.effects,
initialEffect : schema.initialEffect initialEffect : schema.initialEffect
} }, true);
});
$('#editor_container .well').css("background-color","white");
// $('#editor_container .well').css("border","none");
// $('#editor_container .well').css("box-shadow","none");
$('#editor_container .btn').addClass("btn-primary");
$('#editor_container h3').first().remove();
//Called everytime a Input Field is changed = No need for save button
// general_conf_editor.off().on('change',function() {
// console.log(JSON.stringify(general_conf_editor.getValue()));
// requestWriteConfig(general_conf_editor.getValue());
// });
//Alternative Function with submit button to get Values
$('#btn_submit').off().on('click',function() { $('#btn_submit').off().on('click',function() {
console.log(general_conf_editor.getValue()); requestWriteConfig(conf_editor.getValue());
}); });
$(hyperion).on("cmd-config-setconfig",function(event){
parsedServerInfoJSON = event.response;
console.log(parsedServerInfoJSON);
});
}); });
$(document).ready( function() { $(document).ready( function() {

View File

@ -2,33 +2,20 @@
var conf_editor = null; var conf_editor = null;
$(hyperion).one("cmd-config-getschema", function(event) { $(hyperion).one("cmd-config-getschema", function(event) {
parsedConfSchemaJSON = event.response.result;
schema = parsedConfSchemaJSON.properties; schema = parsedConfSchemaJSON.properties;
conf_editor = createJsonEditor('editor_container', {
conf_editor = createJsonEditor('editor_container',
{
title:'',
properties: {
framegrabber: schema.framegrabber, framegrabber: schema.framegrabber,
grabberV4L2 : schema.grabberV4L2 grabberV4L2 : schema.grabberV4L2
} }, true);
$('#btn_submit').off().on('click',function() {
requestWriteConfig(conf_editor.getValue());
}); });
$('#editor_container .well').css("background-color","white");
$('#editor_container .well').css("border","none");
$('#editor_container .well').css("box-shadow","none");
$('#editor_container .btn').addClass("btn-primary");
$('#editor_container h3').first().remove();
}); });
$(document).ready( function() { $(document).ready( function() {
requestServerConfigSchema(); requestServerConfigSchema();
document.getElementById('btn_submit').addEventListener('click',function() {
// Get the value from the editor
console.log(conf_editor.getValue());
});
}); });

View File

@ -68,8 +68,13 @@ $(document).ready( function() {
$(hyperion).one("cmd-config-getschema", function(event) { $(hyperion).one("cmd-config-getschema", function(event) {
parsedConfSchemaJSON = event.response.result; parsedConfSchemaJSON = event.response.result;
requestServerConfig();
}); });
$(hyperion).one("cmd-config-getconfig", function(event) {
parsedConfJSON = event.response.result;
requestServerInfo();
});
$(hyperion).on("error",function(event){ $(hyperion).on("error",function(event){
showErrorDialog("error", event.reason); showErrorDialog("error", event.reason);
@ -77,7 +82,6 @@ $(document).ready( function() {
$(hyperion).on("open",function(event){ $(hyperion).on("open",function(event){
requestServerConfigSchema(); requestServerConfigSchema();
requestServerInfo();
}); });
$("#btn_hyperion_reload").on("click", function(){ $("#btn_hyperion_reload").on("click", function(){

View File

@ -1,32 +1,20 @@
var conf_editor = null; var conf_editor = null;
$(hyperion).one("cmd-config-getschema", function(event) { $(hyperion).one("cmd-config-getschema", function(event) {
parsedConfSchemaJSON = event.response.result;
schema = parsedConfSchemaJSON.properties; schema = parsedConfSchemaJSON.properties;
conf_editor = createJsonEditor('editor_container', {
kodiVideoChecker: schema.kodiVideoChecker
}, true);
conf_editor = createJsonEditor('editor_container',
{
title:'',
properties: {
kodiVideoChecker: schema.kodiVideoChecker,
}
});
$('#editor_container .well').css("background-color","white");
$('#editor_container .well').css("border","none");
$('#editor_container .well').css("box-shadow","none");
$('#editor_container .btn').addClass("btn-primary");
$('#editor_container h3').remove(); $('#editor_container h3').remove();
$('#btn_submit').off().on('click',function() {
requestWriteConfig(conf_editor.getValue());
});
}); });
$(document).ready( function() { $(document).ready( function() {
requestServerConfigSchema(); requestServerConfigSchema();
document.getElementById('btn_submit').addEventListener('click',function() {
// Get the value from the editor
console.log(conf_editor.getValue());
});
}); });

View File

@ -133,18 +133,14 @@ $(document).ready(function() {
}); });
// ------------------------------------------------------------------ // ------------------------------------------------------------------
var grabber_conf_editor = null; var conf_editor = null;
$("#leddevices").off().on("change", function(event) { $("#leddevices").off().on("change", function(event) {
generalOptions = parsedConfSchemaJSON.properties.device; generalOptions = parsedConfSchemaJSON.properties.device;
specificOptions = parsedConfSchemaJSON.properties.alldevices[$(this).val()]; specificOptions = parsedConfSchemaJSON.properties.alldevices[$(this).val()];
//$('#ledDeviceOptions').html(JSON.stringify(generalOptions)+"<br>"+JSON.stringify(specificOptions)); //$('#ledDeviceOptions').html(JSON.stringify(generalOptions)+"<br>"+JSON.stringify(specificOptions));
grabber_conf_editor = createJsonEditor('editor_container', conf_editor = createJsonEditor('editor_container', {
{
title:' ',
properties: {
generalOptions : generalOptions, generalOptions : generalOptions,
specificOptions : specificOptions, specificOptions : specificOptions,
}
}); });
values_general = {}; values_general = {};
@ -155,23 +151,21 @@ $(document).ready(function() {
if (key != "type" && key in generalOptions.properties) if (key != "type" && key in generalOptions.properties)
values_general[key] = parsedConfJSON.device[key]; values_general[key] = parsedConfJSON.device[key];
}; };
grabber_conf_editor.getEditor("root.generalOptions").setValue( values_general ); conf_editor.getEditor("root.generalOptions").setValue( values_general );
if (isCurrentDevice) if (isCurrentDevice)
{ {
specificOptions_val = grabber_conf_editor.getEditor("root.specificOptions").getValue() specificOptions_val = conf_editor.getEditor("root.specificOptions").getValue()
for(var key in specificOptions_val){ for(var key in specificOptions_val){
values_specific[key] = (key in parsedConfJSON.device) ? parsedConfJSON.device[key] : specificOptions_val[key]; values_specific[key] = (key in parsedConfJSON.device) ? parsedConfJSON.device[key] : specificOptions_val[key];
}; };
grabber_conf_editor.getEditor("root.specificOptions").setValue( values_specific ); conf_editor.getEditor("root.specificOptions").setValue( values_specific );
}; };
$('#editor_container .well').css("background-color","white"); $('#editor_container .well').css("background-color","white");
$('#editor_container .well').css("border","none"); $('#editor_container .well').css("border","none");
$('#editor_container .well').css("box-shadow","none"); $('#editor_container .well').css("box-shadow","none");
$('#editor_container .btn').addClass("btn-primary");
$('#editor_container h3').first().remove();
if ($(this).val() == "philipshue") if ($(this).val() == "philipshue")
{ {
@ -193,14 +187,14 @@ $(document).ready(function() {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
$("#btn_submit_controller").off().on("click", function(event) { $("#btn_submit_controller").off().on("click", function(event) {
if (grabber_conf_editor==null) if (conf_editor==null)
return; return;
ledDevice = $("#leddevices").val(); ledDevice = $("#leddevices").val();
result = {device:{}}; result = {device:{}};
general = grabber_conf_editor.getEditor("root.generalOptions").getValue(); general = conf_editor.getEditor("root.generalOptions").getValue();
specific = grabber_conf_editor.getEditor("root.specificOptions").getValue(); specific = conf_editor.getEditor("root.specificOptions").getValue();
for(var key in general){ for(var key in general){
result.device[key] = general[key]; result.device[key] = general[key];
} }

View File

@ -1,36 +1,22 @@
var conf_editor = null; var conf_editor = null;
$(hyperion).one("cmd-config-getschema", function(event) { $(hyperion).one("cmd-config-getschema", function(event) {
parsedConfSchemaJSON = event.response.result;
schema = parsedConfSchemaJSON.properties; schema = parsedConfSchemaJSON.properties;
conf_editor = createJsonEditor('editor_container', {
conf_editor = createJsonEditor('editor_container',
{
title:'',
properties: {
jsonServer : schema.jsonServer, jsonServer : schema.jsonServer,
protoServer : schema.protoServer, protoServer : schema.protoServer,
boblightServer : schema.boblightServer, boblightServer : schema.boblightServer,
udpListener : schema.udpListener, udpListener : schema.udpListener,
forwarder : schema.forwarder, forwarder : schema.forwarder,
} }, true);
$('#btn_submit').off().on('click',function() {
requestWriteConfig(conf_editor.getValue());
}); });
$('#editor_container .well').css("background-color","white");
$('#editor_container .well').css("border","none");
$('#editor_container .well').css("box-shadow","none");
$('#editor_container .btn').addClass("btn-primary");
$('#editor_container h3').first().remove();
}); });
$(document).ready( function() { $(document).ready( function() {
requestServerConfigSchema(); requestServerConfigSchema();
document.getElementById('btn_submit').addEventListener('click',function() {
// Get the value from the editor
console.log(conf_editor.getValue());
});
}); });

View File

@ -68,12 +68,12 @@ function isJsonString(str)
} }
function createJsonEditor(container,schema) function createJsonEditor(container,schema,setconfig)
{ {
$('#'+container).off(); $('#'+container).off();
$('#'+container).html(""); $('#'+container).html("");
return new JSONEditor(document.getElementById(container), var editor = new JSONEditor(document.getElementById(container),
{ {
theme: 'bootstrap3', theme: 'bootstrap3',
iconlib: "fontawesome4", iconlib: "fontawesome4",
@ -82,6 +82,25 @@ function createJsonEditor(container,schema)
disable_edit_json: 'true', disable_edit_json: 'true',
disable_properties: 'true', disable_properties: 'true',
no_additional_properties: 'true', no_additional_properties: 'true',
schema: schema schema: {
title:'',
properties: schema
}
}); });
$('#editor_container .well').css("background-color","white");
$('#editor_container .well').css("border","none");
$('#editor_container .well').css("box-shadow","none");
$('#editor_container .btn').addClass("btn-primary");
$('#editor_container h3').first().remove();
if (setconfig)
{
for(var key in editor.root.editors)
{
editor.getEditor("root."+key).setValue( parsedConfJSON[key] );
}
}
return editor;
} }