From 66dc0aefa9972071a8d3f5163048867071dd2b59 Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Mon, 18 Mar 2019 16:10:06 -0400 Subject: Fixes for ink --- src/client/views/InkingCanvas.tsx | 2 +- src/fields/Document.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/client/views/InkingCanvas.tsx b/src/client/views/InkingCanvas.tsx index d7b8bf3c3..8d0121035 100644 --- a/src/client/views/InkingCanvas.tsx +++ b/src/client/views/InkingCanvas.tsx @@ -46,7 +46,7 @@ export class InkingCanvas extends React.Component { } set inkData(value: StrokeMap) { - this.props.Document.SetOnPrototype(KeyStore.Ink, new InkField(value)); + this.props.Document.SetDataOnPrototype(KeyStore.Ink, value, InkField); } componentDidMount() { diff --git a/src/fields/Document.ts b/src/fields/Document.ts index be0137128..b6439364a 100644 --- a/src/fields/Document.ts +++ b/src/fields/Document.ts @@ -248,6 +248,13 @@ export class Document extends Field { } } + @action + SetDataOnPrototype(key: Key, value: T, ctor: { new(): U }, replaceWrongType = true) { + this.GetAsync(KeyStore.Prototype, (f: Field) => { + (f as Document).SetData(key, value, ctor) + }) + } + @action SetData(key: Key, value: T, ctor: { new(): U }, replaceWrongType = true) { -- cgit v1.2.3-70-g09d2 From 9e55d38acc7a6ef1477a81068c5b201f9b13a2e8 Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Mon, 18 Mar 2019 16:13:21 -0400 Subject: Got rid of some SetOnPrototype --- src/client/views/InkingControl.tsx | 2 +- src/client/views/nodes/FormattedTextBox.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/client/views/InkingControl.tsx b/src/client/views/InkingControl.tsx index ad6bbd476..eb2172d03 100644 --- a/src/client/views/InkingControl.tsx +++ b/src/client/views/InkingControl.tsx @@ -40,7 +40,7 @@ export class InkingControl extends React.Component { if (SelectionManager.SelectedDocuments().length == 1) { var sdoc = SelectionManager.SelectedDocuments()[0]; if (sdoc.props.ContainingCollectionView && sdoc.props.ContainingCollectionView) { - sdoc.props.Document.SetOnPrototype(KeyStore.BackgroundColor, new TextField(color.hex)); + sdoc.props.Document.SetDataOnPrototype(KeyStore.BackgroundColor, color.hex, TextField); } } } diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index 4bd5726f4..ba9bd9566 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -56,7 +56,7 @@ export class FormattedTextBox extends React.Component { const state = this._editorView.state.apply(tx); this._editorView.updateState(state); const { doc, fieldKey } = this.props; - doc.SetOnPrototype(fieldKey, new RichTextField(JSON.stringify(state.toJSON()))) + doc.SetDataOnPrototype(fieldKey, JSON.stringify(state.toJSON()), RichTextField); // doc.SetData(fieldKey, JSON.stringify(state.toJSON()), RichTextField); } } -- cgit v1.2.3-70-g09d2 From e367d4240f3158f7e67ba4d312e9c63356b79b9e Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Mon, 18 Mar 2019 16:53:00 -0400 Subject: Made drop code work better --- .../views/collections/CollectionDockingView.tsx | 3 +- .../views/collections/CollectionViewBase.tsx | 91 +++++++++++++--------- 2 files changed, 55 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx index 19788447e..bc510c9d5 100644 --- a/src/client/views/collections/CollectionDockingView.tsx +++ b/src/client/views/collections/CollectionDockingView.tsx @@ -16,6 +16,7 @@ import "./CollectionDockingView.scss"; import { COLLECTION_BORDER_WIDTH } from "./CollectionView"; import React = require("react"); import { SubCollectionViewProps } from "./CollectionViewBase"; +import { ServerUtils } from "../../../server/ServerUtil"; @observer export class CollectionDockingView extends React.Component { @@ -215,7 +216,7 @@ export class CollectionDockingView extends React.Component } } + protected getDocumentFromType(type: string, path: string, options: DocumentOptions): Opt { + let ctor: ((path: string, options: DocumentOptions) => Document) | undefined; + if (type.indexOf("image") !== -1) { + ctor = Documents.ImageDocument; + } + if (type.indexOf("video") !== -1) { + ctor = Documents.VideoDocument; + } + if (type.indexOf("audio") !== -1) { + ctor = Documents.AudioDocument; + } + if (type.indexOf("pdf") !== -1) { + ctor = Documents.PdfDocument; + } + if (type.indexOf("html") !== -1) { + ctor = Documents.WebDocument; + options = { height: options.width, ...options, }; + } + return ctor ? ctor(path, options) : undefined; + } + @action protected onDrop(e: React.DragEvent, options: DocumentOptions): void { let that = this; @@ -115,16 +138,25 @@ export class CollectionViewBase extends React.Component return; } - console.log(e.dataTransfer.items.length); - for (let i = 0; i < e.dataTransfer.items.length; i++) { const upload = window.location.origin + RouteStore.upload; let item = e.dataTransfer.items[i]; if (item.kind === "string" && item.type.indexOf("uri") != -1) { - e.dataTransfer.items[i].getAsString(action((s: string) => this.props.addDocument(Documents.WebDocument(s, options), false))) + e.dataTransfer.items[i].getAsString(action((s: string) => { + let document: Document; + request.head(ServerUtils.prepend(RouteStore.corsProxy + "/" + s), (err, res, body) => { + let type = res.headers["content-type"]; + if (type) { + let doc = this.getDocumentFromType(type, s, { ...options, width: 300, nativeWidth: 300 }) + if (doc) { + this.props.addDocument(doc, false); + } + } + }); + // this.props.addDocument(Documents.WebDocument(s, { ...options, width: 300, height: 300 }), false) + })) } let type = item.type - console.log(type) if (item.kind == "file") { let file = item.getAsFile(); let formData = new FormData() @@ -136,44 +168,27 @@ export class CollectionViewBase extends React.Component fetch(upload, { method: 'POST', body: formData - }) - .then((res: Response) => { - return res.json() - }).then(json => { - - json.map((file: any) => { - let path = window.location.origin + file - runInAction(() => { - var doc: any; - - if (type.indexOf("image") !== -1) { - doc = Documents.ImageDocument(path, { ...options, nativeWidth: 200, width: 200, }) - } - if (type.indexOf("video") !== -1) { - doc = Documents.VideoDocument(path, { ...options, nativeWidth: 300, width: 300, }) + }).then((res: Response) => { + return res.json() + }).then(json => { + json.map((file: any) => { + let path = window.location.origin + file + runInAction(() => { + let doc = this.getDocumentFromType(type, path, { ...options, nativeWidth: 300, width: 300 }) + + let docs = that.props.Document.GetT(KeyStore.Data, ListField); + if (docs != FieldWaiting) { + if (!docs) { + docs = new ListField(); + that.props.Document.Set(KeyStore.Data, docs) } - if (type.indexOf("audio") !== -1) { - doc = Documents.AudioDocument(path, { ...options, nativeWidth: 300, width: 300, }) + if (doc) { + docs.Data.push(doc); } - if (type.indexOf("pdf") !== -1) { - doc = Documents.PdfDocument(path, { ...options, nativeWidth: 300, width: 300, }) - } - let docs = that.props.Document.GetT(KeyStore.Data, ListField); - if (docs != FieldWaiting) { - if (!docs) { - docs = new ListField(); - that.props.Document.Set(KeyStore.Data, docs) - } - if (doc) { - docs.Data.push(doc); - } - - } - }) + } }) }) - - + }) } } } -- cgit v1.2.3-70-g09d2 From ab55b4745e4c30547f8b3e23dcc9af455241e7ae Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Mon, 18 Mar 2019 18:40:12 -0400 Subject: Got rid of web box in FieldView --- src/client/views/nodes/FieldView.tsx | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx index e84c5f933..b6d50bffb 100644 --- a/src/client/views/nodes/FieldView.tsx +++ b/src/client/views/nodes/FieldView.tsx @@ -59,9 +59,6 @@ export class FieldView extends React.Component { else if (field instanceof ImageField) { return } - else if (field instanceof WebField) { - return - } else if (field instanceof VideoField) { return } -- cgit v1.2.3-70-g09d2 From 700d10e7bdba9e6536b8a5616fc333c11e1ed289 Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Mon, 18 Mar 2019 19:53:23 -0400 Subject: increased the timeout on login sessions --- src/server/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/index.ts b/src/server/index.ts index 5773514ea..6226dbfe2 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -52,7 +52,7 @@ app.use(cookieParser()); app.use(session({ secret: "64d6866242d3b5a5503c675b32c9605e4e90478e9b77bcf2bc", resave: true, - cookie: { maxAge: 7 * 24 * 60 * 60 }, + cookie: { maxAge: 7 * 24 * 60 * 60 * 1000 }, saveUninitialized: true, store: new MongoStore({ url: 'mongodb://localhost:27017/Dash' -- cgit v1.2.3-70-g09d2