Skip to content

Commit 64715cf

Browse files
authored
RedisDesktopManager 0.9.0-alpha4 (RedisInsight#3781)
New features and improvements: - Add initial implementation of Native Formatters (RedisInsight#3534) - Add support for Pub/Sub commands in console - Remove build-in zlib compression/decompression - Remove php-unserialize.js formatter - Remove msgpack.js formatter - Update translations - Improve connections dialog - Remove qgamp and clean code - Migrate to Qt 5.8 - Change breakpad origin to github Fixes: - Fix issue RedisInsight#3732: RDM shows invalid error message when trying to connect to invalid host/port - Fix issue RedisInsight#3758: RDM Shows Key Values for One Key Only - Fix tree rendering with multi-char NS - Fix issue RedisInsight#3724: Load NS seperator from connection settings in NS deletion - Fix RedisInsight#3691: RDM doesn't fade deleted keys & namespaces - Fix issue RedisInsight#3791: Model doesn't hide removed row on page > 1
1 parent 1dac2ff commit 64715cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1018
-1397
lines changed

.gitmodules

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,4 @@
99
url = https://github.com/uglide/qredisclient.git
1010
[submodule "3rdparty/gbreakpad"]
1111
path = 3rdparty/gbreakpad
12-
url = https://chromium.googlesource.com/breakpad/breakpad
13-
[submodule "3rdparty/qgamp"]
14-
path = 3rdparty/qgamp
15-
url = https://github.com/uglide/qgamp.git
16-
[submodule "src/qml/3rdparty/php-unserialize-js"]
17-
path = src/qml/3rdparty/php-unserialize-js
18-
url = https://github.com/uglide/php-unserialize-js.git
12+
url = https://github.com/google/breakpad.git

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ install:
1515
fi
1616
- cd ./src && ./configure && cd ./../
1717
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
18-
source /opt/qt57/bin/qt57-env.sh
18+
source /opt/qt58/bin/qt58-env.sh
1919
;
2020
fi
2121
- qmake -v

3rdparty/3rdparty.pri

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ OTHER_FILES += $$PWD/../src/resources/qml/3rdparty/php-unserialize-js/phpUnseria
99
# qredisclient
1010
include($$PWD/qredisclient/qredisclient.pri)
1111

12-
#qgamp
13-
include($$PWD/qgamp/qgamp.pri)
14-
DEFINES += GMP_ID=\\\"UA-68484170-1\\\"
15-
1612
# Easylogging
1713
INCLUDEPATH += $$PWD/easyloggingpp/src
1814
HEADERS += $$PWD/easyloggingpp/src/easylogging++.h

3rdparty/gbreakpad

Submodule gbreakpad updated 276 files

3rdparty/qgamp

Lines changed: 0 additions & 1 deletion
This file was deleted.

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 0.9.0.{build}
33
clone_depth: 5
44
install:
55
- git submodule update --init --recursive
6-
- set QTDIR=C:\Qt\5.7\msvc2015
6+
- set QTDIR=C:\Qt\5.8\msvc2015
77
- set PATH=%QTDIR%\bin;%PATH%
88
- call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
99
- nuget install -Version 1.6.0.2 -OutputDirectory ./3rdparty/qredisclient/3rdparty/windows rmt_libssh2

build/common_functions

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@ function build_breakpad {
1111
git clone https://chromium.googlesource.com/linux-syscall-support src/third_party/lss || true
1212
touch README
1313
./configure
14-
make -j 2
14+
make -s -j 2
1515
}
1616

1717
function build_libssh2 {
18-
cd $DEPS_DIR
19-
git clone https://github.com/libssh2/libssh2.git libssh2 || true
20-
cd libssh2
21-
mkdir bin || rm -fR ./bin && mkdir bin
22-
cd bin
23-
cmake -DCRYPTO_BACKEND=OpenSSL -DENABLE_ZLIB_COMPRESSION=ON ..
24-
cmake --build .
25-
sudo make install
18+
if [ ! -f /usr/local/lib/libssh2.a ]; then
19+
cd $DEPS_DIR
20+
git clone https://github.com/libssh2/libssh2.git libssh2 || true
21+
cd libssh2
22+
mkdir bin || rm -fR ./bin && mkdir bin
23+
cd bin
24+
cmake -DCRYPTO_BACKEND=OpenSSL -DENABLE_ZLIB_COMPRESSION=ON ..
25+
cmake --build .
26+
sudo make install
27+
fi
2628
}
2729

2830
function print_line {

src/app/app.cpp

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <QSettings>
88
#include <QMessageBox>
99
#include <easylogging++.h>
10-
#include <googlemp.h>
1110
#include <qredisclient/redisclient.h>
1211

1312
#include "logger.h"
@@ -21,21 +20,14 @@
2120
#include "modules/value-editor/valueviewmodel.h"
2221
#include "modules/value-editor/viewmodel.h"
2322
#include "modules/value-editor/sortfilterproxymodel.h"
23+
#include "modules/value-editor/formattersmanager.h"
2424
#include "modules/console/consolemodel.h"
2525
#include "modules/server-stats/serverstatsmodel.h"
2626
#include "modules/bulk-operations/bulkoperationsmanager.h"
2727

2828

2929
INITIALIZE_EASYLOGGINGPP
3030

31-
static QObject *analytics_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
32-
{
33-
Q_UNUSED(engine)
34-
Q_UNUSED(scriptEngine)
35-
36-
GoogleMP *gmp = GoogleMP::instance();
37-
return gmp;
38-
}
3931

4032
Application::Application(int &argc, char **argv)
4133
: QApplication(argc, argv),
@@ -45,8 +37,7 @@ Application::Application(int &argc, char **argv)
4537
// Init components required for models and qml
4638
initLog();
4739
initAppInfo();
48-
initAppFonts();
49-
initAppAnalytics();
40+
initAppFonts();
5041
initRedisClient();
5142
initUpdater();
5243
installTranslator();
@@ -65,6 +56,9 @@ void Application::initModels()
6556

6657
connect(m_connections.data(), &ConnectionsManager::openServerStats,
6758
m_serverStatsModel.data(), &TabViewModel::openTab);
59+
60+
m_formattersManager = QSharedPointer<ValueEditor::FormattersManager>(new ValueEditor::FormattersManager());
61+
m_formattersManager->loadFormatters();
6862
}
6963

7064
void Application::initAppInfo()
@@ -103,17 +97,10 @@ void Application::initAppFonts()
10397
QApplication::setFont(defaultFont);
10498
}
10599

106-
void Application::initAppAnalytics()
107-
{
108-
GoogleMP::startSession(QDateTime::currentMSecsSinceEpoch());
109-
GoogleMP::instance()->reportEvent("rdm:cpp", "app start", "");
110-
}
111-
112100
void Application::registerQmlTypes()
113101
{
114102
qmlRegisterType<ValueEditor::ValueViewModel>("rdm.models", 1, 0, "ValueViewModel");
115-
qmlRegisterType<SortFilterProxyModel>("rdm.models", 1, 0, "SortFilterProxyModel");
116-
qmlRegisterSingletonType<GoogleMP>("MeasurementProtocol", 1, 0, "Analytics", analytics_singletontype_provider);
103+
qmlRegisterType<SortFilterProxyModel>("rdm.models", 1, 0, "SortFilterProxyModel");
117104
qRegisterMetaType<ServerConfig>();
118105
}
119106

@@ -124,14 +111,15 @@ void Application::registerQmlRootObjects()
124111
m_engine.rootContext()->setContextProperty("connectionsManager", m_connections.data());
125112
m_engine.rootContext()->setContextProperty("viewModel", m_keyValues.data()); // TODO: Remove legacy name usage in qml
126113
m_engine.rootContext()->setContextProperty("valuesModel", m_keyValues.data());
114+
m_engine.rootContext()->setContextProperty("formattersManager", m_formattersManager.data());
127115
m_engine.rootContext()->setContextProperty("consoleModel", m_consoleModel.data());
128116
m_engine.rootContext()->setContextProperty("serverStatsModel", m_serverStatsModel.data());
129117
m_engine.rootContext()->setContextProperty("appLogger", m_logger);
130118
m_engine.rootContext()->setContextProperty("bulkOperations", m_bulkOperations.data());
131119
}
132120

133121
void Application::initQml()
134-
{
122+
{
135123
registerQmlTypes();
136124
registerQmlRootObjects();
137125
m_engine.load(QUrl(QStringLiteral("qrc:///app.qml")));

src/app/app.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <QQmlApplicationEngine>
55
#include <QFontDatabase>
66
#include <QMenu>
7-
#include <googlemp.h>
87

98
#ifndef RDM_VERSION
109
#include "../version.h"
@@ -16,6 +15,7 @@ class Updater;
1615
class LogHandler;
1716
class TabViewModel;
1817
namespace ValueEditor { class ViewModel; }
18+
namespace ValueEditor { class FormattersManager; }
1919
namespace BulkOperations { class Manager; }
2020

2121

@@ -30,8 +30,7 @@ class Application : public QApplication
3030

3131
private:
3232
void initAppInfo();
33-
void initAppFonts();
34-
void initAppAnalytics();
33+
void initAppFonts();
3534
void registerQmlTypes();
3635
void registerQmlRootObjects();
3736
void initLog();
@@ -48,6 +47,7 @@ private slots:
4847
QSharedPointer<ConnectionsManager> m_connections;
4948
QSharedPointer<Updater> m_updater;
5049
QSharedPointer<ValueEditor::ViewModel> m_keyValues;
50+
QSharedPointer<ValueEditor::FormattersManager> m_formattersManager;
5151
QSharedPointer<BulkOperations::Manager> m_bulkOperations;
5252
QSharedPointer<TabViewModel> m_consoleModel;
5353
QSharedPointer<TabViewModel> m_serverStatsModel;

src/app/models/configmanager.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,7 @@ ConfigManager::ConfigManager(const QString &basePath)
1919

2020
QString ConfigManager::getApplicationConfigPath(const QString &configFile, bool checkPath)
2121
{
22-
QString configDir;
23-
#ifdef Q_OS_MACX
24-
configDir = QDir::toNativeSeparators(
25-
QString("%1/%2").arg(m_basePath).arg("/Library/Preferences/rdm/")
26-
);
27-
#else
28-
configDir = QDir::toNativeSeparators(
29-
QString("%1/%2").arg(m_basePath).arg(".rdm")
30-
);
31-
#endif
22+
QString configDir = getConfigPath(m_basePath);
3223
QDir settingsPath(configDir);
3324

3425
if (!settingsPath.exists() && settingsPath.mkpath(configDir)) {
@@ -189,6 +180,21 @@ void ConfigManager::setPermissions(QFile &file)
189180
#endif
190181
}
191182

183+
QString ConfigManager::getConfigPath(QString basePath)
184+
{
185+
QString configDir;
186+
#ifdef Q_OS_MACX
187+
configDir = QDir::toNativeSeparators(
188+
QString("%1/%2").arg(basePath).arg("/Library/Preferences/rdm/")
189+
);
190+
#else
191+
configDir = QDir::toNativeSeparators(
192+
QString("%1/%2").arg(basePath).arg(".rdm")
193+
);
194+
#endif
195+
return configDir;
196+
}
197+
192198
bool saveJsonArrayToFile(const QJsonArray &c, const QString &f)
193199
{
194200
QJsonDocument config(c);

src/app/models/configmanager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ class ConfigManager
1111
QString getApplicationConfigPath(const QString &, bool checkPath=true);
1212
bool migrateOldConfig(const QString &oldFileName, const QString &newFileName);
1313
public:
14+
static QString getConfigPath(QString basePath = QDir::homePath());
1415
static QJsonArray xmlConfigToJsonArray(const QString &xmlConfigPath);
1516

1617
private:
1718
static bool chechPath(const QString&);
18-
static void setPermissions(QFile&);
19+
static void setPermissions(QFile&);
1920
private:
2021
QString m_basePath;
2122
};

src/app/models/key-models/abstractkey.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ template < typename T > class KeyModel : public ValueEditor::Model
9494
virtual void setTTL(const long long ttl) override
9595
{
9696
RedisClient::Response result;
97-
qDebug(QString("TTL=%1").arg(ttl).toLatin1().constData());
97+
qDebug() << QString("TTL=%1").arg(ttl);
9898
try {
9999
if (ttl >= 0)
100100
result = m_connection->commandSync({"EXPIRE", m_keyFullPath, QString::number(ttl).toLatin1()}, m_dbIndex);
@@ -105,7 +105,7 @@ template < typename T > class KeyModel : public ValueEditor::Model
105105
}
106106

107107
if (result.getValue().toInt() == 0) {
108-
throw Exception("Not supprt TTL at this key");
108+
throw Exception("Not support TTL at this key");
109109
}
110110
if (ttl >= 0)
111111
m_ttl = ttl;

src/app/models/key-models/stringkey.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void StringKeyModel::loadRows(unsigned long, unsigned long, std::function<void(c
7373
m_connection->command({"GET", m_keyFullPath}, getConnector().data(),
7474
[this, callback](RedisClient::Response r, QString e)
7575
{
76-
if (r.getType() != RedisClient::Response::Bulk) {
76+
if (r.getType() != RedisClient::Response::Bulk || !e.isEmpty()) {
7777
return callback(QString("Cannot load value"));
7878
}
7979

src/app/models/treeoperations.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,21 @@ TreeOperations::TreeOperations(QSharedPointer<RedisClient::Connection> connectio
2020

2121
void TreeOperations::getDatabases(std::function<void (RedisClient::DatabaseList)> callback)
2222
{
23-
if (!m_connection->isConnected()) {
23+
bool connected = m_connection->isConnected();
24+
25+
if (!connected) {
2426
try {
25-
m_connection->connect(true);
27+
connected = m_connection->connect(true);
2628
} catch (const RedisClient::Connection::Exception& e) {
2729
throw ConnectionsTree::Operations::Exception(QObject::tr("Connection error: ") + QString(e.what()));
2830
}
2931
}
3032

33+
if (!connected) {
34+
throw ConnectionsTree::Operations::Exception(
35+
QObject::tr("Cannot connect to server '%1'. Check log for details.").arg(m_connection->getConfig().name()));
36+
}
37+
3138
if (m_connection->getServerVersion() < 2.8)
3239
throw ConnectionsTree::Operations::Exception(QObject::tr("RedisDesktopManager >= 0.9.0 doesn't support old versions of "
3340
"redis-server (< 2.8). Please use RedisDesktopManager 0.8.8 or upgrade your redis-server."));
@@ -116,9 +123,9 @@ void TreeOperations::deleteDbKey(ConnectionsTree::KeyItem& key, std::function<vo
116123
return;
117124
}
118125

119-
QRegExp filter(key.getFullPath(), Qt::CaseSensitive, QRegExp::Wildcard);
120-
emit m_manager.closeDbKeys(m_connection, key.getDbIndex(), filter);
121126
key.setRemoved();
127+
QRegExp filter(key.getFullPath(), Qt::CaseSensitive, QRegExp::Wildcard);
128+
emit m_manager.closeDbKeys(m_connection, key.getDbIndex(), filter);
122129
};
123130

124131
try {
@@ -130,7 +137,9 @@ void TreeOperations::deleteDbKey(ConnectionsTree::KeyItem& key, std::function<vo
130137

131138
void TreeOperations::deleteDbNamespace(ConnectionsTree::NamespaceItem &ns)
132139
{
133-
QString pattern = QString("%1:*").arg(QString::fromUtf8(ns.getFullPath()));
140+
QString pattern = QString("%1%2*")
141+
.arg(QString::fromUtf8(ns.getFullPath()))
142+
.arg(static_cast<ServerConfig>(m_connection->getConfig()).namespaceSeparator());
134143
QRegExp filter(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
135144

136145
int dbIndex = ns.getDbIndex();

src/app/qmlutils.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@ long QmlUtils::binaryStringLength(const QVariant &value)
2424
return val.size();
2525
}
2626

27+
QString QmlUtils::humanSize(long size)
28+
{
29+
double num = size;
30+
QStringList list;
31+
list << "KB" << "MB" << "GB";
32+
33+
QStringListIterator i(list);
34+
QString unit("bytes");
35+
36+
while(num >= 1024.0 && i.hasNext())
37+
{
38+
unit = i.next();
39+
num /= 1024.0;
40+
}
41+
return QString().setNum(num,'f',2)+" "+unit;
42+
}
43+
44+
2745
QVariant QmlUtils::valueToBinary(const QVariant &value)
2846
{
2947
if (!value.canConvert(QVariant::ByteArray)) {
@@ -48,13 +66,18 @@ QVariant QmlUtils::binaryListToValue(const QVariantList &binaryList)
4866
return value;
4967
}
5068

51-
QVariant QmlUtils::printable(const QVariant &value)
69+
QVariant QmlUtils::printable(const QVariant &value, bool htmlEscaped)
5270
{
5371
if (!value.canConvert(QVariant::ByteArray)) {
5472
return QVariant();
5573
}
5674
QByteArray val = value.toByteArray();
57-
return printableString(val);
75+
76+
if (htmlEscaped) {
77+
return printableString(val).toHtmlEscaped();
78+
} else {
79+
return printableString(val);
80+
}
5881
}
5982

6083
QVariant QmlUtils::printableToValue(const QVariant &printable)

src/app/qmlutils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ class QmlUtils : public QObject
1111
public:
1212
Q_INVOKABLE bool isBinaryString(const QVariant &value);
1313
Q_INVOKABLE long binaryStringLength(const QVariant &value);
14+
Q_INVOKABLE QString humanSize(long size);
1415
Q_INVOKABLE QVariant valueToBinary(const QVariant &value);
1516
Q_INVOKABLE QVariant binaryListToValue(const QVariantList& binaryList);
16-
Q_INVOKABLE QVariant printable(const QVariant &value);
17+
Q_INVOKABLE QVariant printable(const QVariant &value, bool htmlEscaped=false);
1718
Q_INVOKABLE QVariant printableToValue(const QVariant &printable);
1819
Q_INVOKABLE QVariant toUtf(const QVariant &value);
1920
Q_INVOKABLE QString getPathFromUrl(const QUrl &url);

0 commit comments

Comments
 (0)