From 150af985a8e5b77b7bb2d0a314749360405d8b63 Mon Sep 17 00:00:00 2001 From: Satinder Grewal Date: Sun, 5 Feb 2017 00:47:04 +1300 Subject: [PATCH] refresh basilisk connections action added to basilisk actions menu --- assets/scripts/dashboard.js | 19 ++++++- assets/scripts/iguana_api.js | 105 ++++++++++++++++++++++++++++++++++- index.html | 80 +++++++++++++++++++++++--- 3 files changed, 192 insertions(+), 12 deletions(-) diff --git a/assets/scripts/dashboard.js b/assets/scripts/dashboard.js index ab2c836..5bb4465 100644 --- a/assets/scripts/dashboard.js +++ b/assets/scripts/dashboard.js @@ -255,6 +255,7 @@ var Dashboard = function() { var edexcoin_sendto_result_tbl = ''; edexcoin_sendto_result_tbl += 'InfoThe transaction submitted is processing. Once processed the transaction details will be displayed here.'; $('#edexcoin_sendto_result tbody').html(edexcoin_sendto_result_tbl); + $('#edexcoin_send_coins_anothertx_btn').hide(); var tmp_json_data = {'coin':active_edexcoin,'sendtoaddr':tmp_send_to_addr,'amount':tmp_send_total_amount}; console.log(tmp_json_data); @@ -476,12 +477,25 @@ var Dashboard = function() { $('#atomic_explorer_select_command_options option[value=dex_getnotaries]').attr('selected','selected'); $( "#atomic_explorer_getcoinpeers_btn" ).trigger( "click" ); }) - + $(".btn_edexcoin_dashboard_register").click(function() { var selected_coin = $(this).data('edexcoin') var coinmainaddr = EDEXMainAddr(selected_coin); Iguana_DEXImportAddr(selected_coin,coinmainaddr[0]); - + }) + + $(".btn_edexcoin_dashboard_refresh_basilisk_conn").click(function() { + var show_mdl = setTimeout(function() { + var selected_coin = $(this).data('edexcoin') + $('#RefreshBasiliskConnectionsMdl').modal('show') + }, 0) + var start_refresh = setTimeout(function() { + EDEX_DEXgetinfoAll() + }, 3000) + + Promise.all([show_mdl, start_refresh]).then(function() { + console.log('all promises executed!!!'); + }); }) $(".btn_edexcoin_dashboard_validate").click(function() { @@ -666,6 +680,7 @@ function edexCoinBtnAction() { $.each($('[data-edexcoinmenu]'), function(index, value) {$('[data-edexcoinmenu]').attr("data-edexcoinmenu",coincode); $('[data-edexcoinmenu="'+coincode+'"]')}); $('#edexcoin-active').text(selected_coinname); + $('#edex_total_balance_coincode').text(coincode); //populate selected coin's address var coinmainaddr = EDEXMainAddr(coincode); $('#edexcoin_active_addr').text(coinmainaddr[0]); diff --git a/assets/scripts/iguana_api.js b/assets/scripts/iguana_api.js index 98084e6..b618260 100644 --- a/assets/scripts/iguana_api.js +++ b/assets/scripts/iguana_api.js @@ -676,24 +676,28 @@ function EDEXSendToAddr(data) { toastr.error("Sent Transaction failed. Please check send Transaction page for details.", "Wallet Notification"); edexcoin_sendto_result_tbl += 'error' + SendToAddrData.error + ''; $('#edexcoin_sendto_result tbody').html(edexcoin_sendto_result_tbl); + $('#edexcoin_send_coins_anothertx_btn').show(); } if ( SendToAddrData.complete !== undefined ) { + var active_edexcoin = $('[data-edexcoin]').attr("data-edexcoin"); toastr.success("Transaction sent successfully. Check send section for details.", "Wallet Notification"); edexcoin_sendto_result_tbl += 'complete' + SendToAddrData.complete + '' edexcoin_sendto_result_tbl += 'result' + SendToAddrData.result + '' edexcoin_sendto_result_tbl += 'sendrawtransaction' + SendToAddrData.sendrawtransaction + '' edexcoin_sendto_result_tbl += 'signedtx' + SendToAddrData.signedtx + '' $('#edexcoin_sendto_result tbody').html(edexcoin_sendto_result_tbl); + $('#edexcoin_send_coins_anothertx_btn').show(); } - var active_edexcoin = $('[data-edexcoin]').attr("data-edexcoin"); var selected_coinmode = sessionStorage.getItem('edexTmpMode') if ( selected_coinmode == 'Basilisk' ) { + var active_edexcoin = $('[data-edexcoin]').attr("data-edexcoin"); var coinwalletbalance = getDEXCoinBalance(active_edexcoin) console.log(coinwalletbalance) //coinwalletbalance = coinwalletbalance.total $('#edex_total_balance').text(coinwalletbalance.total); } else { + var active_edexcoin = $('[data-edexcoin]').attr("data-edexcoin"); var tmp_get_coin_balance = EDEXlistunspent(active_edexcoin) if (tmp_get_coin_balance[0] != undefined) { //console.log(tmp_get_coin_balance[0]) @@ -1109,6 +1113,105 @@ function EDEX_DEXlistunspent(coin,addr) { } +function EDEX_DEXnotarychains() { + NProgress.done(true); + NProgress.configure({ + template: '
' + }); + NProgress.start(); + var result = []; + + var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth'); + var ajax_data = {'userpass':tmpIguanaRPCAuth,"agent":"dpow","method":"notarychains"} + console.log(ajax_data); + $.ajax({ + async: false, + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + //dataType: 'text', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); //Ajax output gets the whole list of unspent coin with addresses + console.log('== EDEX_DEXnotarychains Data OutPut =='); + //console.log(AjaxOutputData); + result.push(AjaxOutputData); + }, + error: function(xhr, textStatus, error) { + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); + //console.log(result); + NProgress.done(); + return result[0]; +} + + +function EDEX_DEXgetinfoAll() { + NProgress.done(true); + NProgress.configure({ + template: '
' + }); + NProgress.start(); + var result = []; + + var get_dex_notarychains = EDEX_DEXnotarychains(); + console.log(get_dex_notarychains.length) + + //var refresh_percent = ''; + + $.each(get_dex_notarychains, function( coin_index, coin_value ) { + console.log(coin_index + ': ' + coin_value); + //var refresh_percent = parseFloat(parseInt(coin_index, 10) * 100)/ parseInt(get_dex_notarychains.length, 10); + //console.log(refresh_percent) + //$('#basilisk-connections-refresh-title').text(coin_value); + //$('#basilisk-connections-refresh-percent').text(refresh_percent+'%'); + //$('#basilisk-connections-refresh-progress-bar').width(refresh_percent+'%') + var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth'); + var ajax_data = {'userpass':tmpIguanaRPCAuth,"agent":"dex","method":"getinfo","symbol":coin_value} + //console.log(ajax_data); + $.ajax({ + async: false, + type: 'POST', + data: JSON.stringify(ajax_data), + url: 'http://127.0.0.1:7778', + //dataType: 'text', + success: function(data, textStatus, jqXHR) { + var AjaxOutputData = JSON.parse(data); //Ajax output gets the whole list of unspent coin with addresses + console.log('== EDEX_DEXgetinfoAll Data OutPut =='); + console.log(AjaxOutputData); + if (AjaxOutputData == '' ) { + result.push([{"amount":0}]); + } + result.push(AjaxOutputData); + if (AjaxOutputData.error === 'less than required responses') { + toastr.info("Less than required responses for "+coin_value+".", "Basilisk Notification") + } + }, + error: function(xhr, textStatus, error) { + console.log(xhr.statusText); + if ( xhr.readyState == 0 ) { + Iguana_ServiceUnavailable(); + } + console.log(textStatus); + console.log(error); + } + }); + }); + //$('#basilisk-connections-refresh-progress-bar').width('100%') + $('#RefreshBasiliskConnectionsMdl').modal('hide') + toastr.success("Basilsk nodes connections refreshed.", "Basilisk Notification") + + //console.log(result); + NProgress.done(); + return result[0]; +} + + function Shepherd_getConf(coin) { var result = []; var ajax_data = {"chain":coin}; diff --git a/index.html b/index.html index 17648c3..58c7787 100755 --- a/index.html +++ b/index.html @@ -77,6 +77,66 @@
+ + +