aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/LoadingBox.tsx
blob: 249461b67eb4bb2ef08ac61995b015e62cae6255 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { observer } from 'mobx-react';
import { ViewBoxAnnotatableComponent } from '../DocComponent';
import { FieldView, FieldViewProps } from './FieldView';
import * as React from 'react';
import './LoadingBox.scss';
import ReactLoading from 'react-loading';
import { StrCast } from '../../../fields/Types';
import { computed, observable } from 'mobx';
import { Docs } from '../../documents/Documents';

@observer
export class LoadingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
    public static LayoutString(fieldKey: string) {
        return FieldView.LayoutString(LoadingBox, fieldKey);
    }

    @computed
    private get isLoading() {
        const file = Docs.Create.filesToDocs.get(this.rootDoc);
        return file ? true : false;
    }

    componentDidMount() {
        console.log(this.rootDoc);
        // 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);
    }

    render() {
        return (
            <div className="loadingBoxContainer">
                {this.isLoading ? (
                    <div>
                        <p className="text">Loading:</p>
                        <br></br>
                        <span className="text">{StrCast(this.rootDoc.title)}</span>
                        <ReactLoading type={'spinningBubbles'} color={'blue'} height={100} width={100} />
                    </div>
                ) : (
                    <div>
                        <span>Error Loading File: {StrCast(this.rootDoc.title)}</span>
                    </div>
                )}
            </div>
        );
    }
}