diff --git a/redis-desktop-manager/forms/connection.ui b/redis-desktop-manager/forms/connection.ui index ff0ba151..fb703337 100644 --- a/redis-desktop-manager/forms/connection.ui +++ b/redis-desktop-manager/forms/connection.ui @@ -10,7 +10,7 @@ 0 0 341 - 305 + 306 @@ -121,13 +121,16 @@ - - + + - Remote host + User + + + @@ -135,9 +138,6 @@ - - - @@ -151,35 +151,40 @@ - - - - - - - QLineEdit::Password + + + + Remote host - - - + + + Password - - - - - - User - - - - - - - Show password + + true + + + + + + + + QLineEdit::Password + + + + + + + Show password + + + + @@ -328,7 +333,6 @@ sshHost sshPort sshUser - sshPass tabs diff --git a/redis-desktop-manager/forms/demo.ui b/redis-desktop-manager/forms/demo.ui index ea8a1fa0..4f503acc 100644 --- a/redis-desktop-manager/forms/demo.ui +++ b/redis-desktop-manager/forms/demo.ui @@ -8,7 +8,7 @@ 0 0 1036 - 618 + 671 @@ -59,9 +59,6 @@ Qt::LeftToRight - - QLayout::SetNoConstraint - 3 @@ -72,60 +69,67 @@ 3 - 0 + 3 - - 5 - - - 0 + + 3 - - - - 0 - 0 - + + + 0 - Qt::Horizontal + Qt::Vertical - - true + + 1 - - false - - - - - 2 - - - - - - - - 0 - 25 - - - - - 16777215 - 25 - - - - - 0 - 25 - - - - <p><b>Key search supports regular expressions:</b></p> + + + + 0 + 0 + + + + Qt::Horizontal + + + true + + + false + + + + + 2 + + + + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + + 0 + 25 + + + + <p><b>Key search supports regular expressions:</b></p> <pre> . Any character except newline. @@ -152,370 +156,370 @@ aa|bb Either aa or bb. (?!expr) Not followed by expr. </pre> - - - - - - key search... - - - - - - - - 35 - 25 - - - - - 50 - 25 - - - - - 0 - 0 - - - - - 0 - 25 - - - - Apply filter - - - Find - - - - :/images/ok.png:/images/ok.png - - - - - - - false - - - - 35 - 25 - - - - - 60 - 25 - - - - - 0 - 25 - - - - - 0 - 25 - - - - Reset filter - - - Clear - - - - :/images/clear.png:/images/clear.png - - - - - - - - - - 0 - 0 - - - - - 300 - 0 - - - - - 8000 - 16777215 - - - - font-family: monospaced; - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOn - - - true - - - false - - - true - - - 300 - - - false - - - - - - - 2 - - - - - - 145 - 35 - - - - - 145 - 35 - - - - - 145 - 35 - - - - Manage Connections - - - - :/images/menu.png:/images/menu.png - - - QToolButton::InstantPopup - - - Qt::ToolButtonTextBesideIcon - - - false - - - - - - - - 0 - 0 - - - - - 135 - 35 - - - - - 300 - 16777215 - - - - - 135 - 35 - - - - Qt::LeftToRight - - - padding-left: 50px; - - - - - Add New Connection - - - - :/images/add.png:/images/add.png - - - Qt::ToolButtonTextBesideIcon - - - - - - - - - - - 1 - 0 - - - - - 580 - 0 - - - - false - - - - - - QTabWidget::North - - - QTabWidget::Rounded - - - 0 - - - Qt::ElideNone - - - true - - - false - - - true - - - true - - - - - 2 - 2 - - - - - 50000 - 16777215 - - - - - :/images/redisIcon.png:/images/redisIcon.png - - - Redis Desktop Manager - - - - QLayout::SetNoConstraint - - - + + + + + + key search... + + + + + + + + 35 + 25 + + + + + 50 + 25 + + + + + 0 + 0 + + + + + 0 + 25 + + + + Apply filter + + + Find + + + + :/images/ok.png:/images/ok.png + + + + + + + false + + + + 35 + 25 + + + + + 60 + 25 + + + + + 0 + 25 + + + + + 0 + 25 + + + + Reset filter + + + Clear + + + + :/images/clear.png:/images/clear.png + + + + + + + - + 0 0 - 570 - 255 + 300 + 0 - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 190 - - - - - 16777215 - 190 - - - - - 0 - 190 - - - - Qt::LeftToRight - - - false - - - QFrame::NoFrame - - - <html><head/> + + + 8000 + 16777215 + + + + font-family: monospaced; + + + Qt::ScrollBarAlwaysOn + + + Qt::ScrollBarAlwaysOn + + + true + + + false + + + true + + + 300 + + + false + + + + + + + 2 + + + + + + 145 + 35 + + + + + 145 + 35 + + + + + 145 + 35 + + + + Manage Connections + + + + :/images/menu.png:/images/menu.png + + + QToolButton::InstantPopup + + + Qt::ToolButtonTextBesideIcon + + + false + + + + + + + + 0 + 0 + + + + + 135 + 35 + + + + + 300 + 16777215 + + + + + 135 + 35 + + + + Qt::LeftToRight + + + padding-left: 50px; + + + + + Add New Connection + + + + :/images/add.png:/images/add.png + + + Qt::ToolButtonTextBesideIcon + + + + + + + + + + + 1 + 0 + + + + + 580 + 0 + + + + false + + + + + + QTabWidget::North + + + QTabWidget::Rounded + + + 0 + + + Qt::ElideNone + + + true + + + false + + + true + + + true + + + + + 2 + 2 + + + + + 50000 + 16777215 + + + + + :/images/redisIcon.png:/images/redisIcon.png + + + Redis Desktop Manager + + + + QLayout::SetNoConstraint + + + + + + 0 + 0 + + + + + 570 + 255 + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 190 + + + + + 16777215 + 190 + + + + + 0 + 190 + + + + Qt::LeftToRight + + + false + + + QFrame::NoFrame + + + <html><head/> <style>a {color: darkblue; text-decoration: none}</style> <body style="width:100%;"><div style="font-size:20pt; padding-top:10px;"><img style="float:left;" src=":/images/logo.png"/><div style=" font-size:24pt; margin-left: 100px; margin-top:2px; display: inline-block; padding-left:50px;">Redis Desktop Manager</div><div style="margin-left: 100px; display: inline-block; padding-left:53px; font-size: 11px; line-height: 21px"><b>Cross-platform GUI application for managing Redis.</b> <br /><b>Version</b> %VERSION% &nbsp;&nbsp;&nbsp; Developed by - <a href="http://glide.name/?rdm">Igor Malinovskiy</a> </div> @@ -536,43 +540,94 @@ aa|bb Either aa or bb. </div> </div> </body></html> - - - Qt::RichText - - - false - - - Qt::AlignJustify|Qt::AlignVCenter - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 20 - 20 - - - - - - - - + + + Qt::RichText + + + false + + + Qt::AlignJustify|Qt::AlignVCenter + + + true + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 20 + 20 + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 100 + + + + + 16777215 + 150 + + + + + 0 + 0 + + + + + 0 + 150 + + + + false + + + Qt::ScrollBarAlwaysOn + + + System console + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + 100000 + + diff --git a/redis-desktop-manager/include/application.h b/redis-desktop-manager/include/application.h index be54f885..7dce7577 100644 --- a/redis-desktop-manager/include/application.h +++ b/redis-desktop-manager/include/application.h @@ -36,6 +36,7 @@ private: void initContextMenus(); void initUpdater(); void initFilter(); + void initSystemConsole(); private slots: void OnAddConnectionClick(); @@ -54,7 +55,9 @@ private: void OnServerInfoOpen(); void OnConsoleOpen(); void OnError(QString); + void OnLogMessage(QString); void OnUIUnlock(); void OnStatusMessage(QString); void OnKeyOpenInNewTab(); + void OnConsoleStateChanged(); }; diff --git a/redis-desktop-manager/include/redis/ConnectionBridge.h b/redis-desktop-manager/include/redis/ConnectionBridge.h index f1075982..73af4cdf 100644 --- a/redis-desktop-manager/include/redis/ConnectionBridge.h +++ b/redis-desktop-manager/include/redis/ConnectionBridge.h @@ -30,6 +30,7 @@ signals: void loadDatabasesList(); void dbListLoaded(RedisConnectionAbstract::RedisDatabases); void error(QString); + void log(QString); void operationProgress(int percents, QObject *); protected: diff --git a/redis-desktop-manager/include/redis/RedisConnectionAbstract.h b/redis-desktop-manager/include/redis/RedisConnectionAbstract.h index d80897fc..1ceede13 100644 --- a/redis-desktop-manager/include/redis/RedisConnectionAbstract.h +++ b/redis-desktop-manager/include/redis/RedisConnectionAbstract.h @@ -62,6 +62,7 @@ signals: void operationProgress(int percents, QObject *); void databesesLoaded(RedisConnectionAbstract::RedisDatabases); void errorOccurred(QString); + void log(QString); protected: bool connected; diff --git a/redis-desktop-manager/include/redis/Response.h b/redis-desktop-manager/include/redis/Response.h index 81d1b00c..013f3097 100644 --- a/redis-desktop-manager/include/redis/Response.h +++ b/redis-desktop-manager/include/redis/Response.h @@ -30,6 +30,8 @@ public: bool isErrorMessage() const; + QString toString(); + private: QByteArray responseSource; diff --git a/redis-desktop-manager/source/application.cpp b/redis-desktop-manager/source/application.cpp index 6096e4e1..f93e8d28 100644 --- a/redis-desktop-manager/source/application.cpp +++ b/redis-desktop-manager/source/application.cpp @@ -25,6 +25,7 @@ MainWin::MainWin(QWidget *parent) initFormButtons(); initUpdater(); initFilter(); + initSystemConsole(); qRegisterMetaType("RedisConnectionAbstract::RedisDatabases"); qRegisterMetaType("Command"); @@ -90,6 +91,21 @@ void MainWin::initFilter() connect(ui.pbClearFilter, SIGNAL(clicked()), SLOT(OnClearFilter())); } +void MainWin::initSystemConsole() +{ + QPushButton * systemConsoleActivator = new QPushButton( QIcon(":/images/terminal.png"), "System console" ); + + connect(systemConsoleActivator, SIGNAL(clicked()), this, SLOT(OnConsoleStateChanged())); + + ui.systemConsole->hide(); + ui.statusBar->addPermanentWidget(systemConsoleActivator); +} + +void MainWin::OnConsoleStateChanged() +{ + ui.systemConsole->setVisible(!ui.systemConsole->isVisible()); +} + QString MainWin::getConfigPath(const QString& configFile) { /* @@ -390,6 +406,11 @@ void MainWin::OnError(QString msg) QMessageBox::warning(this, "Error", msg); } +void MainWin::OnLogMessage(QString message) +{ + ui.systemConsole->appendPlainText(QString("[%1] %2").arg(QTime::currentTime().toString()).arg(message)); +} + void MainWin::OnUIUnlock() { treeViewUILocked = false; diff --git a/redis-desktop-manager/source/redis/ConnectionBridge.cpp b/redis-desktop-manager/source/redis/ConnectionBridge.cpp index 5aeb7939..9bdafed0 100644 --- a/redis-desktop-manager/source/redis/ConnectionBridge.cpp +++ b/redis-desktop-manager/source/redis/ConnectionBridge.cpp @@ -29,6 +29,7 @@ void ConnectionBridge::initWorker() this, SIGNAL(dbListLoaded(RedisConnectionAbstract::RedisDatabases))); connect(worker, SIGNAL(errorOccurred(QString)),this, SIGNAL(error(QString))); + connect(worker, SIGNAL(log(QString)),this, SIGNAL(log(QString))); connect(worker, SIGNAL(operationProgress(int, QObject *)),this, SIGNAL(operationProgress(int, QObject *))); connect(workerThread, SIGNAL(finished()) , worker, SLOT(disconnect())); diff --git a/redis-desktop-manager/source/redis/RedisConnection.cpp b/redis-desktop-manager/source/redis/RedisConnection.cpp index 2541c642..c194eeca 100644 --- a/redis-desktop-manager/source/redis/RedisConnection.cpp +++ b/redis-desktop-manager/source/redis/RedisConnection.cpp @@ -32,15 +32,27 @@ bool RedisConnection::connect() socket->connectToHost(config.host, config.port); if (socket->waitForConnected(config.connectionTimeout)) - { - connected = true; - + { if (config.useAuth()) { execute(QString("AUTH %1").arg(config.auth)); } + + connected = (execute("PING") == "PONG"); + + if (!connected) + emit errorOccurred("Redis server require password or password invalid"); + } else { connected = false; - } + emit errorOccurred("Connection timeout"); + } + + if (connected) { + emit log(QString("%1 > connected").arg(config.name)); + } else { + emit log(QString("%1 > connection failed").arg(config.name)); + disconnect(); + } return connected; } @@ -71,6 +83,8 @@ QVariant RedisConnection::execute(QString command) socket->write(cmd); socket->flush(); + emit log(QString("%1 > [execute] %2").arg(config.name).arg(command)); + if (!socket->waitForReadyRead(config.executeTimeout)) { QAbstractSocket::SocketError error = socket->error(); @@ -102,30 +116,36 @@ QVariant RedisConnection::execute(QString command) if (!socket->waitForReadyRead(config.executeTimeout)) { + emit log(QString("%1 > [execute] %2 -> response partially received. Execution timeout").arg(config.name).arg(command)); break; } } } + emit log( + QString("%1 > [execute] %2 -> response received: \n %3") + .arg(config.name) + .arg(command) + .arg(response.toString())); + return response.getValue(); } void RedisConnection::runCommand(const Command &command) { - if (command.hasDbIndex()) { - selectDb(command.getDbIndex()); - } + emit log(QString("%1 > [runCommand] %2").arg(config.name).arg(command.getRawString())); + + if (command.isEmpty() + || (command.hasDbIndex() && !selectDb(command.getDbIndex())) ) { + return sendResponse(); + } resp.clear(); commandRunning = true; runningCommand = command; - executionTimer->start(config.executeTimeout); - - if (command.isEmpty()) { - return sendResponse(); - } + executionTimer->start(config.executeTimeout); // Send command QByteArray cmd = command.getByteRepresentation(); diff --git a/redis-desktop-manager/source/redis/RedisConnectionAbstract.cpp b/redis-desktop-manager/source/redis/RedisConnectionAbstract.cpp index 1ba32ac7..80a425e2 100644 --- a/redis-desktop-manager/source/redis/RedisConnectionAbstract.cpp +++ b/redis-desktop-manager/source/redis/RedisConnectionAbstract.cpp @@ -135,6 +135,8 @@ void RedisConnectionAbstract::sendResponse() emit responseResived(resp.getValue(), runningCommand.getOwner()); } + emit log(QString("%1 > [runCommand] %2 -> response recieved").arg(config.name).arg(runningCommand.getRawString())); + commandRunning = false; processCommandQueue(); diff --git a/redis-desktop-manager/source/redis/RedisConnectionOverSsh.cpp b/redis-desktop-manager/source/redis/RedisConnectionOverSsh.cpp index 5678b1ea..a038cbf4 100644 --- a/redis-desktop-manager/source/redis/RedisConnectionOverSsh.cpp +++ b/redis-desktop-manager/source/redis/RedisConnectionOverSsh.cpp @@ -60,6 +60,7 @@ bool RedisConnectionOverSsh::connect() if (socket == NULL) { socketConnected = false; + emit errorOccurred(QString("SSH connection established, but redis connection failed")); return socketConnected; } @@ -70,7 +71,7 @@ bool RedisConnectionOverSsh::connect() if (!socketConnected && !syncTimer->isActive()) { socketConnected = false; - emit errorOccurred(QString("SSH connection established, but redis connection error occurred")); + emit errorOccurred(QString("SSH connection established, but redis connection failed")); return socketConnected; } @@ -78,6 +79,16 @@ bool RedisConnectionOverSsh::connect() execute(QString("AUTH %1").arg(config.auth)); } + connected = (execute("PING") == "PONG"); + + if (connected) { + emit log(QString("%1 > connected").arg(config.name)); + } else { + emit errorOccurred("Redis server require password or password invalid"); + emit log(QString("%1 > connection failed").arg(config.name)); + disconnect(); + } + return socketConnected; } @@ -213,6 +224,8 @@ QVariant RedisConnectionOverSsh::execute(QString command) socket->write(cString, byteArray.size()); + emit log(QString("%1 > [execute] %2").arg(config.name).arg(command)); + //wait for ready read syncTimer->start(config.executeTimeout); syncLoop->exec(); @@ -260,16 +273,26 @@ QVariant RedisConnectionOverSsh::execute(QString command) continue; } + emit log(QString("%1 > [execute] %2 -> response partially received. Execution timeout").arg(config.name).arg(command)); + break; } } + emit log( + QString("%1 > [execute] %2 -> response received: \n %3") + .arg(config.name) + .arg(command) + .arg(response.toString())); + return response.getValue(); } void RedisConnectionOverSsh::runCommand(const Command &command) { + emit log(QString("%1 > [runCommand] %2").arg(config.name).arg(command.getRawString())); + if (command.isEmpty() || (command.hasDbIndex() && !selectDb(command.getDbIndex())) ) { return sendResponse(); diff --git a/redis-desktop-manager/source/redis/RedisConnectionsManager.cpp b/redis-desktop-manager/source/redis/RedisConnectionsManager.cpp index 7f158a86..91f41f3f 100644 --- a/redis-desktop-manager/source/redis/RedisConnectionsManager.cpp +++ b/redis-desktop-manager/source/redis/RedisConnectionsManager.cpp @@ -34,6 +34,7 @@ void RedisConnectionsManager::AddConnection(ConnectionBridge * c) QObject::connect(item, SIGNAL(databasesLoaded()), this, SLOT(updateFilter())); MainWin * errorViewForm = (MainWin *) parent(); QObject::connect(item, SIGNAL(error(QString)), errorViewForm, SLOT(OnError(QString))); + QObject::connect(c, SIGNAL(log(QString)), errorViewForm, SLOT(OnLogMessage(QString))); QObject::connect(item, SIGNAL(unlockUI()), errorViewForm, SLOT(OnUIUnlock())); QObject::connect(item, SIGNAL(statusMessage(QString)), errorViewForm, SLOT(OnStatusMessage(QString))); diff --git a/redis-desktop-manager/source/redis/Response.cpp b/redis-desktop-manager/source/redis/Response.cpp index 2b1964f3..6101cec9 100644 --- a/redis-desktop-manager/source/redis/Response.cpp +++ b/redis-desktop-manager/source/redis/Response.cpp @@ -42,6 +42,11 @@ void Response::appendToSource(QByteArray& src) responseSource.append(src); } +QString Response::toString() +{ + return responseSource.left(1500); +} + QVariant Response::getValue() { if (responseSource.isEmpty()) { diff --git a/redis-desktop-manager/version.h b/redis-desktop-manager/version.h index 2dc6024b..fe4df192 100644 --- a/redis-desktop-manager/version.h +++ b/redis-desktop-manager/version.h @@ -1,3 +1,3 @@ #ifndef RDM_VERSION - #define RDM_VERSION "0.7.5" + #define RDM_VERSION "0.7.6" #endif // !RDM_VERSION