diff --git a/assets/styles/style.css b/assets/styles/style.css index ba6d112..6334d36 100644 --- a/assets/styles/style.css +++ b/assets/styles/style.css @@ -124,6 +124,12 @@ body.pg-loaded > .inner { height: 150px; } +#dlgAddressListBody { + margin: 0px; + padding: 20px; + background-color: #333; +} + .btn-dialog-confirm { position: absolute; bottom: 10px; @@ -316,6 +322,18 @@ div.noWalletsWrapper { justify-content: center; } -.btnCopyWalletAddress { - margin-right: 10px; +.textAddress { + cursor: pointer; +} + +.addressInputWrapper { + display: flex; +} + +#addressToolbar { + display: flex; +} + +#addressListFilter { + color: #aaa; } \ No newline at end of file diff --git a/assets/templates/addresslist.html b/assets/templates/addresslist.html new file mode 100644 index 0000000..65e51e6 --- /dev/null +++ b/assets/templates/addresslist.html @@ -0,0 +1,28 @@ +
+ + +
+
+ {{#if addressData.length}} + + + + + + + + + + {{#addressData}} + + + + + + {{/addressData}} + +
NameAddress
{{name}}{{address}}
+ {{else}} +
You don't have any wallets, please import them, or create a new one
+ {{/if}} +
\ No newline at end of file diff --git a/assets/templates/send.html b/assets/templates/send.html index 420e4c8..5777a08 100644 --- a/assets/templates/send.html +++ b/assets/templates/send.html @@ -11,9 +11,10 @@ -
+
+
@@ -83,4 +84,11 @@
- \ No newline at end of file + + + +
+
+
+
+ \ No newline at end of file diff --git a/assets/templates/wallets.html b/assets/templates/wallets.html index b251536..feb90e7 100644 --- a/assets/templates/wallets.html +++ b/assets/templates/wallets.html @@ -18,7 +18,7 @@ {{name}} - {{address}} + {{address}} {{balance}} {{/addressData}} @@ -28,8 +28,6 @@
You don't have any wallets, please import them, or create a new one
{{/if}} -
-
diff --git a/main.js b/main.js index a27e6e9..28c37bf 100644 --- a/main.js +++ b/main.js @@ -12,8 +12,8 @@ function createWindow () { mainWindow = new BrowserWindow({ width: 1200, height: 800, - minWidth: 1000, - minHeight: 800, + minWidth: 1100, + minHeight: 700, backgroundColor: "#000000" }); diff --git a/package.json b/package.json index 97f8ce1..3712e2f 100644 --- a/package.json +++ b/package.json @@ -13,16 +13,14 @@ "appId": "Ether1DesktopWallet", "win": { "icon": "build/icon.png", - "target": "portable" + "target": "7z" } }, - "repository": "https://github.com/electron/electron-quick-start", + "repository": "https://github.com/taeguscromis/Ether1DesktopWallet", "keywords": [ - "Electron", - "quick", - "start", - "tutorial", - "demo" + "Ether1", + "Desktop", + "Wallet" ], "author": "Ether1", "license": "CC0-1.0", diff --git a/renderer/blockchain.js b/renderer/blockchain.js index 702c9df..79832df 100644 --- a/renderer/blockchain.js +++ b/renderer/blockchain.js @@ -164,6 +164,34 @@ class Blockchain { } } + getAddressListData(clbError, clbSuccess) { + var rendererData = {}; + rendererData.addressData = []; + + var wallets = ipcRenderer.sendSync('getJSONFile', 'wallets.json'); + var counter = 0; + + web3Local.eth.getAccounts(function(err, res) { + if (err) { + clbError(err); + } else { + for (var i = 0; i < res.length; i++) { + var walletName = vsprintf("Account %d", [i + 1]); + if (wallets) { + walletName = wallets.names[res[i]] || walletName; + } + + var addressInfo = {}; + addressInfo.address = res[i]; + addressInfo.name = walletName; + rendererData.addressData.push(addressInfo); + } + + clbSuccess(rendererData); + } + }); + } + createNewAccount(password, clbError, clbSuccess) { web3Local.eth.personal.newAccount(password, function(error, account) { if (error) { diff --git a/renderer/maingui.js b/renderer/maingui.js index 44643df..ac53e66 100644 --- a/renderer/maingui.js +++ b/renderer/maingui.js @@ -43,11 +43,15 @@ class MainGUI { }); } - renderTemplate(template, data) { + renderTemplate(template, data, container) { var template = Handlebars.compile(ipcRenderer.sendSync('getTemplateContent', template)); - $("#mainContent").empty(); - $("#mainContent").html(template(data)); + if (!container) { + container = $("#mainContent") + } + + container.empty(); + container.html(template(data)); } copyToClipboard(text) { diff --git a/renderer/send.js b/renderer/send.js index b33bc46..91cec70 100644 --- a/renderer/send.js +++ b/renderer/send.js @@ -66,55 +66,40 @@ $(document).on("render_send", function() { web3Local.eth.getBalance(this.value, function(error, balance) { $("#sendMaxAmmount").html(parseFloat(web3Local.utils.fromWei(balance, 'ether'))); }); - - /* - // list all transactions for this address - if (this.value) { - $("#cardTransactionsForAddress").css("display", "block"); - - setTimeout(() => { - // render the transactions - $('#tableTransactionsForAddress').DataTable({ - "paging": false, - "scrollY": "calc(100vh - 115px)", - "responsive": true, - "processing": true, - "order": [[ 0, "desc" ]], - "data": ipcRenderer.sendSync('getTransactions', this.value), - "columnDefs": [ - { - "className": "transactionsBlockNum", - "targets": 0 - }, - { - "targets": 1, - "render": function ( data, type, row ) { - return moment(data).format("MMM Do YYYY"); - } - }, - { - "targets": 4, - "render": function ( data, type, row ) { - return parseFloat(web3Local.utils.fromWei(EthoUtils.toFixed(parseFloat(data)).toString(), 'ether')).toFixed(2); - } - } - ], - "drawCallback": function( settings ) { - $("#loadingTransactionsOverlay").css("display", "none"); - } - }); - }, 200); - } else { - $("#cardTransactionsForAddress").css("display", "none"); - } - */ }); $("#btnSendAll").off('click').on('click', function() { $("#sendAmmount").focus(); $("#sendAmmount").val($("#sendMaxAmmount").html()); }); + + $("#btnLookForToAddress").off('click').on('click', function() { + EthoBlockchain.getAddressListData( + function(error) { + EthoMainGUI.showGeneralError(error); + }, + function(data) { + $("#dlgAddressList").iziModal({ width: "800px" }); + EthoMainGUI.renderTemplate("addresslist.html", data, $("#dlgAddressListBody")); + $('#dlgAddressList').iziModal('open'); + $(".btnSelectToAddress").off('click').on('click', function() { + $("#sendToAddress").val($(this).attr('data-wallet')); + $('#dlgAddressList').iziModal('close'); + }); + + $('#addressListFilter').off('input').on('input',function(e){ + EthoUtils.filterTable($("#addressTable"), $('#addressListFilter').val()); + }); + + $("#btnClearSearchField").off('click').on('click', function() { + EthoUtils.filterTable($("#addressTable"), ""); + $('#addressListFilter').val("") + }); + } + ); + }); + $("#btnSendTransaction").off('click').on('click', function() { if (EthoSend.validateSendForm()) { EthoBlockchain.getTranasctionFee($("#sendFromAddress").val(), $("#sendToAddress").val(), $("#sendAmmount").val(), diff --git a/renderer/utils.js b/renderer/utils.js index c586666..9f41127 100644 --- a/renderer/utils.js +++ b/renderer/utils.js @@ -18,6 +18,27 @@ class Utils { } return x; } + + filterTable(table, text) { + // Declare variables + var filter, tr, td, i, txtValue; + filter = text.toUpperCase(); + tr = $(table).find("tr"); + + // Loop through all table rows, and hide those who don't match the search query + for (i = 0; i < tr.length; i++) { + td = $(tr[i]).find("td")[0]; + + if (td) { + txtValue = td.textContent || td.innerText; + if (txtValue.toUpperCase().indexOf(filter) > -1) { + $(tr[i]).css("display", ""); + } else { + $(tr[i]).css("display", "none"); + } + } + } + } } EthoUtils = new Utils(); \ No newline at end of file diff --git a/renderer/wallets.js b/renderer/wallets.js index de1e6d9..5928cc0 100644 --- a/renderer/wallets.js +++ b/renderer/wallets.js @@ -62,8 +62,8 @@ renderWalletsState() { EthoMainGUI.renderTemplate("wallets.html", data); $(document).trigger("render_wallets"); } - ); -} + ); + } } // the event to tell us that the wallets are rendered @@ -142,8 +142,8 @@ $(document).on("render_wallets", function() { }); }); - $(".btnCopyWalletAddress").off('click').on('click', function() { - EthoMainGUI.copyToClipboard($(this).attr('data-wallet')); + $(".textAddress").off('click').on('click', function() { + EthoMainGUI.copyToClipboard($(this).html()); iziToast.success({ title: 'Copied',