aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts73
1 files changed, 69 insertions, 4 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index da5c8efa9..5c5818f8f 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -11,7 +11,7 @@ import { RichTextField } from "../../fields/RichTextField";
import { SchemaHeaderField } from "../../fields/SchemaHeaderField";
import { ComputedField, ScriptField } from "../../fields/ScriptField";
import { Cast, NumCast, StrCast } from "../../fields/Types";
-import { AudioField, ImageField, PdfField, VideoField, WebField, YoutubeField } from "../../fields/URLField";
+import { AudioField, ImageField, MapField, PdfField, VideoField, WebField, YoutubeField } from "../../fields/URLField";
import { SharingPermissions } from "../../fields/util";
import { Upload } from "../../server/SharedMediaTypes";
import { OmitKeys, Utils } from "../../Utils";
@@ -60,6 +60,7 @@ import { SearchBox } from "../views/search/SearchBox";
import { DashWebRTCVideo } from "../views/webcam/DashWebRTCVideo";
import { DocumentType } from "./DocumentTypes";
import { IconProp } from "@fortawesome/fontawesome-svg-core";
+import { MapBox } from "../views/nodes/MapBox/MapBox";
const path = require('path');
const defaultNativeImageDim = Number(DFLT_IMAGE_NATIVE_DIM.replace("px", ""));
@@ -94,6 +95,7 @@ type DROPt = DAInfo | dropActionType;
export class DocumentOptions {
system?: BOOLt = new BoolInfo("is this a system created/owned doc");
_dropAction?: DROPt = new DAInfo("what should happen to this document when it's dropped somewhere else");
+ allowOverlayDrop?: BOOLt = new BoolInfo("can documents be dropped onto this document without using dragging title bar or holding down embed key (ctrl)?");
childDropAction?: DROPt = new DAInfo("what should happen to the source document when it's dropped onto a child of a collection ");
targetDropAction?: DROPt = new DAInfo("what should happen to the source document when ??? ");
color?: string; // foreground color data doc
@@ -155,6 +157,9 @@ export class DocumentOptions {
x?: number;
y?: number;
z?: number; // whether document is in overlay (1) or not (0 or undefined)
+ lat?: number;
+ lng?: number;
+ infoWindowOpen?: boolean;
author?: string;
_layoutKey?: string;
unrendered?: boolean; // denotes an annotation that is not rendered with a DocumentView (e.g, rtf/pdf text selections and links to scroll locations in web/pdf)
@@ -289,6 +294,7 @@ export class DocumentOptions {
treeViewExpandedViewLock?: boolean; // whether the expanded view can be changed
treeViewChecked?: ScriptField; // script to call when a tree view checkbox is checked
treeViewTruncateTitleWidth?: number;
+ treeViewHasOverlay?: boolean; // whether the treeview has an overlay for freeform annotations
treeViewType?: string; // whether treeview is a Slide, file system, or (default) collection hierarchy
sidebarColor?: string; // background color of text sidebar
sidebarViewType?: string; // collection type of text sidebar
@@ -397,6 +403,10 @@ export namespace Docs {
layout: { view: PDFBox, dataField: defaultDataKey },
options: { _curPage: 1, _fitWidth: true, nativeDimModifiable: true, nativeHeightUnfrozen: true, links: ComputedField.MakeFunction("links(self)") as any }
}],
+ [DocumentType.MAP, {
+ layout: { view: MapBox, dataField: defaultDataKey },
+ options: { _height: 600, _width: 800, links: ComputedField.MakeFunction("links(self)") as any }
+ }],
[DocumentType.IMPORT, {
layout: { view: DirectoryImportBox, dataField: defaultDataKey },
options: { _height: 150 }
@@ -774,6 +784,14 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.WEB), new HtmlField(html), options);
}
+ export function MapDocument(documents: Array<Doc>, options: DocumentOptions = {}) {
+ return InstanceFromProto(Prototypes.get(DocumentType.MAP), new List(documents), options);
+ }
+
+ export function MapMarkerDocument(lat: number, lng: number, infoWindowOpen: boolean, documents: Array<Doc>, options: DocumentOptions, id?: string) {
+ return InstanceFromProto(Prototypes.get(DocumentType.MARKER), new List(documents), { lat, lng, infoWindowOpen, ...options }, id);
+ }
+
export function KVPDocument(document: Doc, options: DocumentOptions = {}) {
return InstanceFromProto(Prototypes.get(DocumentType.KVP), document, { title: document.title + ".kvp", ...options });
}
@@ -804,7 +822,7 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _viewType: CollectionViewType.Linear }, id);
}
- export function MapDocument(documents: Array<Doc>, options: DocumentOptions = {}) {
+ export function MapCollectionDocument(documents: Array<Doc>, options: DocumentOptions = {}) {
return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _viewType: CollectionViewType.Map });
}
@@ -821,7 +839,7 @@ export namespace Docs {
}
export function TreeDocument(documents: Array<Doc>, options: DocumentOptions, id?: string, protoId?: string) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _viewType: CollectionViewType.Tree }, id, undefined, protoId);
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { _xMargin: 5, _yMargin: 5, ...options, _viewType: CollectionViewType.Tree }, id, undefined, protoId);
}
export function StackingDocument(documents: Array<Doc>, options: DocumentOptions, id?: string, protoId?: string) {
@@ -1140,7 +1158,11 @@ export namespace DocUtils {
} else if (field instanceof List && field[0] instanceof Doc) {
created = Docs.Create.StackingDocument(DocListCast(field), resolved);
layout = CollectionView.LayoutString;
- } else {
+ } else if (field instanceof MapField) {
+ created = Docs.Create.MapDocument(DocListCast(field), resolved);
+ layout = MapBox.LayoutString;
+ }
+ else {
created = Docs.Create.TextDocument("", { ...{ _width: 200, _height: 25, _autoHeight: true }, ...resolved });
layout = FormattedTextBox.LayoutString;
}
@@ -1171,6 +1193,12 @@ export namespace DocUtils {
if (!options._width) options._width = 400;
if (!options._height) options._height = (options._width as number) * 1200 / 927;
}
+ //TODO:al+glr
+ // if (type.indexOf("map") !== -1) {
+ // ctor = Docs.Create.MapDocument;
+ // if (!options._width) options._width = 800;
+ // if (!options._height) options._height = (options._width as number) * 3 / 4;
+ // }
if (type.indexOf("html") !== -1) {
if (path.includes(window.location.hostname)) {
const s = path.split('/');
@@ -1376,6 +1404,33 @@ export namespace DocUtils {
return optionsCollection;
}
+ // /**
+ // *
+ // * @param dms Degree Minute Second format exif gps data
+ // * @param ref ref that determines negativity of decimal coordinates
+ // * @returns a decimal format of gps latitude / longitude
+ // */
+ // function getDecimalfromDMS(dms?: number[], ref?: string) {
+ // if (dms && ref) {
+ // let degrees = dms[0] / dms[1];
+ // let minutes = dms[2] / dms[3] / 60.0;
+ // let seconds = dms[4] / dms[5] / 3600.0;
+
+ // if (['S', 'W'].includes(ref)) {
+ // degrees = -degrees; minutes = -minutes; seconds = -seconds
+ // }
+ // return (degrees + minutes + seconds).toFixed(5);
+ // }
+ // }
+
+ function ConvertDMSToDD(degrees: number, minutes: number, seconds: number, direction: string) {
+ var dd = degrees + minutes / 60 + seconds / (60 * 60);
+ if (direction == "S" || direction == "W") {
+ dd = dd * -1;
+ } // Don't do anything for N or E
+ return dd;
+ }
+
async function processFileupload(generatedDocuments: Doc[], name: string, type: string, result: Error | Upload.FileInformation, options: DocumentOptions) {
if (result instanceof Error) {
alert(`Upload failed: ${result.message}`);
@@ -1398,6 +1453,16 @@ export namespace DocUtils {
proto["data-nativeWidth"] = (result.nativeWidth < result.nativeHeight) ? maxNativeDim : maxNativeDim / (result.nativeWidth / result.nativeHeight);
}
proto.contentSize = result.contentSize;
+ // exif gps data coordinates are stored in DMS (Degrees Minutes Seconds), the following operation converts that to decimal coordinates
+ const latitude = result.exifData?.data?.GPSLatitude;
+ const latitudeDirection = result.exifData?.data?.GPSLatitudeRef;
+ const longitude = result.exifData?.data?.GPSLongitude;
+ const longitudeDirection = result.exifData?.data?.GPSLongitudeRef;
+ if (latitude !== undefined && longitude !== undefined && latitudeDirection !== undefined && longitudeDirection !== undefined) {
+ proto.lat = ConvertDMSToDD(latitude[0], latitude[1], latitude[2], latitudeDirection);
+ proto.lng = ConvertDMSToDD(longitude[0], longitude[1], longitude[2], longitudeDirection);
+ }
+
}
generatedDocuments.push(doc);
}