diff options
Diffstat (limited to 'cmd/web')
-rw-r--r-- | cmd/web/js/admin.jsx | 45 | ||||
-rw-r--r-- | cmd/web/js/api.js | 9 | ||||
-rw-r--r-- | cmd/web/js/balance.jsx | 14 | ||||
-rw-r--r-- | cmd/web/js/main.jsx | 7 |
4 files changed, 74 insertions, 1 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; | ||
diff --git a/cmd/web/js/api.js b/cmd/web/js/api.js index 63355f0..b626c5f 100644 --- a/cmd/web/js/api.js +++ b/cmd/web/js/api.js | |||
@@ -142,6 +142,15 @@ var ApiEndpoints = { | |||
142 | return '/otp/validate'; | 142 | return '/otp/validate'; |
143 | } | 143 | } |
144 | }, | 144 | }, |
145 | 'ADMIN_PORTFOLIOS': { | ||
146 | 'type': 'GET', | ||
147 | 'auth': true, | ||
148 | 'parameters': [], | ||
149 | 'buildUrl': function() { | ||
150 | return '/admin/portfolios'; | ||
151 | } | ||
152 | }, | ||
153 | |||
145 | }; | 154 | }; |
146 | 155 | ||
147 | Api.BuildRequest = function(endpointId, params) { | 156 | Api.BuildRequest = function(endpointId, params) { |
diff --git a/cmd/web/js/balance.jsx b/cmd/web/js/balance.jsx index 515a7ed..6217e96 100644 --- a/cmd/web/js/balance.jsx +++ b/cmd/web/js/balance.jsx | |||
@@ -95,4 +95,16 @@ class PFBalance extends React.Component { | |||
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | export {PFBalance, Assets}; | 98 | class PFBalanceMinimal extends React.Component { |
99 | render = () => { | ||
100 | return <React.Fragment> | ||
101 | <div className="balance"> | ||
102 | <div className="col-12"> | ||
103 | <CurrencyLogo currency="BTC" /> <span><strong>{this.props.balance}</strong> <strong>{formatVariation(this.props.variationP)}</strong></span> | ||
104 | </div> | ||
105 | </div> | ||
106 | </React.Fragment>; | ||
107 | } | ||
108 | } | ||
109 | |||
110 | export {PFBalance, Assets, PFBalanceMinimal}; | ||
diff --git a/cmd/web/js/main.jsx b/cmd/web/js/main.jsx index 7fa2d26..8014377 100644 --- a/cmd/web/js/main.jsx +++ b/cmd/web/js/main.jsx | |||
@@ -5,6 +5,7 @@ import ChangePasswordForm from './change_password.js'; | |||
5 | import OtpEnrollForm from './otp.js'; | 5 | import OtpEnrollForm from './otp.js'; |
6 | import PoloniexController from './poloniex.js'; | 6 | import PoloniexController from './poloniex.js'; |
7 | import UserAccount from './account.js'; | 7 | import UserAccount from './account.js'; |
8 | import AdminDashboard from './admin.js'; | ||
8 | import App from './app.js'; | 9 | import App from './app.js'; |
9 | import Api from './api.js'; | 10 | import Api from './api.js'; |
10 | import cookies from './cookies.js'; | 11 | import cookies from './cookies.js'; |
@@ -101,6 +102,12 @@ App.page('/account', true, function(context) { | |||
101 | </div>); | 102 | </div>); |
102 | }); | 103 | }); |
103 | 104 | ||
105 | App.page('/admin', true, function(context) { | ||
106 | App.mount(<div> | ||
107 | <AdminDashboard/> | ||
108 | </div>); | ||
109 | }); | ||
110 | |||
104 | App.page('/not_confirmed', true, function(context) { | 111 | App.page('/not_confirmed', true, function(context) { |
105 | App.mount(<div> | 112 | App.mount(<div> |
106 | <div className="row"> | 113 | <div className="row"> |