diff options
author | jloup <jean-loup.jamet@trainline.com> | 2018-07-19 18:00:20 +0200 |
---|---|---|
committer | jloup <jean-loup.jamet@trainline.com> | 2018-07-19 18:00:20 +0200 |
commit | 1fcb77583201f9979a839fcae2dd642edc25af96 (patch) | |
tree | 778f6aca2612fc277c612dcb748cacf2e0d975ac /cmd/web/js/admin.jsx | |
parent | 574bf1e47f1b611449faa8fa5848ba63dfc7d0e9 (diff) | |
download | Front-1fcb77583201f9979a839fcae2dd642edc25af96.tar.gz Front-1fcb77583201f9979a839fcae2dd642edc25af96.tar.zst Front-1fcb77583201f9979a839fcae2dd642edc25af96.zip |
Display total balance/performance.v0.0.24
Diffstat (limited to 'cmd/web/js/admin.jsx')
-rw-r--r-- | cmd/web/js/admin.jsx | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/cmd/web/js/admin.jsx b/cmd/web/js/admin.jsx index 81ce15d..19eb3ef 100644 --- a/cmd/web/js/admin.jsx +++ b/cmd/web/js/admin.jsx | |||
@@ -6,7 +6,7 @@ import Panel from './panel.js'; | |||
6 | class AdminDashboard extends React.Component { | 6 | class AdminDashboard extends React.Component { |
7 | constructor(state) { | 7 | constructor(state) { |
8 | super(state); | 8 | super(state); |
9 | this.state = {'portfolios': null}; | 9 | this.state = {'portfolios': null, 'globalPerformance': null}; |
10 | } | 10 | } |
11 | 11 | ||
12 | load = () => { | 12 | load = () => { |
@@ -16,7 +16,13 @@ class AdminDashboard extends React.Component { | |||
16 | return; | 16 | return; |
17 | } | 17 | } |
18 | 18 | ||
19 | this.setState({'portfolios': data}); | 19 | this.setState({ |
20 | 'portfolios': data.portfolios, | ||
21 | 'globalPerformance': { | ||
22 | 'totalBtcValue': data.totalBtcValue, | ||
23 | 'totalBtcVariation': data.totalBtcVariation | ||
24 | } | ||
25 | }); | ||
20 | }.bind(this)); | 26 | }.bind(this)); |
21 | } | 27 | } |
22 | 28 | ||
@@ -28,15 +34,24 @@ class AdminDashboard extends React.Component { | |||
28 | if (this.state.portfolios === null) { | 34 | if (this.state.portfolios === null) { |
29 | return <div></div>; | 35 | return <div></div>; |
30 | } | 36 | } |
37 | |||
38 | var globalPerformance = <div className="row" key="global"> | ||
39 | <div className="col-6"><span>Total:</span></div> | ||
40 | <div className="col-6 text-center"> | ||
41 | <PFBalanceMinimal variationP={this.state.globalPerformance.totalBtcVariation} balance={this.state.globalPerformance.totalBtcValue} isPercent={false}/> | ||
42 | </div> | ||
43 | </div>; | ||
31 | var portfolios = Object.keys(this.state.portfolios).map(function(email) { | 44 | var portfolios = Object.keys(this.state.portfolios).map(function(email) { |
32 | return <div className="row" key={email}> | 45 | return <div className="row" key={email}> |
33 | <div className="col-6"><span>{email}:</span></div> | 46 | <div className="col-6"><span>{email}:</span></div> |
34 | <div className="col-6 text-center"> | 47 | <div className="col-6 text-center"> |
35 | <PFBalanceMinimal variationP={this.state.portfolios[email].performance.variationP} balance={this.state.portfolios[email].value} periodStart={this.state.portfolios[email].periodStart}/> | 48 | <PFBalanceMinimal variationP={this.state.portfolios[email].performance.variationP} balance={this.state.portfolios[email].value} isPercent={true}/> |
36 | </div> | 49 | </div> |
37 | </div>; | 50 | </div>; |
38 | }.bind(this)); | 51 | }.bind(this)); |
39 | 52 | ||
53 | portfolios.push(<hr key="hr"/>, globalPerformance); | ||
54 | |||
40 | return <Panel component={<div>{portfolios}</div>} title="Portfolios Overview"/>; | 55 | return <Panel component={<div>{portfolios}</div>} title="Portfolios Overview"/>; |
41 | } | 56 | } |
42 | 57 | ||