From da792d534024d8e0d266e291f92b9a1e83be51c2 Mon Sep 17 00:00:00 2001
From: ab <abdullah_ahmed@brown.edu>
Date: Tue, 30 Apr 2019 18:38:05 -0400
Subject: set not working

---
 src/debug/Test.tsx | 50 +++++++++++++++++++++++++-------------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

(limited to 'src/debug/Test.tsx')

diff --git a/src/debug/Test.tsx b/src/debug/Test.tsx
index 6a677f80f..47cfac2c1 100644
--- a/src/debug/Test.tsx
+++ b/src/debug/Test.tsx
@@ -46,34 +46,34 @@ class Test extends React.Component {
         doc.fields = "test";
         doc.test = "hello doc";
         doc.url = url;
-        doc.testDoc = doc2;
+        //doc.testDoc = doc2;
 
 
-        const test1: TestDoc = TestDoc(doc);
-        const test2: Test2Doc = Test2Doc(doc);
-        assert(test1.hello === 5);
-        assert(test1.fields === undefined);
-        assert(test1.test === "hello doc");
-        assert(test1.url === url);
-        assert(test1.testDoc === doc2);
-        test1.myField = 20;
-        assert(test1.myField === 20);
+        // const test1: TestDoc = TestDoc(doc);
+        // const test2: Test2Doc = Test2Doc(doc);
+        // assert(test1.hello === 5);
+        // assert(test1.fields === undefined);
+        // assert(test1.test === "hello doc");
+        // assert(test1.url === url);
+        // //assert(test1.testDoc === doc2);
+        // test1.myField = 20;
+        // assert(test1.myField === 20);
 
-        assert(test2.hello === undefined);
-        // assert(test2.fields === "test");
-        assert(test2.test === undefined);
-        assert(test2.url === undefined);
-        assert(test2.testDoc === undefined);
-        test2.url = 35;
-        assert(test2.url === 35);
-        const l = new List<number>();
-        //TODO push, and other array functions don't go through the proxy
-        l.push(1);
-        //TODO currently length, and any other string fields will get serialized
-        l.length = 3;
-        l[2] = 5;
-        console.log(l.slice());
-        console.log(SerializationHelper.Serialize(l));
+        // assert(test2.hello === undefined);
+        // // assert(test2.fields === "test");
+        // assert(test2.test === undefined);
+        // assert(test2.url === undefined);
+        // assert(test2.testDoc === undefined);
+        // test2.url = 35;
+        // assert(test2.url === 35);
+        // const l = new List<number>();
+        // //TODO push, and other array functions don't go through the proxy
+        // l.push(1);
+        // //TODO currently length, and any other string fields will get serialized
+        // l.length = 3;
+        // l[2] = 5;
+        // console.log(l.slice());
+        // console.log(SerializationHelper.Serialize(l));
     }
 
     render() {
-- 
cgit v1.2.3-70-g09d2


From e19fdbba4cf672aee5bfb59b91b6162431d146d3 Mon Sep 17 00:00:00 2001
From: ab <abdullah_ahmed@brown.edu>
Date: Sat, 4 May 2019 18:48:01 -0400
Subject: queries semi work

---
 package.json         |  3 ++-
 src/debug/Test.tsx   | 19 ++++++++++++++++++-
 src/server/Search.ts | 25 +++++++++++++++++++++++++
 src/server/index.ts  |  3 +++
 4 files changed, 48 insertions(+), 2 deletions(-)

(limited to 'src/debug/Test.tsx')

diff --git a/package.json b/package.json
index fd794d062..3393eacc6 100644
--- a/package.json
+++ b/package.json
@@ -167,9 +167,10 @@
         "serializr": "^1.5.1",
         "socket.io": "^2.2.0",
         "socket.io-client": "^2.2.0",
+        "solr-node": "^1.1.3",
         "typescript-collections": "^1.3.2",
         "url-loader": "^1.1.2",
         "uuid": "^3.3.2",
         "xoauth2": "^1.2.0"
     }
-}
\ No newline at end of file
+}
diff --git a/src/debug/Test.tsx b/src/debug/Test.tsx
index 47cfac2c1..7d72a1ba0 100644
--- a/src/debug/Test.tsx
+++ b/src/debug/Test.tsx
@@ -3,6 +3,9 @@ import * as ReactDOM from 'react-dom';
 import { serialize, deserialize, map } from 'serializr';
 import { URLField, Doc, createSchema, makeInterface, makeStrictInterface, List, ListSpec } from '../fields/NewDoc';
 import { SerializationHelper } from '../client/util/SerializationHelper';
+import { Search } from '../server/Search';
+import { restProperty } from 'babel-types';
+import * as rp from 'request-promise';
 
 const schema1 = createSchema({
     hello: "number",
@@ -76,8 +79,22 @@ class Test extends React.Component {
         // console.log(SerializationHelper.Serialize(l));
     }
 
+    onEnter = async (e: any) => {
+        var key = e.keyCode || e.which;
+        if (key === 13) {
+            var query = e.target.value;
+            await rp.get('http://localhost:1050/search', {
+                qs: {
+                    query
+                }
+            });
+        }
+    }
+
     render() {
-        return <button onClick={this.onClick}>Click me</button>;
+        return <div><button onClick={this.onClick}>Click me</button>
+            <input onKeyPress={this.onEnter}></input>
+        </div>;
     }
 }
 
diff --git a/src/server/Search.ts b/src/server/Search.ts
index 9e462f0ae..4911edd1d 100644
--- a/src/server/Search.ts
+++ b/src/server/Search.ts
@@ -5,6 +5,31 @@ import { thisExpression } from 'babel-types';
 export class Search {
     public static Instance = new Search();
     private url = 'http://localhost:8983/solr/';
+    private client: any;
+
+    constructor() {
+        console.log("Search Instantiated!");
+        var SolrNode = require('solr-node');
+        this.client = new SolrNode({
+            host: 'localhost',
+            port: '8983',
+            core: 'dash',
+            protocol: 'http'
+        });
+        var strQuery = this.client.query().q('text:test');
+
+        console.log(strQuery);
+
+        // Search documents using strQuery
+        // client.search(strQuery, (err: any, result: any) => {
+        //     if (err) {
+        //         console.log(err);
+        //         return;
+        //     }
+        //     console.log('Response:', result.response);
+        // });
+    }
+
 
     public async updateDocument(document: any) {
         console.log("UPDATE: ", JSON.stringify(document));
diff --git a/src/server/index.ts b/src/server/index.ts
index f90724152..f2bcd3f00 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -122,11 +122,14 @@ app.get("/pull", (req, res) =>
         res.redirect("/");
     }));
 
+// SEARCH
+
 // GETTERS
 
 app.get("/search", async (req, res) => {
     let query = req.query.query || "hello";
     let results = await Search.Instance.search(query);
+    console.log(results);
     res.send(results);
 });
 
-- 
cgit v1.2.3-70-g09d2

