From 3daca894b6eaf1eb8590f54b1a5bf5feca663a08 Mon Sep 17 00:00:00 2001 From: yipstanley Date: Fri, 12 Jul 2019 22:34:09 -0400 Subject: links now go between users --- src/client/documents/Documents.ts | 18 +++++++++++++++++- src/client/util/LinkManager.ts | 5 ++++- src/client/views/Main.tsx | 23 +++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 2a3827782..638ba287f 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -54,7 +54,8 @@ export enum DocumentType { PDF = "pdf", ICON = "icon", IMPORT = "import", - LINK = "link" + LINK = "link", + LINKDOC = "linkdoc" } export interface DocumentOptions { @@ -85,6 +86,12 @@ export interface DocumentOptions { // [key: string]: Opt; } +class EmptyBox { + public static LayoutString() { + return ""; + } +} + export namespace Docs { export namespace Prototypes { @@ -148,6 +155,11 @@ export namespace Docs { [DocumentType.IMPORT, { layout: { view: DirectoryImportBox }, options: { height: 150 } + }], + [DocumentType.LINKDOC, { + data: new List(), + layout: { view: EmptyBox }, + options: {} }] ]); @@ -195,6 +207,10 @@ export namespace Docs { return PrototypeMap.get(type)!; } + export function MainLinkDocument() { + return Prototypes.get(DocumentType.LINKDOC); + } + /** * This is a convenience method that is used to initialize * prototype documents for the first time. diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts index 1ed040aa4..a647f22c1 100644 --- a/src/client/util/LinkManager.ts +++ b/src/client/util/LinkManager.ts @@ -5,6 +5,7 @@ import { listSpec } from "../../new_fields/Schema"; import { List } from "../../new_fields/List"; import { Id } from "../../new_fields/FieldSymbols"; import { CurrentUserUtils } from "../../server/authentication/models/current_user_utils"; +import { Docs } from "../documents/Documents"; /* @@ -35,7 +36,9 @@ export class LinkManager { // the linkmanagerdoc stores a list of docs representing all linkdocs in 'allLinks' and a list of strings representing all group types in 'allGroupTypes' // lists of strings representing the metadata keys for each group type is stored under a key that is the same as the group type public get LinkManagerDoc(): Doc | undefined { - return FieldValue(Cast(CurrentUserUtils.UserDocument.linkManagerDoc, Doc)); + // return FieldValue(Cast(CurrentUserUtils.UserDocument.linkManagerDoc, Doc)); + + return Docs.Prototypes.MainLinkDocument(); } public getAllLinks(): Doc[] { diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index 932a6375f..1b9a45f0b 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -3,9 +3,32 @@ import { Docs } from "../documents/Documents"; import { CurrentUserUtils } from "../../server/authentication/models/current_user_utils"; import * as ReactDOM from 'react-dom'; import * as React from 'react'; +import { Cast } from "../../new_fields/Types"; +import { Doc, DocListCastAsync } from "../../new_fields/Doc"; +import { List } from "../../new_fields/List"; + +let swapDocs = async () => { + let oldDoc = await Cast(CurrentUserUtils.UserDocument.linkManagerDoc, Doc); + Docs.Prototypes.MainLinkDocument().allLinks = new List(); + if (oldDoc) { + let links = await DocListCastAsync(oldDoc.allLinks); + // if (links && DocListCast(links)) { + if (links && links.length) { + let data = await DocListCastAsync(Docs.Prototypes.MainLinkDocument().allLinks); + if (data) { + data.push(...links); + } + else { + Docs.Prototypes.MainLinkDocument().allLinks = new List(links); + } + } + CurrentUserUtils.UserDocument.LinkManagerDoc = undefined; + } +} (async () => { await Docs.Prototypes.initialize(); await CurrentUserUtils.loadCurrentUser(); + await swapDocs(); ReactDOM.render(, document.getElementById('root')); })(); \ No newline at end of file -- cgit v1.2.3-70-g09d2 From dafd50255e9a748d6d1032561d208b633e97f424 Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Sat, 13 Jul 2019 15:58:55 -0400 Subject: tweaked audio box rendering. played with recording audio. --- src/client/documents/Documents.ts | 2 +- src/client/views/nodes/AudioBox.scss | 4 +++- src/client/views/nodes/AudioBox.tsx | 8 +++---- src/client/views/nodes/ImageBox.tsx | 41 ++++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 2a3827782..8c0220a44 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -135,7 +135,7 @@ export namespace Docs { }], [DocumentType.AUDIO, { layout: { view: AudioBox }, - options: { height: 150 } + options: { height: 32 } }], [DocumentType.PDF, { layout: { view: PDFBox, collectionView: [CollectionPDFView, data, anno] as CollectionViewType }, diff --git a/src/client/views/nodes/AudioBox.scss b/src/client/views/nodes/AudioBox.scss index 704cdc31c..972966204 100644 --- a/src/client/views/nodes/AudioBox.scss +++ b/src/client/views/nodes/AudioBox.scss @@ -1,4 +1,6 @@ .audiobox-cont{ - height: 100%; + top:0; + max-height: 32px; + position: absolute; width: 100%; } \ No newline at end of file diff --git a/src/client/views/nodes/AudioBox.tsx b/src/client/views/nodes/AudioBox.tsx index be12dced3..be6ae630f 100644 --- a/src/client/views/nodes/AudioBox.tsx +++ b/src/client/views/nodes/AudioBox.tsx @@ -16,12 +16,10 @@ export class AudioBox extends React.Component { let path = field.url.href; return ( -
-
); } } \ No newline at end of file diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx index 77e44b807..73ae8955d 100644 --- a/src/client/views/nodes/ImageBox.tsx +++ b/src/client/views/nodes/ImageBox.tsx @@ -21,6 +21,7 @@ import { FieldView, FieldViewProps } from './FieldView'; import "./ImageBox.scss"; import React = require("react"); import { RouteStore } from '../../../server/RouteStore'; +import { Docs } from '../../documents/Documents'; var requestImageSize = require('../../util/request-image-size'); var path = require('path'); @@ -32,6 +33,15 @@ export const pageSchema = createSchema({ curPage: "number", }); +interface window { + MediaRecorder: MediaRecorder; +} + +declare class MediaRecorder { + // whatever MediaRecorder has + constructor(e: any); +} + type ImageDocument = makeInterface<[typeof pageSchema, typeof positionSchema]>; const ImageDocument = makeInterface(pageSchema, positionSchema); @@ -138,12 +148,43 @@ export class ImageBox extends DocComponent(ImageD } } + recordAudioAnnotation = () => { + let gumStream: any; + let recorder: any; + let self = this; + navigator.mediaDevices.getUserMedia({ + audio: true + }).then(function (stream) { + gumStream = stream; + recorder = new MediaRecorder(stream); + recorder.ondataavailable = function (e: any) { + var url = URL.createObjectURL(e.data); + // upload to server with known URL + let audioDoc = Docs.Create.AudioDocument(url, { title: "audio test", x: NumCast(self.props.Document.x), y: NumCast(self.props.Document.y), width: 200, height: 32 }); + audioDoc.embed = true; + let audioAnnos = Cast(self.extensionDoc.audioAnnotations, listSpec(Doc)); + if (audioAnnos === undefined) { + self.extensionDoc.audioAnnotations = new List([audioDoc]); + } else { + audioAnnos.push(audioDoc); + } + }; + recorder.start(); + setTimeout(() => { + recorder.stop(); + + gumStream.getAudioTracks()[0].stop(); + }, 1000); + }); + } + specificContextMenu = (e: React.MouseEvent): void => { let field = Cast(this.Document[this.props.fieldKey], ImageField); if (field) { let url = field.url.href; let subitems: ContextMenuProps[] = []; subitems.push({ description: "Copy path", event: () => Utils.CopyText(url), icon: "expand-arrows-alt" }); + subitems.push({ description: "Record 1sec audio", event: this.recordAudioAnnotation, icon: "expand-arrows-alt" }); subitems.push({ description: "Rotate", event: action(() => { let proto = Doc.GetProto(this.props.Document); -- cgit v1.2.3-70-g09d2 From 3c6c4e6da942ef4c1e7faebdc165eb4fcaa7bee4 Mon Sep 17 00:00:00 2001 From: yipstanley Date: Sat, 13 Jul 2019 16:34:42 -0400 Subject: oops --- src/client/views/Main.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index 1b9a45f0b..971658473 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -9,7 +9,7 @@ import { List } from "../../new_fields/List"; let swapDocs = async () => { let oldDoc = await Cast(CurrentUserUtils.UserDocument.linkManagerDoc, Doc); - Docs.Prototypes.MainLinkDocument().allLinks = new List(); + // Docs.Prototypes.MainLinkDocument().allLinks = new List(); if (oldDoc) { let links = await DocListCastAsync(oldDoc.allLinks); // if (links && DocListCast(links)) { -- cgit v1.2.3-70-g09d2