aboutsummaryrefslogtreecommitdiff
path: root/src/mobile/ImageUpload.tsx
diff options
context:
space:
mode:
authortschicke-brown <tyler_schicke@brown.edu>2019-03-18 14:07:18 -0400
committerGitHub <noreply@github.com>2019-03-18 14:07:18 -0400
commit7d5bb60662dc6a879df261f9eafeda89d6574cd7 (patch)
tree8275d70be6aa728de3fea9af76b9422464143227 /src/mobile/ImageUpload.tsx
parent861614569c2d72e0ee9a6a698f3978f609a3b2bc (diff)
parentbe117e38a63a558684baa69f719787f11dfc3be3 (diff)
Merge pull request #65 from browngraphicslab/authentication
Authentication
Diffstat (limited to 'src/mobile/ImageUpload.tsx')
-rw-r--r--src/mobile/ImageUpload.tsx53
1 files changed, 28 insertions, 25 deletions
diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx
index 292a3a035..16808a598 100644
--- a/src/mobile/ImageUpload.tsx
+++ b/src/mobile/ImageUpload.tsx
@@ -1,15 +1,15 @@
import * as ReactDOM from 'react-dom';
import React = require('react');
import "./ImageUpload.scss"
-import { action, runInAction } from "mobx";
-import { type } from 'os';
-import { Documents } from '../client/documents/Documents';
import { Document } from '../fields/Document';
+import { KeyStore } from '../fields/KeyStore';
import { Server } from '../client/Server';
-import { Opt, Field } from '../fields/Field';
+import { Documents } from '../client/documents/Documents';
import { ListField } from '../fields/ListField';
-import { KeyStore } from '../fields/KeyStore';
import { ImageField } from '../fields/ImageField';
+import request = require('request');
+import { ServerUtils } from '../server/ServerUtil';
+import { RouteStore } from '../server/RouteStore';
@@ -20,7 +20,6 @@ import { ImageField } from '../fields/ImageField';
// imgInput.click();
// }
// }
-const pendingDocId = "pending-doc"
const onFileLoad = (file: any) => {
let imgPrev = document.getElementById("img_preview")
@@ -40,32 +39,36 @@ const onFileLoad = (file: any) => {
}).then(json => {
json.map((file: any) => {
let path = window.location.origin + file
- runInAction(() => {
- var doc: Document = Documents.ImageDocument(path, { nativeWidth: 200, width: 200 })
- doc.GetTAsync(KeyStore.Data, ImageField, (i) => {
- if (i) {
- document.getElementById("message")!.innerText = i.Data.href;
- }
- })
- Server.GetField(pendingDocId, (res: Opt<Field>) => {
- if (res) {
- if (res instanceof Document) {
- res.GetOrCreateAsync(KeyStore.Data, ListField, (f: ListField<Document>) => {
- f.Data.push(doc)
- })
+ var doc: Document = Documents.ImageDocument(path, { nativeWidth: 200, width: 200 })
+ doc.GetTAsync(KeyStore.Data, ImageField, (i) => {
+ if (i) {
+ document.getElementById("message")!.innerText = i.Data.href;
+ }
+ })
+ request.get(ServerUtils.prepend(RouteStore.getActiveWorkspace), (error, response, body) => {
+ if (body) {
+ Server.GetField(body, field => {
+ if (field instanceof Document) {
+ field.GetTAsync(KeyStore.OptionalRightCollection, Document,
+ pending => {
+ if (pending) {
+ pending.GetOrCreateAsync(KeyStore.Data, ListField, list => {
+ list.Data.push(doc);
+ })
+ }
+ })
}
}
- })
+ );
+ }
})
+ // console.log(window.location.origin + file[0])
+
+ //imgPrev.setAttribute("src", window.location.origin + files[0].name)
})
})
- // console.log(window.location.origin + file[0])
-
- //imgPrev.setAttribute("src", window.location.origin + files[0].name)
}
}
-
-
}
ReactDOM.render((