pretty-print json display
This commit is contained in:
parent
d0becd0c3c
commit
5ea969e10c
@ -77,7 +77,7 @@ bool BoltDB::pumpNext(GoInt64 jobRef, QString& errorOut, NameReciever cb)
|
||||
return (errorOut.length() == 0);
|
||||
}
|
||||
|
||||
bool BoltDB::getStatsJSON(std::function<void(QString)> onSuccess, std::function<void(QString)> onError)
|
||||
bool BoltDB::getStatsJSON(std::function<void(QByteArray)> onSuccess, std::function<void(QString)> onError)
|
||||
{
|
||||
auto statresp = Bolt_DBStats(this->gmsDbRef);
|
||||
|
||||
@ -88,9 +88,8 @@ bool BoltDB::getStatsJSON(std::function<void(QString)> onSuccess, std::function<
|
||||
return false;
|
||||
|
||||
} else if (statresp.r0 == REAL_MESSAGE) {
|
||||
QString json = QString::fromUtf8(statresp.r1, statresp.r2);
|
||||
onSuccess(QByteArray(statresp.r1, statresp.r2));
|
||||
free(statresp.r1);
|
||||
onSuccess(json);
|
||||
return true;
|
||||
|
||||
} else {
|
||||
@ -99,7 +98,7 @@ bool BoltDB::getStatsJSON(std::function<void(QString)> onSuccess, std::function<
|
||||
}
|
||||
}
|
||||
|
||||
bool BoltDB::getBucketStatsJSON(QStringList bucketPath, std::function<void(QString)> onSuccess, std::function<void(QString)> onError)
|
||||
bool BoltDB::getBucketStatsJSON(QStringList bucketPath, std::function<void(QByteArray)> onSuccess, std::function<void(QString)> onError)
|
||||
{
|
||||
GoSliceManagedWrapper sliceWrapper(&bucketPath);
|
||||
auto statresp = Bolt_BucketStats(this->gmsDbRef, sliceWrapper.slice);
|
||||
@ -111,9 +110,8 @@ bool BoltDB::getBucketStatsJSON(QStringList bucketPath, std::function<void(QStri
|
||||
return false;
|
||||
|
||||
} else if (statresp.r0 == REAL_MESSAGE) {
|
||||
QString json = QString::fromUtf8(statresp.r1, statresp.r2);
|
||||
onSuccess(QByteArray(statresp.r1, statresp.r2));
|
||||
free(statresp.r1);
|
||||
onSuccess(json);
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
@ -20,9 +20,9 @@ public:
|
||||
|
||||
bool listBuckets(QStringList bucketPath, QString& errorOut, NameReciever cb);
|
||||
|
||||
bool getStatsJSON(std::function<void(QString)> onSuccess, std::function<void(QString)> onError);
|
||||
bool getStatsJSON(std::function<void(QByteArray)> onSuccess, std::function<void(QString)> onError);
|
||||
|
||||
bool getBucketStatsJSON(QStringList bucketPath, std::function<void(QString)> onSuccess, std::function<void(QString)> onError);
|
||||
bool getBucketStatsJSON(QStringList bucketPath, std::function<void(QByteArray)> onSuccess, std::function<void(QString)> onError);
|
||||
|
||||
~BoltDB();
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QJsonDocument>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
@ -177,8 +178,9 @@ void MainWindow::on_bucketTree_currentItemChanged(QTreeWidgetItem *current, QTre
|
||||
|
||||
auto *bdb = GET_BDB(current);
|
||||
bdb->getStatsJSON(
|
||||
[=](QString j) {
|
||||
ui->databasePropertiesArea->setPlainText(j);
|
||||
[=](QByteArray j) {
|
||||
auto doc = QJsonDocument::fromJson(j);
|
||||
ui->databasePropertiesArea->setPlainText(QString::fromUtf8(doc.toJson(QJsonDocument::Indented)));
|
||||
},
|
||||
[=](QString error) {
|
||||
ui->databasePropertiesArea->setPlainText(tr("Error retrieving database statistics: %1").arg(error));
|
||||
@ -201,8 +203,9 @@ void MainWindow::on_bucketTree_currentItemChanged(QTreeWidgetItem *current, QTre
|
||||
|
||||
bdb->getBucketStatsJSON(
|
||||
browse,
|
||||
[=](QString j) {
|
||||
ui->bucketPropertiesArea->setPlainText(j);
|
||||
[=](QByteArray j) {
|
||||
auto doc = QJsonDocument::fromJson(j);
|
||||
ui->bucketPropertiesArea->setPlainText(QString::fromUtf8(doc.toJson(QJsonDocument::Indented)));
|
||||
},
|
||||
[=](QString error) {
|
||||
ui->bucketPropertiesArea->setPlainText(tr("Error retrieving bucket statistics: %1").arg(error));
|
||||
|
Loading…
Reference in New Issue
Block a user