diff options
Diffstat (limited to 'cmd/web/js/admin.jsx')
-rw-r--r-- | cmd/web/js/admin.jsx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/cmd/web/js/admin.jsx b/cmd/web/js/admin.jsx new file mode 100644 index 0000000..81ce15d --- /dev/null +++ b/cmd/web/js/admin.jsx | |||
@@ -0,0 +1,45 @@ | |||
1 | import Api from './api.js'; | ||
2 | import React from 'react'; | ||
3 | import {PFBalanceMinimal} from './balance.js'; | ||
4 | import Panel from './panel.js'; | ||
5 | |||
6 | class AdminDashboard extends React.Component { | ||
7 | constructor(state) { | ||
8 | super(state); | ||
9 | this.state = {'portfolios': null}; | ||
10 | } | ||
11 | |||
12 | load = () => { | ||
13 | Api.Call('ADMIN_PORTFOLIOS', {}, function(err, status, data) { | ||
14 | if (err) { | ||
15 | console.error(err, data); | ||
16 | return; | ||
17 | } | ||
18 | |||
19 | this.setState({'portfolios': data}); | ||
20 | }.bind(this)); | ||
21 | } | ||
22 | |||
23 | componentDidMount = () => { | ||
24 | this.load(); | ||
25 | } | ||
26 | |||
27 | render = () => { | ||
28 | if (this.state.portfolios === null) { | ||
29 | return <div></div>; | ||
30 | } | ||
31 | var portfolios = Object.keys(this.state.portfolios).map(function(email) { | ||
32 | return <div className="row" key={email}> | ||
33 | <div className="col-6"><span>{email}:</span></div> | ||
34 | <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}/> | ||
36 | </div> | ||
37 | </div>; | ||
38 | }.bind(this)); | ||
39 | |||
40 | return <Panel component={<div>{portfolios}</div>} title="Portfolios Overview"/>; | ||
41 | } | ||
42 | |||
43 | } | ||
44 | |||
45 | export default AdminDashboard; | ||