From 843ac47f04f8c9bd687600f9f07fe4c15744e4ec Mon Sep 17 00:00:00 2001 From: Abdullah Ahmed Date: Tue, 13 Aug 2019 11:12:41 -0400 Subject: recommendations --- src/Recommendations.scss | 21 ++++++ src/Recommendations.tsx | 28 ++++++++ src/client/views/nodes/DocumentView.tsx | 113 +++++++++++++++++--------------- 3 files changed, 108 insertions(+), 54 deletions(-) create mode 100644 src/Recommendations.scss create mode 100644 src/Recommendations.tsx (limited to 'src') diff --git a/src/Recommendations.scss b/src/Recommendations.scss new file mode 100644 index 000000000..5129a59d9 --- /dev/null +++ b/src/Recommendations.scss @@ -0,0 +1,21 @@ +.recommendation-content *{ + display: inline-block; + margin: auto; + border: 1px dashed grey; + padding: 2px 2px; +} + +.recommendation-content { + float: left; + border: 1px solid green; + width: 200px; + align-content: center; +} + +.rec-scroll { + overflow-y: scroll; + height: 300px; + width: auto; + position: absolute; + background: #cdcdcd; +} \ No newline at end of file diff --git a/src/Recommendations.tsx b/src/Recommendations.tsx new file mode 100644 index 000000000..ca1123ef9 --- /dev/null +++ b/src/Recommendations.tsx @@ -0,0 +1,28 @@ +import { observer } from "mobx-react"; +import React = require("react"); +import { Doc } from "./new_fields/Doc"; +import { NumCast } from "./new_fields/Types"; + +export interface RecProps { + documents: { preview: string, similarity: number }[], + node: Doc; +} + +@observer +export class Recommendations extends React.Component { + render() { + const transform = "translate(" + (NumCast(this.props.node.x) + 350) + "px, " + NumCast(this.props.node.y) + "px" + return ( +
+ {this.props.documents.map(doc => { + return ( +
+ +
{doc.similarity}
+
+ ) + })} +
+ ) + } +} \ No newline at end of file diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index c8eab85c2..24bcc0217 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -40,6 +40,7 @@ import React = require("react"); import { DictationManager } from '../../util/DictationManager'; import { MainView } from '../MainView'; import requestPromise = require('request-promise'); +import { Recommendations } from '../../../Recommendations'; const JsxParser = require('react-jsx-parser').default; //TODO Why does this need to be imported like this? library.add(fa.faTrash); @@ -680,6 +681,7 @@ export class DocumentView extends DocComponent(Docu } render() { + let documents = [{ preview: "hi", similarity: 0 }]; let backgroundColor = this.layoutDoc.isBackground || (this.props.ContainingCollectionView && this.props.ContainingCollectionView.props.Document.clusterOverridesDefaultBackground && this.layoutDoc.backgroundColor === this.layoutDoc.defaultBackgroundColor) ? this.props.backgroundColor(this.layoutDoc) || StrCast(this.layoutDoc.backgroundColor) : StrCast(this.layoutDoc.backgroundColor) || this.props.backgroundColor(this.layoutDoc); @@ -699,61 +701,64 @@ export class DocumentView extends DocComponent(Docu let showTextTitle = showTitle && StrCast(this.layoutDoc.layout).startsWith(" - {!showTitle && !showCaption ? this.contents : -
- -
- {this.contents} -
- {!showTitle ? (null) : -
- StrCast((this.layoutDoc.isTemplate || !this.dataDoc ? this.layoutDoc : this.dataDoc)[showTitle!])} - SetValue={(value: string) => (Doc.GetProto(this.layoutDoc)[showTitle!] = value) ? true : true} - /> -
- } - {!showCaption ? (null) : -
- +
+
+ {!showTitle && !showCaption ? this.contents : +
+ +
+ {this.contents}
- } -
- } + {!showTitle ? (null) : +
+ StrCast((this.layoutDoc.isTemplate || !this.dataDoc ? this.layoutDoc : this.dataDoc)[showTitle!])} + SetValue={(value: string) => (Doc.GetProto(this.layoutDoc)[showTitle!] = value) ? true : true} + /> +
+ } + {!showCaption ? (null) : +
+ +
+ } +
+ } +
+
); } -- cgit v1.2.3-70-g09d2