Add autoscoll for log view
This commit is contained in:
parent
74293535b8
commit
c17fe76027
@ -52,6 +52,7 @@ function connectWebsocket() {
|
|||||||
var message = messageEvent.data;
|
var message = messageEvent.data;
|
||||||
console.log("WebSocket data received: " + message);
|
console.log("WebSocket data received: " + message);
|
||||||
document.getElementById("logsTextArea").value += message;
|
document.getElementById("logsTextArea").value += message;
|
||||||
|
document.getElementById("logsTextArea").scrollTop = document.getElementById("logsTextArea").scrollHeight
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
|
|||||||
@ -48,13 +48,6 @@ DebugServerHandler::DebugServerHandler(QObject *parent) :
|
|||||||
}
|
}
|
||||||
qCDebug(dcWebServer()) << "DebugServer: Started debug server websocket interface on" << m_websocketServer->serverUrl().toString();
|
qCDebug(dcWebServer()) << "DebugServer: Started debug server websocket interface on" << m_websocketServer->serverUrl().toString();
|
||||||
|
|
||||||
m_timer = new QTimer(this);
|
|
||||||
m_timer->setSingleShot(false);
|
|
||||||
m_timer->setInterval(1000);
|
|
||||||
connect(m_timer, &QTimer::timeout, this, &DebugServerHandler::onTimeout);
|
|
||||||
|
|
||||||
//m_timer->start();
|
|
||||||
|
|
||||||
s_oldLogMessageHandler = qInstallMessageHandler(&logMessageHandler);
|
s_oldLogMessageHandler = qInstallMessageHandler(&logMessageHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1055,7 +1048,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
|
|||||||
// Dig section
|
// Dig section
|
||||||
writer.writeEmptyElement("hr");
|
writer.writeEmptyElement("hr");
|
||||||
//: The ping section of the debug interface
|
//: The ping section of the debug interface
|
||||||
writer.writeTextElement("h3", tr("Trace path nymea.io"));
|
writer.writeTextElement("h3", tr("Trace path to nymea.io"));
|
||||||
writer.writeEmptyElement("hr");
|
writer.writeEmptyElement("hr");
|
||||||
|
|
||||||
// Start tracepath button
|
// Start tracepath button
|
||||||
@ -1084,7 +1077,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
|
|||||||
writer.writeAttribute("class", "logstream");
|
writer.writeAttribute("class", "logstream");
|
||||||
writer.writeEmptyElement("hr");
|
writer.writeEmptyElement("hr");
|
||||||
//: The network section of the debug interface
|
//: The network section of the debug interface
|
||||||
writer.writeTextElement("h2", tr("Server debug log stream"));
|
writer.writeTextElement("h2", tr("Server live logs"));
|
||||||
writer.writeEmptyElement("hr");
|
writer.writeEmptyElement("hr");
|
||||||
|
|
||||||
// Start stream button
|
// Start stream button
|
||||||
@ -1094,7 +1087,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
|
|||||||
writer.writeAttribute("id", "connectWebsocketButton");
|
writer.writeAttribute("id", "connectWebsocketButton");
|
||||||
writer.writeAttribute("onClick", "connectWebsocket()");
|
writer.writeAttribute("onClick", "connectWebsocket()");
|
||||||
//: The connect button for the log stream of the debug interface
|
//: The connect button for the log stream of the debug interface
|
||||||
writer.writeCharacters(tr("Connect stream"));
|
writer.writeCharacters(tr("Start server live logs"));
|
||||||
writer.writeEndElement(); // button
|
writer.writeEndElement(); // button
|
||||||
|
|
||||||
// Stop stream button
|
// Stop stream button
|
||||||
@ -1105,7 +1098,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
|
|||||||
writer.writeAttribute("onClick", "disconnectWebsocket()");
|
writer.writeAttribute("onClick", "disconnectWebsocket()");
|
||||||
writer.writeAttribute("disabled", "true");
|
writer.writeAttribute("disabled", "true");
|
||||||
//: The disconnect button for the log stream of the debug interface
|
//: The disconnect button for the log stream of the debug interface
|
||||||
writer.writeCharacters(tr("Disconnect stream"));
|
writer.writeCharacters(tr("Stop server live logs"));
|
||||||
writer.writeEndElement(); // button
|
writer.writeEndElement(); // button
|
||||||
|
|
||||||
|
|
||||||
@ -1209,13 +1202,6 @@ QByteArray DebugServerHandler::createErrorXmlDocument(HttpReply::HttpStatusCode
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugServerHandler::onTimeout()
|
|
||||||
{
|
|
||||||
foreach (QWebSocket *client, s_websocketClients) {
|
|
||||||
client->sendTextMessage("Hallo!\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebugServerHandler::onWebsocketClientConnected()
|
void DebugServerHandler::onWebsocketClientConnected()
|
||||||
{
|
{
|
||||||
QWebSocket *client = m_websocketServer->nextPendingConnection();
|
QWebSocket *client = m_websocketServer->nextPendingConnection();
|
||||||
|
|||||||
@ -43,7 +43,6 @@ private:
|
|||||||
static QList<QWebSocket*> s_websocketClients;
|
static QList<QWebSocket*> s_websocketClients;
|
||||||
static void logMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message);
|
static void logMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message);
|
||||||
|
|
||||||
QTimer *m_timer = nullptr;
|
|
||||||
QWebSocketServer *m_websocketServer = nullptr;
|
QWebSocketServer *m_websocketServer = nullptr;
|
||||||
|
|
||||||
QProcess *m_pingProcess = nullptr;
|
QProcess *m_pingProcess = nullptr;
|
||||||
@ -65,7 +64,6 @@ private:
|
|||||||
QByteArray createErrorXmlDocument(HttpReply::HttpStatusCode statusCode, const QString &errorMessage);
|
QByteArray createErrorXmlDocument(HttpReply::HttpStatusCode statusCode, const QString &errorMessage);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onTimeout();
|
|
||||||
void onWebsocketClientConnected();
|
void onWebsocketClientConnected();
|
||||||
void onWebsocketClientDisconnected();
|
void onWebsocketClientDisconnected();
|
||||||
void onWebsocketClientError(QAbstractSocket::SocketError error);
|
void onWebsocketClientError(QAbstractSocket::SocketError error);
|
||||||
|
|||||||
Reference in New Issue
Block a user