aboutsummaryrefslogtreecommitdiff
path: root/src/client/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views')
-rw-r--r--src/client/views/collections/CollectionSubView.tsx70
-rw-r--r--src/client/views/nodes/LoadingBox.tsx25
2 files changed, 48 insertions, 47 deletions
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 79f629072..1ff4f5ab8 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -449,48 +449,6 @@ export function CollectionSubView<X>(moreProps?: X) {
this.slowLoadDocuments(files, options, generatedDocuments, text, completed, e.clientX, e.clientY, addDocument).then(batch.end);
}
- /**
- * Creates a placeholder doc view for files being uploaded and removes placeholder docs once files are uplodaded.
- *
- * @param files the files to upload that we want to create placeholders for
- * @param options the document options (primarily the x and y coordinates to put doc)
- * @param text in the case of youtube the text is the url to the video
- * @returns a disposer action that removes the placeholders created after files get uploaded
- */
- placeHolderDisposer = (files: File[] | string, options: DocumentOptions, text: string) => {
- // TODO: nda - create a specialized view for placeholder upload with a spinner and ability to retry upload
- let placeholders: Doc[] = [];
- // handle yt case
- if (typeof files === 'string') {
- placeholders.push(Docs.Create.LoadingDocument('Loading...', text, 500, 500, { ...options }));
- // placeholders.push(Docs.Create.TextDocument('Loading: ' + text, { ...options, title: text, _width: 400, _height: 30 }));
- } else {
- // every other doc type is an array of File
-
- // Get the file names as a text
- let textStr = '';
- files.forEach(file => {
- textStr += file.name + '\n';
- });
- placeholders.push(Docs.Create.LoadingDocument('Loading...', textStr, 500, 500, { ...options }));
-
- // placeholders.push(Docs.Create.TextDocument('Loading: \n' + textStr, { ...options, title: files.length + ' files', _width: 500, _height: files.length * 40 }));
- }
- // disposer action to remove placeholders once files are uploaded
- const remove = action(() => {
- if (!this.props.DataDoc) {
- return;
- }
- for (let i = 0; i < placeholders.length; i++) {
- Doc.RemoveDocFromList(this.props.DataDoc, 'data', placeholders[i]);
- }
- });
- placeholders.forEach(pl => {
- this.addDocument(pl);
- });
- return remove;
- };
-
slowLoadDocuments = async (
files: File[] | string,
options: DocumentOptions,
@@ -501,13 +459,31 @@ export function CollectionSubView<X>(moreProps?: X) {
clientY: number,
addDocument: (doc: Doc | Doc[]) => boolean
) => {
+ // create placeholder docs
+ // inside placeholder docs have some func that
+
// TODO: once loading thing is moved it should update the x and y of the file it is placeholder for
- const disposer = this.placeHolderDisposer(files, options, text);
+ let pileUpDoc = undefined;
// const disposer = OverlayView.Instance.addElement(<ReactLoading type={'spinningBubbles'} color={'green'} height={250} width={250} />, { x: clientX - 125, y: clientY - 125 });
if (typeof files === 'string') {
- generatedDocuments.push(...(await DocUtils.uploadYoutubeVideo(files, options)));
+ // uploadYoutubeVideo and similar should return a placeholder, one for each placeholder
+ // generatedDocuments.push(Docs.Create.LoadingDocument(files, options));
} else {
- generatedDocuments.push(...(await DocUtils.uploadFilesToDocs(files, options)));
+ // uploadFilesToDocs and similar should return a placeholder, one for each placeholder
+ generatedDocuments.push(
+ ...files.map(file => {
+ const loading = Docs.Create.LoadingDocument(file, options);
+ // now that there is a doc do whatever slowload was going to do with that file
+ if (typeof file === 'string') {
+ // uploadYoutubeVideo and similar should return a placeholder, one for each placeholder
+ // (await DocUtils.uploadYoutubeVideo(files, options)));
+ } else {
+ // uploadFilesToDocs and similar should return a placeholder, one for each placeholder
+ DocUtils.uploadFileToDoc(file, {}, loading);
+ }
+ return loading;
+ })
+ );
}
if (generatedDocuments.length) {
// Creating a dash document
@@ -523,7 +499,8 @@ export function CollectionSubView<X>(moreProps?: X) {
if (completed) completed(set);
else {
if (isFreeformView && generatedDocuments.length > 1) {
- addDocument(DocUtils.pileup(generatedDocuments, options.x as number, options.y as number)!);
+ pileUpDoc = DocUtils.pileup(generatedDocuments, options.x as number, options.y as number)!;
+ addDocument(pileUpDoc);
} else {
generatedDocuments.forEach(addDocument);
}
@@ -535,7 +512,6 @@ export function CollectionSubView<X>(moreProps?: X) {
alert('Document upload failed - possibly an unsupported file type.');
}
}
- disposer();
};
}
diff --git a/src/client/views/nodes/LoadingBox.tsx b/src/client/views/nodes/LoadingBox.tsx
index 0e0619241..9d4668dde 100644
--- a/src/client/views/nodes/LoadingBox.tsx
+++ b/src/client/views/nodes/LoadingBox.tsx
@@ -4,6 +4,7 @@ import { FieldView, FieldViewProps } from './FieldView';
import * as React from 'react';
import './LoadingBox.scss';
import ReactLoading from 'react-loading';
+import { Docs, DocUtils } from '../../documents/Documents';
export interface LoadingBoxProps {
title: string;
@@ -16,6 +17,30 @@ export class LoadingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
return FieldView.LayoutString(LoadingBox, fieldKey);
}
+ componentDidMount() {
+ // const file = Docs.Create.filesToDocs.get(this.rootDoc);
+ // if (file) {
+ // console.log('Got to file');
+ // Docs.Create.filesToDocs.delete(this.rootDoc);
+ // // now that there is a doc do whatever slowload was going to do with that file
+ // if (typeof file === 'string') {
+ // // uploadYoutubeVideo and similar should return a placeholder, one for each placeholder
+ // // (await DocUtils.uploadYoutubeVideo(files, options)));
+ // } else {
+ // // uploadFilesToDocs and similar should return a placeholder, one for each placeholder
+ // DocUtils.uploadFileToDoc(file, {}, this.rootDoc);
+ // }
+ // } else {
+ // // check if file now exists on server or not
+ // // if it does we need to retreieve it and create the appropriate doc (rest of what uploadFileToDoc was doing minus uploading)
+ // // if it doesn't display an error message "upload failed"
+ // }
+ // query endpoints to:
+ // check if file now exists on server or not
+ // if it does we need to retreieve it and create the appropriate doc (rest of what uploadFileToDoc was doing minus uploading)
+ // if it doesn't display an error message "upload failed"
+ }
+
constructor(props: any) {
super(props);
}