aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/DocumentView.tsx
diff options
context:
space:
mode:
authorab <abdullah_ahmed@brown.edu>2019-09-16 14:40:22 -0400
committerab <abdullah_ahmed@brown.edu>2019-09-16 14:40:22 -0400
commitd3b4f8991aefcc939768cfa82617e42862693bc6 (patch)
tree3388770a317fe191c9aecd6532c821d031cdcf5c /src/client/views/nodes/DocumentView.tsx
parentaf59d641022119e25402f1f13ae2c3f3eb4c20a2 (diff)
parent3f63b49ccc1ebcbeac64443702826ea4597200f3 (diff)
Merge branch 'recommender_system' of https://github.com/browngraphicslab/Dash-Web into recommender_ui
Diffstat (limited to 'src/client/views/nodes/DocumentView.tsx')
-rw-r--r--src/client/views/nodes/DocumentView.tsx26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index d1e87b663..2ae71f1da 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -642,11 +642,23 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
a.click();
}
});
- cm.addItem({
- description: "Recommender System",
+ let recommender_subitems: ContextMenuProps[] = [];
+
+ recommender_subitems.push({
+ description: "Internal recommendations",
event: () => this.recommender(e),
icon: "brain"
});
+
+ recommender_subitems.push({
+ description: "External recommendations",
+ event: () => this.externalRecommendation(e),
+ icon: "brain"
+ });
+
+ cm.addItem({ description: "Recommender System", subitems: recommender_subitems, icon: "brain" });
+
+
cm.addItem({ description: "Delete", event: this.deleteClicked, icon: "trash" });
type User = { email: string, userDocumentId: string };
let usersMenu: ContextMenuProps[] = [];
@@ -729,7 +741,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
if (!documents.includes(dataDoc)) {
documents.push(dataDoc);
const extdoc = doc.data_ext as Doc;
- return ClientRecommender.Instance.extractText(doc, extdoc ? extdoc : doc, mainDoc);
+ return ClientRecommender.Instance.extractText(doc, extdoc ? extdoc : doc, true, mainDoc);
}
}
}));
@@ -757,6 +769,14 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
// RecommendationsBox.Instance.displayRecommendations(e.pageX + 100, e.pageY);
}
+ externalRecommendation = async (e: React.MouseEvent) => {
+ if (!ClientRecommender.Instance) new ClientRecommender({ title: "Client Recommender" });
+ ClientRecommender.Instance.reset_docs();
+ const doc = Doc.GetDataDoc(this.props.Document);
+ const extdoc = doc.data_ext as Doc;
+ return ClientRecommender.Instance.extractText(doc, extdoc ? extdoc : doc, false);
+ }
+
onPointerEnter = (e: React.PointerEvent): void => { Doc.BrushDoc(this.props.Document); };
onPointerLeave = (e: React.PointerEvent): void => { Doc.UnBrushDoc(this.props.Document); };