From 8ea26fc316685f0a3d1b81b7c2e8bd612acbb99c Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Fri, 8 Mar 2019 23:42:40 -0500 Subject: workspace persistencegit add -Agit add -A --- src/client/views/Main.tsx | 11 ++++++++++- src/client/views/nodes/DocumentView.tsx | 2 +- src/server/authentication/controllers/WorkspacesMenu.tsx | 14 ++++++++++---- src/server/index.ts | 1 - 4 files changed, 21 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index da7e17f1f..cb13e172e 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -35,6 +35,11 @@ export class Main extends React.Component { this.initEventListeners(); Documents.initProtos(() => { + // retrieve all workspace documents from the server + request.get(this.contextualize("getAllWorkspaceIds"), (error, res, body) => { + let ids = JSON.parse(body) as string[]; + Server.GetFields(ids, action((fields: { [id: string]: Field }) => this.userWorkspaces = ids.map(id => fields[id] as Document))); + }) this.initAuthenticationRouters(); }); } @@ -54,6 +59,7 @@ export class Main extends React.Component { // Load the user's active workspace, or create a new one if initial session after signup request.get(this.contextualize("getActiveWorkspaceId"), (error, response, body) => { if (body) { + console.log("FROM THE TOP, SOMEONE'S ALREADY BEEN HERE"); Server.GetField(body, field => { if (field instanceof Document) { this.openDocument(field); @@ -62,6 +68,7 @@ export class Main extends React.Component { } }); } else { + console.log("FROM THE TOP, WE THINK THERE'S NO CURRENT USER"); this.createNewWorkspace(); } }); @@ -69,7 +76,7 @@ export class Main extends React.Component { @action createNewWorkspace = (): void => { - let mainDoc = Documents.DockDocument(JSON.stringify({ content: [{ type: 'row', content: [] }] }), { title: "main container" }); + let mainDoc = Documents.DockDocument(JSON.stringify({ content: [{ type: 'row', content: [] }] }), { title: `Main Container ${this.userWorkspaces.length}` }); let newId = mainDoc.Id; request.post(this.contextualize("addWorkspaceId"), { body: { target: newId }, @@ -86,6 +93,7 @@ export class Main extends React.Component { this.openDocument(mainDoc); }, 0); this.userWorkspaces.push(mainDoc); + console.log(this.userWorkspaces.length); } @action @@ -94,6 +102,7 @@ export class Main extends React.Component { body: { target: doc.Id }, json: true }); + console.log(`OPENING ${doc.Id}`); this.mainContainer = doc; this.mainContainer.GetAsync(KeyStore.ActiveFrame, field => this.mainfreeform = field as Document); } diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 19a455b74..0052e9316 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -212,7 +212,7 @@ export class DocumentView extends React.Component { SelectionManager.SelectDoc(this, e.ctrlKey); } - @computed get mainContent() { + get mainContent() { return { height: "auto", borderRadius: 5, position: "absolute", - top: 50, - left: this.workspacesExposed ? 8 : -500, + top: 55, + left: this.workspacesExposed ? 11 : -500, background: "white", border: "black solid 2px", transition: "all 1s ease", zIndex: 15, padding: 10, + paddingRight: 12, }}> { color: s.Id === this.props.active.Id ? "darkblue" : "black", cursor: "grab" }} - onClick={() => this.props.open(s)} + onClick={() => { + this.props.open(s); + console.log(this.props.allWorkspaces.length); + }} >{s.Title} )} diff --git a/src/server/index.ts b/src/server/index.ts index 40e1f6686..3e0c28f14 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -117,7 +117,6 @@ addSecureRoute(Method.Get, "home", (user, req, res) => { }, res => res.redirect("/login")) addSecureRoute(Method.Get, "getActiveWorkspaceId", (user, req, res) => { - console.log(`/getActiveWorkspaceId in index.ts ${user.activeWorkspaceId}`); res.send(user.activeWorkspaceId || ""); }, () => { }); -- cgit v1.2.3-70-g09d2