mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Fix logger and led colors (#906)
This commit is contained in:
parent
773b47bf53
commit
d4b4158cb7
@ -1,13 +1,14 @@
|
||||
var conf_editor = null;
|
||||
var createdCont = false;
|
||||
performTranslation();
|
||||
requestLoggingStart();
|
||||
var conf_editor = null;
|
||||
var createdCont = false;
|
||||
|
||||
performTranslation();
|
||||
requestLoggingStart();
|
||||
|
||||
$(document).ready(function() {
|
||||
var messages;
|
||||
var loguplmess = "";
|
||||
var reportUrl = 'https://report.hyperion-project.org/#';
|
||||
|
||||
|
||||
$('#conf_cont').append(createOptPanel('fa-reorder', $.i18n("edt_conf_log_heading_title"), 'editor_container', 'btn_submit'));
|
||||
if(window.showOptHelp)
|
||||
{
|
||||
@ -15,15 +16,15 @@ $(document).ready(function() {
|
||||
createHintH("intro", $.i18n('conf_logging_label_intro'), "log_head");
|
||||
}
|
||||
$("#log_upl_pol").append('<span style="color:grey;font-size:80%">'+$.i18n("conf_logging_uplpolicy")+' '+buildWL("user/support#report_privacy_policy",$.i18n("conf_logging_contpolicy")));
|
||||
|
||||
|
||||
conf_editor = createJsonEditor('editor_container', {
|
||||
logger : window.schema.logger
|
||||
}, true, true);
|
||||
|
||||
|
||||
conf_editor.on('change',function() {
|
||||
conf_editor.validate().length ? $('#btn_submit').attr('disabled', true) : $('#btn_submit').attr('disabled', false);
|
||||
});
|
||||
|
||||
|
||||
$('#btn_submit').off().on('click',function() {
|
||||
requestWriteConfig(conf_editor.getValue());
|
||||
});
|
||||
@ -33,7 +34,7 @@ $(document).ready(function() {
|
||||
$(this).attr("disabled", true);
|
||||
$('#upl_link').html($.i18n('conf_logging_uploading'))
|
||||
});
|
||||
|
||||
|
||||
//show prev uploads
|
||||
var ent;
|
||||
|
||||
@ -48,7 +49,7 @@ $(document).ready(function() {
|
||||
}
|
||||
else
|
||||
ent = [];
|
||||
|
||||
|
||||
function updateLastReports(id,time,title)
|
||||
{
|
||||
if(ent.length > 4)
|
||||
@ -56,7 +57,7 @@ $(document).ready(function() {
|
||||
ent.unshift({"id": id ,"time": time,"title": title})
|
||||
setStorage("prev_reports",JSON.stringify(ent));
|
||||
}
|
||||
|
||||
|
||||
function uploadLog()
|
||||
{
|
||||
var log = "";
|
||||
@ -66,7 +67,7 @@ $(document).ready(function() {
|
||||
var sys = window.sysInfo.system;
|
||||
var shy = window.sysInfo.hyperion;
|
||||
var info;
|
||||
|
||||
|
||||
//create log
|
||||
log = (messages ? loguplmess : "Log was empty!");
|
||||
|
||||
@ -83,7 +84,7 @@ $(document).ready(function() {
|
||||
info += 'Arch: '+sys.architecture+'\n';
|
||||
info += 'Kernel: '+sys.kernelType+' ('+sys.kernelVersion+' (WS: '+sys.wordSize+'))\n';
|
||||
info += 'Browser/OS: '+navigator.userAgent+'\n\n';
|
||||
|
||||
|
||||
//create prios
|
||||
info += "### PRIORITIES ### \n";
|
||||
for(var i = 0; i<prios.length; i++)
|
||||
@ -96,14 +97,14 @@ $(document).ready(function() {
|
||||
info += ' ('+prios[i].component+') Owner: '+prios[i].owner+'\n';
|
||||
}
|
||||
info += '\npriorities_autoselect: '+window.serverInfo.priorities_autoselect+'\n\n';
|
||||
|
||||
|
||||
//create comps
|
||||
info += '### COMPONENTS ### \n';
|
||||
for(var i = 0; i<comps.length; i++)
|
||||
{
|
||||
info += comps[i].enabled+' - '+comps[i].name+'\n';
|
||||
}
|
||||
|
||||
|
||||
//escape data
|
||||
info = JSON.stringify(info);
|
||||
log = JSON.stringify(log);
|
||||
@ -143,24 +144,25 @@ $(document).ready(function() {
|
||||
{
|
||||
window.loggingHandlerInstalled = true;
|
||||
$(window.hyperion).on("cmd-logging-update",function(event){
|
||||
|
||||
|
||||
if ($("#logmessages").length == 0 && window.loggingStreamActive)
|
||||
{
|
||||
requestLoggingStop();
|
||||
window.loggingStreamActive = false;
|
||||
}
|
||||
|
||||
|
||||
messages = (event.response.result.messages);
|
||||
if(messages.length != 0 && !createdCont)
|
||||
{
|
||||
$('#log_content').html('<pre><div id="logmessages" style="overflow:scroll;max-height:400px"></div></pre><button class="btn btn-primary" id="btn_autoscroll"><i class="fa fa-long-arrow-down fa-fw"></i>'+$.i18n('conf_logging_btn_autoscroll')+'</button>');
|
||||
createdCont = true;
|
||||
|
||||
|
||||
$('#btn_autoscroll').off().on('click',function() {
|
||||
toggleClass('#btn_autoscroll', "btn-success", "btn-danger");
|
||||
});
|
||||
}
|
||||
for(var idx=0; idx<messages.length; idx++)
|
||||
|
||||
for(var idx = 0; idx < messages.length; idx++)
|
||||
{
|
||||
var app_name = messages[idx].appName;
|
||||
var logger_name = messages[idx].loggerName;
|
||||
@ -169,23 +171,27 @@ $(document).ready(function() {
|
||||
var file_name = messages[idx].fileName;
|
||||
var msg = messages[idx].message;
|
||||
var level_string = messages[idx].levelString;
|
||||
|
||||
var utime = messages[idx].utime;
|
||||
|
||||
var debug = "";
|
||||
|
||||
if(level_string == "DEBUG") {
|
||||
debug = "("+file_name+":"+line+":"+function_+"()) ";
|
||||
}
|
||||
|
||||
$("#logmessages").append("\n <code>"+"["+app_name+" "+logger_name+"] ("+level_string+") "+debug+msg+"</code>");
|
||||
|
||||
var date = new Date(parseInt(utime));
|
||||
|
||||
$("#logmessages").append("\n <code>"+date.toISOString()+" ["+app_name+" "+logger_name+"] ("+level_string+") "+debug+msg+"</code>");
|
||||
loguplmess += "["+app_name+" "+logger_name+"] ("+level_string+") "+debug+msg+"\n";
|
||||
}
|
||||
if($("#btn_autoscroll").hasClass('btn-success')){
|
||||
|
||||
if($("#btn_autoscroll").hasClass('btn-success'))
|
||||
{
|
||||
$('#logmessages').stop().animate({
|
||||
scrollTop: $('#logmessages')[0].scrollHeight
|
||||
}, 800);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
removeOverlay();
|
||||
});
|
||||
|
@ -165,9 +165,9 @@ public:
|
||||
///
|
||||
/// @param[out] image The image that buffers the output
|
||||
///
|
||||
void toRgb(Image<ColorRgb>& image)
|
||||
void toRgb(Image<ColorRgb>& image) const
|
||||
{
|
||||
_d_ptr->toRgb(*(image.imageData()));
|
||||
_d_ptr->toRgb(*image._d_ptr);
|
||||
}
|
||||
|
||||
///
|
||||
@ -186,12 +186,10 @@ public:
|
||||
_d_ptr->clear();
|
||||
}
|
||||
|
||||
QSharedDataPointer<ImageData<Pixel_T>> imageData() const
|
||||
{
|
||||
return _d_ptr;
|
||||
}
|
||||
|
||||
private:
|
||||
template<class T>
|
||||
friend class Image;
|
||||
|
||||
///
|
||||
/// Translate x and y coordinate to index of the underlying vector
|
||||
///
|
||||
|
@ -134,7 +134,7 @@ public:
|
||||
return _pixels;
|
||||
}
|
||||
|
||||
void toRgb(ImageData<ColorRgb>& image)
|
||||
void toRgb(ImageData<ColorRgb>& image) const
|
||||
{
|
||||
if (image.width() != _width || image.height() != _height)
|
||||
image.resize(_width, _height);
|
||||
|
@ -79,7 +79,7 @@ protected:
|
||||
~Logger();
|
||||
|
||||
private:
|
||||
void write(const Logger::T_LOG_MESSAGE & message) const;
|
||||
void write(const Logger::T_LOG_MESSAGE & message);
|
||||
|
||||
static QMutex MapLock;
|
||||
static QMap<QString,Logger*> LoggerMap;
|
||||
@ -106,7 +106,7 @@ public slots:
|
||||
void handleNewLogMessage(const Logger::T_LOG_MESSAGE&);
|
||||
|
||||
signals:
|
||||
void newLogMessage(Logger::T_LOG_MESSAGE);
|
||||
void newLogMessage(const Logger::T_LOG_MESSAGE&);
|
||||
|
||||
protected:
|
||||
LoggerManager();
|
||||
|
@ -1053,7 +1053,7 @@ void JsonAPI::handleLoggingCommand(const QJsonObject &message, const QString &co
|
||||
if (!_streaming_logging_activated)
|
||||
{
|
||||
_streaming_logging_reply["command"] = command + "-update";
|
||||
connect(LoggerManager::getInstance(), SIGNAL(newLogMessage(Logger::T_LOG_MESSAGE)), this, SLOT(incommingLogMessage(Logger::T_LOG_MESSAGE)));
|
||||
connect(LoggerManager::getInstance(), &LoggerManager::newLogMessage, this, &JsonAPI::incommingLogMessage);
|
||||
Debug(_log, "log streaming activated for client %s", _peerAddress.toStdString().c_str()); // needed to trigger log sending
|
||||
}
|
||||
}
|
||||
@ -1061,7 +1061,7 @@ void JsonAPI::handleLoggingCommand(const QJsonObject &message, const QString &co
|
||||
{
|
||||
if (_streaming_logging_activated)
|
||||
{
|
||||
disconnect(LoggerManager::getInstance(), SIGNAL(newLogMessage(Logger::T_LOG_MESSAGE)), this, 0);
|
||||
disconnect(LoggerManager::getInstance(), &LoggerManager::newLogMessage, this, &JsonAPI::incommingLogMessage);
|
||||
_streaming_logging_activated = false;
|
||||
Debug(_log, "log streaming deactivated for client %s", _peerAddress.toStdString().c_str());
|
||||
}
|
||||
@ -1561,6 +1561,7 @@ void JsonAPI::incommingLogMessage(const Logger::T_LOG_MESSAGE &msg)
|
||||
message["fileName"] = logBuffer->at(i).fileName;
|
||||
message["message"] = logBuffer->at(i).message;
|
||||
message["levelString"] = logBuffer->at(i).levelString;
|
||||
message["utime"] = QString::number(logBuffer->at(i).utime);
|
||||
|
||||
messageArray.append(message);
|
||||
}
|
||||
@ -1574,6 +1575,7 @@ void JsonAPI::incommingLogMessage(const Logger::T_LOG_MESSAGE &msg)
|
||||
message["fileName"] = msg.fileName;
|
||||
message["message"] = msg.message;
|
||||
message["levelString"] = msg.levelString;
|
||||
message["utime"] = QString::number(msg.utime);
|
||||
|
||||
messageArray.append(message);
|
||||
}
|
||||
|
@ -379,8 +379,18 @@ void Hyperion::setColor(const int priority, const std::vector<ColorRgb> &ledColo
|
||||
_effectEngine->channelCleared(priority);
|
||||
|
||||
// create full led vector from single/multiple colors
|
||||
size_t size = _ledString.leds().size();
|
||||
std::vector<ColorRgb> newLedColors;
|
||||
std::copy_n(ledColors.begin(), _ledString.leds().size(), std::back_inserter(newLedColors));
|
||||
while (true)
|
||||
{
|
||||
for (const auto &entry : ledColors)
|
||||
{
|
||||
newLedColors.emplace_back(entry);
|
||||
if (newLedColors.size() == size)
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
end:
|
||||
|
||||
if (getPriorityInfo(priority).componentId != hyperion::COMP_COLOR)
|
||||
clear(priority);
|
||||
|
@ -243,9 +243,10 @@ QJsonObject LedDeviceWled::getProperties(const QJsonObject& params)
|
||||
return properties;
|
||||
}
|
||||
|
||||
void LedDeviceWled::identify(const QJsonObject& params)
|
||||
void LedDeviceWled::identify(const QJsonObject& /*params*/)
|
||||
{
|
||||
Debug(_log, "params: [%s]", QString(QJsonDocument(params).toJson(QJsonDocument::Compact)).toUtf8().constData() );
|
||||
#if 0
|
||||
Debug(_log, "params: [%s]", QString(QJsonDocument(params).toJson(QJsonDocument::Compact)).toUtf8().constData());
|
||||
QJsonObject properties;
|
||||
|
||||
// Get Nanoleaf device properties
|
||||
@ -281,6 +282,7 @@ void LedDeviceWled::identify(const QJsonObject& params)
|
||||
// Warning (_log, "%s identification failed with error: '%s'", QSTRING_CSTR(_activeDeviceType), QSTRING_CSTR(response.getErrorReason()));
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int LedDeviceWled::write(const std::vector<ColorRgb> &ledValues)
|
||||
|
@ -9,6 +9,10 @@
|
||||
#include <QNetworkInterface>
|
||||
#include <QNetworkConfigurationManager>
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
#include <QRandomGenerator>
|
||||
#endif
|
||||
|
||||
static const QString SSDP_HYPERION_ST("urn:hyperion-project.org:device:basic:1");
|
||||
|
||||
SSDPHandler::SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const quint16& jsonServerPort, const QString& name, QObject * parent)
|
||||
@ -162,7 +166,11 @@ void SSDPHandler::handleMSearchRequest(const QString& target, const QString& mx,
|
||||
if (ok)
|
||||
{
|
||||
/* Pick a random delay between 0 and MX seconds */
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
int randomDelay = QRandomGenerator::global()->generate() % (maxDelay * 1000);
|
||||
#else
|
||||
int randomDelay = qrand() % (maxDelay * 1000);
|
||||
#endif
|
||||
QTimer::singleShot(randomDelay, respond);
|
||||
}
|
||||
else
|
||||
|
@ -155,7 +155,7 @@ Logger::~Logger()
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::write(const Logger::T_LOG_MESSAGE & message) const
|
||||
void Logger::write(const Logger::T_LOG_MESSAGE & message)
|
||||
{
|
||||
QString location;
|
||||
if (message.level == Logger::DEBUG)
|
||||
@ -179,6 +179,8 @@ void Logger::write(const Logger::T_LOG_MESSAGE & message) const
|
||||
.arg(message.message)
|
||||
.toStdString()
|
||||
<< std::endl;
|
||||
|
||||
newLogMessage(message);
|
||||
}
|
||||
|
||||
void Logger::Message(LogLevel level, const char* sourceFile, const char* func, unsigned int line, const char* fmt, ...)
|
||||
|
Loading…
Reference in New Issue
Block a user