From 22b0d8347cfb80d01c83bc62a0fa0e8aab7bb467 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 22 Jul 2015 10:02:40 +0200 Subject: [PATCH] ui/ux changes --- mix/QBigInt.h | 2 + mix/qml/Block.qml | 1 + mix/qml/BlockChain.qml | 6 ++ mix/qml/DeployContractStep.qml | 21 ++++++ mix/qml/DeploymentDialog.qml | 1 + mix/qml/DeploymentDialogSteps.qml | 113 +++++++++++++++++++++++------- mix/qml/DeploymentWorker.qml | 13 +++- mix/qml/KeyValuePanel.qml | 6 ++ mix/qml/PackagingStep.qml | 2 + mix/qml/RegisteringStep.qml | 2 + mix/qml/ScenarioLoader.qml | 2 +- mix/qml/js/NetworkDeployment.js | 14 ++-- mix/qml/js/TransactionHelper.js | 5 +- 13 files changed, 152 insertions(+), 36 deletions(-) diff --git a/mix/QBigInt.h b/mix/QBigInt.h index 700c817e5..a2dac8cf9 100644 --- a/mix/QBigInt.h +++ b/mix/QBigInt.h @@ -82,6 +82,8 @@ public: BigIntVariant internalValue() const { return m_internalValue; } /// @returns a string representation of the big integer used. Invokable from QML. Q_INVOKABLE QString value() const; + /// hex value. + Q_INVOKABLE QString hexValue() const { return QString::fromStdString(dev::toHex(dev::u256(value().toStdString()))); } /// Set the value of the BigInteger used. Will use u256 type. Invokable from QML. Q_INVOKABLE void setValue(QString const& _value) { m_internalValue = dev::jsToU256(_value.toStdString()); } Q_INVOKABLE void setBigInt(QString const& _value) { m_internalValue = bigint(_value.toStdString()); } diff --git a/mix/qml/Block.qml b/mix/qml/Block.qml index 732166628..383cb85e8 100644 --- a/mix/qml/Block.qml +++ b/mix/qml/Block.qml @@ -105,6 +105,7 @@ ColumnLayout anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right anchors.rightMargin: 14 + visible: false MouseArea { anchors.fill: parent diff --git a/mix/qml/BlockChain.qml b/mix/qml/BlockChain.qml index 1b1b68862..b9d00d885 100644 --- a/mix/qml/BlockChain.qml +++ b/mix/qml/BlockChain.qml @@ -115,11 +115,17 @@ ColumnLayout { property int horizontalMargin: 10 property int cellSpacing: 10 + RowLayout + { + Layout.preferredHeight: 10 + } + RowLayout { id: header spacing: 0 Layout.preferredHeight: 24 + visible: false Rectangle { Layout.preferredWidth: statusWidth diff --git a/mix/qml/DeployContractStep.qml b/mix/qml/DeployContractStep.qml index 10f879ab7..97fbe664f 100644 --- a/mix/qml/DeployContractStep.qml +++ b/mix/qml/DeployContractStep.qml @@ -13,6 +13,7 @@ Rectangle { property variant worker property variant gas: [] color: "#E3E3E3E3" + signal deployed anchors.fill: parent id: root @@ -460,6 +461,25 @@ Rectangle { Layout.alignment: Qt.BottomEdge Button { + Layout.preferredHeight: 22 + anchors.right: deployBtn.left + text: qsTr("Reset") + action: clearDeployAction + } + + Action { + id: clearDeployAction + onTriggered: { + worker.forceStopPooling() + fileIo.deleteDir(projectModel.deploymentDir) + projectModel.cleanDeploymentStatus() + deploymentDialog.steps.reset() + } + } + + Button + { + id: deployBtn anchors.right: parent.right text: qsTr("Deploy Contracts") onClicked: @@ -473,6 +493,7 @@ Rectangle { projectModel.deployBlockNumber = nb projectModel.saveProject() root.updateVerification(nb, trLost) + root.deployed() }) projectModel.deploymentAddresses = addresses projectModel.saveProject() diff --git a/mix/qml/DeploymentDialog.qml b/mix/qml/DeploymentDialog.qml index 39022def2..25f03f818 100644 --- a/mix/qml/DeploymentDialog.qml +++ b/mix/qml/DeploymentDialog.qml @@ -22,6 +22,7 @@ Dialog { property alias packageStep: packageStep property alias registerStep: registerStep property alias worker: worker + property alias steps: steps function close() { diff --git a/mix/qml/DeploymentDialogSteps.qml b/mix/qml/DeploymentDialogSteps.qml index 5ebd81dea..fbf1e55a0 100644 --- a/mix/qml/DeploymentDialogSteps.qml +++ b/mix/qml/DeploymentDialogSteps.qml @@ -26,9 +26,50 @@ Rectangle { selected(step) } + function reset() + { + for (var k in deployLogs.logs) + { + deployLogs.logs[k] = "" + } + deployLogs.switchLogs() + refreshCurrent() + } + border.color: "#cccccc" border.width: 1 + + Connections + { + id: deployStatus + target: deploymentDialog.deployStep + onDeployed: + { + console.log("deployed") + } + } + + Connections + { + id: packagedStatus + target: deploymentDialog.packageStep + onPackaged: + { + console.log("packaged") + } + } + + Connections + { + id: registerStatus + target: deploymentDialog.registerStep + onRegistered: + { + console.log("registered") + } + } + ColumnLayout { anchors.fill: parent @@ -70,6 +111,7 @@ Rectangle { labelContainer.state = "selected" sel = index itemClicked(menu.model[index].type) + deployLogs.switchLogs() } function unselect() @@ -136,11 +178,51 @@ Rectangle { } Connections { + property var logs: ({}) + id: deployLogs + + function switchLogs() + { + if (root.sel) + { + if (!logs[root.sel]) + logs[root.sel] = "" + log.text = logs[root.sel] + } + } + target: projectModel - onDeploymentStarted: log.text = log.text + qsTr("Running deployment...") + "\n" - onDeploymentError: log.text = log.text + error + "\n" - onDeploymentComplete: log.text = log.text + qsTr("Deployment complete") + "\n" - onDeploymentStepChanged: log.text = log.text + message + "\n" + onDeploymentStarted: + { + if (!logs[root.sel]) + logs[root.sel] = "" + logs[root.sel] = logs[root.sel] + qsTr("Running deployment...") + "\n" + log.text = logs[root.sel] + } + + onDeploymentError: + { + if (!logs[root.sel]) + logs[root.sel] = "" + logs[root.sel] = logs[root.sel] + error + "\n" + log.text = logs[root.sel] + } + + onDeploymentComplete: + { + if (!logs[root.sel]) + logs[root.sel] = "" + logs[root.sel] = logs[root.sel] + qsTr("Deployment complete") + "\n" + log.text = logs[root.sel] + } + + onDeploymentStepChanged: + { + if (!logs[root.sel]) + logs[root.sel] = "" + logs[root.sel] = logs[root.sel] + message + "\n" + log.text = logs[root.sel] + } } Rectangle @@ -169,27 +251,10 @@ Rectangle { enabled: log.text !== "" tooltip: qsTr("Clear") onTriggered: { - log.text = "" - } - } - - Button - { - Layout.preferredHeight: 22 - text: qsTr("Clear Deployment") - action: clearDeployAction - } - - Action { - id: clearDeployAction - onTriggered: { - worker.forceStopPooling() - fileIo.deleteDir(projectModel.deploymentDir) - projectModel.cleanDeploymentStatus() - root.refreshCurrent() - log.text = "" + deployLogs.logs[root.sel] = "" + log.text = deployLogs.logs[root.sel] } - } + } } ScrollView diff --git a/mix/qml/DeploymentWorker.qml b/mix/qml/DeploymentWorker.qml index 9aef45112..cdf98ce92 100644 --- a/mix/qml/DeploymentWorker.qml +++ b/mix/qml/DeploymentWorker.qml @@ -21,6 +21,15 @@ Item property variant accounts: [] signal gasPriceLoaded() + function highGasPrice() + { + var hex = deploymentDialog.worker.gasPriceInt.multiply(QEtherHelper.createBigInt(10)).hexValue(); + if (hex.indexOf("0x") !== -1) + return hex + else + return "0x" + hex + } + function renewCtx() { accounts = [] @@ -206,7 +215,7 @@ Item property var callBack property int elapsed property string hash - interval: 500 + interval: 2000 running: false repeat: true onTriggered: { @@ -227,7 +236,7 @@ Item stop(); callBack(1, receipt); } - else if (elapsed > 250000) + else if (elapsed > 2500000) { stop(); callBack(-1, null); diff --git a/mix/qml/KeyValuePanel.qml b/mix/qml/KeyValuePanel.qml index 056384b9e..db09a5e27 100644 --- a/mix/qml/KeyValuePanel.qml +++ b/mix/qml/KeyValuePanel.qml @@ -97,6 +97,9 @@ ColumnLayout { Layout.preferredWidth: columnValues.width / 2 Label { + width: columnValues.width / 2 - 20 + elide: Text.ElideRight + maximumLineCount: 1 anchors.left: parent.left anchors.leftMargin: 10 text: { @@ -113,6 +116,9 @@ ColumnLayout { Layout.preferredWidth: columnValues.width / 2 - 10 Label { + width: columnValues.width / 2 - 10 + elide: Text.ElideRight + maximumLineCount: 1 anchors.right: parent.right anchors.rightMargin: 10 text: { diff --git a/mix/qml/PackagingStep.qml b/mix/qml/PackagingStep.qml index 424732869..6f7ed3f11 100644 --- a/mix/qml/PackagingStep.qml +++ b/mix/qml/PackagingStep.qml @@ -20,6 +20,7 @@ Rectangle { property alias lastDeployDate: lastDeployLabel.text property string deploymentId property string packageDir + signal packaged function show() { @@ -107,6 +108,7 @@ Rectangle { { NetworkDeploymentCode.packageDapp(projectModel.deploymentAddresses); projectModel.saveProject() + root.packaged() } } diff --git a/mix/qml/RegisteringStep.qml b/mix/qml/RegisteringStep.qml index 648e04f16..dfda083ea 100644 --- a/mix/qml/RegisteringStep.qml +++ b/mix/qml/RegisteringStep.qml @@ -19,6 +19,7 @@ Rectangle { id: root color: "#E3E3E3E3" anchors.fill: parent + signal registered function show() { @@ -286,6 +287,7 @@ Rectangle { projectModel.registerUrlBlockNumber = bn projectModel.saveProject() root.updateVerification(bn, bn, trLost, verificationUrl) + root.registered() }); }) }) diff --git a/mix/qml/ScenarioLoader.qml b/mix/qml/ScenarioLoader.qml index 0de779135..10ee4e8b8 100644 --- a/mix/qml/ScenarioLoader.qml +++ b/mix/qml/ScenarioLoader.qml @@ -35,7 +35,7 @@ ColumnLayout { Layout.preferredWidth: 560 anchors.horizontalCenter: parent.horizontalCenter - Layout.preferredHeight: 60 + Layout.preferredHeight: 75 spacing: 0 anchors.top: parent.top anchors.topMargin: 10 diff --git a/mix/qml/js/NetworkDeployment.js b/mix/qml/js/NetworkDeployment.js index 42cbf5207..2fc207ddf 100644 --- a/mix/qml/js/NetworkDeployment.js +++ b/mix/qml/js/NetworkDeployment.js @@ -35,8 +35,6 @@ function deployProject(force) { function deployContracts(gas, callback) { deploymentGas = gas; - var jsonRpcUrl = "http://127.0.0.1:8080"; - console.log("Deploying to " + jsonRpcUrl); deploymentStarted(); var ctrAddresses = {}; @@ -153,7 +151,7 @@ function executeTr(blockIndex, trIndex, state, ctrAddresses, trHashes, callBack) else { var gasCost = clientModel.toHex(deploymentGas[trRealIndex]); - var rpcParams = { "from": deploymentDialog.worker.currentAccount, "gas": "0x" + gasCost }; + var rpcParams = { "from": deploymentDialog.worker.currentAccount, "gas": "0x" + gasCost, "gasPrice": "0x" + deploymentDialog.worker.highGasPrice() }; var params = replaceParamToken(func.parameters, tr.parameters, ctrAddresses); var encodedParams = clientModel.encodeParams(params, contractFromToken(tr.contractId), tr.functionId); @@ -446,7 +444,7 @@ function continueRegistration(dappUrl, addr, callBack, checkOnly) requests.push({ jsonrpc: "2.0", method: "eth_sendTransaction", - params: [ { "from": deploymentDialog.worker.currentAccount, "gas": "0x" + gasCost, "code": "0x600080547fffffffffffffffffffffffff000000000000000000000000000000000000000016331781556105cd90819061003990396000f3007c010000000000000000000000000000000000000000000000000000000060003504630198489281146100b257806321f8a721146100e45780632dff6941146100ee5780633b3b57de1461010e5780635a3a05bd1461013e5780635fd4b08a146101715780637dd564111461017d57806389a69c0e14610187578063b387ef92146101bb578063b5c645bd146101f4578063be99a98014610270578063c3d014d6146102a8578063d93e7573146102dc57005b73ffffffffffffffffffffffffffffffffffffffff600435166000908152600160205260409020548060005260206000f35b6000808052602081f35b600435600090815260026020819052604090912001548060005260206000f35b600435600090815260026020908152604082205473ffffffffffffffffffffffffffffffffffffffff1680835291f35b600435600090815260026020908152604082206001015473ffffffffffffffffffffffffffffffffffffffff1680835291f35b60008060005260206000f35b6000808052602081f35b60005461030c9060043590602435903373ffffffffffffffffffffffffffffffffffffffff908116911614610569576105c9565b60005473ffffffffffffffffffffffffffffffffffffffff168073ffffffffffffffffffffffffffffffffffffffff1660005260206000f35b600435600090815260026020819052604090912080546001820154919092015473ffffffffffffffffffffffffffffffffffffffff9283169291909116908273ffffffffffffffffffffffffffffffffffffffff166000528173ffffffffffffffffffffffffffffffffffffffff166020528060405260606000f35b600054610312906004359060243590604435903373ffffffffffffffffffffffffffffffffffffffff90811691161461045457610523565b6000546103189060043590602435903373ffffffffffffffffffffffffffffffffffffffff90811691161461052857610565565b60005461031e90600435903373ffffffffffffffffffffffffffffffffffffffff90811691161461032457610451565b60006000f35b60006000f35b60006000f35b60006000f35b60008181526002602090815260408083205473ffffffffffffffffffffffffffffffffffffffff16835260019091529020548114610361576103e1565b6000818152600260205260408082205473ffffffffffffffffffffffffffffffffffffffff169183917ff63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a85459190a360008181526002602090815260408083205473ffffffffffffffffffffffffffffffffffffffff16835260019091528120555b600081815260026020819052604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081168255600182018054909116905590910182905582917fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc91a25b50565b600083815260026020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001683179055806104bb57827fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc60006040a2610522565b73ffffffffffffffffffffffffffffffffffffffff8216837ff63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a854560006040a373ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090208390555b5b505050565b600082815260026020819052604080832090910183905583917fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc91a25b5050565b60008281526002602052604080822060010180547fffffffffffffffffffffffff0000000000000000000000000000000000000000168417905583917fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc91a25b505056" } ], + params: [ { "from": deploymentDialog.worker.currentAccount, "gasPrice": deploymentDialog.worker.highGasPrice(), "gas": "0x" + gasCost, "code": "0x600080547fffffffffffffffffffffffff000000000000000000000000000000000000000016331781556105cd90819061003990396000f3007c010000000000000000000000000000000000000000000000000000000060003504630198489281146100b257806321f8a721146100e45780632dff6941146100ee5780633b3b57de1461010e5780635a3a05bd1461013e5780635fd4b08a146101715780637dd564111461017d57806389a69c0e14610187578063b387ef92146101bb578063b5c645bd146101f4578063be99a98014610270578063c3d014d6146102a8578063d93e7573146102dc57005b73ffffffffffffffffffffffffffffffffffffffff600435166000908152600160205260409020548060005260206000f35b6000808052602081f35b600435600090815260026020819052604090912001548060005260206000f35b600435600090815260026020908152604082205473ffffffffffffffffffffffffffffffffffffffff1680835291f35b600435600090815260026020908152604082206001015473ffffffffffffffffffffffffffffffffffffffff1680835291f35b60008060005260206000f35b6000808052602081f35b60005461030c9060043590602435903373ffffffffffffffffffffffffffffffffffffffff908116911614610569576105c9565b60005473ffffffffffffffffffffffffffffffffffffffff168073ffffffffffffffffffffffffffffffffffffffff1660005260206000f35b600435600090815260026020819052604090912080546001820154919092015473ffffffffffffffffffffffffffffffffffffffff9283169291909116908273ffffffffffffffffffffffffffffffffffffffff166000528173ffffffffffffffffffffffffffffffffffffffff166020528060405260606000f35b600054610312906004359060243590604435903373ffffffffffffffffffffffffffffffffffffffff90811691161461045457610523565b6000546103189060043590602435903373ffffffffffffffffffffffffffffffffffffffff90811691161461052857610565565b60005461031e90600435903373ffffffffffffffffffffffffffffffffffffffff90811691161461032457610451565b60006000f35b60006000f35b60006000f35b60006000f35b60008181526002602090815260408083205473ffffffffffffffffffffffffffffffffffffffff16835260019091529020548114610361576103e1565b6000818152600260205260408082205473ffffffffffffffffffffffffffffffffffffffff169183917ff63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a85459190a360008181526002602090815260408083205473ffffffffffffffffffffffffffffffffffffffff16835260019091528120555b600081815260026020819052604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081168255600182018054909116905590910182905582917fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc91a25b50565b600083815260026020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001683179055806104bb57827fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc60006040a2610522565b73ffffffffffffffffffffffffffffffffffffffff8216837ff63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a854560006040a373ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090208390555b5b505050565b600082815260026020819052604080832090910183905583917fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc91a25b5050565b60008281526002602052604080822060010180547fffffffffffffffffffffffff0000000000000000000000000000000000000000168417905583917fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc91a25b505056" } ], id: jsonRpcRequestId++ }); @@ -468,7 +466,7 @@ function continueRegistration(dappUrl, addr, callBack, checkOnly) //setRegister() jsonrpc: "2.0", method: "eth_sendTransaction", - params: [ { "from": deploymentDialog.worker.currentAccount, "gas": "0x" + gasCost, "to": '0x' + addr, "data": "0x89a69c0e" + crLevel + newCtrAddress } ], + params: [ { "from": deploymentDialog.worker.currentAccount, "gasPrice": deploymentDialog.worker.highGasPrice(), "gas": "0x" + gasCost, "to": '0x' + addr, "data": "0x89a69c0e" + crLevel + newCtrAddress } ], id: jsonRpcRequestId++ }); @@ -501,7 +499,7 @@ function reserve(registrar, callBack) //reserve() jsonrpc: "2.0", method: "eth_sendTransaction", - params: [ { "from": deploymentDialog.worker.currentAccount, "gas": "0xfffff", "to": '0x' + registrar, "data": "0x432ced04" + paramTitle } ], + params: [ { "from": deploymentDialog.worker.currentAccount, "gasPrice": deploymentDialog.worker.highGasPrice(), "gas": "0xfffff", "to": '0x' + registrar, "data": "0x432ced04" + paramTitle } ], id: jsonRpcRequestId++ }); rpcCall(requests, function (httpRequest, response) { @@ -524,7 +522,7 @@ function registerContentHash(registrar, callBack) //setContent() jsonrpc: "2.0", method: "eth_sendTransaction", - params: [ { "from": deploymentDialog.worker.currentAccount, "gas": "0x" + gasCost, "to": '0x' + registrar, "data": "0xc3d014d6" + paramTitle + deploymentDialog.packageStep.packageHash } ], + params: [ { "from": deploymentDialog.worker.currentAccount, "gasPrice": deploymentDialog.worker.highGasPrice(), "gas": "0x" + gasCost, "to": '0x' + registrar, "data": "0xc3d014d6" + paramTitle + deploymentDialog.packageStep.packageHash } ], id: jsonRpcRequestId++ }); rpcCall(requests, function (httpRequest, response) { @@ -545,7 +543,7 @@ function registerToUrlHint(url, callback) //urlHint => suggestUrl jsonrpc: "2.0", method: "eth_sendTransaction", - params: [ { "to": '0x' + urlHint, "from": deploymentDialog.worker.currentAccount, "gas": "0x" + gasCost, "data": "0x584e86ad" + deploymentDialog.packageStep.packageHash + paramUrlHttp } ], + params: [ { "to": '0x' + urlHint, "gasPrice": deploymentDialog.worker.highGasPrice(), "from": deploymentDialog.worker.currentAccount, "gas": "0x" + gasCost, "data": "0x584e86ad" + deploymentDialog.packageStep.packageHash + paramUrlHttp } ], id: jsonRpcRequestId++ }); diff --git a/mix/qml/js/TransactionHelper.js b/mix/qml/js/TransactionHelper.js index 33dadab9d..d471824f5 100644 --- a/mix/qml/js/TransactionHelper.js +++ b/mix/qml/js/TransactionHelper.js @@ -19,7 +19,8 @@ function defaultTransaction() function rpcCall(requests, callBack, error) { - var jsonRpcUrl = "http://localhost:8545"; + //var jsonRpcUrl = "http://localhost:8545"; + var jsonRpcUrl = "http://10.10.42.111:8545" var rpcRequest = JSON.stringify(requests); console.log(rpcRequest); var httpRequest = new XMLHttpRequest(); @@ -28,6 +29,8 @@ function rpcCall(requests, callBack, error) httpRequest.setRequestHeader("Content-length", rpcRequest.length); httpRequest.setRequestHeader("Connection", "close"); httpRequest.onreadystatechange = function() { + console.log(httpRequest.readyState) + console.log(httpRequest.responseText) if (httpRequest.readyState === XMLHttpRequest.DONE) { if (httpRequest.status !== 200 || httpRequest.responseText === "") {