mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
commit
ee26abc6c4
@ -8,6 +8,9 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<form id="generalConfForm"></form>
|
<form id="generalConfForm"></form>
|
||||||
|
<div id='editor_holder'></div>
|
||||||
|
|
||||||
|
<button id='submit'>Submit (console.log)</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -38,31 +41,34 @@
|
|||||||
udpListener = JSON.parse(response.data).result.properties.udpListener;
|
udpListener = JSON.parse(response.data).result.properties.udpListener;
|
||||||
webConfig = JSON.parse(response.data).result.properties.webConfig;
|
webConfig = JSON.parse(response.data).result.properties.webConfig;
|
||||||
|
|
||||||
|
var element = document.getElementById('editor_holder');
|
||||||
$('form').jsonForm({
|
//JSONEditor.defaults.options.theme = 'bootstrap3';
|
||||||
|
var editor = new JSONEditor(element,{
|
||||||
|
theme: 'bootstrap3',
|
||||||
|
disable_collapse: 'true',
|
||||||
|
form_name_root: 'sa',
|
||||||
|
disable_edit_json: 'true',
|
||||||
|
disable_properties: 'true',
|
||||||
|
no_additional_properties: 'true',
|
||||||
schema: {
|
schema: {
|
||||||
logger,
|
title:' ',
|
||||||
jsonServer,
|
properties: {
|
||||||
protoServer,
|
logger,
|
||||||
boblightServer,
|
jsonServer,
|
||||||
udpListener,
|
protoServer,
|
||||||
webConfig,
|
boblightServer,
|
||||||
|
udpListener,
|
||||||
},
|
webConfig
|
||||||
onSubmit: function (errors, values) {
|
|
||||||
if (errors) {
|
|
||||||
console.log(errors);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log(values);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById('submit').addEventListener('click',function() {
|
||||||
|
// Get the value from the editor
|
||||||
|
console.log(editor.getValue());
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
enableFormTranslation("generalConfForm", "generalConfForm");
|
|
||||||
|
|
||||||
$("[type='checkbox']").bootstrapSwitch();
|
$("[type='checkbox']").bootstrapSwitch();
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
@ -25,8 +25,9 @@
|
|||||||
<link href="css/bootstrap-switch.min.css" rel="stylesheet">
|
<link href="css/bootstrap-switch.min.css" rel="stylesheet">
|
||||||
|
|
||||||
<!-- JSONForm -->
|
<!-- JSONForm -->
|
||||||
<script src="js/lib/underscore.js"></script>
|
<!--<script src="js/lib/underscore.js"></script>
|
||||||
<script src="js/lib/jsonform.js"></script>
|
<script src="js/lib/jsonform.js"></script>-->
|
||||||
|
<script src="js/lib/jsoneditor.min.js"></script>
|
||||||
|
|
||||||
<!--Language Support -->
|
<!--Language Support -->
|
||||||
<script src="js/lib/jquery-lang.js" charset="utf-8" type="text/javascript"></script>
|
<script src="js/lib/jquery-lang.js" charset="utf-8" type="text/javascript"></script>
|
||||||
@ -35,19 +36,14 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// Create language switcher instance
|
// Create language switcher instance
|
||||||
var lang = new Lang();
|
var lang = new Lang();
|
||||||
|
|
||||||
lang.dynamic('de', 'lang/de.json');
|
lang.dynamic('de', 'lang/de.json');
|
||||||
|
|
||||||
lang.init({
|
lang.init({
|
||||||
defaultLang: 'en',
|
defaultLang: 'en',
|
||||||
|
|
||||||
cookie: {
|
cookie: {
|
||||||
name: 'langCookie',
|
name: 'langCookie',
|
||||||
expiry: 365,
|
expiry: 365,
|
||||||
path: '/'
|
path: '/'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
allowCookieOverride: true
|
allowCookieOverride: true
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@ -490,49 +486,39 @@
|
|||||||
<!-- Custom Theme JavaScript -->
|
<!-- Custom Theme JavaScript -->
|
||||||
<script src="js/lib/sb-admin-2.js"></script>
|
<script src="js/lib/sb-admin-2.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
$(document).ready( function() {
|
$(document).ready( function() {
|
||||||
$("#load_lighttest").on("click", function() {
|
$("#load_lighttest").on("click", function() {
|
||||||
$("#page-wrapper").load("lighttest.html");
|
$("#page-wrapper").load("lighttest.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#load_effects").on("click", function() {
|
$("#load_effects").on("click", function() {
|
||||||
$("#page-wrapper").load("effects.html");
|
$("#page-wrapper").load("effects.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#load_components").on("click", function() {
|
$("#load_components").on("click", function() {
|
||||||
$("#page-wrapper").load("remote_components.html");
|
$("#page-wrapper").load("remote_components.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#load_huebridge").on("click", function() {
|
$("#load_huebridge").on("click", function() {
|
||||||
$("#page-wrapper").load("huebridge.html");
|
$("#page-wrapper").load("huebridge.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#load_support").on("click", function() {
|
$("#load_support").on("click", function() {
|
||||||
$("#page-wrapper").load("support.html");
|
$("#page-wrapper").load("support.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#load_confKodi").on("click", function() {
|
$("#load_confKodi").on("click", function() {
|
||||||
$("#page-wrapper").load("kodiconf.html");
|
$("#page-wrapper").load("kodiconf.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#load_update").on("click", function() {
|
$("#load_update").on("click", function() {
|
||||||
$("#page-wrapper").load("update.html");
|
$("#page-wrapper").load("update.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#load_confGeneral").on("click", function() {
|
$("#load_confGeneral").on("click", function() {
|
||||||
$("#page-wrapper").load("generalconf.html");
|
$("#page-wrapper").load("generalconf.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
//Change all Checkboxes to Switches
|
//Change all Checkboxes to Switches
|
||||||
$("[type='checkbox']").bootstrapSwitch();
|
$("[type='checkbox']").bootstrapSwitch();
|
||||||
|
loaddata();
|
||||||
|
|
||||||
loaddata();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
$(function(){
|
$(function(){
|
||||||
var sidebar = $('#side-menu'); // cache sidebar to a variable for performance
|
var sidebar = $('#side-menu'); // cache sidebar to a variable for performance
|
||||||
|
|
||||||
sidebar.delegate('a.inactive','click',function(){
|
sidebar.delegate('a.inactive','click',function(){
|
||||||
sidebar.find('.active').toggleClass('active inactive');
|
sidebar.find('.active').toggleClass('active inactive');
|
||||||
$(this).toggleClass('active inactive');
|
$(this).toggleClass('active inactive');
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
* Default language in "lang" attribute will always be "en"
|
* Default language in "lang" attribute will always be "en"
|
||||||
* @param {String} tokenPrefix
|
* @param {String} tokenPrefix
|
||||||
* @param {String} formID
|
* @param {String} formID
|
||||||
*/
|
|
||||||
function enableFormTranslation(tokenPrefix, formID) {
|
function enableFormTranslation(tokenPrefix, formID) {
|
||||||
var $inputs = $("#" + formID + " :input");
|
var $inputs = $("#" + formID + " label");
|
||||||
|
|
||||||
$inputs.each(function() {
|
$inputs.each(function() {
|
||||||
console.log("InputID: " + $(this).attr('id'));
|
console.log("InputID: " + $(this).attr('id'));
|
||||||
@ -20,7 +20,7 @@ $inputs.each(function() {
|
|||||||
$("label[for='" + $(this).attr('id') + "']").html('<span lang="en" data-lang-token="' + tokenPrefix + "_" + $(this).attr('id') + '">' + oldtext + '</span>');
|
$("label[for='" + $(this).attr('id') + "']").html('<span lang="en" data-lang-token="' + tokenPrefix + "_" + $(this).attr('id') + '">' + oldtext + '</span>');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// global vars
|
// global vars
|
||||||
var currentVersion;
|
var currentVersion;
|
||||||
var cleanCurrentVersion;
|
var cleanCurrentVersion;
|
||||||
@ -34,13 +34,13 @@ function button_reloaddata(){
|
|||||||
hyperionport = $("#json_port").val();
|
hyperionport = $("#json_port").val();
|
||||||
loaddata();
|
loaddata();
|
||||||
};
|
};
|
||||||
|
|
||||||
function loaddata() {
|
function loaddata() {
|
||||||
|
|
||||||
webSocket = new WebSocket('ws://'+document.location.hostname+':'+hyperionport);
|
webSocket = new WebSocket('ws://'+document.location.hostname+':'+hyperionport);
|
||||||
|
|
||||||
webSocket.onerror = function(event) {
|
webSocket.onerror = function(event) {
|
||||||
$('#con_error_modal').modal('show');
|
$('#con_error_modal').modal('show');
|
||||||
};
|
};
|
||||||
|
|
||||||
webSocket.onopen = function(event) {
|
webSocket.onopen = function(event) {
|
||||||
@ -57,12 +57,12 @@ function loaddata() {
|
|||||||
// get host
|
// get host
|
||||||
var hostname = parsedServerInfoJSON.info.hostname;
|
var hostname = parsedServerInfoJSON.info.hostname;
|
||||||
$('#dash_systeminfo').html(hostname+':'+hyperionport);
|
$('#dash_systeminfo').html(hostname+':'+hyperionport);
|
||||||
|
|
||||||
$.get( "https://raw.githubusercontent.com/hyperion-project/hyperion.ng/master/version.json", function( data ) {
|
$.get( "https://raw.githubusercontent.com/hyperion-project/hyperion.ng/master/version.json", function( data ) {
|
||||||
parsedUpdateJSON = JSON.parse(data);
|
parsedUpdateJSON = JSON.parse(data);
|
||||||
latestVersion = parsedUpdateJSON[0].versionnr;
|
latestVersion = parsedUpdateJSON[0].versionnr;
|
||||||
cleanLatestVersion = latestVersion.replace(/\./g, '');
|
cleanLatestVersion = latestVersion.replace(/\./g, '');
|
||||||
|
|
||||||
$('#currentversion').html(' V'+currentVersion);
|
$('#currentversion').html(' V'+currentVersion);
|
||||||
$('#latestversion').html(' V'+latestVersion);
|
$('#latestversion').html(' V'+latestVersion);
|
||||||
|
|
||||||
@ -73,6 +73,6 @@ function loaddata() {
|
|||||||
$('#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>');
|
$('#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>');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
859
assets/webconfig/js/lib/jsoneditor.min.js
vendored
Normal file
859
assets/webconfig/js/lib/jsoneditor.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
assets/webconfig/js/lib/jsoneditor.min.js.map
Normal file
1
assets/webconfig/js/lib/jsoneditor.min.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -11,6 +11,7 @@
|
|||||||
{
|
{
|
||||||
"level" :
|
"level" :
|
||||||
{
|
{
|
||||||
|
"type" : "string",
|
||||||
"enum" : ["silent", "warn", "verbose", "debug"],
|
"enum" : ["silent", "warn", "verbose", "debug"],
|
||||||
"title" : "Log-Level"
|
"title" : "Log-Level"
|
||||||
}
|
}
|
||||||
@ -747,6 +748,7 @@
|
|||||||
"enable" :
|
"enable" :
|
||||||
{
|
{
|
||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
|
"format": "checkbox",
|
||||||
"title" : "Activate"
|
"title" : "Activate"
|
||||||
},
|
},
|
||||||
"port" :
|
"port" :
|
||||||
@ -774,6 +776,7 @@
|
|||||||
"enable" :
|
"enable" :
|
||||||
{
|
{
|
||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
|
"format": "checkbox",
|
||||||
"title" : "Activate"
|
"title" : "Activate"
|
||||||
},
|
},
|
||||||
"address" :
|
"address" :
|
||||||
@ -802,6 +805,7 @@
|
|||||||
"shared" :
|
"shared" :
|
||||||
{
|
{
|
||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
|
"format": "checkbox",
|
||||||
"title" : "Shared"
|
"title" : "Shared"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -817,6 +821,7 @@
|
|||||||
"enable" :
|
"enable" :
|
||||||
{
|
{
|
||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
|
"format": "checkbox",
|
||||||
"title" : "Activate",
|
"title" : "Activate",
|
||||||
"required" : true
|
"required" : true
|
||||||
},
|
},
|
||||||
@ -829,7 +834,7 @@
|
|||||||
"port" :
|
"port" :
|
||||||
{
|
{
|
||||||
"type" : "integer",
|
"type" : "integer",
|
||||||
"description" : "Port",
|
"title" : "Port",
|
||||||
"required" : true
|
"required" : true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
// Utils-Jsonschema includes
|
// Utils-Jsonschema includes
|
||||||
#include <utils/jsonschema/QJsonSchemaChecker.h>
|
#include <utils/jsonschema/QJsonSchemaChecker.h>
|
||||||
@ -45,9 +45,9 @@ void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &s
|
|||||||
// check the current json value
|
// check the current json value
|
||||||
for (QJsonObject::const_iterator i = schema.begin(); i != schema.end(); ++i)
|
for (QJsonObject::const_iterator i = schema.begin(); i != schema.end(); ++i)
|
||||||
{
|
{
|
||||||
QString attribute = i.key();
|
QString attribute = i.key();
|
||||||
const QJsonValue & attributeValue = *i;
|
const QJsonValue & attributeValue = *i;
|
||||||
|
|
||||||
if (attribute == "type")
|
if (attribute == "type")
|
||||||
checkType(value, attributeValue);
|
checkType(value, attributeValue);
|
||||||
else if (attribute == "properties")
|
else if (attribute == "properties")
|
||||||
@ -71,7 +71,7 @@ void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &s
|
|||||||
const QJsonObject & props = schema["properties"].toObject();
|
const QJsonObject & props = schema["properties"].toObject();
|
||||||
ignoredProperties = props.keys();
|
ignoredProperties = props.keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
checkAdditionalProperties(value.toObject(), attributeValue, ignoredProperties);
|
checkAdditionalProperties(value.toObject(), attributeValue, ignoredProperties);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -108,7 +108,7 @@ void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &s
|
|||||||
; // nothing to do. value is present so always oke
|
; // nothing to do. value is present so always oke
|
||||||
else if (attribute == "id")
|
else if (attribute == "id")
|
||||||
; // references have already been collected
|
; // references have already been collected
|
||||||
else if (attribute == "title" || attribute == "description" || attribute == "default")
|
else if (attribute == "title" || attribute == "description" || attribute == "default" || attribute == "format")
|
||||||
; // nothing to do.
|
; // nothing to do.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -135,7 +135,7 @@ const std::list<std::string> & QJsonSchemaChecker::getMessages() const
|
|||||||
void QJsonSchemaChecker::checkType(const QJsonValue & value, const QJsonValue & schema)
|
void QJsonSchemaChecker::checkType(const QJsonValue & value, const QJsonValue & schema)
|
||||||
{
|
{
|
||||||
QString type = schema.toString();
|
QString type = schema.toString();
|
||||||
|
|
||||||
bool wrongType = false;
|
bool wrongType = false;
|
||||||
if (type == "string")
|
if (type == "string")
|
||||||
wrongType = !value.isString();
|
wrongType = !value.isString();
|
||||||
@ -168,16 +168,16 @@ void QJsonSchemaChecker::checkType(const QJsonValue & value, const QJsonValue &
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QJsonSchemaChecker::checkProperties(const QJsonObject & value, const QJsonObject & schema)
|
void QJsonSchemaChecker::checkProperties(const QJsonObject & value, const QJsonObject & schema)
|
||||||
{
|
{
|
||||||
for (QJsonObject::const_iterator i = schema.begin(); i != schema.end(); ++i)
|
for (QJsonObject::const_iterator i = schema.begin(); i != schema.end(); ++i)
|
||||||
{
|
{
|
||||||
QString property = i.key();
|
QString property = i.key();
|
||||||
|
|
||||||
const QJsonValue & propertyValue = i.value();
|
const QJsonValue & propertyValue = i.value();
|
||||||
|
|
||||||
_currentPath.push_back(std::string(".") + property.toStdString());
|
_currentPath.push_back(std::string(".") + property.toStdString());
|
||||||
QJsonObject::const_iterator required = propertyValue.toObject().find("required");
|
QJsonObject::const_iterator required = propertyValue.toObject().find("required");
|
||||||
|
|
||||||
if (value.contains(property))
|
if (value.contains(property))
|
||||||
{
|
{
|
||||||
validate(value[property], propertyValue.toObject());
|
validate(value[property], propertyValue.toObject());
|
||||||
@ -264,7 +264,7 @@ void QJsonSchemaChecker::checkItems(const QJsonValue & value, const QJsonObject
|
|||||||
setMessage("items only valid for arrays");
|
setMessage("items only valid for arrays");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray jArray = value.toArray();
|
QJsonArray jArray = value.toArray();
|
||||||
for(int i = 0; i < jArray.size(); ++i)
|
for(int i = 0; i < jArray.size(); ++i)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user