get transaction history into qml

This commit is contained in:
David Kelly 2017-08-25 13:55:38 -07:00
parent c5fbd5a2a5
commit f015ac3c68
5 changed files with 31 additions and 0 deletions

View file

@ -39,6 +39,12 @@ Item {
onBalanceResult : {
balanceText.text = parseFloat(result.data.balance/100).toFixed(2);
}
onHistoryResult : {
if (result.status == 'success') {
transactionHistory.text = result.data.history;
}
}
}
SecurityImageModel {
@ -105,6 +111,7 @@ Item {
onVisibleChanged: {
if (visible) {
commerce.balance();
commerce.history();
}
}
}
@ -228,6 +235,7 @@ Item {
// some placeholder stuff
RalewayRegular {
id: transactionHistoryText;
text: homeMessage.visible ? "you <b>CANNOT</b> scroll through this." : "you <b>CAN</b> scroll through this";
// Text size
size: 16;

View file

@ -45,6 +45,7 @@ Handler(buy)
Handler(receiveAt)
Handler(balance)
Handler(inventory)
Handler(history)
void Ledger::send(const QString& endpoint, const QString& success, const QString& fail, QNetworkAccessManager::Operation method, QJsonObject request) {
auto accountManager = DependencyManager::get<AccountManager>();
@ -107,3 +108,6 @@ void Ledger::inventory(const QStringList& keys) {
keysQuery("inventory", "inventorySuccess", "inventoryFailure");
}
void Ledger::history(const QStringList& keys) {
keysQuery("history", "historySuccess", "historyFailure");
}

View file

@ -28,12 +28,14 @@ public:
bool receiveAt(const QString& hfc_key, const QString& old_key);
void balance(const QStringList& keys);
void inventory(const QStringList& keys);
void history(const QStringList& keys);
signals:
void buyResult(QJsonObject result);
void receiveAtResult(QJsonObject result);
void balanceResult(QJsonObject result);
void inventoryResult(QJsonObject result);
void historyResult(QJsonObject result);
public slots:
void buySuccess(QNetworkReply& reply);
@ -44,6 +46,8 @@ public slots:
void balanceFailure(QNetworkReply& reply);
void inventorySuccess(QNetworkReply& reply);
void inventoryFailure(QNetworkReply& reply);
void historySuccess(QNetworkReply& reply);
void historyFailure(QNetworkReply& reply);
private:
QJsonObject apiResponse(const QString& label, QNetworkReply& reply);

View file

@ -26,6 +26,7 @@ QmlCommerce::QmlCommerce(QQuickItem* parent) : OffscreenQmlDialog(parent) {
connect(ledger.data(), &Ledger::inventoryResult, this, &QmlCommerce::inventoryResult);
connect(wallet.data(), &Wallet::securityImageResult, this, &QmlCommerce::securityImageResult);
connect(wallet.data(), &Wallet::keyFilePathResult, this, &QmlCommerce::keyFilePathResult);
connect(ledger.data(), &Ledger::historyResult, this, &QmlCommerce::historyResult);
}
void QmlCommerce::buy(const QString& assetId, int cost, const QString& buyerUsername) {
@ -46,29 +47,41 @@ void QmlCommerce::balance() {
auto wallet = DependencyManager::get<Wallet>();
ledger->balance(wallet->listPublicKeys());
}
void QmlCommerce::inventory() {
auto ledger = DependencyManager::get<Ledger>();
auto wallet = DependencyManager::get<Wallet>();
ledger->inventory(wallet->listPublicKeys());
}
void QmlCommerce::history() {
auto ledger = DependencyManager::get<Ledger>();
auto wallet = DependencyManager::get<Wallet>();
ledger->history(wallet->listPublicKeys());
}
void QmlCommerce::chooseSecurityImage(const QString& imageFile) {
auto wallet = DependencyManager::get<Wallet>();
wallet->chooseSecurityImage(imageFile);
}
void QmlCommerce::getSecurityImage() {
auto wallet = DependencyManager::get<Wallet>();
wallet->getSecurityImage();
}
void QmlCommerce::getLoginStatus() {
emit loginStatusResult(DependencyManager::get<AccountManager>()->isLoggedIn());
}
void QmlCommerce::setPassphrase(const QString& passphrase) {
emit passphraseSetupStatusResult(true);
}
void QmlCommerce::getPassphraseSetupStatus() {
emit passphraseSetupStatusResult(false);
}
void QmlCommerce::getKeyFilePath() {
auto wallet = DependencyManager::get<Wallet>();
wallet->getKeyFilePath();

View file

@ -37,11 +37,13 @@ signals:
void loginStatusResult(bool isLoggedIn);
void passphraseSetupStatusResult(bool passphraseIsSetup);
void keyFilePathResult(const QString& path);
void historyResult(QJsonObject result);
protected:
Q_INVOKABLE void buy(const QString& assetId, int cost, const QString& buyerUsername = "");
Q_INVOKABLE void balance();
Q_INVOKABLE void inventory();
Q_INVOKABLE void history();
Q_INVOKABLE void chooseSecurityImage(const QString& imageFile);
Q_INVOKABLE void getSecurityImage();
Q_INVOKABLE void getLoginStatus();