aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/Main.tsx
diff options
context:
space:
mode:
authorSam Wilkins <abdullah_ahmed@brown.edu>2019-03-09 21:50:07 -0500
committerSam Wilkins <abdullah_ahmed@brown.edu>2019-03-09 21:50:07 -0500
commitf9f0fd90791562c295f8d9b237596cbabb086b79 (patch)
tree4c355c2175a3f8f8aacf0218cc6e62ec1e0ed712 /src/client/views/Main.tsx
parente673d4f70b8feb37dcd328440c019a49f8a22e88 (diff)
parent96eede5f7d1706a3f7ac6ee02a85bb3da217f467 (diff)
finalized workspace manipulation and merged with master
Diffstat (limited to 'src/client/views/Main.tsx')
-rw-r--r--src/client/views/Main.tsx34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index b160a7671..73d5fa8a9 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -4,8 +4,9 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Document } from '../../fields/Document';
import { KeyStore } from '../../fields/KeyStore';
+import "./Main.scss";
+import { MessageStore } from '../../server/Message';
import { Utils } from '../../Utils';
-import { MessageStore, DocumentTransfer } from '../../server/Message';
import * as request from 'request'
import { Documents } from '../documents/Documents';
import { Server } from '../Server';
@@ -20,6 +21,7 @@ import { DocumentView } from './nodes/DocumentView';
import "./Main.scss";
import { observer } from 'mobx-react';
import { Field, Opt } from '../../fields/Field';
+import { InkingControl } from './InkingControl';
@observer
export class Main extends React.Component {
@@ -57,6 +59,7 @@ export class Main extends React.Component {
Server.GetField(body, field => {
if (field instanceof Document) {
this.openDocument(field);
+ this.populateWorkspaces();
} else {
this.createNewWorkspace(true);
}
@@ -74,15 +77,7 @@ export class Main extends React.Component {
request.post(this.contextualize("addWorkspaceId"), {
body: { target: newId },
json: true
- }, () => {
- if (init) {
- // 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)));
- });
- }
- });
+ }, () => { if (init) this.populateWorkspaces(); });
// bcz: strangely, we need a timeout to prevent exceptions/issues initializing GoldenLayout (the rendering engine for Main Container)
setTimeout(() => {
@@ -93,7 +88,15 @@ export class Main extends React.Component {
this.openDocument(mainDoc);
}, 0);
this.userWorkspaces.push(mainDoc);
- console.log(this.userWorkspaces.length);
+ }
+
+ @action
+ populateWorkspaces = () => {
+ // 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)));
+ });
}
@action
@@ -102,7 +105,6 @@ 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);
}
@@ -122,12 +124,15 @@ export class Main extends React.Component {
let schemaRef = React.createRef<HTMLDivElement>();
let colRef = React.createRef<HTMLDivElement>();
let workspacesRef = React.createRef<HTMLDivElement>();
+ let pdfRef = React.createRef<HTMLDivElement>();
let imgurl = "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg";
+ let pdfurl = "http://www.adobe.com/support/products/enterprise/knowledgecenter/media/c4611_sample_explain.pdf"
let weburl = "https://cs.brown.edu/courses/cs166/";
let clearDatabase = action(() => Utils.Emit(Server.Socket, MessageStore.DeleteAll, {}))
let addTextNode = action(() => Documents.TextDocument({ width: 200, height: 200, title: "a text note" }))
let addColNode = action(() => Documents.FreeformDocument([], { width: 200, height: 200, title: "a feeform collection" }));
+ let addPDFNode = action(() => Documents.PdfDocument(pdfurl, { width: 200, height: 200, title: "a schema collection" }));
let addSchemaNode = action(() => Documents.SchemaDocument([Documents.TextDocument()], { width: 200, height: 200, title: "a schema collection" }));
let addImageNode = action(() => Documents.ImageDocument(imgurl, { width: 200, height: 200, title: "an image of a cat" }));
let addWebNode = action(() => Documents.WebDocument(weburl, { width: 200, height: 200, title: "a sample web page" }));
@@ -146,6 +151,7 @@ export class Main extends React.Component {
PanelHeight={() => 0}
isTopMost={true}
SelectOnLoad={false}
+ focus={() => { }}
ContainingCollectionView={undefined} />
<DocumentDecorations />
<ContextMenu />
@@ -164,6 +170,8 @@ export class Main extends React.Component {
<button onClick={clearDatabase}>Clear Database</button></div>
<div className="main-buttonDiv" style={{ top: '25px' }} ref={workspacesRef}>
<button onClick={this.toggleWorkspaces}>View Workspaces</button></div>
+ <div className="main-buttonDiv" style={{ bottom: '150px' }} ref={pdfRef}>
+ <button onPointerDown={setupDrag(pdfRef, addPDFNode)} onClick={addClick(addPDFNode)}>Add PDF</button></div>
<button className="main-undoButtons" style={{ bottom: '25px' }} onClick={() => UndoManager.Undo()}>Undo</button>
<button className="main-undoButtons" style={{ bottom: '0px' }} onClick={() => UndoManager.Redo()}>Redo</button>
</div>
@@ -171,4 +179,4 @@ export class Main extends React.Component {
}
}
-ReactDOM.render(<Main />, document.getElementById('root')); \ No newline at end of file
+ReactDOM.render(<Main />, document.getElementById('root'));