X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=cmd%2Fweb%2Fjs%2Fpoloniex.jsx;h=db6b1c43da71f123ec830dc8d6a8f89bffbe8146;hb=50c6eea630c5bf6d1513d093125f11ce30deaff5;hp=482dbb6c9b437ca2f0bf2af7e93ed2378810ff55;hpb=6b3f0ad04550060fd25b87b68c3f9bc1602f3226;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FFront.git diff --git a/cmd/web/js/poloniex.jsx b/cmd/web/js/poloniex.jsx index 482dbb6..db6b1c4 100644 --- a/cmd/web/js/poloniex.jsx +++ b/cmd/web/js/poloniex.jsx @@ -32,6 +32,8 @@ class PoloniexController extends React.Component { console.error(err, data); if (err.code === 'invalid_market_credentials') { this.setState({'flag': 'invalidCredentials', 'valueCurrency': null, 'balanceValue': null, 'balance': null}); + } else if (err.code === 'ip_restricted_api_key') { + this.setState({'flag': 'ipRestricted', 'valueCurrency': null, 'balanceValue': null, 'balance': null}); } return; } @@ -68,6 +70,9 @@ class PoloniexController extends React.Component { case 'invalidCredentials': displayText = 'Invalid poloniex credentials'; break; + case 'ipRestricted': + displayText = 'Your API key is IP restricted. Please whitelist us.'; + break; case 'emptyCredentials': displayText = 'Please provide poloniex credentials'; break; @@ -108,6 +113,10 @@ class PoloniexBalance extends React.Component { this.state = {'hideMsg': true, 'msg': '', 'msgOk': false}; } + computeCurrencyRatio = (currency) => { + return (parseFloat(this.props.balance[currency].btcValue) / parseFloat(this.props.balanceValue) * 100.0).toFixed(1); + } + render = () => { var dashboard = null; @@ -115,16 +124,18 @@ class PoloniexBalance extends React.Component { var balance = Object.keys(this.props.balance).map(function(currency) { return
- {this.props.balance[currency]} +
+ {this.props.balance[currency].amount} {currency} ({this.computeCurrencyRatio(currency)}%) +
; }.bind(this)); dashboard =
-
+
{balance}
-
+
Balance ({this.props.balanceCurrency}): {this.props.balanceValue}