aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/Import & Export/ImageUtils.ts
diff options
context:
space:
mode:
authorAbdullah Ahmed <abdullah_ahmed@brown.edu>2019-10-19 14:41:16 -0400
committerAbdullah Ahmed <abdullah_ahmed@brown.edu>2019-10-19 14:41:16 -0400
commit1a8292f7588880718a657a5fca5c32f1a5975205 (patch)
tree216639d9d5387ba2563b37b169c678301d671b15 /src/client/util/Import & Export/ImageUtils.ts
parent5e04d7f94d180dc984e48eca888ac2cedfd0c7a3 (diff)
parent3d910bae8771e67cabc1500c49b77d425fdf62e9 (diff)
merged
Diffstat (limited to 'src/client/util/Import & Export/ImageUtils.ts')
-rw-r--r--src/client/util/Import & Export/ImageUtils.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/client/util/Import & Export/ImageUtils.ts b/src/client/util/Import & Export/ImageUtils.ts
new file mode 100644
index 000000000..c9abf38fa
--- /dev/null
+++ b/src/client/util/Import & Export/ImageUtils.ts
@@ -0,0 +1,31 @@
+import { Doc, DocListCast, DocListCastAsync, Opt } from "../../../new_fields/Doc";
+import { ImageField } from "../../../new_fields/URLField";
+import { Cast, StrCast } from "../../../new_fields/Types";
+import { RouteStore } from "../../../server/RouteStore";
+import { Docs } from "../../documents/Documents";
+import { Identified } from "../../Network";
+import { Id } from "../../../new_fields/FieldSymbols";
+import { Utils } from "../../../Utils";
+
+export namespace ImageUtils {
+
+ export const ExtractExif = async (document: Doc): Promise<boolean> => {
+ const field = Cast(document.data, ImageField);
+ if (!field) {
+ return false;
+ }
+ const source = field.url.href;
+ const response = await Identified.PostToServer(RouteStore.inspectImage, { source });
+ const { error, data } = response.exifData;
+ document.exif = error || Docs.Get.DocumentHierarchyFromJson(data);
+ return data !== undefined;
+ };
+
+ export const ExportHierarchyToFileSystem = async (collection: Doc): Promise<void> => {
+ const a = document.createElement("a");
+ a.href = Utils.prepend(`${RouteStore.imageHierarchyExport}/${collection[Id]}`);
+ a.download = `Dash Export [${StrCast(collection.title)}].zip`;
+ a.click();
+ };
+
+} \ No newline at end of file