aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/Import & Export/DirectoryImportBox.tsx
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-12-03 01:46:36 -0500
committerSam Wilkins <samwilkins333@gmail.com>2019-12-03 01:46:36 -0500
commitef94ad7df2a087141ddb8d347d3e3c484ff7609b (patch)
treea7c16be04ff4050da1ff03e02f59df6da4f5f7e2 /src/client/util/Import & Export/DirectoryImportBox.tsx
parent62c888ad25c5580441eaf947a1a0f1638939b868 (diff)
const linter rule and restored google docs push, fixed routing
Diffstat (limited to 'src/client/util/Import & Export/DirectoryImportBox.tsx')
-rw-r--r--src/client/util/Import & Export/DirectoryImportBox.tsx58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/client/util/Import & Export/DirectoryImportBox.tsx b/src/client/util/Import & Export/DirectoryImportBox.tsx
index 104d9e099..e6a215b2c 100644
--- a/src/client/util/Import & Export/DirectoryImportBox.tsx
+++ b/src/client/util/Import & Export/DirectoryImportBox.tsx
@@ -1,7 +1,7 @@
import "fs";
import React = require("react");
import { Doc, DocListCast, DocListCastAsync, Opt } from "../../../new_fields/Doc";
-import { action, observable, autorun, runInAction, computed, reaction, IReactionDisposer } from "mobx";
+import { action, observable, runInAction, computed, reaction, IReactionDisposer } from "mobx";
import { FieldViewProps, FieldView } from "../../views/nodes/FieldView";
import Measure, { ContentRect } from "react-measure";
import { library } from '@fortawesome/fontawesome-svg-core';
@@ -48,7 +48,7 @@ export default class DirectoryImportBox extends React.Component<FieldViewProps>
constructor(props: FieldViewProps) {
super(props);
library.add(faTag, faPlus);
- let doc = this.props.Document;
+ const doc = this.props.Document;
this.editingMetadata = this.editingMetadata || false;
this.persistent = this.persistent || false;
!Cast(doc.data, listSpec(Doc)) && (doc.data = new List<Doc>());
@@ -78,16 +78,16 @@ export default class DirectoryImportBox extends React.Component<FieldViewProps>
this.phase = "Initializing download...";
});
- let docs: Doc[] = [];
+ const docs: Doc[] = [];
- let files = e.target.files;
+ const files = e.target.files;
if (!files || files.length === 0) return;
- let directory = (files.item(0) as any).webkitRelativePath.split("/", 1)[0];
+ const directory = (files.item(0) as any).webkitRelativePath.split("/", 1)[0];
- let validated: File[] = [];
+ const validated: File[] = [];
for (let i = 0; i < files.length; i++) {
- let file = files.item(i);
+ const file = files.item(i);
if (file && !unsupported.includes(file.type)) {
const ext = path.extname(file.name).toLowerCase();
if (AcceptibleMedia.imageFormats.includes(ext)) {
@@ -101,8 +101,8 @@ export default class DirectoryImportBox extends React.Component<FieldViewProps>
this.completed = 0;
});
- let sizes: number[] = [];
- let modifiedDates: number[] = [];
+ const sizes: number[] = [];
+ const modifiedDates: number[] = [];
runInAction(() => this.phase = `Internal: uploading ${this.quota - this.completed} files to Dash...`);
@@ -136,26 +136,26 @@ export default class DirectoryImportBox extends React.Component<FieldViewProps>
}));
for (let i = 0; i < docs.length; i++) {
- let doc = docs[i];
+ const doc = docs[i];
doc.size = sizes[i];
doc.modified = modifiedDates[i];
this.entries.forEach(entry => {
- let target = entry.onDataDoc ? Doc.GetProto(doc) : doc;
+ const target = entry.onDataDoc ? Doc.GetProto(doc) : doc;
target[entry.key] = entry.value;
});
}
- let doc = this.props.Document;
- let height: number = NumCast(doc.height) || 0;
- let offset: number = this.persistent ? (height === 0 ? 0 : height + 30) : 0;
- let options: DocumentOptions = {
+ const doc = this.props.Document;
+ const height: number = NumCast(doc.height) || 0;
+ const offset: number = this.persistent ? (height === 0 ? 0 : height + 30) : 0;
+ const options: DocumentOptions = {
title: `Import of ${directory}`,
width: 1105,
height: 500,
x: NumCast(doc.x),
y: NumCast(doc.y) + offset
};
- let parent = this.props.ContainingCollectionView;
+ const parent = this.props.ContainingCollectionView;
if (parent) {
let importContainer: Doc;
if (docs.length < 50) {
@@ -194,18 +194,18 @@ export default class DirectoryImportBox extends React.Component<FieldViewProps>
@action
preserveCentering = (rect: ContentRect) => {
- let bounds = rect.offset!;
+ const bounds = rect.offset!;
if (bounds.width === 0 || bounds.height === 0) {
return;
}
- let offset = this.dimensions / 2;
+ const offset = this.dimensions / 2;
this.left = bounds.width / 2 - offset;
this.top = bounds.height / 2 - offset;
}
@action
addMetadataEntry = async () => {
- let entryDoc = new Doc();
+ const entryDoc = new Doc();
entryDoc.checked = false;
entryDoc.key = keyPlaceholder;
entryDoc.value = valuePlaceholder;
@@ -214,7 +214,7 @@ export default class DirectoryImportBox extends React.Component<FieldViewProps>
@action
remove = async (entry: ImportMetadataEntry) => {
- let metadata = await DocListCastAsync(this.props.Document.data);
+ const metadata = await DocListCastAsync(this.props.Document.data);
if (metadata) {
let index = this.entries.indexOf(entry);
if (index !== -1) {
@@ -228,18 +228,18 @@ export default class DirectoryImportBox extends React.Component<FieldViewProps>
}
render() {
- let dimensions = 50;
- let entries = DocListCast(this.props.Document.data);
- let isEditing = this.editingMetadata;
- let completed = this.completed;
- let quota = this.quota;
- let uploading = this.uploading;
- let showRemoveLabel = this.removeHover;
- let persistent = this.persistent;
+ const dimensions = 50;
+ const entries = DocListCast(this.props.Document.data);
+ const isEditing = this.editingMetadata;
+ const completed = this.completed;
+ const quota = this.quota;
+ const uploading = this.uploading;
+ const showRemoveLabel = this.removeHover;
+ const persistent = this.persistent;
let percent = `${completed / quota * 100}`;
percent = percent.split(".")[0];
percent = percent.startsWith("100") ? "99" : percent;
- let marginOffset = (percent.length === 1 ? 5 : 0) - 1.6;
+ const marginOffset = (percent.length === 1 ? 5 : 0) - 1.6;
const message = <span className={"phase"}>{this.phase}</span>;
const centerPiece = this.phase.includes("Google Photos") ?
<img src={"/assets/google_photos.png"} style={{