From 2e4885d98ec49203180deb7e4e9148762e4720e7 Mon Sep 17 00:00:00 2001
From: jloup <jloup@jloup.work>
Date: Sun, 13 May 2018 23:14:26 +0200
Subject: Admin minimal dashboard.

---
 cmd/web/js/admin.jsx | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 cmd/web/js/admin.jsx

(limited to 'cmd/web/js/admin.jsx')

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 <div></div>;
+    }
+    var portfolios = Object.keys(this.state.portfolios).map(function(email) {
+      return <div className="row" key={email}>
+               <div className="col-6"><span>{email}:</span></div>
+               <div className="col-6 text-center">
+                 <PFBalanceMinimal variationP={this.state.portfolios[email].performance.variationP} balance={this.state.portfolios[email].value} periodStart={this.state.portfolios[email].periodStart}/>
+               </div>
+             </div>;
+    }.bind(this));
+
+    return <Panel component={<div>{portfolios}</div>} title="Portfolios Overview"/>;
+  }
+
+}
+
+export default AdminDashboard;
-- 
cgit v1.2.3

