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