Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamline API calls from UI (incl. Fix #1311, #1314) #1312

Merged
merged 5 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vs/launch.vs.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"name": "Run hyperion with debug option and external console",
"args": [
"-d",
"-c"
"-c",
"-u test"
],
"externalConsole": true
}
Expand Down
Binary file not shown.
26 changes: 11 additions & 15 deletions assets/webconfig/js/content_index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var instNameInit = false

$(document).ready(function () {
var darkModeOverwrite = getStorage("darkModeOverwrite", true);

Expand Down Expand Up @@ -27,8 +25,6 @@ $(document).ready(function () {
// comps
window.comps = event.response.info.components

$(window.hyperion).trigger("ready");

window.comps.forEach(function (obj) {
if (obj.name == "ALL") {
if (obj.enabled)
Expand All @@ -44,12 +40,6 @@ $(document).ready(function () {
$('#btn_hypinstanceswitch').toggle(true)
else
$('#btn_hypinstanceswitch').toggle(false)
// update listing at button
updateHyperionInstanceListing()
if (!instNameInit) {
window.currentHyperionInstanceName = getInstanceNameByIndex(0);
instNameInit = true;
}

updateSessions();
}); // end cmd-serverinfo
Expand Down Expand Up @@ -112,11 +102,9 @@ $(document).ready(function () {

$(window.hyperion).one("cmd-authorize-getTokenList", function (event) {
tokenList = event.response.info;
requestServerInfo();
});

$(window.hyperion).on("cmd-sysinfo", function (event) {
requestServerInfo();
window.sysInfo = event.response.info;

window.currentVersion = window.sysInfo.hyperion.version;
Expand All @@ -126,16 +114,22 @@ $(document).ready(function () {

$(window.hyperion).one("cmd-config-getschema", function (event) {
window.serverSchema = event.response.info;
requestServerConfig();
window.schema = window.serverSchema.properties;

requestTokenInfo();
requestGetPendingTokenRequests();

window.schema = window.serverSchema.properties;
//Switch to last selected instance and load related config
var lastSelectedInstance = getStorage('lastSelectedInstance', false);
if (!window.serverInfo.instance[lastSelectedInstance]) {
lastSelectedInstance = 0;
}
instanceSwitch(lastSelectedInstance);

});

$(window.hyperion).on("cmd-config-getconfig", function (event) {
window.serverConfig = event.response.info;
requestSysInfo();

window.showOptHelp = window.serverConfig.general.showOptHelp;
});
Expand Down Expand Up @@ -163,6 +157,8 @@ $(document).ready(function () {
if (event.response.hasOwnProperty('info'))
setStorage("loginToken", event.response.info.token, true);

requestSysInfo();
requestServerInfo();
requestServerConfigSchema();
});

Expand Down
29 changes: 16 additions & 13 deletions assets/webconfig/js/content_leds.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,22 +383,24 @@ function blackListLeds(nonBlacklistLedArray, blackList) {
}

function getLedConfig() {

var ledConfig = { classic: {}, matrix: {} };
var slConfig = window.serverConfig.ledConfig;

for (var key in slConfig.classic) {
if (typeof (slConfig.classic[key]) === "boolean")
var classicSchema = window.serverSchema.properties.ledConfig.properties.classic.properties;
for (var key in classicSchema) {
if (classicSchema[key].type === "boolean")
ledConfig.classic[key] = $('#ip_cl_' + key).is(':checked');
else if (Number.isInteger(slConfig.classic[key]))
else if (classicSchema[key].type === "integer")
ledConfig.classic[key] = parseInt($('#ip_cl_' + key).val());
else
ledConfig.classic[key] = $('#ip_cl_' + key).val();
}

for (var key in slConfig.matrix) {
if (typeof (slConfig.matrix[key]) === "boolean")
var matrixSchema = window.serverSchema.properties.ledConfig.properties.matrix.properties;
for (var key in matrixSchema) {
if (matrixSchema[key].type === "boolean")
ledConfig.matrix[key] = $('#ip_ma_' + key).is(':checked');
else if (Number.isInteger(slConfig.matrix[key]))
else if (matrixSchema[key].type === "integer")
ledConfig.matrix[key] = parseInt($('#ip_ma_' + key).val());
else
ledConfig.matrix[key] = $('#ip_ma_' + key).val();
Expand Down Expand Up @@ -876,6 +878,8 @@ $(document).ready(function () {
break;
case 'NONE':
conf_editor.getEditor(specOptPath + "host").enable();
//Trigger getProperties via host value
conf_editor.notifyWatchers(specOptPath + "host");
break;
case 'SELECT':
conf_editor.getEditor(specOptPath + "host").setValue("");
Expand All @@ -884,9 +888,8 @@ $(document).ready(function () {
break;
default:
conf_editor.getEditor(specOptPath + "host").disable();
//Reset host value, to trigger getProperties via host value
conf_editor.getEditor(specOptPath + "host").setValue("");
conf_editor.getEditor(specOptPath + "host").setValue(val);
//Trigger getProperties via host value
conf_editor.notifyWatchers(specOptPath + "host");
break;
}

Expand Down Expand Up @@ -1510,10 +1513,10 @@ async function getProperties_device(ledType, key, params) {
if (!devicesProperties[ledType][key]) {
const res = await requestLedDeviceProperties(ledType, params);
if (res && !res.error) {
var deviceProperties = res.info.properties;
var ledDeviceProperties = res.info.properties;

if (!jQuery.isEmptyObject(deviceProperties)) {
devicesProperties[ledType][key] = deviceProperties;
if (!jQuery.isEmptyObject(ledDeviceProperties)) {
devicesProperties[ledType][key] = ledDeviceProperties;

if (!window.readOnlyMode) {
$('#btn_submit_controller').attr('disabled', false);
Expand Down
54 changes: 38 additions & 16 deletions assets/webconfig/js/ui_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function loadContent(event, forceRefresh) {
var tag;

var lastSelectedInstance = getStorage('lastSelectedInstance', false);

if (lastSelectedInstance && (lastSelectedInstance != window.currentHyperionInstance)) {
if (window.serverInfo.instance[lastSelectedInstance] && window.serverInfo.instance[lastSelectedInstance].running) {
instanceSwitch(lastSelectedInstance);
Expand Down Expand Up @@ -128,12 +128,13 @@ function getInstanceNameByIndex(index) {
}

function updateHyperionInstanceListing() {
var data = window.serverInfo.instance.filter(entry => entry.running);
$('#hyp_inst_listing').html("");
for (var key in data) {
var currInstMarker = (data[key].instance == window.currentHyperionInstance) ? "component-on" : "";
if (window.serverInfo.instance) {
var data = window.serverInfo.instance.filter(entry => entry.running);
$('#hyp_inst_listing').html("");
for (var key in data) {
var currInstMarker = (data[key].instance == window.currentHyperionInstance) ? "component-on" : "";

var html = '<li id="hyperioninstance_' + data[key].instance + '"> \
var html = '<li id="hyperioninstance_' + data[key].instance + '"> \
<a> \
<div> \
<i class="fa fa-circle fa-fw '+ currInstMarker + '"></i> \
Expand All @@ -142,15 +143,16 @@ function updateHyperionInstanceListing() {
</a> \
</li> '

if (data.length - 1 > key)
html += '<li class="divider"></li>'
if (data.length - 1 > key)
html += '<li class="divider"></li>'

$('#hyp_inst_listing').append(html);
$('#hyp_inst_listing').append(html);

$('#hyperioninstance_' + data[key].instance).off().on("click", function (e) {
var inst = e.currentTarget.id.split("_")[1]
instanceSwitch(inst)
});
$('#hyperioninstance_' + data[key].instance).off().on("click", function (e) {
var inst = e.currentTarget.id.split("_")[1]
instanceSwitch(inst)
});
}
}
}

Expand Down Expand Up @@ -290,9 +292,9 @@ function showInfoDialog(type, header, message) {
$('#id_body_rename').append('<h4>' + header + '</h4><br>');
$('#id_body_rename').append('<div class="row"><div class="col-md-4"><p class="text-left">' + $.i18n('infoDialog_username_text') +
'</p></div><div class="col-md-8"><input class="form-control" id="username" type="text" value="Hyperion" disabled></div></div><br>');
$('#id_body_rename').append('<div class="row"><div class="col-md-4"><p class="text-left">' + $.i18n('infoDialog_password_current_text') +
'</p></div><div class="col-md-8"><input class="form-control" id="current-password" placeholder="Old" type="password" autocomplete="current-password"></div></div><br>');
$('#id_body_rename').append('<div class="row"><div class="col-md-4"><p class="text-left">' + $.i18n('infoDialog_password_new_text')+
$('#id_body_rename').append('<div class="row"><div class="col-md-4"><p class="text-left">' + $.i18n('infoDialog_password_current_text') +
'</p></div><div class="col-md-8"><input class="form-control" id="current-password" placeholder="Old" type="password" autocomplete="current-password"></div></div><br>');
$('#id_body_rename').append('<div class="row"><div class="col-md-4"><p class="text-left">' + $.i18n('infoDialog_password_new_text') +
'</p></div><div class="col-md-8"><input class="form-control" id="new-password" placeholder="New" type="password" autocomplete="new-password"></div></div>');
$('#id_body_rename').append('<div class="bs-callout bs-callout-info"><span>' + $.i18n('infoDialog_password_minimum_length') + '</span></div>');
$('#id_footer_rename').html('<button type="button" id="id_btn_ok" class="btn btn-success" data-dismiss-modal="#modal_dialog_rename" disabled><i class="fa fa-fw fa-save"></i>' + $.i18n('general_btn_ok') + '</button></div>');
Expand Down Expand Up @@ -469,6 +471,9 @@ function updateJsonEditorSelection(rootEditor, path, key, addElements, newEnumVa
var editor = rootEditor.getEditor(path);
var orginalProperties = editor.schema.properties[key];

var orginalWatchFunctions = rootEditor.watchlist[path + "." + key];
rootEditor.unwatch(path + "." + key);

var newSchema = [];
newSchema[key] =
{
Expand Down Expand Up @@ -546,12 +551,22 @@ function updateJsonEditorSelection(rootEditor, path, key, addElements, newEnumVa
editor.removeObjectProperty(key);
delete editor.cached_editors[key];
editor.addObjectProperty(key);

if (orginalWatchFunctions) {
for (var i = 0; i < orginalWatchFunctions.length; i++) {
rootEditor.watch(path + "." + key, orginalWatchFunctions[i]);
}
}
rootEditor.notifyWatchers(path + "." + key);
}

function updateJsonEditorMultiSelection(rootEditor, path, key, addElements, newEnumVals, newTitelVals, newDefaultVal) {
var editor = rootEditor.getEditor(path);
var orginalProperties = editor.schema.properties[key];

var orginalWatchFunctions = rootEditor.watchlist[path + "." + key];
rootEditor.unwatch(path + "." + key);

var newSchema = [];
newSchema[key] =
{
Expand Down Expand Up @@ -605,6 +620,13 @@ function updateJsonEditorMultiSelection(rootEditor, path, key, addElements, newE
editor.removeObjectProperty(key);
delete editor.cached_editors[key];
editor.addObjectProperty(key);

if (orginalWatchFunctions) {
for (var i = 0; i < orginalWatchFunctions.length; i++) {
rootEditor.watch(path + "." + key, orginalWatchFunctions[i]);
}
}
rootEditor.notifyWatchers(path + "." + key);
}

function updateJsonEditorRange(rootEditor, path, key, minimum, maximum, defaultValue, step, clear) {
Expand Down
2 changes: 1 addition & 1 deletion dependencies/external/rpi_ws281x
Submodule rpi_ws281x updated 4 files
+13 −27 CMakeLists.txt
+0 −9 pkg-config.pc.in
+3 −41 rpihw.c
+2 −3 ws2811.c
2 changes: 1 addition & 1 deletion libsrc/leddevice/dev_net/LedDeviceWled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// Constants
namespace {

const bool verbose = false;
const bool verbose = true;

// Configuration settings
const char CONFIG_ADDRESS[] = "host";
Expand Down