From e5d7c2410fba8b4746217699333c9b7a3661e418 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Wed, 27 Feb 2019 11:29:55 -0500 Subject: workspaces toggle now loads ids --- src/client/views/Main.tsx | 4 +- .../authentication/controllers/WorkspacesMenu.css | 3 ++ .../authentication/controllers/WorkspacesMenu.tsx | 55 +++++++++++++++++----- src/server/index.ts | 2 +- 4 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 src/server/authentication/controllers/WorkspacesMenu.css (limited to 'src') diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index e55bc693e..90ce8be1a 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -187,8 +187,8 @@ function init() { }} onClick={() => window.location.pathname = "/logout"}>Logout diff --git a/src/server/authentication/controllers/WorkspacesMenu.css b/src/server/authentication/controllers/WorkspacesMenu.css new file mode 100644 index 000000000..b89039965 --- /dev/null +++ b/src/server/authentication/controllers/WorkspacesMenu.css @@ -0,0 +1,3 @@ +.ids:hover { + color: darkblue; +} \ No newline at end of file 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 = JSON.parse(body) as Array; + 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 (
- {this.workspaceIds.map(s =>
  • ${s}
  • )} + {this.workspaceIds.map(s => +
  • {s}
  • + )}
    ); } diff --git a/src/server/index.ts b/src/server/index.ts index 8f740b1d7..1d16f65ed 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -110,7 +110,7 @@ app.get("/getAllWorkspaceIds", (req, res) => { if (!dashUser) { return; } - res.send(dashUser.allWorkspaceIds); + res.send(JSON.stringify(dashUser.allWorkspaceIds as Array)); }) app.post("/setActiveWorkspaceId", (req, res) => { -- cgit v1.2.3-70-g09d2