src/DetailNode.cpp

changeset 495
6aa29aaa3f4d
parent 348
c5318497a0b6
--- a/src/DetailNode.cpp	Sun Feb 12 13:58:36 2023 +0100
+++ b/src/DetailNode.cpp	Sun Feb 12 15:05:28 2023 +0100
@@ -31,7 +31,9 @@
 {
     QSqlQuery query;
 
+#ifdef DEBUG_MONITOR
     qDebug() << "DetailNode record:" << id;
+#endif
     ui->setupUi(this);
     this->recno = id;
     setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
@@ -48,8 +50,6 @@
 {
     QSqlQuery query;
 
-    qDebug() << "refreshTable node rec:" << this->recno;
-
     query.prepare("SELECT * FROM mon_nodes WHERE record = :recno");
     query.bindValue(":recno", this->recno);
     query.exec();
@@ -59,14 +59,17 @@
 	_group_id = query.value("group_id").toString();
 	_uuid = query.value("uuid").toString();
 
+	bool online = (query.value("online").toInt() != 0) ? true:false;
+
 	ui->uuidEdit->setText(_uuid);
 	ui->systemEdit->setText(_node);
 	ui->typeEdit->setText(_group_id);
 	ui->firstEdit->setText(query.value("firstseen").toDateTime().toString("dd MMM yyyy HH:mm:ss"));
 	ui->lastEdit->setText(query.value("lastseen").toDateTime().toString("dd MMM yyyy HH:mm:ss"));
 
-	if (query.value("online").toInt()) {
+	if (online) {
 	    ui->statusEdit->setText(tr("Online"));
+	    ui->statusEdit->setStyleSheet("");
 	    ui->makerEdit->show();
 	    ui->modelEdit->show();
 	    ui->osEdit->show();
@@ -140,7 +143,7 @@
 	} else {
 	    /* Offline */
 	    ui->statusEdit->setText(tr("Offline"));
-
+	    ui->statusEdit->setStyleSheet("background-color: red");
 	    ui->makerEdit->hide();
             ui->modelEdit->hide();
             ui->osEdit->hide();
@@ -176,7 +179,6 @@
 
 DetailNode::~DetailNode()
 {
-    qDebug() << "DetailNode done";
     delete ui;
     emit entry_changed();
 }
@@ -210,7 +212,9 @@
 	return;
 
     QString msg = QString("{\"node\":\""+_node+"\",\"group_id\":\""+_group_id+"\",\"control\":\"reboot\"}");
+#ifdef DEBUG_MONITOR
     qDebug() << msg;
+#endif
     webSocket->sendTextMessage(msg);
 }
 
@@ -218,7 +222,9 @@
 void DetailNode::control_rebirth()
 {
     QString msg = QString("{\"node\":\""+_node+"\",\"group_id\":\""+_group_id+"\",\"control\":\"rebirth\"}");
+#ifdef DEBUG_MONITOR
     qDebug() << msg;
+#endif
     webSocket->sendTextMessage(msg);
 }
 

mercurial