From 1183f65cea62078cfa1df615da20b72f5b60433e Mon Sep 17 00:00:00 2001 From: Monika Hedman Date: Sat, 9 Mar 2019 19:06:39 -0500 Subject: image uploading --- .../views/collections/CollectionViewBase.tsx | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src/client/views/collections/CollectionViewBase.tsx') 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 @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 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(); + 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(); -- cgit v1.2.3-70-g09d2