From e101cc6b32111247041244313b1708b5fb225f5d Mon Sep 17 00:00:00 2001 From: yann300 Date: Sat, 21 Feb 2015 02:13:23 +0100 Subject: [PATCH] small changes --- mix/qml/DeploymentDialog.qml | 313 +++++++++++++++++++---------------- mix/qml/ProjectModel.qml | 30 +++- mix/qml/js/ProjectModel.js | 23 ++- 3 files changed, 215 insertions(+), 151 deletions(-) diff --git a/mix/qml/DeploymentDialog.qml b/mix/qml/DeploymentDialog.qml index 5ee0a3422..e72866512 100644 --- a/mix/qml/DeploymentDialog.qml +++ b/mix/qml/DeploymentDialog.qml @@ -2,6 +2,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.1 import QtQuick.Window 2.0 +import QtQuick.Dialogs 1.1 import QtQuick.Controls.Styles 1.3 import org.ethereum.qml.QEther 1.0 import "js/TransactionHelper.js" as TransactionHelper @@ -13,7 +14,7 @@ import "." Window { id: modalDeploymentDialog modality: Qt.ApplicationModal - width: 520 + width: 600 height: 350 visible: false property alias applicationUrlEth: applicationUrlEth.text @@ -21,9 +22,9 @@ Window { property string urlHintContract: "29a2e6d3c56ef7713a4e7229c3d1a23406f0161a" property string packageHash property alias packageBase64: base64Value.text - property string root: "42f6279a5b6d350e1ce2a9ebef05657c79275c6a"; - property string eth: "31f6aee7f26e9d3320753c112ed34bcfc3c989b8"; - property string wallet: "c4040ef9635e7503bbbc74b73a9385ac78733d09"; + property string root: "165fd25527c23aa90f8009dad4465bafab5d7dd0"; + property string eth: "afb7cdbd076674fd2c67f8a66518e3145b184ae4"; + property string wallet: "c83d3e22645fb015d02043a744921cc2f828c64d"; color: Style.generic.layout.backgroundColor @@ -49,87 +50,110 @@ Window { return h; } - GridLayout + Rectangle { - columns: 2 - anchors.top: parent.top - anchors.left: parent.left - anchors.topMargin: 10 - anchors.leftMargin: 10 - anchors.rightMargin: 10 - DefaultLabel + anchors.fill : parent + anchors.margins: 10 + color: Style.generic.layout.backgroundColor + GridLayout { - text: qsTr("Eth URL: ") - } + columns: 2 + anchors.top: parent.top + anchors.left: parent.left + width: parent.width + DefaultLabel + { + text: qsTr("Ethereum Application URL: ") + } - DefaultTextField - { - id: applicationUrlEth - } + DefaultTextField + { + Layout.fillWidth: true + id: applicationUrlEth + } - DefaultLabel - { - text: qsTr("Http URL: ") - } + DefaultLabel + { + text: qsTr("Web Application Ressources URL: ") + } - DefaultTextField - { - id: applicationUrlHttp - } + DefaultTextField + { + Layout.fillWidth: true + id: applicationUrlHttp + } - DefaultLabel - { - text: qsTr("Package: ") + DefaultLabel + { + text: qsTr("Package (Base64): ") + } + + TextArea + { + Layout.fillWidth: true + readOnly: true + id: base64Value + height: 60 + enabled: base64Value.text != "" + } } - TextArea - { - id: base64Value - height: 60 + MessageDialog { + id: deployDialog + standardButtons: StandardButton.Ok + icon: StandardIcon.Warning } - } - RowLayout - { - anchors.bottom: parent.bottom - anchors.right: parent.right; - anchors.bottomMargin: 10 - Button { - text: qsTr("Deploy on Ethereum"); - tooltip: qsTr("Deploy the contract and Package ressources files.") - enabled: applicationUrlHttp.text !== "" - onClicked: { - if (Object.keys(projectModel.deploymentAddresses).length > 0) - deployWarningDialog.open(); - else - ProjectModelCode.startDeployProject(); + RowLayout + { + anchors.bottom: parent.bottom + anchors.right: parent.right; + anchors.bottomMargin: 10 + Button { + text: qsTr("Deploy on Ethereum"); + tooltip: qsTr("Deploy the contract and Package ressources files.") + onClicked: { + if (applicationUrlEth.text === "") + { + deployDialog.title = text; + deployDialog.text = qsTr("Please provide the Ethereum link you want to use for this application.") + deployDialog.open(); + } + else + deployWarningDialog.open(); + } } - } - Button { - text: qsTr("Register Web Application"); - tooltip: qsTr("Register hosted Web Application.") - enabled: Object.keys(projectModel.deploymentAddresses).length > 0 && applicationUrlHttp.text !== "" - onClicked: { - ProjectModelCode.registerToUrlHint(); + Button { + text: qsTr("Register Web Application"); + tooltip: qsTr("Register hosted Web Application.") + onClicked: { + if (applicationUrlHttp.text === "" || deploymentDialog.packageHash === "") + { + deployDialog.title = text; + deployDialog.text = qsTr("Please provide the link where the ressources are stored and ensure the package is aleary built using the deployment step. ") + deployDialog.open(); + } + else + ProjectModelCode.registerToUrlHint(); + } } - } - Button { - text: qsTr("Close"); - onClicked: close(); - } + Button { + text: qsTr("Close"); + onClicked: close(); + } - Button { - text: qsTr("Check Ownership"); - visible : false - onClicked: { - var requests = []; - var ethStr = QEtherHelper.createString("mul"); + Button { + text: qsTr("Check Ownership"); + visible : false + onClicked: { + var requests = []; + var ethStr = QEtherHelper.createString("eth"); - var ethHash = QEtherHelper.createHash(eth); + var ethHash = QEtherHelper.createHash(eth); - /*requests.push({ //owner + requests.push({ //owner jsonrpc: "2.0", method: "eth_call", params: [ { "to": '0x' + modalDeploymentDialog.root, "data": "0xec7b9200" + ethStr.encodeValueAsString() } ], @@ -141,101 +165,102 @@ Window { method: "eth_call", params: [ { "to": '0x' + modalDeploymentDialog.root, "data": "0x6be16bed" + ethStr.encodeValueAsString() } ], id: 4 - });*/ - - requests.push({ //register - jsonrpc: "2.0", - method: "eth_call", - params: [ { "to": '0x' + modalDeploymentDialog.wallet, "data": "0x618242da" + ethStr.encodeValueAsString() } ], - id: 4 }); - var jsonRpcUrl = "http://localhost:8080"; - var rpcRequest = JSON.stringify(requests); - var httpRequest = new XMLHttpRequest(); - httpRequest.open("POST", jsonRpcUrl, true); - httpRequest.setRequestHeader("Content-type", "application/json"); - httpRequest.setRequestHeader("Content-length", rpcRequest.length); - httpRequest.setRequestHeader("Connection", "close"); - httpRequest.onreadystatechange = function() { - if (httpRequest.readyState === XMLHttpRequest.DONE) { - if (httpRequest.status === 200) { - console.log(httpRequest.responseText); - } else { - var errorText = qsTr("path registration failed ") + httpRequest.status; - console.log(errorText); + requests.push({ //register + jsonrpc: "2.0", + method: "eth_call", + params: [ { "to": '0x' + modalDeploymentDialog.wallet, "data": "0x618242da" + ethStr.encodeValueAsString() } ], + id: 4 + }); + + var jsonRpcUrl = "http://localhost:8080"; + var rpcRequest = JSON.stringify(requests); + var httpRequest = new XMLHttpRequest(); + httpRequest.open("POST", jsonRpcUrl, true); + httpRequest.setRequestHeader("Content-type", "application/json"); + httpRequest.setRequestHeader("Content-length", rpcRequest.length); + httpRequest.setRequestHeader("Connection", "close"); + httpRequest.onreadystatechange = function() { + if (httpRequest.readyState === XMLHttpRequest.DONE) { + if (httpRequest.status === 200) { + console.log(httpRequest.responseText); + } else { + var errorText = qsTr("path registration failed ") + httpRequest.status; + console.log(errorText); + } } } + httpRequest.send(rpcRequest); } - httpRequest.send(rpcRequest); } - } - Button { - text: qsTr("Generate registrar init"); - visible: false - onClicked: { - console.log("registering eth/wallet") - var jsonRpcRequestId = 0; + Button { + text: qsTr("Generate registrar init"); + visible: false + onClicked: { + console.log("registering eth/wallet") + var jsonRpcRequestId = 0; - var requests = []; - var ethStr = QEtherHelper.createString("eth"); - var ethHash = QEtherHelper.createHash(eth); - requests.push({ //reserve - jsonrpc: "2.0", - method: "eth_transact", - params: [ { "to": '0x' + modalDeploymentDialog.root, "data": "0x1c83171b" + ethStr.encodeValueAsString() } ], - id: jsonRpcRequestId++ - }); + var requests = []; + var ethStr = QEtherHelper.createString("eth"); + var ethHash = QEtherHelper.createHash(eth); + requests.push({ //reserve + jsonrpc: "2.0", + method: "eth_transact", + params: [ { "to": '0x' + modalDeploymentDialog.root, "data": "0x1c83171b" + ethStr.encodeValueAsString() } ], + id: jsonRpcRequestId++ + }); - console.log("0x7d2e3ce9" + ethStr.encodeValueAsString() + pad(eth)); - console.log(ethStr.encodeValueAsString()); - console.log(pad(eth)); + console.log("0x7d2e3ce9" + ethStr.encodeValueAsString() + pad(eth)); + console.log(ethStr.encodeValueAsString()); + console.log(pad(eth)); - requests.push({ //setRegister - jsonrpc: "2.0", - method: "eth_transact", - params: [ { "to": '0x' + modalDeploymentDialog.root, "data": "0x96077307" + ethStr.encodeValueAsString() + pad(eth) /*ethHash.encodeValueAsString()*/ } ], - id: jsonRpcRequestId++ - }); + requests.push({ //setRegister + jsonrpc: "2.0", + method: "eth_transact", + params: [ { "to": '0x' + modalDeploymentDialog.root, "data": "0x96077307" + ethStr.encodeValueAsString() + pad(eth) /*ethHash.encodeValueAsString()*/ } ], + id: jsonRpcRequestId++ + }); - var walletStr = QEtherHelper.createString("wallet"); - var walletHash = QEtherHelper.createHash(wallet); + var walletStr = QEtherHelper.createString("wallet"); + var walletHash = QEtherHelper.createHash(wallet); - requests.push({ //reserve - jsonrpc: "2.0", - method: "eth_transact", - params: [ { "to": '0x' + modalDeploymentDialog.eth, "data": "0x1c83171b" + walletStr.encodeValueAsString() } ], - id: jsonRpcRequestId++ - }); + requests.push({ //reserve + jsonrpc: "2.0", + method: "eth_transact", + params: [ { "to": '0x' + modalDeploymentDialog.eth, "data": "0x1c83171b" + walletStr.encodeValueAsString() } ], + id: jsonRpcRequestId++ + }); - requests.push({ //setRegister - jsonrpc: "2.0", - method: "eth_transact", - params: [ { "to": '0x' + modalDeploymentDialog.eth, "data": "0x96077307" + walletStr.encodeValueAsString() + pad(wallet) } ], - id: jsonRpcRequestId++ - }); + requests.push({ //setRegister + jsonrpc: "2.0", + method: "eth_transact", + params: [ { "to": '0x' + modalDeploymentDialog.eth, "data": "0x96077307" + walletStr.encodeValueAsString() + pad(wallet) } ], + id: jsonRpcRequestId++ + }); - var jsonRpcUrl = "http://localhost:8080"; - var rpcRequest = JSON.stringify(requests); - var httpRequest = new XMLHttpRequest(); - httpRequest.open("POST", jsonRpcUrl, true); - httpRequest.setRequestHeader("Content-type", "application/json"); - httpRequest.setRequestHeader("Content-length", rpcRequest.length); - httpRequest.setRequestHeader("Connection", "close"); - httpRequest.onreadystatechange = function() { - if (httpRequest.readyState === XMLHttpRequest.DONE) { - if (httpRequest.status === 200) { - console.log(httpRequest.responseText); - } else { - var errorText = qsTr("path registration failed ") + httpRequest.status; - console.log(errorText); + var jsonRpcUrl = "http://localhost:8080"; + var rpcRequest = JSON.stringify(requests); + var httpRequest = new XMLHttpRequest(); + httpRequest.open("POST", jsonRpcUrl, true); + httpRequest.setRequestHeader("Content-type", "application/json"); + httpRequest.setRequestHeader("Content-length", rpcRequest.length); + httpRequest.setRequestHeader("Connection", "close"); + httpRequest.onreadystatechange = function() { + if (httpRequest.readyState === XMLHttpRequest.DONE) { + if (httpRequest.status === 200) { + console.log(httpRequest.responseText); + } else { + var errorText = qsTr("path registration failed ") + httpRequest.status; + console.log(errorText); + } } } + httpRequest.send(rpcRequest); } - httpRequest.send(rpcRequest); } } } diff --git a/mix/qml/ProjectModel.qml b/mix/qml/ProjectModel.qml index d14f9379f..02929d39e 100644 --- a/mix/qml/ProjectModel.qml +++ b/mix/qml/ProjectModel.qml @@ -93,13 +93,37 @@ Item { MessageDialog { id: deployWarningDialog + property bool redeploy title: qsTr("Project") - text: qsTr("This project has been already deployed to the network. Do you want to re-deploy it?") - standardButtons: StandardButton.Ok | StandardButton.Cancel + text: + { + if (Object.keys(projectModel.deploymentAddresses).length > 0) + { + redeploy = true + standardButtons = StandardButton.Ok | StandardButton.Reset | StandardButton.Abort; + return qsTr("This project has been already deployed to the network. Do you want to repackage the ressources only, or also reset the deployed contract to his initial state?") + } + else + { + redeploy = false; + standardButtons = StandardButton.Ok | StandardButton.Abort; + return qsTr("This action will deploy to the network. Do you want to deploy it?") + } + } icon: StandardIcon.Question onAccepted: { - ProjectModelCode.startDeployProject(); + ProjectModelCode.startDeployProject(!redeploy); } + onReset: { + ProjectModelCode.startDeployProject(true); + } + } + + MessageDialog { + id: deployRessourcesDialog + title: qsTr("Project") + standardButtons: StandardButton.Ok + icon: StandardIcon.Info } DeploymentDialog diff --git a/mix/qml/js/ProjectModel.js b/mix/qml/js/ProjectModel.js index 81d774857..c2f1a1d4b 100644 --- a/mix/qml/js/ProjectModel.js +++ b/mix/qml/js/ProjectModel.js @@ -48,7 +48,9 @@ function saveProject() { title: projectTitle, deploymentAddresses: deploymentAddresses, applicationUrlEth: deploymentDialog.applicationUrlEth, - applicationUrlHttp: deploymentDialog.applicationUrlHttp + applicationUrlHttp: deploymentDialog.applicationUrlHttp, + packageHash: deploymentDialog.packageHash, + packageBase64: deploymentDialog.packageBase64 }; for (var i = 0; i < projectListModel.count; i++) projectData.files.push(projectListModel.get(i).fileName) @@ -66,6 +68,10 @@ function loadProject(path) { var projectFile = path + projectFileName; var json = fileIo.readFile(projectFile); var projectData = JSON.parse(json); + if (projectData.packageHash) + deploymentDialog.packageHash = projectData.packageHash + if (projectData.packageBase64) + deploymentDialog.packageBase64 = projectData.packageBase64 if (projectData.applicationUrlEth) deploymentDialog.applicationUrlEth = projectData.applicationUrlEth if (projectData.applicationUrlHttp) @@ -283,10 +289,16 @@ function deployProject(force) { deploymentDialog.open(); } -function startDeployProject() +function startDeployProject(erasePrevious) { var date = new Date(); var deploymentId = date.toLocaleString(Qt.locale(), "ddMMyyHHmmsszzz"); + if (!erasePrevious) + { + finalizeDeployment(deploymentId, projectModel.deploymentAddresses); + return; + } + var jsonRpcUrl = "http://localhost:8080"; console.log("Deploying " + deploymentId + " to " + jsonRpcUrl); deploymentStarted(); @@ -384,9 +396,12 @@ function finalizeDeployment(deploymentId, addresses) { var applicationUrlEth = deploymentDialog.applicationUrlEth; applicationUrlEth = formatAppUrl(applicationUrlEth); - deploymentStepChanged(qsTr("Registering application on Ethereum ...")); + + deploymentStepChanged(qsTr("Registering application on the Ethereum network ...")); checkRegistration(applicationUrlEth, deploymentDialog.root, function () { deploymentComplete(); + deployRessourcesDialog.text = qsTr("Register Web Application to finalize deployment."); + deployRessourcesDialog.open(); }); } @@ -552,7 +567,7 @@ function formatAppUrl(url) var dot = url.indexOf("."); if (slash === -1 && dot === -1) return url; - if (slash !== -1 && slash < dot) + if ((slash !== -1 && slash < dot) || dot === -1) return url.split("/"); else {