From 2e4885d98ec49203180deb7e4e9148762e4720e7 Mon Sep 17 00:00:00 2001 From: jloup Date: Sun, 13 May 2018 23:14:26 +0200 Subject: Admin minimal dashboard. --- cmd/web/js/admin.jsx | 45 +++++++++++++++++++++++++++++++++++++++++++++ cmd/web/js/api.js | 9 +++++++++ cmd/web/js/balance.jsx | 14 +++++++++++++- cmd/web/js/main.jsx | 7 +++++++ 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 cmd/web/js/admin.jsx (limited to 'cmd/web/js') 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 @@ +import Api from './api.js'; +import React from 'react'; +import {PFBalanceMinimal} from './balance.js'; +import Panel from './panel.js'; + +class AdminDashboard extends React.Component { + constructor(state) { + super(state); + this.state = {'portfolios': null}; + } + + load = () => { + Api.Call('ADMIN_PORTFOLIOS', {}, function(err, status, data) { + if (err) { + console.error(err, data); + return; + } + + this.setState({'portfolios': data}); + }.bind(this)); + } + + componentDidMount = () => { + this.load(); + } + + render = () => { + if (this.state.portfolios === null) { + return
; + } + var portfolios = Object.keys(this.state.portfolios).map(function(email) { + return
+
{email}:
+
+ +
+
; + }.bind(this)); + + return {portfolios}} title="Portfolios Overview"/>; + } + +} + +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 = { return '/otp/validate'; } }, + 'ADMIN_PORTFOLIOS': { + 'type': 'GET', + 'auth': true, + 'parameters': [], + 'buildUrl': function() { + return '/admin/portfolios'; + } + }, + }; 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 { } } -export {PFBalance, Assets}; +class PFBalanceMinimal extends React.Component { + render = () => { + return +
+
+ {this.props.balance} {formatVariation(this.props.variationP)} +
+
+
; + } +} + +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'; import OtpEnrollForm from './otp.js'; import PoloniexController from './poloniex.js'; import UserAccount from './account.js'; +import AdminDashboard from './admin.js'; import App from './app.js'; import Api from './api.js'; import cookies from './cookies.js'; @@ -101,6 +102,12 @@ App.page('/account', true, function(context) { ); }); +App.page('/admin', true, function(context) { + App.mount(
+ +
); +}); + App.page('/not_confirmed', true, function(context) { App.mount(
-- cgit v1.2.3