From f8a2744ea03ec03236284939d14787b04b9c8aa6 Mon Sep 17 00:00:00 2001
From: Andrew Kim <andrewdkim@users.noreply.github.com>
Date: Sat, 16 Mar 2019 18:19:08 -0400
Subject: asdfasfd

---
 src/mobile/ImageUpload.tsx | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 src/mobile/ImageUpload.tsx

(limited to 'src/mobile/ImageUpload.tsx')

diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx
new file mode 100644
index 000000000..566fe9d6c
--- /dev/null
+++ b/src/mobile/ImageUpload.tsx
@@ -0,0 +1,11 @@
+ReactDOM.render((
+    <div
+        style={{
+            position: "absolute",
+            width: "100%",
+            height: "100%",
+            background: "yellow"
+        }}
+    ></div>),
+    document.getElementById('root')
+);
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2


From 7d24a1a063b0a087b51a4c521479ffcb63638d98 Mon Sep 17 00:00:00 2001
From: Andrew Kim <andrewdkim@users.noreply.github.com>
Date: Sat, 16 Mar 2019 19:06:36 -0400
Subject: yellow page

---
 src/mobile/ImageUpload.tsx | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'src/mobile/ImageUpload.tsx')

diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx
index 566fe9d6c..a43e6e365 100644
--- a/src/mobile/ImageUpload.tsx
+++ b/src/mobile/ImageUpload.tsx
@@ -1,3 +1,6 @@
+import * as ReactDOM from 'react-dom'; 
+import React = require('react');
+
 ReactDOM.render((
     <div
         style={{
-- 
cgit v1.2.3-70-g09d2


From eeae1bd225080e900d78d41dca3ec62d16d47e6f Mon Sep 17 00:00:00 2001
From: Andrew Kim <andrewdkim@users.noreply.github.com>
Date: Sat, 16 Mar 2019 23:58:19 -0400
Subject: Testing Mobile Image

---
 src/mobile/ImageUpload.scss | 20 ++++++++++++++++++++
 src/mobile/ImageUpload.tsx  | 23 +++++++++++++++--------
 2 files changed, 35 insertions(+), 8 deletions(-)
 create mode 100644 src/mobile/ImageUpload.scss

(limited to 'src/mobile/ImageUpload.tsx')

diff --git a/src/mobile/ImageUpload.scss b/src/mobile/ImageUpload.scss
new file mode 100644
index 000000000..0663b977b
--- /dev/null
+++ b/src/mobile/ImageUpload.scss
@@ -0,0 +1,20 @@
+.imgupload_cont{
+    height: 100%;
+    width: 100%;
+    align-content: center;
+  
+   
+    .button_file{
+        text-align: center; 
+        height: 50%; 
+        width: 50%; 
+        background-color: paleturquoise; 
+        color: grey; 
+        font-size: 3em; 
+    }
+    .input_file{
+        background-color: transparent; 
+        display: none; 
+    }
+
+}
\ No newline at end of file
diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx
index a43e6e365..6e15b0802 100644
--- a/src/mobile/ImageUpload.tsx
+++ b/src/mobile/ImageUpload.tsx
@@ -1,14 +1,21 @@
 import * as ReactDOM from 'react-dom'; 
 import React = require('react');
+import "./ImageUpload.scss"
+
+
+
+const onPointerDown = (e: React.TouchEvent) => {
+    let imgInput = document.getElementById("input_image_file"); 
+    if (imgInput){
+        imgInput.click(); 
+    }
+}
 
 ReactDOM.render((
-    <div
-        style={{
-            position: "absolute",
-            width: "100%",
-            height: "100%",
-            background: "yellow"
-        }}
-    ></div>),
+    <div className = "imgupload_cont">
+        <button className = "button_file" onTouchStart = {onPointerDown}> Open Image </button>
+        <input type= "file" accept = "image/*" capture="camera" className = "input_file" id = "input_image_file"></input>
+        
+    </div>),
     document.getElementById('root')
 );
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2


From 94baa241afd3a99b233ae6197b7e404951347413 Mon Sep 17 00:00:00 2001
From: Andrew Kim <andrewdkim@users.noreply.github.com>
Date: Sun, 17 Mar 2019 19:07:17 -0400
Subject: Updated ImageUpload

---
 src/mobile/ImageUpload.tsx | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

(limited to 'src/mobile/ImageUpload.tsx')

diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx
index 6e15b0802..9a9ea0693 100644
--- a/src/mobile/ImageUpload.tsx
+++ b/src/mobile/ImageUpload.tsx
@@ -1,6 +1,8 @@
 import * as ReactDOM from 'react-dom'; 
 import React = require('react');
 import "./ImageUpload.scss"
+import { action, runInAction } from "mobx";
+
 
 
 
@@ -11,11 +13,31 @@ const onPointerDown = (e: React.TouchEvent) => {
     }
 }
 
+const onFileLoad = (file:any) => {
+    let img = new Image(); 
+    let imgPrev = document.getElementById("img_preview")
+    if (imgPrev){
+        let files = file.target.files; 
+        if (files.length != 0){
+            console.log(files[0]);
+            console.log(window.location.origin) 
+            const upload = window.location.origin + "/upload";
+            let formData = new FormData(); 
+            formData.append("file", files[0]);
+            console.log(window.location.origin + file[0])
+           
+            //imgPrev.setAttribute("src", window.location.origin + files[0].name)
+        }
+    }
+    
+   
+}
+
 ReactDOM.render((
     <div className = "imgupload_cont">
         <button className = "button_file" onTouchStart = {onPointerDown}> Open Image </button>
-        <input type= "file" accept = "image/*" capture="camera" className = "input_file" id = "input_image_file"></input>
-        
+        <input type= "file" accept = "image/*" capture="camera" onChange = {onFileLoad} className = "input_file" id = "input_image_file"></input>
+        <img id = "img_preview" src = ""></img>
     </div>),
     document.getElementById('root')
 );
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2


From 16eb812f464af0a4604b9cae60526c4282382b40 Mon Sep 17 00:00:00 2001
From: yipstanley <stanley_yip@brown.edu>
Date: Sun, 17 Mar 2019 19:33:10 -0400
Subject: uh

---
 src/mobile/ImageUpload.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/mobile/ImageUpload.tsx')

diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx
index ad589d51f..4f60c8c7d 100644
--- a/src/mobile/ImageUpload.tsx
+++ b/src/mobile/ImageUpload.tsx
@@ -36,7 +36,7 @@ const onFileLoad = (file: any) => {
 ReactDOM.render((
     <div className="imgupload_cont">
         <button className="button_file" onTouchStart={onPointerDown}> Open Image </button>
-        <input type="file" accept="image/*" capture="filesystem" onChange={onFileLoad} className="input_file" id="input_image_file"></input>
+        <input type="file" accept="image/*" onChange={onFileLoad} className="input_file" id="input_image_file"></input>
         <img id="img_preview" src=""></img>
     </div>),
     document.getElementById('root')
-- 
cgit v1.2.3-70-g09d2


From 345c445474292fe0bf56ff1a36f5a9a4b8411e95 Mon Sep 17 00:00:00 2001
From: yipstanley <stanley_yip@brown.edu>
Date: Sun, 17 Mar 2019 19:35:25 -0400
Subject: ah

---
 src/mobile/ImageUpload.scss | 24 ++++++++++--------------
 src/mobile/ImageUpload.tsx  |  2 +-
 2 files changed, 11 insertions(+), 15 deletions(-)

(limited to 'src/mobile/ImageUpload.tsx')

diff --git a/src/mobile/ImageUpload.scss b/src/mobile/ImageUpload.scss
index 0663b977b..2d8966be1 100644
--- a/src/mobile/ImageUpload.scss
+++ b/src/mobile/ImageUpload.scss
@@ -1,20 +1,16 @@
-.imgupload_cont{
+.imgupload_cont {
     height: 100%;
     width: 100%;
     align-content: center;
-  
-   
-    .button_file{
-        text-align: center; 
-        height: 50%; 
-        width: 50%; 
-        background-color: paleturquoise; 
-        color: grey; 
-        font-size: 3em; 
+    .button_file {
+        text-align: center;
+        height: 50%;
+        width: 50%;
+        background-color: paleturquoise;
+        color: grey;
+        font-size: 3em;
     }
-    .input_file{
-        background-color: transparent; 
-        display: none; 
+    .input_file {
+        background-color: transparent; // display: none; 
     }
-
 }
\ No newline at end of file
diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx
index 4f60c8c7d..8ad781990 100644
--- a/src/mobile/ImageUpload.tsx
+++ b/src/mobile/ImageUpload.tsx
@@ -35,7 +35,7 @@ const onFileLoad = (file: any) => {
 
 ReactDOM.render((
     <div className="imgupload_cont">
-        <button className="button_file" onTouchStart={onPointerDown}> Open Image </button>
+        {/* <button className="button_file" onTouchStart={onPointerDown}> Open Image </button> */}
         <input type="file" accept="image/*" onChange={onFileLoad} className="input_file" id="input_image_file"></input>
         <img id="img_preview" src=""></img>
     </div>),
-- 
cgit v1.2.3-70-g09d2


From 1328b125d2b414380d037206ab6f39b9d12f1ff1 Mon Sep 17 00:00:00 2001
From: yipstanley <stanley_yip@brown.edu>
Date: Sun, 17 Mar 2019 21:16:17 -0400
Subject: nacho fries

---
 .gitignore                  |  1 -
 src/client/views/Main.tsx   |  2 +-
 src/mobile/ImageUpload.scss |  7 ++----
 src/mobile/ImageUpload.tsx  | 55 ++++++++++++++++++++++++++++++++++-----------
 src/server/index.ts         |  2 +-
 5 files changed, 46 insertions(+), 21 deletions(-)

(limited to 'src/mobile/ImageUpload.tsx')

diff --git a/.gitignore b/.gitignore
index 7b9483f69..2f9680a59 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
 node_modules
 dist/
 .DS_Store
-src/server/public/files/*
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index 89ef16cc9..437d025ef 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -98,7 +98,7 @@ Documents.initProtos(mainDocId, (res?: Document) => {
                 })
             }
         })
-    }, 50)
+    }, 100)
 
     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"
diff --git a/src/mobile/ImageUpload.scss b/src/mobile/ImageUpload.scss
index 2d8966be1..d0b7d4e41 100644
--- a/src/mobile/ImageUpload.scss
+++ b/src/mobile/ImageUpload.scss
@@ -1,6 +1,6 @@
 .imgupload_cont {
-    height: 100%;
-    width: 100%;
+    height: 100vh;
+    width: 100vw;
     align-content: center;
     .button_file {
         text-align: center;
@@ -10,7 +10,4 @@
         color: grey;
         font-size: 3em;
     }
-    .input_file {
-        background-color: transparent; // display: none; 
-    }
 }
\ No newline at end of file
diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx
index 8ad781990..935f5b5c1 100644
--- a/src/mobile/ImageUpload.tsx
+++ b/src/mobile/ImageUpload.tsx
@@ -2,29 +2,58 @@ 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 { Server } from '../client/Server';
+import { Opt, Field } from '../fields/Field';
+import { ListField } from '../fields/ListField';
+import { KeyStore } from '../fields/KeyStore';
 
 
 
 
-const onPointerDown = (e: React.TouchEvent) => {
-    let imgInput = document.getElementById("input_image_file");
-    if (imgInput) {
-        imgInput.click();
-    }
-}
+// const onPointerDown = (e: React.TouchEvent) => {
+//     let imgInput = document.getElementById("input_image_file");
+//     if (imgInput) {
+//         imgInput.click();
+//     }
+// }
+const pendingDocId = "pending-doc"
 
 const onFileLoad = (file: any) => {
-    let img = new Image();
     let imgPrev = document.getElementById("img_preview")
     if (imgPrev) {
-        let files = file.target.files;
+        let files: File[] = file.target.files;
         if (files.length != 0) {
             console.log(files[0]);
-            console.log(window.location.origin)
-            const upload = window.location.origin + "/upload";
             let formData = new FormData();
             formData.append("file", files[0]);
-            console.log(window.location.origin + file[0])
+
+            const upload = window.location.origin + "/upload"
+            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: Document = Documents.ImageDocument(path, { nativeWidth: 200, width: 200 })
+                        Server.GetField(pendingDocId, (res: Opt<Field>) => {
+                            if (res) {
+                                if (res instanceof Document) {
+                                    res.GetOrCreateAsync(KeyStore.Data, ListField, (f: ListField<Document>) => {
+                                        f.Data.push(doc)
+                                    })
+                                }
+                            }
+                        })
+                    })
+                })
+            })
+            // console.log(window.location.origin + file[0])
 
             //imgPrev.setAttribute("src", window.location.origin + files[0].name)
         }
@@ -35,8 +64,8 @@ const onFileLoad = (file: any) => {
 
 ReactDOM.render((
     <div className="imgupload_cont">
-        {/* <button className="button_file" onTouchStart={onPointerDown}> Open Image </button> */}
-        <input type="file" accept="image/*" onChange={onFileLoad} className="input_file" id="input_image_file"></input>
+        {/* <button className = "button_file"  = {onPointerDown}> Open Image </button> */}
+        <input type="file" accept="image/*" capture="camera" onChange={onFileLoad} className="input_file" id="input_image_file"></input>
         <img id="img_preview" src=""></img>
     </div>),
     document.getElementById('root')
diff --git a/src/server/index.ts b/src/server/index.ts
index 0a89c61bd..4be35b7b7 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -106,7 +106,7 @@ app.get("/", (req: express.Request, res: express.Response) => {
     if (detector.mobile() != null) {
         res.sendFile(path.join(__dirname, '../../deploy/mobile/image.html'));
     } else {
-        res.sendFile(path.join(__dirname, '../../deploy/index.html'));
+        res.redirect("/doc/mainDoc");
     }
 });
 
-- 
cgit v1.2.3-70-g09d2


From 63ceada966447c67703a8f649d23c735dff23f3b Mon Sep 17 00:00:00 2001
From: Tyler Schicke <tyler_schicke@brown.edu>
Date: Mon, 18 Mar 2019 00:33:29 -0400
Subject: small change

---
 package-lock.json          | 103 ++++++++++++++++++++++-----------------------
 src/mobile/ImageUpload.tsx |   2 +-
 2 files changed, 52 insertions(+), 53 deletions(-)

(limited to 'src/mobile/ImageUpload.tsx')

diff --git a/package-lock.json b/package-lock.json
index bf9741d15..4ac055cf6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -227,7 +227,7 @@
     "@types/chai": {
       "version": "4.1.7",
       "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.7.tgz",
-      "integrity": "sha1-G44zthqMCcvh+FEzBxuqDb+fpxo=",
+      "integrity": "sha512-2Y8uPt0/jwjhQ6EiluT0XCri1Dbplr0ZxfFXUz+ye13gaqE8u5gL5ppao1JrUYr9cIip5S6MvQzBS7Kke7U9VA==",
       "dev": true
     },
     "@types/connect": {
@@ -637,7 +637,7 @@
     "@types/uuid": {
       "version": "3.4.4",
       "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.4.tgz",
-      "integrity": "sha1-evaTYPpl7w3stB/RUL9MpcDO/fU=",
+      "integrity": "sha512-tPIgT0GUmdJQNSHxp0X2jnpQfBSTfGxUMc/2CXBU2mnyTFVYVa2ojpoQ74w0U2yn2vw3jnC640+77lkFFpdVDw==",
       "requires": {
         "@types/node": "*"
       }
@@ -1147,7 +1147,7 @@
         },
         "util": {
           "version": "0.10.3",
-          "resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz",
+          "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
           "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
           "dev": true,
           "requires": {
@@ -1213,7 +1213,7 @@
     "awesome-typescript-loader": {
       "version": "5.2.1",
       "resolved": "https://registry.npmjs.org/awesome-typescript-loader/-/awesome-typescript-loader-5.2.1.tgz",
-      "integrity": "sha1-pB2veEdRX0klzbqjB11h8onpE/w=",
+      "integrity": "sha512-slv66OAJB8orL+UUaTI3pKlLorwIvS4ARZzYR9iJJyGsEgOqueMfOMdKySWzZ73vIkEe3fcwFgsKMg4d8zyb1g==",
       "dev": true,
       "requires": {
         "chalk": "^2.4.1",
@@ -1664,7 +1664,7 @@
     },
     "browserify-aes": {
       "version": "1.2.0",
-      "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
+      "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
       "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==",
       "dev": true,
       "requires": {
@@ -1701,7 +1701,7 @@
     },
     "browserify-rsa": {
       "version": "4.0.1",
-      "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
+      "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
       "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=",
       "dev": true,
       "requires": {
@@ -1740,7 +1740,7 @@
     },
     "buffer": {
       "version": "4.9.1",
-      "resolved": "http://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
+      "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
       "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=",
       "dev": true,
       "requires": {
@@ -1861,7 +1861,7 @@
     },
     "camelcase-keys": {
       "version": "2.1.0",
-      "resolved": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz",
+      "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz",
       "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=",
       "requires": {
         "camelcase": "^2.0.0",
@@ -1897,7 +1897,7 @@
     "chai": {
       "version": "4.2.0",
       "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz",
-      "integrity": "sha1-dgqnLPION5XoSxKHfODoNzeqKeU=",
+      "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==",
       "dev": true,
       "requires": {
         "assertion-error": "^1.1.0",
@@ -2291,7 +2291,7 @@
     },
     "content-disposition": {
       "version": "0.5.2",
-      "resolved": "http://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz",
+      "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz",
       "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ="
     },
     "content-type": {
@@ -2339,7 +2339,7 @@
     "copy-webpack-plugin": {
       "version": "4.6.0",
       "resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-4.6.0.tgz",
-      "integrity": "sha1-5/QN2KaEd9QF3Rt6hUquMksVi64=",
+      "integrity": "sha512-Y+SQCF+0NoWQryez2zXn5J5knmr9z/9qSQt7fbL78u83rxmigOy8X5+BFn8CFSuX+nKT8gpYwJX68ekqtQt6ZA==",
       "dev": true,
       "requires": {
         "cacache": "^10.0.4",
@@ -2410,7 +2410,7 @@
     },
     "create-hash": {
       "version": "1.2.0",
-      "resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
+      "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
       "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==",
       "dev": true,
       "requires": {
@@ -2423,7 +2423,7 @@
     },
     "create-hmac": {
       "version": "1.1.7",
-      "resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
+      "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
       "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==",
       "dev": true,
       "requires": {
@@ -2549,7 +2549,7 @@
     },
     "d": {
       "version": "1.0.0",
-      "resolved": "http://registry.npmjs.org/d/-/d-1.0.0.tgz",
+      "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz",
       "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=",
       "dev": true,
       "requires": {
@@ -2772,7 +2772,7 @@
     },
     "diffie-hellman": {
       "version": "5.0.3",
-      "resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
+      "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
       "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==",
       "dev": true,
       "requires": {
@@ -3315,7 +3315,7 @@
       "dependencies": {
         "array-flatten": {
           "version": "1.1.1",
-          "resolved": "http://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
+          "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
           "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
         },
         "statuses": {
@@ -3509,7 +3509,7 @@
     },
     "finalhandler": {
       "version": "1.1.1",
-      "resolved": "http://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz",
+      "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz",
       "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==",
       "requires": {
         "debug": "2.6.9",
@@ -3894,8 +3894,7 @@
         "inherits": {
           "version": "2.0.3",
           "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
-          "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
-          "optional": true
+          "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
         },
         "ini": {
           "version": "1.3.5",
@@ -4673,7 +4672,7 @@
     },
     "http-errors": {
       "version": "1.6.3",
-      "resolved": "http://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz",
+      "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz",
       "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=",
       "requires": {
         "depd": "~1.1.2",
@@ -4976,7 +4975,7 @@
     },
     "is-accessor-descriptor": {
       "version": "0.1.6",
-      "resolved": "http://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
+      "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
       "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=",
       "requires": {
         "kind-of": "^3.0.2"
@@ -5020,7 +5019,7 @@
     },
     "is-data-descriptor": {
       "version": "0.1.4",
-      "resolved": "http://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
+      "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
       "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=",
       "requires": {
         "kind-of": "^3.0.2"
@@ -5498,7 +5497,7 @@
     },
     "load-json-file": {
       "version": "1.1.0",
-      "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
+      "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
       "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=",
       "requires": {
         "graceful-fs": "^4.1.2",
@@ -5799,7 +5798,7 @@
     },
     "media-typer": {
       "version": "0.3.0",
-      "resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
+      "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
       "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
     },
     "mem": {
@@ -5831,7 +5830,7 @@
     },
     "meow": {
       "version": "3.7.0",
-      "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz",
+      "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz",
       "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=",
       "requires": {
         "camelcase-keys": "^2.0.0",
@@ -5997,7 +5996,7 @@
     },
     "mkdirp": {
       "version": "0.5.1",
-      "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
+      "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
       "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
       "requires": {
         "minimist": "0.0.8"
@@ -6023,7 +6022,7 @@
     "mobx-react": {
       "version": "5.4.3",
       "resolved": "https://registry.npmjs.org/mobx-react/-/mobx-react-5.4.3.tgz",
-      "integrity": "sha1-Zwm33YlnDEDpgVkUrCyknMAr+0c=",
+      "integrity": "sha512-WC8yFlwvJ91hy8j6CrydAuFteUafcuvdITFQeHl3LRIf5ayfT/4W3M/byhEYD2BcJWejeXr8y4Rh2H26RunCRQ==",
       "requires": {
         "hoist-non-react-statics": "^3.0.0",
         "react-lifecycles-compat": "^3.0.2"
@@ -6037,7 +6036,7 @@
     "mocha": {
       "version": "5.2.0",
       "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz",
-      "integrity": "sha1-bYrlCPWRZ/lA8rWzxKYSrlDJCuY=",
+      "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==",
       "dev": true,
       "requires": {
         "browser-stdout": "1.3.1",
@@ -6056,7 +6055,7 @@
         "debug": {
           "version": "3.1.0",
           "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
-          "integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=",
+          "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
           "dev": true,
           "requires": {
             "ms": "2.0.0"
@@ -6065,7 +6064,7 @@
         "glob": {
           "version": "7.1.2",
           "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
-          "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=",
+          "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
           "dev": true,
           "requires": {
             "fs.realpath": "^1.0.0",
@@ -6085,7 +6084,7 @@
         "supports-color": {
           "version": "5.4.0",
           "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz",
-          "integrity": "sha1-HGszdALCE3YF7+GfEP7DkPb6q1Q=",
+          "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==",
           "dev": true,
           "requires": {
             "has-flag": "^3.0.0"
@@ -6280,7 +6279,7 @@
     },
     "next-tick": {
       "version": "1.0.0",
-      "resolved": "http://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
+      "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
       "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=",
       "dev": true
     },
@@ -6339,7 +6338,7 @@
         },
         "semver": {
           "version": "5.3.0",
-          "resolved": "http://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
+          "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
           "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8="
         },
         "tar": {
@@ -6388,7 +6387,7 @@
     "node-sass": {
       "version": "4.11.0",
       "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.11.0.tgz",
-      "integrity": "sha1-GD+uw5jpy+k7pDNi4naMqYimNpo=",
+      "integrity": "sha512-bHUdHTphgQJZaF1LASx0kAviPH7sGlcyNhWade4eVIpFp6tsn7SV8xNMTbsQFpEV9VXpnwTTnNYlfsZXgGgmkA==",
       "requires": {
         "async-foreach": "^0.1.3",
         "chalk": "^1.1.1",
@@ -9727,12 +9726,12 @@
     },
     "os-homedir": {
       "version": "1.0.2",
-      "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
+      "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
       "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M="
     },
     "os-tmpdir": {
       "version": "1.0.2",
-      "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
+      "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
       "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ="
     },
     "osenv": {
@@ -9906,7 +9905,7 @@
     },
     "path-browserify": {
       "version": "0.0.0",
-      "resolved": "http://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz",
+      "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz",
       "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=",
       "dev": true
     },
@@ -9925,7 +9924,7 @@
     },
     "path-is-absolute": {
       "version": "1.0.1",
-      "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
+      "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
       "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
     },
     "path-is-inside": {
@@ -10938,7 +10937,7 @@
     },
     "readable-stream": {
       "version": "2.3.6",
-      "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
+      "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
       "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
       "requires": {
         "core-util-is": "~1.0.0",
@@ -11199,7 +11198,7 @@
     },
     "safe-regex": {
       "version": "1.1.0",
-      "resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
+      "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
       "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
       "requires": {
         "ret": "~0.1.10"
@@ -11233,7 +11232,7 @@
     "sass-loader": {
       "version": "7.1.0",
       "resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-7.1.0.tgz",
-      "integrity": "sha1-Fv1ROMuLQkv4p1lSihly1yqtBp0=",
+      "integrity": "sha512-+G+BKGglmZM2GUSfT9TLuEp6tzehHPjAMoRRItOojWIqIGPloVCMhNIQuG639eJ+y033PaGTSjLaTHts8Kw79w==",
       "dev": true,
       "requires": {
         "clone-deep": "^2.0.1",
@@ -11421,7 +11420,7 @@
     },
     "sha.js": {
       "version": "2.4.11",
-      "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
+      "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
       "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
       "dev": true,
       "requires": {
@@ -12201,7 +12200,7 @@
     },
     "string_decoder": {
       "version": "1.1.1",
-      "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
+      "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
       "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
       "requires": {
         "safe-buffer": "~5.1.0"
@@ -12209,7 +12208,7 @@
     },
     "strip-ansi": {
       "version": "3.0.1",
-      "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
+      "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
       "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
       "requires": {
         "ansi-regex": "^2.0.0"
@@ -12225,7 +12224,7 @@
     },
     "strip-eof": {
       "version": "1.0.0",
-      "resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
+      "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
       "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8="
     },
     "strip-indent": {
@@ -12244,7 +12243,7 @@
     "style-loader": {
       "version": "0.23.1",
       "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-0.23.1.tgz",
-      "integrity": "sha1-y5FUYG8+dxq2xKtjcCahBJF02SU=",
+      "integrity": "sha512-XK+uv9kWwhZMZ1y7mysB+zoihsEj4wneFWAS5qoiLwzW0WzSqMrrsIy+a3zkQJq0ipFtBpX5W3MqyRIBF/WFGg==",
       "dev": true,
       "requires": {
         "loader-utils": "^1.1.0",
@@ -12640,7 +12639,7 @@
     "ts-node": {
       "version": "7.0.1",
       "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz",
-      "integrity": "sha1-lWLcLR5tJI0kvFX3c+P2FDN9m68=",
+      "integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==",
       "dev": true,
       "requires": {
         "arrify": "^1.0.0",
@@ -12661,7 +12660,7 @@
     },
     "tty-browserify": {
       "version": "0.0.0",
-      "resolved": "http://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
+      "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
       "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=",
       "dev": true
     },
@@ -13032,7 +13031,7 @@
     "uuid": {
       "version": "3.3.2",
       "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
-      "integrity": "sha1-G0r0lV6zB3xQHCOHL8ZROBFYcTE="
+      "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
     },
     "v8-compile-cache": {
       "version": "2.0.2",
@@ -13071,7 +13070,7 @@
     },
     "vm-browserify": {
       "version": "0.0.4",
-      "resolved": "http://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz",
+      "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz",
       "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=",
       "dev": true,
       "requires": {
@@ -13612,7 +13611,7 @@
         "webpack-log": {
           "version": "2.0.0",
           "resolved": "https://registry.npmjs.org/webpack-log/-/webpack-log-2.0.0.tgz",
-          "integrity": "sha1-W3ko4GN1k/EZ0y9iJ8HgrDHhtH8=",
+          "integrity": "sha512-cX8G2vR/85UYG59FgkoMamwHUIkSSlV3bBMRsbxVXVUk2j6NleCKjQ/WE9eYg9WY4w25O9w8wKP4rzNZFmUcUg==",
           "dev": true,
           "requires": {
             "ansi-colors": "^3.0.0",
@@ -13860,7 +13859,7 @@
     },
     "wrap-ansi": {
       "version": "2.1.0",
-      "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
+      "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
       "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=",
       "requires": {
         "string-width": "^1.0.1",
diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx
index 935f5b5c1..ac46cb4fc 100644
--- a/src/mobile/ImageUpload.tsx
+++ b/src/mobile/ImageUpload.tsx
@@ -65,7 +65,7 @@ const onFileLoad = (file: any) => {
 ReactDOM.render((
     <div className="imgupload_cont">
         {/* <button className = "button_file"  = {onPointerDown}> Open Image </button> */}
-        <input type="file" accept="image/*" capture="camera" onChange={onFileLoad} className="input_file" id="input_image_file"></input>
+        <input type="file" accept="image/*" onChange={onFileLoad} className="input_file" id="input_image_file"></input>
         <img id="img_preview" src=""></img>
     </div>),
     document.getElementById('root')
-- 
cgit v1.2.3-70-g09d2


From a300c4e5040e975cdcd7367a1345335d52ff6aad Mon Sep 17 00:00:00 2001
From: Tyler Schicke <tyler_schicke@brown.edu>
Date: Mon, 18 Mar 2019 01:00:09 -0400
Subject: Debugger changes

---
 src/mobile/ImageUpload.tsx | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'src/mobile/ImageUpload.tsx')

diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx
index ac46cb4fc..292a3a035 100644
--- a/src/mobile/ImageUpload.tsx
+++ b/src/mobile/ImageUpload.tsx
@@ -9,6 +9,7 @@ import { Server } from '../client/Server';
 import { Opt, Field } from '../fields/Field';
 import { ListField } from '../fields/ListField';
 import { KeyStore } from '../fields/KeyStore';
+import { ImageField } from '../fields/ImageField';
 
 
 
@@ -41,6 +42,11 @@ const onFileLoad = (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) {
@@ -67,6 +73,7 @@ ReactDOM.render((
         {/* <button className = "button_file"  = {onPointerDown}> Open Image </button> */}
         <input type="file" accept="image/*" onChange={onFileLoad} className="input_file" id="input_image_file"></input>
         <img id="img_preview" src=""></img>
+        <div id="message" />
     </div>),
     document.getElementById('root')
 );
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2


From 4354f7f9d7a62a4193ac8f84380722db75d806d8 Mon Sep 17 00:00:00 2001
From: Tyler Schicke <tyler_schicke@brown.edu>
Date: Mon, 18 Mar 2019 06:57:25 -0400
Subject: Fixed image upload to mostly work with authentication

---
 src/client/views/Main.tsx  | 16 ++++++++------
 src/mobile/ImageUpload.tsx | 53 ++++++++++++++++++++++++----------------------
 2 files changed, 37 insertions(+), 32 deletions(-)

(limited to 'src/mobile/ImageUpload.tsx')

diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index d0f84f779..26a07fdfe 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -176,13 +176,15 @@ export class Main extends React.Component {
         this.mainContainer.GetTAsync(KeyStore.ActiveFrame, Document, field => this.mainfreeform = field);
         this.mainContainer.GetTAsync(KeyStore.OptionalRightCollection, Document, col => {
             // if there is a pending doc, and it has new data, show it (syip: we use a timeout to prevent collection docking view from being uninitialized)
-            if (col) {
-                col.GetTAsync<ListField<Document>>(KeyStore.Data, ListField, (f: Opt<ListField<Document>>) => {
-                    if (f && f.Data.length > 0) {
-                        CollectionDockingView.Instance.AddRightSplit(col);
-                    }
-                })
-            }
+            setTimeout(() => {
+                if (col) {
+                    col.GetTAsync<ListField<Document>>(KeyStore.Data, ListField, (f: Opt<ListField<Document>>) => {
+                        if (f && f.Data.length > 0) {
+                            CollectionDockingView.Instance.AddRightSplit(col);
+                        }
+                    })
+                }
+            }, 100);
         });
     }
 
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((
-- 
cgit v1.2.3-70-g09d2


From bece3110a3d6fa18dd89415a5e636c6792aea4e1 Mon Sep 17 00:00:00 2001
From: Tyler Schicke <tyler_schicke@brown.edu>
Date: Wed, 20 Mar 2019 05:07:52 -0400
Subject: Refactored users to have a single user document instead of a list of
 workspaces

---
 src/client/views/Main.tsx                          | 132 ++++++++++++---------
 src/fields/KeyStore.ts                             |   2 +
 src/mobile/ImageUpload.tsx                         |  38 +++---
 src/server/RouteStore.ts                           |   5 +-
 .../authentication/controllers/WorkspacesMenu.tsx  |  19 +--
 .../authentication/controllers/user_controller.ts  |   3 +-
 .../authentication/models/current_user_utils.ts    |  46 +++++--
 src/server/authentication/models/user_model.ts     |  11 +-
 src/server/index.ts                                |  33 +-----
 9 files changed, 144 insertions(+), 145 deletions(-)

(limited to 'src/mobile/ImageUpload.tsx')

diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index ac51a7d87..a1a6cc475 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -8,6 +8,7 @@ import "./Main.scss";
 import { MessageStore } from '../../server/Message';
 import { Utils } from '../../Utils';
 import * as request from 'request'
+import * as rp from 'request-promise'
 import { Documents } from '../documents/Documents';
 import { Server } from '../Server';
 import { setupDrag } from '../util/DragManager';
@@ -40,7 +41,7 @@ import Measure from 'react-measure';
 import { DashUserModel } from '../../server/authentication/models/user_model';
 import { ServerUtils } from '../../server/ServerUtil';
 import { CurrentUserUtils } from '../../server/authentication/models/current_user_utils';
-import { Field, Opt } from '../../fields/Field';
+import { Field, Opt, FieldWaiting } from '../../fields/Field';
 import { ListField } from '../../fields/ListField';
 import { map } from 'bluebird';
 import { Gateway, Settings } from '../northstar/manager/Gateway';
@@ -49,13 +50,26 @@ import { Catalog } from '../northstar/model/idea/idea';
 @observer
 export class Main extends React.Component {
     // dummy initializations keep the compiler happy
-    @observable private mainContainer?: Document;
     @observable private mainfreeform?: Document;
-    @observable private userWorkspaces: Document[] = [];
     @observable public pwidth: number = 0;
     @observable public pheight: number = 0;
     @observable private _northstarCatalog: Catalog | undefined = undefined;
 
+    @computed private get mainContainer(): Document | undefined {
+        let doc = this.userDocument.GetT(KeyStore.ActiveWorkspace, Document);
+        return doc == FieldWaiting ? undefined : doc;
+    }
+
+    private set mainContainer(doc: Document | undefined) {
+        if (doc) {
+            this.userDocument.Set(KeyStore.ActiveWorkspace, doc);
+        }
+    }
+
+    private get userDocument(): Document {
+        return CurrentUserUtils.UserDocument;
+    }
+
     public mainDocId: string | undefined;
     private currentUser?: DashUserModel;
     public static Instance: Main;
@@ -67,12 +81,12 @@ export class Main extends React.Component {
         configure({ enforceActions: "observed" });
         if (window.location.pathname !== RouteStore.home) {
             let pathname = window.location.pathname.split("/");
-            this.mainDocId = pathname[pathname.length - 1];
+            if (pathname.length > 1 && pathname[pathname.length - 2] == 'doc') {
+                this.mainDocId = pathname[pathname.length - 1];
+            }
         };
 
-        this.initializeNorthstar();
-
-        CurrentUserUtils.loadCurrentUser();
+        // this.initializeNorthstar();
 
         library.add(faFont);
         library.add(faImage);
@@ -143,63 +157,50 @@ export class Main extends React.Component {
 
     initAuthenticationRouters = () => {
         // Load the user's active workspace, or create a new one if initial session after signup
-        request.get(ServerUtils.prepend(RouteStore.getActiveWorkspace), (error, response, body) => {
-            if (this.mainDocId || body) {
-                Server.GetField(this.mainDocId || body, field => {
-                    if (field instanceof Document) {
-                        this.openWorkspace(field);
-                        this.populateWorkspaces();
-                    } else {
-                        this.createNewWorkspace(true, this.mainDocId);
-                    }
-                });
-            } else {
-                this.createNewWorkspace(true, this.mainDocId);
-            }
-        });
-    }
-
-    @action
-    createNewWorkspace = (init: boolean, id?: string): void => {
-        let mainDoc = Documents.DockDocument(JSON.stringify({ content: [{ type: 'row', content: [] }] }), { title: `Main Container ${this.userWorkspaces.length + 1}` }, id);
-        let newId = mainDoc.Id;
-        request.post(ServerUtils.prepend(RouteStore.addWorkspace), {
-            body: { target: newId },
-            json: true
-        }, () => { if (init) this.populateWorkspaces(); });
-
-        // bcz: strangely, we need a timeout to prevent exceptions/issues initializing GoldenLayout (the rendering engine for Main Container)
-        setTimeout(() => {
-            let freeformDoc = Documents.FreeformDocument([], { x: 0, y: 400, title: "mini collection" });
-            var dockingLayout = { content: [{ type: 'row', content: [CollectionDockingView.makeDocumentConfig(freeformDoc)] }] };
-            mainDoc.SetText(KeyStore.Data, JSON.stringify(dockingLayout));
-            mainDoc.Set(KeyStore.ActiveFrame, freeformDoc);
-            this.openWorkspace(mainDoc);
-            let pendingDocument = Documents.SchemaDocument([], { title: "New Mobile Uploads" })
-            mainDoc.Set(KeyStore.OptionalRightCollection, pendingDocument);
-        }, 0);
-        this.userWorkspaces.push(mainDoc);
+        if (!this.mainDocId) {
+            this.userDocument.GetTAsync(KeyStore.ActiveWorkspace, Document).then(doc => {
+                if (doc) {
+                    this.openWorkspace(doc);
+                } else {
+                    this.createNewWorkspace();
+                }
+            })
+        } else {
+            Server.GetField(this.mainDocId).then(field => {
+                if (field instanceof Document) {
+                    this.openWorkspace(field)
+                } else {
+                    this.createNewWorkspace(this.mainDocId);
+                }
+            })
+        }
     }
 
     @action
-    populateWorkspaces = () => {
-        // retrieve all workspace documents from the server
-        request.get(ServerUtils.prepend(RouteStore.getAllWorkspaces), (error, res, body) => {
-            let ids = JSON.parse(body) as string[];
-            Server.GetFields(ids, action((fields: { [id: string]: Field }) => this.userWorkspaces = ids.map(id => fields[id] as Document)));
-        });
+    createNewWorkspace = (id?: string): void => {
+        this.userDocument.GetTAsync<ListField<Document>>(KeyStore.Workspaces, ListField).then(action((list: Opt<ListField<Document>>) => {
+            if (list) {
+                let freeformDoc = Documents.FreeformDocument([], { x: 0, y: 400, title: "mini collection" });
+                var dockingLayout = { content: [{ type: 'row', content: [CollectionDockingView.makeDocumentConfig(freeformDoc)] }] };
+                let mainDoc = Documents.DockDocument(JSON.stringify(dockingLayout), { title: `Main Container ${list.Data.length + 1}` }, id);
+                list.Data.push(mainDoc);
+                // bcz: strangely, we need a timeout to prevent exceptions/issues initializing GoldenLayout (the rendering engine for Main Container)
+                setTimeout(() => {
+                    mainDoc.Set(KeyStore.ActiveFrame, freeformDoc);
+                    this.openWorkspace(mainDoc);
+                    let pendingDocument = Documents.SchemaDocument([], { title: "New Mobile Uploads" })
+                    mainDoc.Set(KeyStore.OptionalRightCollection, pendingDocument);
+                }, 0);
+            }
+        }));
     }
 
     @action
     openWorkspace = (doc: Document, fromHistory = false): void => {
-        request.post(ServerUtils.prepend(RouteStore.setActiveWorkspace), {
-            body: { target: doc.Id },
-            json: true
-        });
         this.mainContainer = doc;
         fromHistory || window.history.pushState(null, doc.Title, "/doc/" + doc.Id);
         this.mainContainer.GetTAsync(KeyStore.ActiveFrame, Document, field => this.mainfreeform = field);
-        this.mainContainer.GetTAsync(KeyStore.OptionalRightCollection, Document, col => {
+        this.userDocument.GetTAsync(KeyStore.OptionalRightCollection, Document).then(col => {
             // if there is a pending doc, and it has new data, show it (syip: we use a timeout to prevent collection docking view from being uninitialized)
             setTimeout(() => {
                 if (col) {
@@ -213,10 +214,15 @@ export class Main extends React.Component {
         });
     }
 
+    @observable
+    workspacesShown: boolean = false;
+
+    areWorkspacesShown = () => {
+        return this.workspacesShown;
+    }
+    @action
     toggleWorkspaces = () => {
-        if (WorkspacesMenu.Instance) {
-            WorkspacesMenu.Instance.toggle()
-        }
+        this.workspacesShown = !this.workspacesShown;
     }
 
     screenToLocalTransform = () => Transform.Identity
@@ -310,6 +316,12 @@ export class Main extends React.Component {
     }
 
     render() {
+        let workspaceMenu: any = null;
+        let workspaces = this.userDocument.GetT<ListField<Document>>(KeyStore.Workspaces, ListField);
+        if (workspaces && workspaces !== FieldWaiting) {
+            workspaceMenu = <WorkspacesMenu active={this.mainContainer} open={this.openWorkspace} new={this.createNewWorkspace} allWorkspaces={workspaces.Data}
+                isShown={this.areWorkspacesShown} toggle={this.toggleWorkspaces} />
+        }
         return (
             <div id="main-div">
                 <Measure onResize={(r: any) => runInAction(() => {
@@ -326,11 +338,13 @@ export class Main extends React.Component {
                 <ContextMenu />
                 {this.nodesMenu}
                 {this.miscButtons}
-                <WorkspacesMenu active={this.mainContainer} open={this.openWorkspace} new={this.createNewWorkspace} allWorkspaces={this.userWorkspaces} />
+                {workspaceMenu}
                 <InkingControl />
             </div>
         );
     }
 }
 
-ReactDOM.render(<Main />, document.getElementById('root'));
+CurrentUserUtils.loadCurrentUser().then(() => {
+    ReactDOM.render(<Main />, document.getElementById('root'));
+});
diff --git a/src/fields/KeyStore.ts b/src/fields/KeyStore.ts
index 68883d6f1..891caaa81 100644
--- a/src/fields/KeyStore.ts
+++ b/src/fields/KeyStore.ts
@@ -28,6 +28,7 @@ export namespace KeyStore {
     export const SchemaSplitPercentage = new Key("SchemaSplitPercentage");
     export const Caption = new Key("Caption");
     export const ActiveFrame = new Key("ActiveFrame");
+    export const ActiveWorkspace = new Key("ActiveWorkspace");
     export const DocumentText = new Key("DocumentText");
     export const LinkedToDocs = new Key("LinkedToDocs");
     export const LinkedFromDocs = new Key("LinkedFromDocs");
@@ -41,4 +42,5 @@ export namespace KeyStore {
     export const OptionalRightCollection = new Key("OptionalRightCollection");
     export const Archives = new Key("Archives");
     export const Updated = new Key("Updated");
+    export const Workspaces = new Key("Workspaces");
 }
diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx
index 16808a598..47b9d8f0b 100644
--- a/src/mobile/ImageUpload.tsx
+++ b/src/mobile/ImageUpload.tsx
@@ -7,7 +7,7 @@ import { Server } from '../client/Server';
 import { Documents } from '../client/documents/Documents';
 import { ListField } from '../fields/ListField';
 import { ImageField } from '../fields/ImageField';
-import request = require('request');
+import * as rp from 'request-promise'
 import { ServerUtils } from '../server/ServerUtil';
 import { RouteStore } from '../server/RouteStore';
 
@@ -40,28 +40,24 @@ const onFileLoad = (file: any) => {
                 json.map((file: any) => {
                     let path = window.location.origin + file
                     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;
+
+                    rp.get(ServerUtils.prepend(RouteStore.getUserDocumentId)).then(res => {
+                        if (res) {
+                            return Server.GetField(res);
+                        }
+                        throw new Error("No user id returned");
+                    }).then(field => {
+                        if (field instanceof Document) {
+                            return field.GetTAsync(KeyStore.OptionalRightCollection, Document)
                         }
-                    })
-                    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);
-                                                })
-                                            }
-                                        })
-                                }
-                            }
-                            );
+                    }).then(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)
diff --git a/src/server/RouteStore.ts b/src/server/RouteStore.ts
index fb06b878b..fdf5b6a5c 100644
--- a/src/server/RouteStore.ts
+++ b/src/server/RouteStore.ts
@@ -15,10 +15,7 @@ export enum RouteStore {
 
     // USER AND WORKSPACES
     getCurrUser = "/getCurrentUser",
-    addWorkspace = "/addWorkspaceId",
-    getAllWorkspaces = "/getAllWorkspaceIds",
-    getActiveWorkspace = "/getActiveWorkspaceId",
-    setActiveWorkspace = "/setActiveWorkspaceId",
+    getUserDocumentId = "/getUserDocumentId",
     updateCursor = "/updateCursor",
 
     openDocumentWithId = "/doc/:docId",
diff --git a/src/server/authentication/controllers/WorkspacesMenu.tsx b/src/server/authentication/controllers/WorkspacesMenu.tsx
index 1533b1e62..8e14cf98e 100644
--- a/src/server/authentication/controllers/WorkspacesMenu.tsx
+++ b/src/server/authentication/controllers/WorkspacesMenu.tsx
@@ -9,30 +9,23 @@ import { KeyStore } from '../../../fields/KeyStore';
 export interface WorkspaceMenuProps {
     active: Document | undefined;
     open: (workspace: Document) => void;
-    new: (init: boolean) => void;
+    new: () => void;
     allWorkspaces: Document[];
+    isShown: () => boolean;
+    toggle: () => void;
 }
 
 @observer
 export class WorkspacesMenu extends React.Component<WorkspaceMenuProps> {
-    static Instance: WorkspacesMenu;
-    @observable private workspacesExposed: boolean = false;
-
     constructor(props: WorkspaceMenuProps) {
         super(props);
-        WorkspacesMenu.Instance = this;
         this.addNewWorkspace = this.addNewWorkspace.bind(this);
     }
 
     @action
     addNewWorkspace() {
-        this.props.new(false);
-        this.toggle();
-    }
-
-    @action
-    toggle() {
-        this.workspacesExposed = !this.workspacesExposed;
+        this.props.new();
+        this.props.toggle();
     }
 
     render() {
@@ -45,7 +38,7 @@ export class WorkspacesMenu extends React.Component<WorkspaceMenuProps> {
                     borderRadius: 5,
                     position: "absolute",
                     top: 78,
-                    left: this.workspacesExposed ? 11 : -500,
+                    left: this.props.isShown() ? 11 : -500,
                     background: "white",
                     border: "black solid 2px",
                     transition: "all 1s ease",
diff --git a/src/server/authentication/controllers/user_controller.ts b/src/server/authentication/controllers/user_controller.ts
index 2cef958e8..e365b8dce 100644
--- a/src/server/authentication/controllers/user_controller.ts
+++ b/src/server/authentication/controllers/user_controller.ts
@@ -11,6 +11,7 @@ import * as async from 'async';
 import * as nodemailer from 'nodemailer';
 import c = require("crypto");
 import { RouteStore } from "../../RouteStore";
+import { Utils } from "../../../Utils";
 
 /**
  * GET /signup
@@ -54,7 +55,7 @@ export let postSignup = (req: Request, res: Response, next: NextFunction) => {
     const user = new User({
         email,
         password,
-        userDoc: "document here"
+        userDocumentId: Utils.GenerateGuid()
     });
 
     User.findOne({ email }, (err, existingUser) => {
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index cc433eb73..17a6d493b 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -1,29 +1,61 @@
 import { DashUserModel } from "./user_model";
-import * as request from 'request'
+import * as rp from 'request-promise';
 import { RouteStore } from "../../RouteStore";
 import { ServerUtils } from "../../ServerUtil";
+import { Server } from "../../../client/Server";
+import { Document } from "../../../fields/Document";
+import { KeyStore } from "../../../fields/KeyStore";
+import { ListField } from "../../../fields/ListField";
+import { Documents } from "../../../client/documents/Documents";
 
 export class CurrentUserUtils {
     private static curr_email: string;
     private static curr_id: string;
+    private static user_document: Document;
 
-    public static get email() {
+    public static get email(): string {
         return CurrentUserUtils.curr_email;
     }
 
-    public static get id() {
+    public static get id(): string {
         return CurrentUserUtils.curr_id;
     }
 
-    public static loadCurrentUser() {
-        request.get(ServerUtils.prepend(RouteStore.getCurrUser), (error, response, body) => {
-            if (body) {
-                let obj = JSON.parse(body);
+    public static get UserDocument(): Document {
+        return CurrentUserUtils.user_document;
+    }
+
+    private static createUserDocument(id: string): Document {
+        let doc = new Document(id);
+
+        doc.Set(KeyStore.Workspaces, new ListField<Document>());
+        doc.Set(KeyStore.OptionalRightCollection, Documents.SchemaDocument([], { title: "Pending documents" }))
+        return doc;
+    }
+
+    public static loadCurrentUser(): Promise<any> {
+        let userPromise = rp.get(ServerUtils.prepend(RouteStore.getCurrUser)).then((response) => {
+            if (response) {
+                let obj = JSON.parse(response);
                 CurrentUserUtils.curr_id = obj.id as string;
                 CurrentUserUtils.curr_email = obj.email as string;
             } else {
                 throw new Error("There should be a user! Why does Dash think there isn't one?")
             }
         });
+        let userDocPromise = rp.get(ServerUtils.prepend(RouteStore.getUserDocumentId)).then(id => {
+            if (id) {
+                return Server.GetField(id).then(field => {
+                    if (field instanceof Document) {
+                        this.user_document = field;
+                    } else {
+                        this.user_document = this.createUserDocument(id);
+                    }
+                })
+            } else {
+                throw new Error("There should be a user id! Why does Dash think there isn't one?")
+            }
+        });
+        return Promise.all([userPromise, userDocPromise]);
     }
 }
\ No newline at end of file
diff --git a/src/server/authentication/models/user_model.ts b/src/server/authentication/models/user_model.ts
index 3d4ed6896..81580aad5 100644
--- a/src/server/authentication/models/user_model.ts
+++ b/src/server/authentication/models/user_model.ts
@@ -21,9 +21,7 @@ export type DashUserModel = mongoose.Document & {
     passwordResetToken: string | undefined,
     passwordResetExpires: Date | undefined,
 
-    allWorkspaceIds: Array<String>,
-    activeWorkspaceId: String,
-    activeUsersId: String,
+    userDocumentId: string;
 
     profile: {
         name: string,
@@ -49,12 +47,7 @@ const userSchema = new mongoose.Schema({
     passwordResetToken: String,
     passwordResetExpires: Date,
 
-    allWorkspaceIds: {
-        type: Array,
-        default: []
-    },
-    activeWorkspaceId: String,
-    activeUsersId: String,
+    userDocumentId: String,
 
     facebook: String,
     twitter: String,
diff --git a/src/server/index.ts b/src/server/index.ts
index d1eb6847d..16304f1c5 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -156,16 +156,9 @@ addSecureRoute(
 
 addSecureRoute(
     Method.GET,
-    (user, res) => res.send(user.activeWorkspaceId || ""),
+    (user, res) => res.send(user.userDocumentId || ""),
     undefined,
-    RouteStore.getActiveWorkspace,
-);
-
-addSecureRoute(
-    Method.GET,
-    (user, res) => res.send(JSON.stringify(user.allWorkspaceIds)),
-    undefined,
-    RouteStore.getAllWorkspaces
+    RouteStore.getUserDocumentId,
 );
 
 addSecureRoute(
@@ -182,28 +175,6 @@ addSecureRoute(
 
 // SETTERS
 
-addSecureRoute(
-    Method.POST,
-    (user, res, req) => {
-        user.update({ $set: { activeWorkspaceId: req.body.target } }, (err, raw) => {
-            res.sendStatus(err ? 500 : 200);
-        });
-    },
-    undefined,
-    RouteStore.setActiveWorkspace
-);
-
-addSecureRoute(
-    Method.POST,
-    (user, res, req) => {
-        user.update({ $push: { allWorkspaceIds: req.body.target } }, (err, raw) => {
-            res.sendStatus(err ? 500 : 200);
-        });
-    },
-    undefined,
-    RouteStore.addWorkspace
-);
-
 addSecureRoute(
     Method.POST,
     (user, res, req) => {
-- 
cgit v1.2.3-70-g09d2

