From 19375927c677ad6c99c77d0c7dac17fe7a2712a9 Mon Sep 17 00:00:00 2001
From: ab <abdullah_ahmed@brown.edu>
Date: Mon, 16 Sep 2019 15:26:36 -0400
Subject: beginning to handle external interactions

---
 src/client/views/collections/CollectionSchemaCells.tsx | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

(limited to 'src/client/views/collections/CollectionSchemaCells.tsx')

diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index 9c26a08f0..bf8c4b6f7 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -27,6 +27,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
 import { SchemaHeaderField } from "../../../new_fields/SchemaHeaderField";
 import { KeyCodes } from "../../northstar/utils/KeyCodes";
 import { undoBatch } from "../../util/UndoManager";
+import { List } from "lodash";
 
 library.add(faExpand);
 
@@ -86,10 +87,23 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
     }
 
     @action
-    onPointerDown = (e: React.PointerEvent): void => {
+    onPointerDown = async (e: React.PointerEvent): Promise<void> => {
         this.props.changeFocusedCellByIndex(this.props.row, this.props.col);
         this.props.setPreviewDoc(this.props.rowProps.original);
 
+        const data = await DocListCastAsync(this.props.Document.data);
+        if (data) {
+            let url: string;
+            if (url = StrCast(data[0].href)) {
+                try {
+                    new URL(url);
+                    const temp = window.open(url)!;
+                    temp.blur();
+                    window.focus();
+                } catch { }
+            }
+        }
+
         // this._isEditing = true;
         // this.props.setIsEditing(true);
 
-- 
cgit v1.2.3-70-g09d2


From e0b84cf329d7a9c9bda1aadbf25894c4bcc8f13a Mon Sep 17 00:00:00 2001
From: ab <abdullah_ahmed@brown.edu>
Date: Mon, 16 Sep 2019 17:15:37 -0400
Subject: demo touches

---
 src/client/ClientRecommender.tsx                   | 26 +++++++++++++++-------
 .../views/collections/CollectionSchemaCells.tsx    | 19 +++++++---------
 src/client/views/nodes/DocumentView.tsx            | 13 ++++++++---
 3 files changed, 36 insertions(+), 22 deletions(-)

(limited to 'src/client/views/collections/CollectionSchemaCells.tsx')

diff --git a/src/client/ClientRecommender.tsx b/src/client/ClientRecommender.tsx
index 103993a67..14af0a69b 100644
--- a/src/client/ClientRecommender.tsx
+++ b/src/client/ClientRecommender.tsx
@@ -212,7 +212,7 @@ export class ClientRecommender extends React.Component<RecommenderProps> {
     arxivrequest = async (query: string) => {
         let xhttp = new XMLHttpRequest();
         let serveraddress = "http://export.arxiv.org/api";
-        let endpoint = serveraddress + "/query?search_query=all:" + query + "&start=0&max_results=1";
+        let endpoint = serveraddress + "/query?search_query=all:" + query + "&start=0&max_results=5";
         let promisified = (resolve: any, reject: any) => {
             xhttp.onreadystatechange = function () {
                 if (this.readyState === 4) {
@@ -221,22 +221,32 @@ export class ClientRecommender extends React.Component<RecommenderProps> {
                     console.log(xml);
                     switch (this.status) {
                         case 200:
-                            let title: string = "Title";
-                            let url: string = "Url";
+                            let title_vals: string[] = [];
+                            let url_vals: string[] = [];
                             //console.log(result);
                             if (xml) {
                                 let titles = xml.getElementsByTagName("title");
+                                let counter = 1;
                                 if (titles && titles.length > 1) {
-                                    title = titles[1].childNodes[0].nodeValue!;
-                                    console.log(title);
+                                    while (counter <= 5) {
+                                        const title = titles[counter].childNodes[0].nodeValue!;
+                                        console.log(title)
+                                        title_vals.push(title);
+                                        counter++;
+                                    }
                                 }
                                 let ids = xml.getElementsByTagName("id");
+                                counter = 1;
                                 if (ids && ids.length > 1) {
-                                    url = ids[1].childNodes[0].nodeValue!;
-                                    console.log(url);
+                                    while (counter <= 5) {
+                                        const url = ids[counter].childNodes[0].nodeValue!;
+                                        console.log(url);
+                                        url_vals.push(url);
+                                        counter++;
+                                    }
                                 }
                             }
-                            return resolve({ title, url });
+                            return resolve({ title_vals, url_vals });
                         case 400:
                         default:
                             return reject(result);
diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index bf8c4b6f7..511fbc3a0 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -91,17 +91,14 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
         this.props.changeFocusedCellByIndex(this.props.row, this.props.col);
         this.props.setPreviewDoc(this.props.rowProps.original);
 
-        const data = await DocListCastAsync(this.props.Document.data);
-        if (data) {
-            let url: string;
-            if (url = StrCast(data[0].href)) {
-                try {
-                    new URL(url);
-                    const temp = window.open(url)!;
-                    temp.blur();
-                    window.focus();
-                } catch { }
-            }
+        let url: string;
+        if (url = StrCast(this.props.rowProps.row.href)) {
+            try {
+                new URL(url);
+                const temp = window.open(url)!;
+                temp.blur();
+                window.focus();
+            } catch { }
         }
 
         // this._isEditing = true;
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index a034bc1f4..a80eafde2 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -777,9 +777,16 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
         const extdoc = doc.data_ext as Doc;
         const values = await ClientRecommender.Instance.extractText(doc, extdoc ? extdoc : doc, false);
         const headers = [new SchemaHeaderField("title"), new SchemaHeaderField("href")];
-        const body = Docs.Create.FreeformDocument([], { title: values.title });
-        body.href = values.url;
-        CollectionDockingView.Instance.AddRightSplit(Docs.Create.SchemaDocument(headers, [body], { title: `Showing External Recommendations for "${StrCast(doc.title)}"` }), undefined);
+        let bodies: Doc[] = [];
+        const titles = values.title_vals;
+        const urls = values.url_vals;
+        for (let i = 0; i < 5; i++) {
+            const body = Docs.Create.FreeformDocument([], { title: titles[i] });
+            body.href = urls[i];
+            bodies.push(body);
+        }
+
+        CollectionDockingView.Instance.AddRightSplit(Docs.Create.SchemaDocument(headers, bodies, { title: `Showing External Recommendations for "${StrCast(doc.title)}"` }), undefined);
     }
 
     onPointerEnter = (e: React.PointerEvent): void => { Doc.BrushDoc(this.props.Document); };
-- 
cgit v1.2.3-70-g09d2

