From b4dc598ff08c7c684daa4b75508e17213d29d8e5 Mon Sep 17 00:00:00 2001 From: yipstanley Date: Sun, 17 Mar 2019 13:34:10 -0400 Subject: commitment is difficult --- src/client/views/Main.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/client/views/Main.tsx') diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index c9bdc24c2..020f49528 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -43,7 +43,7 @@ Documents.initProtos(mainDocId, (res?: Document) => { // bcz: strangely, we need a timeout to prevent exceptions/issues initializing GoldenLayout (the rendering engine for Main Container) setTimeout(() => { - mainfreeform = Documents.FreeformDocument([], { x: 0, y: 400, title: "mini collection" }); + mainfreeform = Documents.FreeformDocument([], { x: 0, y: 400, title: "mini collection" }, undefined, false); var dockingLayout = { content: [{ type: 'row', content: [CollectionDockingView.makeDocumentConfig(mainfreeform)] }] }; mainContainer.SetText(KeyStore.Data, JSON.stringify(dockingLayout)); -- cgit v1.2.3-70-g09d2 From 641656b5e803305971006c386db2f465da0373ac Mon Sep 17 00:00:00 2001 From: yipstanley Date: Sun, 17 Mar 2019 19:18:59 -0400 Subject: client side interactions --- src/client/Server.ts | 2 +- src/client/views/Main.tsx | 18 ++++++++++++++++++ src/fields/KeyStore.ts | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src/client/views/Main.tsx') diff --git a/src/client/Server.ts b/src/client/Server.ts index f2d7de75c..5e42c8285 100644 --- a/src/client/Server.ts +++ b/src/client/Server.ts @@ -145,4 +145,4 @@ export class Server { } Server.Socket.on(MessageStore.Foo.Message, Server.connected); -Server.Socket.on(MessageStore.SetField.Message, Server.updateField); \ No newline at end of file +Server.Socket.on(MessageStore.SetField.Message, Server.updateField); diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index 345371884..89ef16cc9 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -32,6 +32,8 @@ import { faPenNib } from '@fortawesome/free-solid-svg-icons'; import { faFilm } from '@fortawesome/free-solid-svg-icons'; import { faMusic } from '@fortawesome/free-solid-svg-icons'; import Measure from 'react-measure'; +import { Field, Opt } from '../../fields/Field'; +import { ListField } from '../../fields/ListField'; configure({ enforceActions: "observed" }); // causes errors to be generated when modifying an observable outside of an action @@ -44,6 +46,7 @@ document.addEventListener("pointerdown", action(function (e: PointerEvent) { }), true) const pathname = window.location.pathname.split("/"); const mainDocId = pathname[pathname.length - 1]; +const pendingDocId = "pending-doc" var mainContainer: Document; let mainfreeform: Document; @@ -79,9 +82,24 @@ Documents.initProtos(mainDocId, (res?: Document) => { var dockingLayout = { content: [{ type: 'row', content: [CollectionDockingView.makeDocumentConfig(mainfreeform)] }] }; mainContainer.SetText(KeyStore.Data, JSON.stringify(dockingLayout)); mainContainer.Set(KeyStore.ActiveFrame, mainfreeform); + let pendingDocument = Documents.SchemaDocument([], { title: "New Mobile Uploads" }, pendingDocId) + mainContainer.Set(KeyStore.OptionalRightCollection, pendingDocument) }, 0); } + // 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(() => { + Server.GetField(pendingDocId, (res?: Field) => { + if (res instanceof Document) { + res.GetTAsync>(KeyStore.Data, ListField, (f: Opt>) => { + if (f && f.Data.length > 0) { + CollectionDockingView.Instance.AddRightSplit(res) + } + }) + } + }) + }, 50) + 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" let weburl = "https://cs.brown.edu/courses/cs166/"; diff --git a/src/fields/KeyStore.ts b/src/fields/KeyStore.ts index 06cdc8fc8..9c7a45af4 100644 --- a/src/fields/KeyStore.ts +++ b/src/fields/KeyStore.ts @@ -37,4 +37,7 @@ export namespace KeyStore { export const CurPage = new Key("CurPage"); export const NumPages = new Key("NumPages"); export const Ink = new Key("Ink"); + export const OptionalRightCollection = new Key("OptionalRightCollection"); + export const Archives = new Key("Archives"); + export const Updated = new Key("Updated"); } -- cgit v1.2.3-70-g09d2 From 1328b125d2b414380d037206ab6f39b9d12f1ff1 Mon Sep 17 00:00:00 2001 From: yipstanley 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/client/views/Main.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) => { + if (res) { + if (res instanceof Document) { + res.GetOrCreateAsync(KeyStore.Data, ListField, (f: ListField) => { + 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((
- {/* */} - + {/* */} +
), 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