diff options
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/ClientRecommender.tsx | 8 | ||||
| -rw-r--r-- | src/client/apis/IBM_Recommender.ts | 66 | ||||
| -rw-r--r-- | src/client/util/DocumentManager.ts | 7 | ||||
| -rw-r--r-- | src/client/views/nodes/AudioBox.tsx | 26 | ||||
| -rw-r--r-- | src/client/views/nodes/FormattedTextBoxComment.tsx | 2 | ||||
| -rw-r--r-- | src/client/views/nodes/WebBox.tsx | 2 |
6 files changed, 57 insertions, 54 deletions
diff --git a/src/client/ClientRecommender.tsx b/src/client/ClientRecommender.tsx index cb1674943..0e67a6e57 100644 --- a/src/client/ClientRecommender.tsx +++ b/src/client/ClientRecommender.tsx @@ -5,10 +5,10 @@ import { CognitiveServices, Confidence, Tag, Service } from "./cognitive_service import React = require("react"); import { observer } from "mobx-react"; import { observable, action, computed, reaction } from "mobx"; -var assert = require('assert'); -var sw = require('stopword'); -var FeedParser = require('feedparser'); -var https = require('https'); +// var assert = require('assert'); +// var sw = require('stopword'); +// var FeedParser = require('feedparser'); +// var https = require('https'); import "./ClientRecommender.scss"; import { JSXElement } from "babel-types"; import { RichTextField } from "../new_fields/RichTextField"; diff --git a/src/client/apis/IBM_Recommender.ts b/src/client/apis/IBM_Recommender.ts index da6257f28..4e1c541c8 100644 --- a/src/client/apis/IBM_Recommender.ts +++ b/src/client/apis/IBM_Recommender.ts @@ -1,40 +1,40 @@ -import { Opt } from "../../new_fields/Doc"; +// import { Opt } from "../../new_fields/Doc"; -const NaturalLanguageUnderstandingV1 = require('ibm-watson/natural-language-understanding/v1'); -const { IamAuthenticator } = require('ibm-watson/auth'); +// const NaturalLanguageUnderstandingV1 = require('ibm-watson/natural-language-understanding/v1'); +// const { IamAuthenticator } = require('ibm-watson/auth'); -export namespace IBM_Recommender { +// export namespace IBM_Recommender { - // pass to IBM account is Browngfx1 +// // pass to IBM account is Browngfx1 - const naturalLanguageUnderstanding = new NaturalLanguageUnderstandingV1({ - version: '2019-07-12', - authenticator: new IamAuthenticator({ - apikey: 'tLiYwbRim3CnBcCO4phubpf-zEiGcub1uh0V-sD9OKhw', - }), - url: 'https://gateway-wdc.watsonplatform.net/natural-language-understanding/api' - }); +// const naturalLanguageUnderstanding = new NaturalLanguageUnderstandingV1({ +// version: '2019-07-12', +// authenticator: new IamAuthenticator({ +// apikey: 'tLiYwbRim3CnBcCO4phubpf-zEiGcub1uh0V-sD9OKhw', +// }), +// url: 'https://gateway-wdc.watsonplatform.net/natural-language-understanding/api' +// }); - const analyzeParams = { - 'text': 'this is a test of the keyword extraction feature I am integrating into the program', - 'features': { - 'keywords': { - 'sentiment': true, - 'emotion': true, - 'limit': 3 - }, - } - }; +// const analyzeParams = { +// 'text': 'this is a test of the keyword extraction feature I am integrating into the program', +// 'features': { +// 'keywords': { +// 'sentiment': true, +// 'emotion': true, +// 'limit': 3 +// }, +// } +// }; - export const analyze = async (_parameters: any): Promise<Opt<string>> => { - try { - const response = await naturalLanguageUnderstanding.analyze(_parameters); - console.log(response); - return (JSON.stringify(response, null, 2)); - } catch (err) { - console.log('error: ', err); - return undefined; - } - }; +// export const analyze = async (_parameters: any): Promise<Opt<string>> => { +// try { +// const response = await naturalLanguageUnderstanding.analyze(_parameters); +// console.log(response); +// return (JSON.stringify(response, null, 2)); +// } catch (err) { +// console.log('error: ', err); +// return undefined; +// } +// }; -}
\ No newline at end of file +// }
\ No newline at end of file diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts index 4e82459f0..162a8fffe 100644 --- a/src/client/util/DocumentManager.ts +++ b/src/client/util/DocumentManager.ts @@ -209,7 +209,12 @@ export class DocumentManager { const maxLocation = StrCast(linkDoc.maximizeLocation, "inTab"); const targetContext = !Doc.AreProtosEqual(linkFollowDocContexts[reverse ? 1 : 0], currentContext) ? linkFollowDocContexts[reverse ? 1 : 0] : undefined; const target = linkFollowDocs[reverse ? 1 : 0]; - target.currentTimecode !== undefined && (target.currentTimecode = linkFollowTimecodes[reverse ? 1 : 0]); + let annotatedDoc = await Cast(target.annotationOn, Doc); + if (annotatedDoc) { + annotatedDoc.currentTimecode !== undefined && (target.currentTimecode = linkFollowTimecodes[reverse ? 1 : 0]); + } else { + target.currentTimecode !== undefined && (target.currentTimecode = linkFollowTimecodes[reverse ? 1 : 0]); + } DocumentManager.Instance.jumpToDocument(linkFollowDocs[reverse ? 1 : 0], zoom, (doc: Doc) => focus(doc, maxLocation), targetContext, linkDoc[Id], undefined, doc); } else if (link) { DocumentManager.Instance.jumpToDocument(link, zoom, (doc: Doc) => focus(doc, "onRight"), undefined, undefined); diff --git a/src/client/views/nodes/AudioBox.tsx b/src/client/views/nodes/AudioBox.tsx index ea26cc43d..05b9fd14a 100644 --- a/src/client/views/nodes/AudioBox.tsx +++ b/src/client/views/nodes/AudioBox.tsx @@ -20,6 +20,8 @@ import { DocumentView } from "./DocumentView"; import { Docs } from "../../documents/Documents"; import { ComputedField } from "../../../new_fields/ScriptField"; +// testing testing + interface Window { MediaRecorder: MediaRecorder; } @@ -46,6 +48,7 @@ export class AudioBox extends DocExtendableComponent<FieldViewProps, AudioDocume _ele: HTMLAudioElement | null = null; _recorder: any; _recordStart = 0; + _stream: MediaStream | undefined; public static START = 0; @observable private static _scrubTime = 0; @@ -137,12 +140,11 @@ export class AudioBox extends DocExtendableComponent<FieldViewProps, AudioDocume } recordAudioAnnotation = () => { - let gumStream: any; const self = this; navigator.mediaDevices.getUserMedia({ audio: true }).then(function (stream) { - gumStream = stream; + self._stream = stream; self._recorder = new MediaRecorder(stream); self.dataDoc[self.props.fieldKey + "-recordingStart"] = new DateField(new Date()); AudioBox.START = new DateField(new Date()).date.getTime(); @@ -154,23 +156,16 @@ export class AudioBox extends DocExtendableComponent<FieldViewProps, AudioDocume method: 'POST', body: formData }); - const json = await res.json(); - json.map(async (file: any) => { - const path = file.result.accessPaths.agnostic.client; - const url = Utils.prepend(path); - // upload to server with known URL - self.props.Document[self.props.fieldKey] = new AudioField(url); - }); + const files = await res.json(); + const url = Utils.prepend(files[0].result.accessPaths.agnostic.client); + // upload to server with known URL + self.props.Document[self.props.fieldKey] = new AudioField(url); }; self._recordStart = new Date().getTime(); - console.log("RECORD START = " + self._recordStart); runInAction(() => self.audioState = "recording"); setTimeout(self.updateRecordTime, 0); self._recorder.start(); - setTimeout(() => { - self.stopRecording(); - gumStream.getAudioTracks()[0].stop(); - }, 60 * 60 * 1000); // stop after an hour? + setTimeout(() => self._recorder && self.stopRecording(), 60 * 1000); // stop after an hour }); } @@ -183,8 +178,10 @@ export class AudioBox extends DocExtendableComponent<FieldViewProps, AudioDocume stopRecording = action(() => { this._recorder.stop(); + this._recorder = undefined; this.dataDoc.duration = (new Date().getTime() - this._recordStart) / 1000; this.audioState = "paused"; + this._stream?.getAudioTracks()[0].stop(); const ind = AudioBox.ActiveRecordings.indexOf(this.props.Document); ind !== -1 && (AudioBox.ActiveRecordings.splice(ind, 1)); }); @@ -237,6 +234,7 @@ export class AudioBox extends DocExtendableComponent<FieldViewProps, AudioDocume </audio>; } + // line 226 is stop button but it doesn't do anything render() { const interactive = this.active() ? "-interactive" : ""; return <div className={`audiobox-container`} onContextMenu={this.specificContextMenu} diff --git a/src/client/views/nodes/FormattedTextBoxComment.tsx b/src/client/views/nodes/FormattedTextBoxComment.tsx index a3096f60b..61df188f8 100644 --- a/src/client/views/nodes/FormattedTextBoxComment.tsx +++ b/src/client/views/nodes/FormattedTextBoxComment.tsx @@ -83,7 +83,7 @@ export class FormattedTextBoxComment { const keep = e.target && (e.target as any).type === "checkbox" ? true : false; const textBox = FormattedTextBoxComment.textBox; if (FormattedTextBoxComment.linkDoc && !keep && textBox) { - DocumentManager.Instance.FollowLink(FormattedTextBoxComment.linkDoc, textBox.dataDoc, + DocumentManager.Instance.FollowLink(FormattedTextBoxComment.linkDoc, textBox.props.Document, (doc: Doc, maxLocation: string) => textBox.props.addDocTab(doc, e.ctrlKey ? "inTab" : "onRight")); } else if (textBox && (FormattedTextBoxComment.tooltipText as any).href) { textBox.props.addDocTab(Docs.Create.WebDocument((FormattedTextBoxComment.tooltipText as any).href, { title: (FormattedTextBoxComment.tooltipText as any).href, _width: 200, _height: 400 }), "onRight"); diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx index c169d9423..2f8b6167f 100644 --- a/src/client/views/nodes/WebBox.tsx +++ b/src/client/views/nodes/WebBox.tsx @@ -36,7 +36,7 @@ export class WebBox extends DocAnnotatableComponent<FieldViewProps, WebDocument> public static LayoutString(fieldKey: string) { return FieldView.LayoutString(WebBox, fieldKey); } @observable private collapsed: boolean = true; - @observable private url: string = ""; + @observable private url: string = "hello"; private _longPressSecondsHack?: NodeJS.Timeout; private _iframeRef = React.createRef<HTMLIFrameElement>(); |
