From 5e416c352ebfb875482f890c6362fee5f84af1f6 Mon Sep 17 00:00:00 2001
From: bob <bcz@cs.brown.edu>
Date: Tue, 19 Mar 2019 15:50:54 -0400
Subject: started to integrate Northstar.  changed server port to 4321.

---
 src/client/views/Main.tsx | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

(limited to 'src/client/views/Main.tsx')

diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index 8a52a501c..ac51a7d87 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -43,6 +43,8 @@ import { CurrentUserUtils } from '../../server/authentication/models/current_use
 import { Field, Opt } from '../../fields/Field';
 import { ListField } from '../../fields/ListField';
 import { map } from 'bluebird';
+import { Gateway, Settings } from '../northstar/manager/Gateway';
+import { Catalog } from '../northstar/model/idea/idea';
 
 @observer
 export class Main extends React.Component {
@@ -52,6 +54,7 @@ export class Main extends React.Component {
     @observable private userWorkspaces: Document[] = [];
     @observable public pwidth: number = 0;
     @observable public pheight: number = 0;
+    @observable private _northstarCatalog: Catalog | undefined = undefined;
 
     public mainDocId: string | undefined;
     private currentUser?: DashUserModel;
@@ -65,7 +68,9 @@ export class Main extends React.Component {
         if (window.location.pathname !== RouteStore.home) {
             let pathname = window.location.pathname.split("/");
             this.mainDocId = pathname[pathname.length - 1];
-        }
+        };
+
+        this.initializeNorthstar();
 
         CurrentUserUtils.loadCurrentUser();
 
@@ -82,9 +87,26 @@ export class Main extends React.Component {
         library.add(faMusic);
 
         this.initEventListeners();
-        Documents.initProtos(() => {
-            this.initAuthenticationRouters();
+        Documents.initProtos(() => this.initAuthenticationRouters());
+    }
+
+    @action SetNorthstarCatalog(ctlog: Catalog) {
+        this._northstarCatalog = ctlog;
+        if (this._northstarCatalog) {
+            console.log("CATALOG " + this._northstarCatalog.schemas);
+        }
+    }
+    async initializeNorthstar(): Promise<void> {
+        let envPath = "assets/env.json";
+        const response = await fetch(envPath, {
+            redirect: "follow",
+            method: "GET",
+            credentials: "include"
         });
+        const env = await response.json();
+        Settings.Instance.Update(env);
+        let cat = Gateway.Instance.ClearCatalog();
+        cat.then(async () => this.SetNorthstarCatalog(await Gateway.Instance.GetCatalog()));
     }
 
     onHistory = () => {
-- 
cgit v1.2.3-70-g09d2

