From 388db7a9bc2cdc94729e11be11cebd8abd098b6f Mon Sep 17 00:00:00 2001 From: hmisty Date: Tue, 9 Jan 2024 18:01:04 +0800 Subject: [PATCH] improve unwrap dialog --- scripts/controllers/addressInfoController.js | 44 ++++++++++- views/addressInfo.html | 80 ++++++++++++++------ 2 files changed, 98 insertions(+), 26 deletions(-) diff --git a/scripts/controllers/addressInfoController.js b/scripts/controllers/addressInfoController.js index 9c1ebc2..ae6181a 100644 --- a/scripts/controllers/addressInfoController.js +++ b/scripts/controllers/addressInfoController.js @@ -125,11 +125,27 @@ angular.module('ethExplorer') $('#dialog-unwrap-wjoule').modal('show'); } + $scope.wjUnwrapToConfirm = function () { + const amt = $('#wj-unwrap-amount')[0].value; + const to = $('#wj-unwrap-to')[0].value; + const save_info = $('#wj-unwrap-save-info')[0].checked; + console.log('wjUnwrapTo', amt, to, save_info); + + $('#confirm-unwrap-wj-from').text($scope.addressId); + $('#confirm-unwrap-wj-amount').text(amt ? amt : '0'); + $('#confirm-unwrap-wj-amount2').text(amt ? amt : '0'); + $('#confirm-unwrap-wj-to').text(to ? to : $scope.addressId); + + $('#dialog-unwrap-wjoule-confirm').modal({keyboard:false, backdrop:'static'}); + $('#dialog-unwrap-wjoule-confirm').modal('show'); + } + $scope.wjUnwrapTo = function () { const DIALOG_TITLE = 'Unwrap wJ'; const amt = $('#wj-unwrap-amount')[0].value; const to = $('#wj-unwrap-to')[0].value; - console.log('wjUnwrapTo', amt, to); + const save_info = $('#wj-unwrap-save-info')[0].checked; + console.log('wjUnwrapTo', amt, to, save_info); if (amt && !isNaN(amt)) { // isNaN works, nice. if (!(amt > 0)) { @@ -148,6 +164,11 @@ angular.module('ethExplorer') wj_contract.methods.withdraw(e) .send({from: connectedAccount}, handlerShowTx(DIALOG_TITLE)) .then(handlerShowRct(DIALOG_TITLE)); + + if (!save_info) { + $('#wj-unwrap-amount')[0].value = ''; + $('#wj-unwrap-to')[0].value = ''; + } } else { dialogShowTxt(DIALOG_TITLE, '错误:无法评估gas:' + err.message); //展示合约逻辑报错 } @@ -158,6 +179,11 @@ angular.module('ethExplorer') wj_contract.methods.withdrawTo(to, e) .send({from: connectedAccount}, handlerShowTx(DIALOG_TITLE)) .then(handlerShowRct(DIALOG_TITLE)); + + if (!save_info) { + $('#wj-unwrap-amount')[0].value = ''; + $('#wj-unwrap-to')[0].value = ''; + } } else { dialogShowTxt(DIALOG_TITLE, '错误:无法评估gas:' + err.message); //展示合约逻辑报错 } @@ -234,9 +260,11 @@ angular.module('ethExplorer') console.log('loading golden_idx.json ...'); }); - getJNSDAOV(); - getAllJNS(); - getAllJNSVote(); + // JNS -> JNSDAOV, JNSVote, etc. + getAllJNS().then(() => { + getJNSDAOV(); + getAllJNSVote(); + }); } function getAddressInfos(){ @@ -512,6 +540,8 @@ angular.module('ethExplorer') } function getAllJNS() { + var deferred = $q.defer(); + $scope.allJNS = []; var addr = $scope.addressId; var contract = new web3.eth.Contract(jns_ABI, jns_contract_address); @@ -542,6 +572,9 @@ angular.module('ethExplorer') } }); } + + if (balance > 0) + deferred.resolve(); } }); @@ -553,6 +586,9 @@ angular.module('ethExplorer') console.log('[addressInfo] chainId: ', $scope.chainId, 'account: ', $scope.account, 'jnsContractOwner: ', $scope.jnsContractOwner); $scope.$apply(); }); + + + return deferred.promise; } function getAllJNSVote() { diff --git a/views/addressInfo.html b/views/addressInfo.html index d00fc06..a7809e4 100644 --- a/views/addressInfo.html +++ b/views/addressInfo.html @@ -30,7 +30,7 @@

能量余额: - {{balanceInEther || "计算中..."}} J (焦耳),即 {{balance || "计算中..."}} e (能量单位) + {{balanceInEther || "-"}} J (焦耳),即 {{balance || "-"}} e (能量单位) 数字资产: @@ -38,7 +38,7 @@

Wrapped Joule - {{wjBalanceInJoule || "计算中..."}} wJ + {{wjBalanceInJoule || "-"}} wJ @@ -49,26 +49,23 @@

藏品和徽章: - JTI: {{countJTI || "统计中..."}} + JTI: {{countJTI || "-"}} - , - FlyingJ: {{countFlyingJ || "统计中..."}} - , - CryptoJunks: {{countCryptoJunks || "统计中..."}} - , - JNSDAO V: {{countJNSDAOV || "统计中..."}} - - - - , - JNS: {{countJNS || "统计中..."}} + , FlyingJ: {{countFlyingJ}} + , CryptoJunks: {{countCryptoJunks}} + , JNS: {{countJNS}} - , - JNSVote POAP: {{countJNSVote || "统计中..."}} + , JNSVote POAP: {{countJNSVote}} + + , JNSDAO V: {{countJNSDAOV || "统计中..."}} + + + + @@ -134,15 +131,24 @@

@@ -150,4 +156,34 @@ + + + +