From 72a2ac36fef07f20062e8a7ee8477ec78c9baa50 Mon Sep 17 00:00:00 2001 From: denis <denis.sumin> Date: Wed, 26 Jul 2023 18:20:20 +0300 Subject: [PATCH 1/2] [+] add tool console cmd and more fixes --- .../CellFrameDashboardGUI.pro | 2 + .../Modules/Console/DapModuleConsole.cpp | 16 +++- .../Modules/Console/DapModuleConsole.h | 16 ++++ .../Diagnostics/AbstractDiagnostic.cpp | 8 +- .../Modules/Wallet/DapTxWorker.cpp | 7 ++ .../Modules/Wallet/DapTxWorker.h | 20 ++++ .../BlackTheme/icons/other/icon_wiki.svg | 6 ++ CellFrameDashboardGUI/qml.qrc | 2 + .../screen/desktop/Console/DapConsoleTab.qml | 2 +- .../desktop/Console/DapConsoleTopPanel.qml | 91 +++++++++++++++++++ .../DapNewPaymentMainRightPanel.qml | 17 ++-- .../DapNewPaymentMainRightPanelForm.qml | 14 +++ .../DapServiceController.cpp | 2 +- cellframe-node | 2 +- cellframe-ui-sdk | 2 +- dap-ui-sdk | 2 +- version.mk | 2 +- web3_api | 2 +- 18 files changed, 196 insertions(+), 17 deletions(-) create mode 100644 CellFrameDashboardGUI/Modules/Wallet/DapTxWorker.cpp create mode 100644 CellFrameDashboardGUI/Modules/Wallet/DapTxWorker.h create mode 100644 CellFrameDashboardGUI/Resources/BlackTheme/icons/other/icon_wiki.svg create mode 100644 CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTopPanel.qml diff --git a/CellFrameDashboardGUI/CellFrameDashboardGUI.pro b/CellFrameDashboardGUI/CellFrameDashboardGUI.pro index ee40b83de..466adbb91 100644 --- a/CellFrameDashboardGUI/CellFrameDashboardGUI.pro +++ b/CellFrameDashboardGUI/CellFrameDashboardGUI.pro @@ -35,6 +35,7 @@ HEADERS += $$PWD/DapServiceController.h \ Modules/Tokens/DapModuleTokens.h \ Modules/TxExplorer/DapModuleTxExplorer.h \ Modules/Wallet/DapModuleWallet.h \ + Modules/Wallet/DapTxWorker.h \ Modules/Wallet/WalletRestore/randomfile.h \ Modules/Wallet/WalletRestore/randomwords.h \ Modules/Wallet/WalletRestore/wallethashmanager.h \ @@ -89,6 +90,7 @@ SOURCES += $$PWD/main.cpp \ Modules/Tokens/DapModuleTokens.cpp \ Modules/TxExplorer/DapModuleTxExplorer.cpp \ Modules/Wallet/DapModuleWallet.cpp \ + Modules/Wallet/DapTxWorker.cpp \ Modules/Wallet/WalletRestore/randomfile.cpp \ Modules/Wallet/WalletRestore/randomwords.cpp \ Modules/Wallet/WalletRestore/wallethashmanager.cpp \ diff --git a/CellFrameDashboardGUI/Modules/Console/DapModuleConsole.cpp b/CellFrameDashboardGUI/Modules/Console/DapModuleConsole.cpp index 0d6c41058..9002c7101 100644 --- a/CellFrameDashboardGUI/Modules/Console/DapModuleConsole.cpp +++ b/CellFrameDashboardGUI/Modules/Console/DapModuleConsole.cpp @@ -8,6 +8,7 @@ DapModuleConsole::DapModuleConsole(DapModulesController *parent) : DapAbstractModule(parent) , m_modulesCtrl(parent) { + m_currentMode = (ConsoleMode)QSettings().value("ConsoleMode", 0).toInt(); connect(s_serviceCtrl, &DapServiceController::cmdRunned, this, &DapModuleConsole::getAnswer); m_modulesCtrl->s_appEngine->rootContext()->setContextProperty("modelConsoleCommand", model); @@ -20,7 +21,7 @@ void DapModuleConsole::runCommand(const QString &command) QVariantList args; args.append(command); args.append("isConsole"); - args.append(""); + args.append((int)m_currentMode); s_serviceCtrl->requestToService("DapRunCmdCommand", args); @@ -46,3 +47,16 @@ void DapModuleConsole::clearModel() m_modulesCtrl->s_appEngine->rootContext()->setContextProperty("modelConsoleCommand", model); } + +int DapModuleConsole::Mode() +{ + return (int)m_currentMode; +} + +void DapModuleConsole::setMode(int mode) +{ + m_currentMode = (ConsoleMode)mode; + QSettings().setValue("ConsoleMode", mode); + + emit ModeChanged(); +} diff --git a/CellFrameDashboardGUI/Modules/Console/DapModuleConsole.h b/CellFrameDashboardGUI/Modules/Console/DapModuleConsole.h index 92c6647f8..5231124ee 100644 --- a/CellFrameDashboardGUI/Modules/Console/DapModuleConsole.h +++ b/CellFrameDashboardGUI/Modules/Console/DapModuleConsole.h @@ -4,6 +4,7 @@ #include <QObject> #include "../DapAbstractModule.h" #include "../DapModulesController.h" +#include "QSettings" class DapModuleConsole : public DapAbstractModule { @@ -14,6 +15,18 @@ public: Q_INVOKABLE void runCommand(const QString &command); Q_INVOKABLE void clearModel(); + enum ConsoleMode{ + CLI_MODE = 0, + TOOL_MODE = 1 + }; + + ConsoleMode m_currentMode{ConsoleMode::CLI_MODE}; + + Q_PROPERTY(int Mode READ Mode WRITE setMode NOTIFY ModeChanged) + int Mode(); + void setMode(int mode); + + private slots: void getAnswer(const QVariant &answer); @@ -21,6 +34,9 @@ private: DapModulesController* m_modulesCtrl; QVariantList model; + +signals: + void ModeChanged(); }; #endif // DAPMODULECONSOLE_H diff --git a/CellFrameDashboardGUI/Modules/Diagnostics/AbstractDiagnostic.cpp b/CellFrameDashboardGUI/Modules/Diagnostics/AbstractDiagnostic.cpp index d3bbaeeb1..2a1537bf7 100644 --- a/CellFrameDashboardGUI/Modules/Diagnostics/AbstractDiagnostic.cpp +++ b/CellFrameDashboardGUI/Modules/Diagnostics/AbstractDiagnostic.cpp @@ -171,7 +171,7 @@ void AbstractDiagnostic::start_write(bool isStart) void AbstractDiagnostic::remove_data() { - qInfo()<<"AbstractDiagnostic::remove_data"; +// qInfo()<<"AbstractDiagnostic::remove_data"; QString key = s_mac.toString(); QProcess proc; @@ -248,16 +248,18 @@ void AbstractDiagnostic::write_data() { // qInfo()<<"AbstractDiagnostic::write_data"; - if(s_full_info.isEmpty()) + if(s_full_info.isEmpty() || s_full_info.isNull()) return; + QJsonDocument docBuff = s_full_info; + QString key = s_mac.toString(); QProcess proc; QString program = QString(CLI_PATH); QStringList arguments; arguments << "global_db" << "write" << "-group" << QString(group) - << "-key" << QString(key) << "-value" << QByteArray(s_full_info.toJson()); + << "-key" << QString(key) << "-value" << QByteArray(docBuff.toJson()); proc.start(program, arguments); proc.waitForFinished(5000); QString res = proc.readAll(); diff --git a/CellFrameDashboardGUI/Modules/Wallet/DapTxWorker.cpp b/CellFrameDashboardGUI/Modules/Wallet/DapTxWorker.cpp new file mode 100644 index 000000000..aa1a45456 --- /dev/null +++ b/CellFrameDashboardGUI/Modules/Wallet/DapTxWorker.cpp @@ -0,0 +1,7 @@ +#include "DapTxWorker.h" + +DapTxWorker::DapTxWorker(QObject *parent) + : QObject{parent} +{ + +} diff --git a/CellFrameDashboardGUI/Modules/Wallet/DapTxWorker.h b/CellFrameDashboardGUI/Modules/Wallet/DapTxWorker.h new file mode 100644 index 000000000..e1e523700 --- /dev/null +++ b/CellFrameDashboardGUI/Modules/Wallet/DapTxWorker.h @@ -0,0 +1,20 @@ +#ifndef DAPTXWORKER_H +#define DAPTXWORKER_H + +#include <QObject> + +class DapTxWorker : public QObject +{ + Q_OBJECT +public: + explicit DapTxWorker(QObject *parent = nullptr); + + + void getFee(QString net); +// void + +signals: + +}; + +#endif // DAPTXWORKER_H diff --git a/CellFrameDashboardGUI/Resources/BlackTheme/icons/other/icon_wiki.svg b/CellFrameDashboardGUI/Resources/BlackTheme/icons/other/icon_wiki.svg new file mode 100644 index 000000000..a178f6e1a --- /dev/null +++ b/CellFrameDashboardGUI/Resources/BlackTheme/icons/other/icon_wiki.svg @@ -0,0 +1,6 @@ +<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> +<path d="M19.875 3H4.125C3.50368 3 3 3.50368 3 4.125V19.875C3 20.4963 3.50368 21 4.125 21H19.875C20.4963 21 21 20.4963 21 19.875V4.125C21 3.50368 20.4963 3 19.875 3Z" stroke="white" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/> +<path d="M12 11H16" stroke="white" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/> +<path d="M12 8H16" stroke="white" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/> +<path d="M7 21V3" stroke="white" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/> +</svg> diff --git a/CellFrameDashboardGUI/qml.qrc b/CellFrameDashboardGUI/qml.qrc index 9dd4858f7..2fcbfa9dd 100644 --- a/CellFrameDashboardGUI/qml.qrc +++ b/CellFrameDashboardGUI/qml.qrc @@ -334,5 +334,7 @@ <file>Resources/BlackTheme/icons/other/icon_pause_hover.svg</file> <file>screen/desktop/Dashboard/DapWalletComboBox.qml</file> <file>screen/desktop/controls/DapFeePopup.qml</file> + <file>screen/desktop/Console/DapConsoleTopPanel.qml</file> + <file>Resources/BlackTheme/icons/other/icon_wiki.svg</file> </qresource> </RCC> diff --git a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTab.qml b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTab.qml index f8e665ad0..5fde14f44 100755 --- a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTab.qml +++ b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTab.qml @@ -15,7 +15,7 @@ DapPage ///@detalis rAnswer Answer for the sended command property string rAnswer - dapHeader.initialItem: DapTopPanel { } + dapHeader.initialItem: DapConsoleTopPanel { } dapScreen.initialItem: DapConsoleScreen diff --git a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTopPanel.qml b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTopPanel.qml new file mode 100644 index 000000000..46b06cf29 --- /dev/null +++ b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTopPanel.qml @@ -0,0 +1,91 @@ +import QtQuick 2.4 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 +import Demlabs 1.0 +import "../../" +import "../controls" as Controls +import "qrc:/widgets" + +Controls.DapTopPanel { + + RowLayout + { + id: layout + anchors.fill: parent + spacing: 0 + + Text{ + Layout.alignment: Qt.AlignLeft + text: qsTr("Console mode: ") + font: mainFont.dapFont.medium14 + color: currTheme.white + Layout.leftMargin: 21 + } + + DapSelectorSwitch{ + Layout.alignment: Qt.AlignLeft + Layout.leftMargin: 6 + + id: modeSelector + visible: true + + height: 32 + firstName: qsTr("Cli") + secondName: qsTr("Tool") + firstColor: currTheme.mainButtonColorNormal0 + secondColor: currTheme.mainButtonColorNormal0 + itemHorisontalBorder: 16 + onToggled: consoleModule.Mode = !consoleModule.Mode + + Component.onCompleted: setSelected(consoleModule.Mode ? "first" : "second") + } + Item{ + Layout.fillWidth: true + } + + Item{ + Layout.alignment: Qt.AlignRight + Layout.fillHeight: true + Layout.rightMargin: 24 + width: 58 + id: wikiButton + + MouseArea{ + id: area + anchors.fill: parent + hoverEnabled: true + onClicked: Qt.openUrlExternally("https://wiki.cellframe.net/en/soft/node_commands") + } + + DapCustomToolTip{ + id: toolTip + visible: area.containsMouse? true : false + contentText: "wiki.cellframe.net" + textFont: mainFont.dapFont.regular14 + onVisibleChanged: updatePos() +// y: 45 + } + + Image{ + id: img + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + mipmap: true + source: "qrc:/Resources/BlackTheme/icons/other/icon_wiki.svg" + } + + Text{ + width: 28 + anchors.left: img.right + anchors.leftMargin: 6 + anchors.verticalCenter: parent.verticalCenter + + verticalAlignment: Text.AlignVCenter + text: qsTr("Wiki") + font: mainFont.dapFont.medium14 + color: area.containsMouse? currTheme.orange : currTheme.white + + } + } + } +} diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml index a9682718f..403792cfe 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml @@ -64,7 +64,9 @@ DapNewPaymentMainRightPanelForm dapTextNotEnoughTokensWarning.visible = true dapButtonSend.visible = true } - + if(dapComboboxNetwork.displayText !== "") + modulesController.getComission(dapComboboxNetwork.displayText) +// console.log("NETWORK SELECTED ", dapComboboxNetwork.displayText) // dapTextInputAmountPayment.text = "" balance.fullText = dapComboBoxTokenModel.get(dapComboBoxToken.currentIndex).coins + " " + dapComboBoxToken.displayText @@ -143,11 +145,11 @@ DapNewPaymentMainRightPanelForm var amount = mathWorker.coinsToBalance(dapTextInputAmountPayment.text) var commission = mathWorker.sumCoins(dapWalletMessagePopup.feeStruct.network_fee.fee_datoshi, dapWalletMessagePopup.feeStruct.validator_fee.average_fee_datoshi, - false) + true) var fee = dapWalletMessagePopup.feeStruct.validator_fee.average_fee_datoshi - var amountWithCommission = mathWorker.sumCoins(dapTextInputAmountPayment.text, commission, true) +// console.log("AMOUT WITH FEE TEST: ", amount, commission) + var amountWithCommission = mathWorker.sumCoins(amount, commission, false) - commission = mathWorker.coinsToBalance(commission) var full_balance = dapComboBoxTokenModel.get(dapComboBoxToken.currentIndex).coins console.log("amount_datoshi", amount) @@ -158,9 +160,10 @@ DapNewPaymentMainRightPanelForm if (!stringWorker.testAmount(full_balance, amountWithCommission)) { console.log("Not enough tokens") + var maxValue = mathWorker.subCoins(mathWorker.coinsToBalance(full_balance), commission, false) dapTextNotEnoughTokensWarning.text = qsTr("Not enough available tokens. Maximum value = %1. Enter a lower value. Current value with comission = %2"). - arg(dapComboBoxTokenModel.get(dapComboBoxToken.currentIndex).coins).arg(amountWithCommission) + arg(maxValue).arg(amountWithCommission) } else { @@ -190,7 +193,9 @@ DapNewPaymentMainRightPanelForm } function calculatePrecentAmount(percent) { - var commission = 0.05 + var commission = mathWorker.sumCoins(dapWalletMessagePopup.feeStruct.network_fee.fee_datoshi, + dapWalletMessagePopup.feeStruct.validator_fee.average_fee_datoshi, + false) if(!stringWorker.testAmount(dapComboBoxTokenModel.get(dapComboBoxToken.currentIndex).coins, commission)) return "0.00" diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml index 8538d3677..798ca8b65 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml @@ -68,6 +68,12 @@ DapRectangleLitAndShaded // console.log(walletMessagePopup.feeStruct, feeDoc) } } + +// Component.onCompleted: +// { +// console.log("NETWORK SELECTED ", dapComboboxNetwork.displayText) +// modulesController.getComission(dapComboboxNetwork.displayText) +// } } contentData: @@ -159,6 +165,14 @@ DapRectangleLitAndShaded font: mainFont.dapFont.regular16 defaultText: qsTr("Networks") + + Component.onCompleted: + { +// console.log("NETWORK INIT ", displayText) + modulesController.getComission(displayText) + } + + } } diff --git a/CellFrameDashboardService/DapServiceController.cpp b/CellFrameDashboardService/DapServiceController.cpp index 7b513a4b7..a7af70af4 100755 --- a/CellFrameDashboardService/DapServiceController.cpp +++ b/CellFrameDashboardService/DapServiceController.cpp @@ -189,7 +189,7 @@ void DapServiceController::initServices() m_servicePool.append(new DapMempoolProcessCommand ("DapMempoolProcessCommand" , m_pServer, CLI_PATH)); m_servicePool.append(new DapGetWalletHistoryCommand ("DapGetWalletHistoryCommand" , m_pServer, CLI_PATH)); m_servicePool.append(new DapGetAllWalletHistoryCommand ("DapGetAllWalletHistoryCommand" , m_pServer, CLI_PATH)); - m_servicePool.append(new DapRunCmdCommand ("DapRunCmdCommand" , m_pServer, CLI_PATH)); + m_servicePool.append(new DapRunCmdCommand ("DapRunCmdCommand" , m_pServer, CLI_PATH, TOOLS_PATH)); m_servicePool.append(new DapGetHistoryExecutedCmdCommand ("DapGetHistoryExecutedCmdCommand" , m_pServer, CMD_HISTORY)); m_servicePool.append(new DapSaveHistoryExecutedCmdCommand ("DapSaveHistoryExecutedCmdCommand" , m_pServer, CMD_HISTORY)); m_servicePool.append(new DapVersionController ("DapVersionController" , m_pServer)); diff --git a/cellframe-node b/cellframe-node index dac2216fd..05390ed0c 160000 --- a/cellframe-node +++ b/cellframe-node @@ -1 +1 @@ -Subproject commit dac2216fdbc242a2272113eff152fdcde2b924ce +Subproject commit 05390ed0cfd4039a31acb6ae1b618e4715e37ebd diff --git a/cellframe-ui-sdk b/cellframe-ui-sdk index 15b034e8f..289dc5307 160000 --- a/cellframe-ui-sdk +++ b/cellframe-ui-sdk @@ -1 +1 @@ -Subproject commit 15b034e8f0868a8ad840588a708edc9a82beefda +Subproject commit 289dc5307ae8351d83b1afa80149b0a83f91e8c7 diff --git a/dap-ui-sdk b/dap-ui-sdk index 8b394696e..69222bfb7 160000 --- a/dap-ui-sdk +++ b/dap-ui-sdk @@ -1 +1 @@ -Subproject commit 8b394696e9b954b9035923d2c59425aca8810b41 +Subproject commit 69222bfb7b4b008dcbf55f592dbc1c5e38645265 diff --git a/version.mk b/version.mk index dfe9663e2..5c742e875 100644 --- a/version.mk +++ b/version.mk @@ -1,4 +1,4 @@ VERSION_MAJOR=2 VERSION_MINOR=12 -VERSION_PATCH=38 +VERSION_PATCH=39 diff --git a/web3_api b/web3_api index 324d8dc19..dff1aaac1 160000 --- a/web3_api +++ b/web3_api @@ -1 +1 @@ -Subproject commit 324d8dc193e2672292554f205c6adee44d67a66f +Subproject commit dff1aaac192d1d5a2c63508a67bf253162029e22 -- GitLab From 565d0d6ce067e0685072eaa2868b6db7ebffb87d Mon Sep 17 00:00:00 2001 From: denis <denis.sumin> Date: Wed, 26 Jul 2023 18:43:24 +0300 Subject: [PATCH 2/2] ... --- web3_api | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web3_api b/web3_api index dff1aaac1..8208b9759 160000 --- a/web3_api +++ b/web3_api @@ -1 +1 @@ -Subproject commit dff1aaac192d1d5a2c63508a67bf253162029e22 +Subproject commit 8208b97596ebc38f1760ced4add15f79afac00de -- GitLab