diff options
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/views/Main.tsx | 2 | ||||
| -rw-r--r-- | src/client/views/collections/CollectionViewBase.tsx | 28 |
2 files changed, 27 insertions, 3 deletions
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index d845fa7a3..32b6335d8 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -50,7 +50,7 @@ Documents.initProtos(mainDocId, (res?: Document) => { }, 0); } - let imgurl = "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg"; + let imgurl = "http://localhost:1050/images/upload_9a3bfff22137b88012650570fb1fe344.png"; 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" })) diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx index 47c9e0986..661cec8ae 100644 --- a/src/client/views/collections/CollectionViewBase.tsx +++ b/src/client/views/collections/CollectionViewBase.tsx @@ -1,4 +1,4 @@ -import { action } from "mobx"; +import { action, runInAction } from "mobx"; import { Document } from "../../../fields/Document"; import { ListField } from "../../../fields/ListField"; import React = require("react"); @@ -62,7 +62,6 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps> @action protected onDrop(e: React.DragEvent, options: DocumentOptions): void { - console.log("DRRRRROOOOPPPPPP"); e.stopPropagation() e.preventDefault() let that = this; @@ -112,6 +111,31 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps> method: 'POST', body: formData }) + .then((res: Response) => { + return res.json() + }).then(json => { + + json.map((file: any) => { + console.log(file) + console.log(typeof file) + let path = window.location.origin + file + console.log(path) + runInAction(() => { + var img = Documents.ImageDocument(path, { ...options, nativeWidth: 300, width: 300, }) + let docs = that.props.Document.GetT(KeyStore.Data, ListField); + if (docs != FieldWaiting) { + if (!docs) { + docs = new ListField<Document>(); + that.props.Document.Set(KeyStore.Data, docs) + } + docs.Data.push(img); + + } + }) + + + }) + }) // fReader.addEventListener("load", action("drop", () => { // if (fReader.result) { // let form = request.post(upload).form(); |
