From e5d7c2410fba8b4746217699333c9b7a3661e418 Mon Sep 17 00:00:00 2001
From: Sam Wilkins <samwilkins333@gmail.com>
Date: Wed, 27 Feb 2019 11:29:55 -0500
Subject: workspaces toggle now loads ids

---
 .../authentication/controllers/WorkspacesMenu.tsx  | 55 +++++++++++++++++-----
 1 file changed, 42 insertions(+), 13 deletions(-)

(limited to 'src/server/authentication/controllers/WorkspacesMenu.tsx')

diff --git a/src/server/authentication/controllers/WorkspacesMenu.tsx b/src/server/authentication/controllers/WorkspacesMenu.tsx
index 77e3a9778..23a3d35da 100644
--- a/src/server/authentication/controllers/WorkspacesMenu.tsx
+++ b/src/server/authentication/controllers/WorkspacesMenu.tsx
@@ -3,6 +3,7 @@ import * as ReactDOM from 'react-dom';
 import { observable, action, configure, reaction, computed } from 'mobx';
 import { observer } from "mobx-react";
 import * as request from 'request'
+import './WorkspacesMenu.css'
 
 @observer
 export class WorkspacesMenu extends React.Component {
@@ -15,33 +16,61 @@ export class WorkspacesMenu extends React.Component {
         WorkspacesMenu.Instance = this;
     }
 
+    @action
     toggle() {
-        action(() => {
-            if (!this.workspacesExposed) {
-                request.get(window.location.origin + "/getAllWorkspaceIds", (error, response, body) => {
-                    this.workspaceIds = body;
-                    console.log(this.workspaceIds);
-                })
+        if (this.workspacesExposed) {
+            this.workspacesExposed = !this.workspacesExposed;
+        } else {
+            request.get(window.location.origin + "/getAllWorkspaceIds", this.idCallback)
+        }
+    }
+
+    @action.bound
+    idCallback: request.RequestCallback = (error, response, body) => {
+        this.workspaceIds = [];
+        let ids: Array<string> = JSON.parse(body) as Array<string>;
+        if (ids) {
+            for (let i = 0; i < ids.length; i++) {
+                this.workspaceIds.push(ids[i]);
             }
+            console.log(this.workspaceIds);
             this.workspacesExposed = !this.workspacesExposed;
-        });
+        }
+    }
+
+    setWorkspaceId = (e: React.MouseEvent) => {
+
     }
 
     render() {
         return (
             <div
                 style={{
-                    width: "150px",
-                    height: "150px",
+                    width: "auto",
+                    height: "auto",
+                    borderRadius: 5,
                     position: "absolute",
-                    top: 75,
-                    right: 0,
-                    background: "grey",
+                    top: 50,
+                    left: 8,
+                    background: "white",
+                    border: "black solid 2px",
+                    transition: "all 0.3s ease",
                     zIndex: 15,
+                    padding: 10,
                     visibility: this.workspacesExposed ? "visible" : "hidden"
                 }}
             >
-                {this.workspaceIds.map(s => <li key={s} >${s}</li>)}
+                {this.workspaceIds.map(s =>
+                    <li className={"ids"}
+                        key={s}
+                        style={{
+                            listStyleType: "none",
+                            paddingTop: 3,
+                            paddingBottom: 3
+                        }}
+                        onClick={this.setWorkspaceId}
+                    >{s}</li>
+                )}
             </div>
         );
     }
-- 
cgit v1.2.3-70-g09d2

