aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/Main.tsx22
-rw-r--r--src/server/authentication/controllers/WorkspacesMenu.tsx48
-rw-r--r--src/server/authentication/models/user_model.ts5
-rw-r--r--src/server/index.ts23
4 files changed, 77 insertions, 21 deletions
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index e66816b6b..e55bc693e 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -1,4 +1,4 @@
-import { action, configure, reaction, computed } from 'mobx';
+import { action, configure, reaction, computed, observable } from 'mobx';
import "normalize.css";
import * as React from 'react';
import * as ReactDOM from 'react-dom';
@@ -19,6 +19,7 @@ import { Transform } from '../util/Transform';
import { CollectionDockingView } from './collections/CollectionDockingView';
import { FieldWaiting } from '../../fields/Field';
import { UndoManager } from '../util/UndoManager';
+import { WorkspacesMenu } from '../../server/authentication/controllers/WorkspacesMenu';
configure({
@@ -49,13 +50,13 @@ request.get(window.location.origin + "/getActiveWorkspaceId", (error, response,
},
json: true
})
+ request.post(here + "/setActiveWorkspaceId", {
+ body: {
+ target: mainDocId
+ },
+ json: true
+ })
}
- request.post(here + "/setActiveWorkspaceId", {
- body: {
- target: mainDocId
- },
- json: true
- })
init();
})
@@ -184,6 +185,13 @@ function init() {
right: '0px',
width: '150px'
}} onClick={() => window.location.pathname = "/logout"}>Logout</button>
+ <button style={{
+ position: 'absolute',
+ top: '50px',
+ right: '0px',
+ width: '150px'
+ }} onClick={() => WorkspacesMenu.Instance.toggle()}>Workspaces</button>
+ <WorkspacesMenu />
</div>),
document.getElementById('root'));
})
diff --git a/src/server/authentication/controllers/WorkspacesMenu.tsx b/src/server/authentication/controllers/WorkspacesMenu.tsx
new file mode 100644
index 000000000..77e3a9778
--- /dev/null
+++ b/src/server/authentication/controllers/WorkspacesMenu.tsx
@@ -0,0 +1,48 @@
+import * as React from 'react';
+import * as ReactDOM from 'react-dom';
+import { observable, action, configure, reaction, computed } from 'mobx';
+import { observer } from "mobx-react";
+import * as request from 'request'
+
+@observer
+export class WorkspacesMenu extends React.Component {
+ static Instance: WorkspacesMenu;
+ @observable private workspacesExposed: boolean = false;
+ @observable private workspaceIds: Array<string> = [];
+
+ constructor(props: Readonly<{}>) {
+ super(props);
+ WorkspacesMenu.Instance = this;
+ }
+
+ toggle() {
+ action(() => {
+ if (!this.workspacesExposed) {
+ request.get(window.location.origin + "/getAllWorkspaceIds", (error, response, body) => {
+ this.workspaceIds = body;
+ console.log(this.workspaceIds);
+ })
+ }
+ this.workspacesExposed = !this.workspacesExposed;
+ });
+ }
+
+ render() {
+ return (
+ <div
+ style={{
+ width: "150px",
+ height: "150px",
+ position: "absolute",
+ top: 75,
+ right: 0,
+ background: "grey",
+ zIndex: 15,
+ visibility: this.workspacesExposed ? "visible" : "hidden"
+ }}
+ >
+ {this.workspaceIds.map(s => <li key={s} >${s}</li>)}
+ </div>
+ );
+ }
+} \ No newline at end of file
diff --git a/src/server/authentication/models/user_model.ts b/src/server/authentication/models/user_model.ts
index dfd104ef8..29076ba19 100644
--- a/src/server/authentication/models/user_model.ts
+++ b/src/server/authentication/models/user_model.ts
@@ -23,7 +23,6 @@ export type DashUserModel = mongoose.Document & {
allWorkspaceIds: Array<String>,
activeWorkspaceId: String,
- didSelectSessionWorkspace: Boolean,
profile: {
name: string,
@@ -54,10 +53,6 @@ const userSchema = new mongoose.Schema({
default: []
},
activeWorkspaceId: String,
- didSelectSessionWorkspace: {
- type: Boolean,
- default: false
- },
facebook: String,
twitter: String,
diff --git a/src/server/index.ts b/src/server/index.ts
index 6136b8d94..8f740b1d7 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -87,18 +87,15 @@ app.get("/home", (req, res) => {
}
// otherwise, connect them to Dash
// TODO: store and manage users' workspaces
- if (dashUser.allWorkspaceIds.length > 0) {
- if (!dashUser.didSelectSessionWorkspace) {
- return res.redirect("/workspaces");
- }
- } else {
- console.log("OK, UPDATED TO TRUE");
- dashUser.update({ $set: { didSelectSessionWorkspace: true } }, () => { })
- }
+ // if (dashUser.allWorkspaceIds.length > 0) {
+ // if (!dashUser.didSelectSessionWorkspace) {
+ // return res.redirect("/workspaces");
+ // }
+ // }
res.sendFile(path.join(__dirname, '../../deploy/index.html'));
});
-app.get("/workspaces", getWorkspaces);
+// app.get("/workspaces", getWorkspaces);
app.get("/getActiveWorkspaceId", (req, res) => {
const dashUser: DashUserModel = req.user;
@@ -108,6 +105,14 @@ app.get("/getActiveWorkspaceId", (req, res) => {
res.send(dashUser.activeWorkspaceId || "");
});
+app.get("/getAllWorkspaceIds", (req, res) => {
+ const dashUser: DashUserModel = req.user;
+ if (!dashUser) {
+ return;
+ }
+ res.send(dashUser.allWorkspaceIds);
+})
+
app.post("/setActiveWorkspaceId", (req, res) => {
const dashUser: DashUserModel = req.user;
if (!dashUser) {