aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/northstar/manager/Gateway.ts22
-rw-r--r--src/client/views/Main.tsx15
-rw-r--r--src/client/views/collections/CollectionBaseView.tsx16
-rw-r--r--src/client/views/collections/CollectionSubView.tsx2
4 files changed, 37 insertions, 18 deletions
diff --git a/src/client/northstar/manager/Gateway.ts b/src/client/northstar/manager/Gateway.ts
index 1c8d3fd73..8f3b6b11c 100644
--- a/src/client/northstar/manager/Gateway.ts
+++ b/src/client/northstar/manager/Gateway.ts
@@ -23,6 +23,17 @@ export class Gateway {
}
}
+ public async GetSchema(dbName: string): Promise<Catalog> {
+ try {
+ const json = await this.MakeGetRequest("schema", undefined, dbName);
+ const cat = Catalog.fromJS(json);
+ return cat;
+ }
+ catch (error) {
+ throw new Error("can not reach northstar's backend");
+ }
+ }
+
public async ClearCatalog(): Promise<void> {
try {
const json = await this.MakePostJsonRequest("Datamart/ClearAllAugmentations", {});
@@ -133,8 +144,15 @@ export class Gateway {
});
}
- public async MakeGetRequest(endpoint: string, signal?: AbortSignal): Promise<any> {
- const url = Gateway.ConstructUrl(endpoint);
+ public async MakeGetRequest(endpoint: string, signal?: AbortSignal, data?: any): Promise<any> {
+ let url = !data ? Gateway.ConstructUrl(endpoint) :
+ (() => {
+ let newUrl = new URL(Gateway.ConstructUrl(endpoint));
+ newUrl.searchParams.append("data", data);
+ return Gateway.ConstructUrl(endpoint) + newUrl.search;
+ return newUrl as any;
+ })();
+
const response = await fetch(url,
{
redirect: "follow",
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index fd2e23c91..32798631d 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -348,10 +348,10 @@ export class Main extends React.Component {
// --------------- Northstar hooks ------------- /
- @action SetNorthstarCatalog(ctlog: Catalog) {
- CurrentUserUtils.NorthstarDBCatalog = ctlog;
+ @action AddToNorthstarCatalog(ctlog: Catalog) {
+ CurrentUserUtils.NorthstarDBCatalog = CurrentUserUtils.NorthstarDBCatalog ? CurrentUserUtils.NorthstarDBCatalog : ctlog;
if (ctlog && ctlog.schemas) {
- this._northstarSchemas = ctlog.schemas.map(schema => {
+ this._northstarSchemas.push(...ctlog.schemas.map(schema => {
let schemaDoc = Documents.TreeDocument([], { width: 50, height: 100, title: schema.displayName! });
let schemaDocuments = schemaDoc.GetList(KeyStore.Data, [] as Document[]);
CurrentUserUtils.GetAllNorthstarColumnAttributes(schema).map(attr => {
@@ -369,7 +369,7 @@ export class Main extends React.Component {
}));
});
return schemaDoc;
- });
+ }));
}
}
async initializeNorthstar(): Promise<void> {
@@ -382,7 +382,12 @@ export class Main extends React.Component {
const env = await response.json();
Settings.Instance.Update(env);
let cat = Gateway.Instance.ClearCatalog();
- cat.then(async () => this.SetNorthstarCatalog(await Gateway.Instance.GetCatalog()));
+ cat.then(async () => {
+ this.AddToNorthstarCatalog(await Gateway.Instance.GetCatalog());
+ if (!CurrentUserUtils.GetNorthstarSchema("Book1"))
+ this.AddToNorthstarCatalog(await Gateway.Instance.GetSchema("http://www.cs.brown.edu/~bcz/Book1.csv"));
+ });
+
}
}
diff --git a/src/client/views/collections/CollectionBaseView.tsx b/src/client/views/collections/CollectionBaseView.tsx
index 4afa7cbf6..4380c8194 100644
--- a/src/client/views/collections/CollectionBaseView.tsx
+++ b/src/client/views/collections/CollectionBaseView.tsx
@@ -1,17 +1,13 @@
+import { action } from 'mobx';
+import { observer } from 'mobx-react';
import * as React from 'react';
-import { FieldViewProps } from '../nodes/FieldView';
+import { Document } from '../../../fields/Document';
+import { Field, FieldValue, FieldWaiting } from '../../../fields/Field';
import { KeyStore } from '../../../fields/KeyStore';
+import { ListField } from '../../../fields/ListField';
import { NumberField } from '../../../fields/NumberField';
-import { FieldWaiting, Field, FieldValue } from '../../../fields/Field';
import { ContextMenu } from '../ContextMenu';
-import { SelectionManager } from '../../util/SelectionManager';
-import { Document } from '../../../fields/Document';
-import { ListField } from '../../../fields/ListField';
-import { action } from 'mobx';
-import { Transform } from '../../util/Transform';
-import { observer } from 'mobx-react';
-import { CompileScript } from '../../util/Scripting';
-import { ScriptField } from '../../../fields/ScriptField';
+import { FieldViewProps } from '../nodes/FieldView';
export enum CollectionViewType {
Invalid,
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index f058aaccc..5cdea0568 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -73,7 +73,7 @@ export class CollectionSubView extends React.Component<SubCollectionViewProps> {
draggedDocument.GetTAsync(key, NumberField, (f: Opt<NumberField>) => f ? de.data.droppedDocuments[i].SetNumber(key, f.Data) : null)));
}
let added = false;
- if (de.data.aliasOnDrop) {
+ if (de.data.aliasOnDrop || de.data.copyOnDrop) {
added = de.data.droppedDocuments.reduce((added: boolean, d) => added || this.props.addDocument(d), false);
} else if (de.data.moveDocument) {
const move = de.data.moveDocument;