From 4126d3b15d8a93004df4e6eefe485c9f1fb86a00 Mon Sep 17 00:00:00 2001 From: bob Date: Tue, 19 Mar 2019 10:27:44 -0400 Subject: cleaned up main and fixed resizing. --- src/client/views/Main.scss | 11 ++- src/client/views/Main.tsx | 163 +++++++++++++++++++++++---------------------- 2 files changed, 93 insertions(+), 81 deletions(-) (limited to 'src') diff --git a/src/client/views/Main.scss b/src/client/views/Main.scss index bb42db202..698a9c617 100644 --- a/src/client/views/Main.scss +++ b/src/client/views/Main.scss @@ -154,7 +154,16 @@ button:hover { cursor: pointer; } } - +#main-div { + width:100%; + height:100%; + position:absolute; +} +#mainContent-div { + width:100%; + height:100%; + position:absolute; +} #add-options-content { display: table; opacity: 1; diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index d103bf34a..8a52a501c 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -1,4 +1,4 @@ -import { action, configure, observable, runInAction } from 'mobx'; +import { action, configure, observable, runInAction, trace, computed } from 'mobx'; import "normalize.css"; import * as React from 'react'; import * as ReactDOM from 'react-dom'; @@ -42,6 +42,7 @@ import { ServerUtils } from '../../server/ServerUtil'; import { CurrentUserUtils } from '../../server/authentication/models/current_user_utils'; import { Field, Opt } from '../../fields/Field'; import { ListField } from '../../fields/ListField'; +import { map } from 'bluebird'; @observer export class Main extends React.Component { @@ -196,112 +197,114 @@ export class Main extends React.Component { } } - render() { - let imgRef = React.createRef(); - let pdfRef = React.createRef(); - let webRef = React.createRef(); - let textRef = React.createRef(); - let schemaRef = React.createRef(); - let videoRef = React.createRef(); - let audioRef = React.createRef(); - let colRef = React.createRef(); - let workspacesRef = React.createRef(); - let logoutRef = React.createRef(); + screenToLocalTransform = () => Transform.Identity + pwidthFunc = () => this.pwidth; + pheightFunc = () => this.pheight; + focusDocument = (doc: Document) => { } + noScaling = () => 1; + get content() { + return !this.mainContainer ? (null) : + + } + + /* for the expandable add nodes menu. Not included with the miscbuttons because once it expands it expands the whole div with it, making canvas interactions limited. */ + @computed + get nodesMenu() { 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 audiourl = "http://techslides.com/demos/samples/sample.mp3"; let videourl = "http://techslides.com/demos/sample-videos/small.mp4"; - 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 freeform collection" })); - let addSchemaNode = action(() => Documents.SchemaDocument([Documents.TextDocument()], { width: 200, height: 200, title: "a schema collection" })); + let addSchemaNode = action(() => Documents.SchemaDocument([], { width: 200, height: 200, title: "a schema collection" })); let addVideoNode = action(() => Documents.VideoDocument(videourl, { width: 200, height: 200, title: "video node" })); let addPDFNode = action(() => Documents.PdfDocument(pdfurl, { 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" })); let addAudioNode = action(() => Documents.AudioDocument(audiourl, { width: 200, height: 200, title: "audio node" })) + let btns = [ + [React.createRef(), "font", "Add Textbox", addTextNode], + [React.createRef(), "image", "Add Image", addImageNode], + [React.createRef(), "file-pdf", "Add PDF", addPDFNode], + [React.createRef(), "film", "Add Video", addVideoNode], + [React.createRef(), "music", "Add Audio", addAudioNode], + [React.createRef(), "globe-asia", "Add Web Clipping", addWebNode], + [React.createRef(), "object-group", "Add Collection", addColNode], + [React.createRef(), "table", "Add Schema", addSchemaNode], + ] + let addClick = (creator: () => Document) => action(() => this.mainfreeform!.GetList(KeyStore.Data, []).push(creator())); + return < div id="add-nodes-menu" > + + + +
+
    + {btns.map(btn => +
  • }> + +
  • )} +
+
+ + } + + /* @TODO this should really be moved into a moveable toolbar component, but for now let's put it here to meet the deadline */ + @computed + get miscButtons() { + let workspacesRef = React.createRef(); + let logoutRef = React.createRef(); + + let clearDatabase = action(() => Utils.Emit(Server.Socket, MessageStore.DeleteAll, {})) + return [ + , +
+ + + +
, +
+
, +
+
+ ] + } + + render() { return ( -
+
runInAction(() => { this.pwidth = r.entry.width; this.pheight = r.entry.height; })}> - {({ measureRef }) => { - if (!this.mainContainer) { - return
- } - return
- Transform.Identity} - ContentScaling={() => 1} - PanelWidth={() => this.pwidth} - PanelHeight={() => this.pheight} - isTopMost={true} - SelectOnLoad={false} - focus={() => { }} - ContainingCollectionView={undefined} /> + {({ measureRef }) => +
+ {this.content}
- }} + } - - - - {/* @TODO this should really be moved into a moveable toolbar component, but for now let's put it here to meet the deadline */} - < div id="toolbar" > - - - -
- -
-
-
-
- + {this.nodesMenu} + {this.miscButtons} - {/* for the expandable add nodes menu. Not included with the above because once it expands it expands the whole div with it, making canvas interactions limited. */} - < div id="add-nodes-menu" > - - - -
-
    -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
-
-
-
); -- cgit v1.2.3-70-g09d2