aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts47
-rw-r--r--src/client/views/collections/CollectionSubView.tsx11
-rw-r--r--src/client/views/nodes/LoadingBox.scss5
-rw-r--r--src/client/views/nodes/LoadingBox.tsx12
4 files changed, 48 insertions, 27 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index d8497e3af..e54fe16de 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -844,9 +844,9 @@ export namespace Docs {
return viewDoc;
}
- export function ImageDocument(url: string | ImageField, options: DocumentOptions = {}) {
+ export function ImageDocument(url: string | ImageField, options: DocumentOptions = {}, overwriteDoc?: Doc) {
const imgField = url instanceof ImageField ? url : new ImageField(url);
- return InstanceFromProto(Prototypes.get(DocumentType.IMG), imgField, { title: basename(imgField.url.href), ...options });
+ return InstanceFromProto(Prototypes.get(DocumentType.IMG), imgField, { title: basename(imgField.url.href), ...options }, undefined, undefined, undefined, overwriteDoc);
}
export function PresDocument(options: DocumentOptions = {}) {
@@ -857,12 +857,12 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.SCRIPTING), script ? script : undefined, { ...options, layout: fieldKey ? ScriptingBox.LayoutString(fieldKey) : undefined });
}
- export function VideoDocument(url: string, options: DocumentOptions = {}) {
- return InstanceFromProto(Prototypes.get(DocumentType.VID), new VideoField(url), options);
+ export function VideoDocument(url: string, options: DocumentOptions = {}, overwriteDoc?: Doc) {
+ return InstanceFromProto(Prototypes.get(DocumentType.VID), new VideoField(url), options, undefined, undefined, undefined, overwriteDoc);
}
- export function YoutubeDocument(url: string, options: DocumentOptions = {}) {
- return InstanceFromProto(Prototypes.get(DocumentType.YOUTUBE), new YoutubeField(url), options);
+ export function YoutubeDocument(url: string, options: DocumentOptions = {}, overwriteDoc?: Doc) {
+ return InstanceFromProto(Prototypes.get(DocumentType.YOUTUBE), new YoutubeField(url), options, undefined, undefined, undefined, overwriteDoc);
}
export function WebCamDocument(url: string, options: DocumentOptions = {}) {
@@ -877,8 +877,16 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.COMPARISON), '', options);
}
- export function AudioDocument(url: string, options: DocumentOptions = {}) {
- return InstanceFromProto(Prototypes.get(DocumentType.AUDIO), new AudioField(url), { ...options, backgroundColor: ComputedField.MakeFunction("this._mediaState === 'playing' ? 'green':'gray'") as any });
+ export function AudioDocument(url: string, options: DocumentOptions = {}, overwriteDoc?: Doc) {
+ return InstanceFromProto(
+ Prototypes.get(DocumentType.AUDIO),
+ new AudioField(url),
+ { ...options, backgroundColor: ComputedField.MakeFunction("this._mediaState === 'playing' ? 'green':'gray'") as any },
+ undefined,
+ undefined,
+ undefined,
+ overwriteDoc
+ );
}
export function RecordingDocument(url: string, options: DocumentOptions = {}) {
@@ -895,8 +903,10 @@ export namespace Docs {
export const filesToDocs = new Map<Doc, File>();
- export function LoadingDocument(file: File, options: DocumentOptions, ytString?: string) {
- const loading = InstanceFromProto(Prototypes.get(DocumentType.LOADING), file.name, { _height: 300, _width: 300, ...options });
+ export function LoadingDocument(file: File | string, options: DocumentOptions, ytString?: string) {
+ const fileName = typeof file == 'string' ? file : file.name;
+ options.title = fileName;
+ const loading = InstanceFromProto(Prototypes.get(DocumentType.LOADING), fileName, { _height: 150, _width: 150, ...options });
// filesToDocs.set(loading, file);
return loading;
}
@@ -1114,8 +1124,8 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.PRESELEMENT), undefined, { ...(options || {}) });
}
- export function DataVizDocument(url: string, options?: DocumentOptions) {
- return InstanceFromProto(Prototypes.get(DocumentType.DATAVIZ), new CsvField(url), { title: 'Data Viz', ...options });
+ export function DataVizDocument(url: string, options?: DocumentOptions, overwriteDoc?: Doc) {
+ return InstanceFromProto(Prototypes.get(DocumentType.DATAVIZ), new CsvField(url), { title: 'Data Viz', ...options }, undefined, undefined, undefined, overwriteDoc);
}
export function DockDocument(documents: Array<Doc>, config: string, options: DocumentOptions, id?: string) {
@@ -1809,6 +1819,18 @@ export namespace DocUtils {
}
return generatedDocuments;
}
+
+ export function uploadYoutubeVideoLoading(videoId: string, options: DocumentOptions, overwriteDoc?: Doc) {
+ const generatedDocuments: Doc[] = [];
+ Networking.UploadYoutubeToServer(videoId).then(upfiles => {
+ const {
+ source: { name, type },
+ result,
+ } = upfiles.lastElement();
+ name && type && processFileupload(generatedDocuments, name, type, result, options, overwriteDoc);
+ });
+ }
+
export async function uploadFilesToDocs(files: File[], options: DocumentOptions) {
const generatedDocuments: Doc[] = [];
const upfiles = await Networking.UploadFilesToServer(files);
@@ -1828,7 +1850,6 @@ export namespace DocUtils {
source: { name, type },
result,
} = upfiles.lastElement();
- console.log(name, type);
name && type && processFileupload(generatedDocuments, name, type, result, options, overwriteDoc);
});
}
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 1ff4f5ab8..30467efa0 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -468,19 +468,16 @@ export function CollectionSubView<X>(moreProps?: X) {
if (typeof files === 'string') {
// uploadYoutubeVideo and similar should return a placeholder, one for each placeholder
// generatedDocuments.push(Docs.Create.LoadingDocument(files, options));
+ const loading = Docs.Create.LoadingDocument(files, options);
+ generatedDocuments.push(loading);
+ DocUtils.uploadYoutubeVideoLoading(files, {}, loading);
} else {
// 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);
- }
+ DocUtils.uploadFileToDoc(file, {}, loading);
return loading;
})
);
diff --git a/src/client/views/nodes/LoadingBox.scss b/src/client/views/nodes/LoadingBox.scss
index 239faa78e..e8890cd82 100644
--- a/src/client/views/nodes/LoadingBox.scss
+++ b/src/client/views/nodes/LoadingBox.scss
@@ -5,3 +5,8 @@
justify-content: center;
background-color: #fdfdfd;
}
+
+.text {
+ text-overflow: ellipsis;
+ text-align: center;
+}
diff --git a/src/client/views/nodes/LoadingBox.tsx b/src/client/views/nodes/LoadingBox.tsx
index 9d4668dde..96620aff9 100644
--- a/src/client/views/nodes/LoadingBox.tsx
+++ b/src/client/views/nodes/LoadingBox.tsx
@@ -4,12 +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;
- text: string;
-}
+import { StrCast } from '../../../fields/Types';
@observer
export class LoadingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
@@ -18,6 +13,7 @@ export class LoadingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
}
componentDidMount() {
+ console.log(this.rootDoc);
// const file = Docs.Create.filesToDocs.get(this.rootDoc);
// if (file) {
// console.log('Got to file');
@@ -48,7 +44,9 @@ export class LoadingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
render() {
return (
<div className="loadingBoxContainer">
- <span>Loading: {this.dataDoc.text}</span>
+ <p className="text">Loading:</p>
+ <br></br>
+ <p className="text">{StrCast(this.rootDoc.title)}</p>
<ReactLoading type={'spinningBubbles'} color={'blue'} height={100} width={100} />
</div>
);