aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/documents/Documents.ts13
-rw-r--r--src/client/northstar/core/filter/FilterModel.ts2
-rw-r--r--src/client/northstar/dash-fields/HistogramField.ts64
-rw-r--r--src/client/northstar/dash-nodes/HistogramBox.scss34
-rw-r--r--src/client/northstar/dash-nodes/HistogramBox.tsx (renamed from src/client/views/nodes/HistogramBox.tsx)108
-rw-r--r--src/client/northstar/dash-nodes/HistogramBoxPrimitives.scss (renamed from src/client/views/nodes/HistogramBoxPrimitives.scss)5
-rw-r--r--src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx (renamed from src/client/views/nodes/HistogramBoxPrimitives.tsx)47
-rw-r--r--src/client/northstar/dash-nodes/HistogramLabelPrimitives.scss (renamed from src/client/views/nodes/HistogramLabelPrimitives.scss)1
-rw-r--r--src/client/northstar/dash-nodes/HistogramLabelPrimitives.tsx (renamed from src/client/views/nodes/HistogramLabelPrimitives.tsx)8
-rw-r--r--src/client/northstar/model/ModelHelpers.ts18
-rw-r--r--src/client/northstar/model/binRanges/VisualBinRangeHelper.ts6
-rw-r--r--src/client/northstar/operations/BaseOperation.ts4
-rw-r--r--src/client/northstar/operations/HistogramOperation.ts13
-rw-r--r--src/client/northstar/utils/SizeConverter.ts6
-rw-r--r--src/client/views/Main.tsx39
-rw-r--r--src/client/views/nodes/DocumentContentsView.tsx5
-rw-r--r--src/client/views/nodes/DocumentView.tsx3
-rw-r--r--src/client/views/nodes/HistogramBox.scss22
-rw-r--r--src/fields/HistogramField.ts59
-rw-r--r--src/fields/KeyStore.ts1
-rw-r--r--src/server/ServerUtil.ts3
-rw-r--r--src/server/authentication/models/current_user_utils.ts27
22 files changed, 286 insertions, 202 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 837dfe815..663ccae61 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -1,6 +1,6 @@
import { AudioField } from "../../fields/AudioField";
import { Document } from "../../fields/Document";
-import { Field, FieldWaiting } from "../../fields/Field";
+import { Field } from "../../fields/Field";
import { HtmlField } from "../../fields/HtmlField";
import { ImageField } from "../../fields/ImageField";
import { InkField, StrokeData } from "../../fields/InkField";
@@ -11,6 +11,9 @@ import { PDFField } from "../../fields/PDFField";
import { TextField } from "../../fields/TextField";
import { VideoField } from "../../fields/VideoField";
import { WebField } from "../../fields/WebField";
+import { HistogramField } from "../northstar/dash-fields/HistogramField";
+import { HistogramBox } from "../northstar/dash-nodes/HistogramBox";
+import { HistogramOperation } from "../northstar/operations/HistogramOperation";
import { Server } from "../Server";
import { CollectionPDFView } from "../views/collections/CollectionPDFView";
import { CollectionVideoView } from "../views/collections/CollectionVideoView";
@@ -22,10 +25,6 @@ import { KeyValueBox } from "../views/nodes/KeyValueBox";
import { PDFBox } from "../views/nodes/PDFBox";
import { VideoBox } from "../views/nodes/VideoBox";
import { WebBox } from "../views/nodes/WebBox";
-import { HistogramBox } from "../views/nodes/HistogramBox";
-import { FieldView } from "../views/nodes/FieldView";
-import { HistogramField } from "../../fields/HistogramField";
-import { HistogramOperation } from "../northstar/operations/HistogramOperation";
export interface DocumentOptions {
x?: number;
@@ -44,7 +43,6 @@ export interface DocumentOptions {
layoutKeys?: Key[];
viewType?: number;
backgroundColor?: string;
- northstarSchema?: string;
}
export namespace Documents {
@@ -88,7 +86,6 @@ export namespace Documents {
if (options.ink !== undefined) { doc.Set(KeyStore.Ink, new InkField(options.ink)); }
if (options.layout !== undefined) { doc.SetText(KeyStore.Layout, options.layout); }
if (options.layoutKeys !== undefined) { doc.Set(KeyStore.LayoutKeys, new ListField(options.layoutKeys)); }
- if (options.northstarSchema !== undefined) { doc.SetText(KeyStore.NorthstarSchema, options.northstarSchema); }
return doc;
}
@@ -126,7 +123,7 @@ export namespace Documents {
function GetHistogramPrototype(): Document {
if (!histoProto) {
histoProto = setupPrototypeOptions(histoProtoId, "HISTO PROTO", CollectionView.LayoutString("AnnotationsKey"),
- { x: 0, y: 0, width: 300, height: 300, layoutKeys: [KeyStore.Data, KeyStore.Annotations, KeyStore.Caption] });
+ { x: 0, y: 0, width: 300, height: 300, backgroundColor: "black", layoutKeys: [KeyStore.Data, KeyStore.Annotations, KeyStore.Caption] });
histoProto.SetText(KeyStore.BackgroundLayout, HistogramBox.LayoutString());
}
return histoProto;
diff --git a/src/client/northstar/core/filter/FilterModel.ts b/src/client/northstar/core/filter/FilterModel.ts
index bc7938947..aee99d2b6 100644
--- a/src/client/northstar/core/filter/FilterModel.ts
+++ b/src/client/northstar/core/filter/FilterModel.ts
@@ -2,10 +2,10 @@ import { ValueComparison } from "./ValueComparision";
import { Utils } from "../../utils/Utils";
import { IBaseFilterProvider } from "./IBaseFilterProvider";
import { FilterOperand } from "./FilterOperand";
-import { HistogramField } from "../../../../fields/HistogramField";
import { KeyStore } from "../../../../fields/KeyStore";
import { FieldWaiting } from "../../../../fields/Field";
import { Document } from "../../../../fields/Document";
+import { HistogramField } from "../../dash-fields/HistogramField";
export class FilterModel {
public ValueComparisons: ValueComparison[];
diff --git a/src/client/northstar/dash-fields/HistogramField.ts b/src/client/northstar/dash-fields/HistogramField.ts
new file mode 100644
index 000000000..00912c595
--- /dev/null
+++ b/src/client/northstar/dash-fields/HistogramField.ts
@@ -0,0 +1,64 @@
+import { BasicField } from "../../../fields/BasicField";
+import { Field, FieldId } from "../../../fields/Field";
+import { Types } from "../../../server/Message";
+import { HistogramOperation } from "../../../client/northstar/operations/HistogramOperation";
+import { action } from "mobx";
+import { AttributeTransformationModel } from "../../../client/northstar/core/attribute/AttributeTransformationModel";
+import { ColumnAttributeModel } from "../../../client/northstar/core/attribute/AttributeModel";
+import { CurrentUserUtils } from "../../../server/authentication/models/current_user_utils";
+import { ArrayUtil } from "../utils/ArrayUtil";
+import { Schema } from "../model/idea/idea";
+
+
+export class HistogramField extends BasicField<HistogramOperation> {
+ constructor(data?: HistogramOperation, id?: FieldId, save: boolean = true) {
+ super(data ? data : HistogramOperation.Empty, save, id);
+ }
+
+ toString(): string {
+ return JSON.stringify(this.Data);
+ }
+
+ Copy(): Field {
+ return new HistogramField(this.Data);
+ }
+
+ ToScriptString(): string {
+ return `new HistogramField("${this.Data}")`;
+ }
+
+ ToJson(): { type: Types, data: string, _id: string } {
+ return {
+ type: Types.HistogramOp,
+ data: JSON.stringify(this.Data),
+ _id: this.Id
+ }
+ }
+
+ @action
+ static FromJson(id: string, data: any): HistogramField {
+ let jp = JSON.parse(data);
+ let X: AttributeTransformationModel | undefined;
+ let Y: AttributeTransformationModel | undefined;
+ let V: AttributeTransformationModel | undefined;
+
+ let schema = CurrentUserUtils.GetNorthstarSchema(jp.SchemaName);
+ if (schema) {
+ CurrentUserUtils.GetAllNorthstarColumnAttributes(schema).map(attr => {
+ if (attr.displayName == jp.X.AttributeModel.Attribute.DisplayName) {
+ X = new AttributeTransformationModel(new ColumnAttributeModel(attr), jp.X.AggregateFunction);
+ }
+ if (attr.displayName == jp.Y.AttributeModel.Attribute.DisplayName) {
+ Y = new AttributeTransformationModel(new ColumnAttributeModel(attr), jp.Y.AggregateFunction);
+ }
+ if (attr.displayName == jp.V.AttributeModel.Attribute.DisplayName) {
+ V = new AttributeTransformationModel(new ColumnAttributeModel(attr), jp.V.AggregateFunction);
+ }
+ });
+ if (X && Y && V) {
+ return new HistogramField(new HistogramOperation(jp.SchemaName, X, Y, V, jp.Normalization), id, false);
+ }
+ }
+ return new HistogramField(HistogramOperation.Empty, id, false);
+ }
+} \ No newline at end of file
diff --git a/src/client/northstar/dash-nodes/HistogramBox.scss b/src/client/northstar/dash-nodes/HistogramBox.scss
new file mode 100644
index 000000000..b11840a65
--- /dev/null
+++ b/src/client/northstar/dash-nodes/HistogramBox.scss
@@ -0,0 +1,34 @@
+.histogrambox-container {
+ padding: 0vw;
+ position: absolute;
+ text-align: center;
+ width: 100%;
+ height: 100%;
+ background: black;
+ }
+ .histogrambox-xaxislabel {
+ position:absolute;
+ width:100%;
+ text-align: center;
+ bottom:0;
+ background: lightgray;
+ font-size: 14;
+ font-weight: bold;
+ }
+ .histogrambox-yaxislabel {
+ position:absolute;
+ height:100%;
+ width: 25px;
+ bottom:0;
+ background: lightgray;
+ }
+ .histogrambox-yaxislabel-text {
+ position:absolute;
+ transform-origin: left;
+ transform: rotate(-90deg);
+ text-align: center;
+ font-size: 14;
+ font-weight: bold;
+ bottom: calc(50% - 25px);
+ }
+ \ No newline at end of file
diff --git a/src/client/views/nodes/HistogramBox.tsx b/src/client/northstar/dash-nodes/HistogramBox.tsx
index 3307925a2..9f8c2cfd0 100644
--- a/src/client/views/nodes/HistogramBox.tsx
+++ b/src/client/northstar/dash-nodes/HistogramBox.tsx
@@ -1,22 +1,23 @@
import React = require("react")
-import { computed, observable, reaction, runInAction } from "mobx";
+import { action, computed, observable, reaction, runInAction } from "mobx";
import { observer } from "mobx-react";
import Measure from "react-measure";
import { Dictionary } from "typescript-collections";
-import { Opt } from "../../../fields/Field";
-import { HistogramField } from "../../../fields/HistogramField";
+import { FieldWaiting, Opt } from "../../../fields/Field";
import { KeyStore } from "../../../fields/KeyStore";
import { CurrentUserUtils } from "../../../server/authentication/models/current_user_utils";
import { FilterModel } from '../../northstar/core/filter/FilterModel';
import { ChartType, VisualBinRange } from '../../northstar/model/binRanges/VisualBinRange';
import { VisualBinRangeHelper } from "../../northstar/model/binRanges/VisualBinRangeHelper";
-import { AggregateBinRange, BinRange, DoubleValueAggregateResult, HistogramResult } from "../../northstar/model/idea/idea";
+import { AggregateBinRange, BinRange, DoubleValueAggregateResult, HistogramResult, Catalog } from "../../northstar/model/idea/idea";
import { ModelHelpers } from "../../northstar/model/ModelHelpers";
import { HistogramOperation } from "../../northstar/operations/HistogramOperation";
import { PIXIRectangle } from "../../northstar/utils/MathUtil";
import { SizeConverter } from "../../northstar/utils/SizeConverter";
-import "./../../northstar/utils/Extensions";
-import { FieldView, FieldViewProps } from './FieldView';
+import { DragManager } from "../../util/DragManager";
+import { FieldView, FieldViewProps } from "../../views/nodes/FieldView";
+import { HistogramField } from "../dash-fields/HistogramField";
+import "../utils/Extensions"
import "./HistogramBox.scss";
import { HistogramBoxPrimitives } from './HistogramBoxPrimitives';
import { HistogramLabelPrimitives } from "./HistogramLabelPrimitives";
@@ -28,16 +29,19 @@ export interface HistogramPrimitivesProps {
@observer
export class HistogramBox extends React.Component<FieldViewProps> {
public static LayoutString(fieldStr: string = "DataKey") { return FieldView.LayoutString(HistogramBox, fieldStr) }
- public HitTargets: Dictionary<PIXIRectangle, FilterModel> = new Dictionary<PIXIRectangle, FilterModel>();
+ private _dropXRef = React.createRef<HTMLDivElement>();
+ private _dropYRef = React.createRef<HTMLDivElement>();
+ private _dropXDisposer?: DragManager.DragDropDisposer;
+ private _dropYDisposer?: DragManager.DragDropDisposer;
@observable public PanelWidth: number = 100;
@observable public PanelHeight: number = 100;
- @observable public HistoOp?: HistogramOperation;
+ @observable public HistoOp: HistogramOperation = HistogramOperation.Empty;
@observable public VisualBinRanges: VisualBinRange[] = [];
@observable public ValueRange: number[] = [];
@observable public SizeConverter: SizeConverter = new SizeConverter();
- @computed get createOperationParamsCache() { return this.HistoOp!.CreateOperationParameters(); }
+ @computed get createOperationParamsCache() { return this.HistoOp.CreateOperationParameters(); }
@computed get HistogramResult() { return this.HistoOp ? this.HistoOp.Result as HistogramResult : undefined; }
@computed get BinRanges() { return this.HistogramResult ? this.HistogramResult.binRanges : undefined; }
@computed get ChartType() {
@@ -46,37 +50,84 @@ export class HistogramBox extends React.Component<FieldViewProps> {
this.BinRanges[1] instanceof AggregateBinRange ? ChartType.VerticalBar : ChartType.HeatMap;
}
+ constructor(props: FieldViewProps) {
+ super(props);
+ }
+
+ @action
+ dropX = (e: Event, de: DragManager.DropEvent) => {
+ if (de.data instanceof DragManager.DocumentDragData) {
+ let h = de.data.draggedDocument.GetT(KeyStore.Data, HistogramField);
+ if (h && h != FieldWaiting) {
+ this.HistoOp.X = h.Data.X;
+ }
+ e.stopPropagation();
+ e.preventDefault();
+ }
+ }
+ @action
+ dropY = (e: Event, de: DragManager.DropEvent) => {
+ if (de.data instanceof DragManager.DocumentDragData) {
+ let h = de.data.draggedDocument.GetT(KeyStore.Data, HistogramField);
+ if (h && h != FieldWaiting) {
+ this.HistoOp.Y = h.Data.X;
+ }
+ e.stopPropagation();
+ e.preventDefault();
+ }
+ }
+
componentDidMount() {
- reaction(() => [CurrentUserUtils.ActiveSchemaName, this.props.doc.GetText(KeyStore.NorthstarSchema, "?")],
- (params: string[]) => params[0] === params[1] && this.activateHistogramOperation(), { fireImmediately: true });
+ if (this._dropXRef.current) {
+ this._dropXDisposer = DragManager.MakeDropTarget(this._dropXRef.current, { handlers: { drop: this.dropX.bind(this) } });
+ }
+ if (this._dropYRef.current) {
+ this._dropYDisposer = DragManager.MakeDropTarget(this._dropYRef.current, { handlers: { drop: this.dropY.bind(this) } });
+ }
+ reaction(() => CurrentUserUtils.NorthstarDBCatalog, (catalog?: Catalog) => this.activateHistogramOperation(catalog), { fireImmediately: true });
reaction(() => [this.VisualBinRanges && this.VisualBinRanges.slice()], () => this.SizeConverter.SetVisualBinRanges(this.VisualBinRanges));
reaction(() => [this.PanelHeight, this.PanelWidth], () => this.SizeConverter.SetIsSmall(this.PanelWidth < 40 && this.PanelHeight < 40))
reaction(() => this.HistogramResult ? this.HistogramResult.binRanges : undefined,
(binRanges: BinRange[] | undefined) => {
if (binRanges) {
this.VisualBinRanges.splice(0, this.VisualBinRanges.length, ...binRanges.map((br, ind) =>
- VisualBinRangeHelper.GetVisualBinRange(br, this.HistogramResult!, ind ? this.HistoOp!.Y : this.HistoOp!.X, this.ChartType)));
+ VisualBinRangeHelper.GetVisualBinRange(this.HistoOp.Schema!.distinctAttributeParameters, br, this.HistogramResult!, ind ? this.HistoOp.Y : this.HistoOp.X, this.ChartType)));
- let valueAggregateKey = ModelHelpers.CreateAggregateKey(this.HistoOp!.V, this.HistogramResult!, ModelHelpers.AllBrushIndex(this.HistogramResult!));
+ let valueAggregateKey = ModelHelpers.CreateAggregateKey(this.HistoOp.Schema!.distinctAttributeParameters, this.HistoOp.V, this.HistogramResult!, ModelHelpers.AllBrushIndex(this.HistogramResult!));
this.ValueRange = Object.values(this.HistogramResult!.bins!).reduce((prev, cur) => {
let value = ModelHelpers.GetAggregateResult(cur, valueAggregateKey) as DoubleValueAggregateResult;
return value && value.hasResult ? [Math.min(prev[0], value.result!), Math.max(prev[1], value.result!)] : prev;
- }, [Number.MIN_VALUE, Number.MAX_VALUE]);
+ }, [Number.MAX_VALUE, Number.MIN_VALUE]);
}
});
}
- activateHistogramOperation() {
- this.props.doc.GetTAsync(this.props.fieldKey, HistogramField).then((histoOp: Opt<HistogramField>) => {
- if (histoOp) {
- runInAction(() => this.HistoOp = histoOp.Data);
- reaction(() => this.props.doc.GetList(KeyStore.LinkedFromDocs, []), docs => this.HistoOp!.Links.splice(0, this.HistoOp!.Links.length, ...docs), { fireImmediately: true });
- reaction(() => this.createOperationParamsCache, () => this.HistoOp!.Update(), { fireImmediately: true });
- }
- })
+ @action
+ xLabelPointerDown = (e: React.PointerEvent) => {
+
+ }
+
+ componentWillUnmount() {
+ if (this._dropXDisposer)
+ this._dropXDisposer();
+ if (this._dropYDisposer)
+ this._dropYDisposer();
+ }
+
+ activateHistogramOperation(catalog?: Catalog) {
+ if (catalog) {
+ this.props.doc.GetTAsync(this.props.fieldKey, HistogramField).then((histoOp: Opt<HistogramField>) => runInAction(() => {
+ this.HistoOp = histoOp ? histoOp.Data : HistogramOperation.Empty;
+ if (this.HistoOp != HistogramOperation.Empty) {
+ reaction(() => this.props.doc.GetList(KeyStore.LinkedFromDocs, []), docs => this.HistoOp.Links.splice(0, this.HistoOp.Links.length, ...docs), { fireImmediately: true });
+ reaction(() => this.createOperationParamsCache, () => this.HistoOp.Update(), { fireImmediately: true });
+ }
+ }));
+ }
}
render() {
- let label = this.HistoOp && this.HistoOp.X ? this.HistoOp.X.AttributeModel.DisplayName : "<...>";
+ let labelY = this.HistoOp && this.HistoOp.Y ? this.HistoOp.Y.PresentedName : "<...>";
+ let labelX = this.HistoOp && this.HistoOp.X ? this.HistoOp.X.PresentedName : "<...>";
var h = this.props.isTopMost ? this.PanelHeight : this.props.doc.GetNumber(KeyStore.Height, 0);
var w = this.props.isTopMost ? this.PanelWidth : this.props.doc.GetNumber(KeyStore.Width, 0);
let loff = this.SizeConverter.LeftOffset;
@@ -87,15 +138,20 @@ export class HistogramBox extends React.Component<FieldViewProps> {
<Measure onResize={(r: any) => runInAction(() => { this.PanelWidth = r.entry.width; this.PanelHeight = r.entry.height })}>
{({ measureRef }) =>
<div className="histogrambox-container" ref={measureRef} style={{ transform: `translate(${-w / 2}px, ${-h / 2}px)` }}>
+ <div className="histogrambox-yaxislabel" ref={this._dropYRef} >
+ <span className="histogrambox-yaxislabel-text">
+ {labelY}
+ </span>
+ </div>
<div style={{
- transform: `translate(${loff}px, ${toff}px)`,
- width: `calc(100% - ${loff + roff}px)`,
+ transform: `translate(${loff + 25}px, ${toff}px)`,
+ width: `calc(100% - ${loff + roff + 25}px)`,
height: `calc(100% - ${toff + boff}px)`,
}}>
<HistogramLabelPrimitives HistoBox={this} />
<HistogramBoxPrimitives HistoBox={this} />
</div>
- <div className="histogrambox-xaxislabel">{label}</div>
+ <div className="histogrambox-xaxislabel" onPointerDown={this.xLabelPointerDown} ref={this._dropXRef} >{labelX}</div>
</div>
}
</Measure>
diff --git a/src/client/views/nodes/HistogramBoxPrimitives.scss b/src/client/northstar/dash-nodes/HistogramBoxPrimitives.scss
index 85f2c092d..9d42219cc 100644
--- a/src/client/views/nodes/HistogramBoxPrimitives.scss
+++ b/src/client/northstar/dash-nodes/HistogramBoxPrimitives.scss
@@ -1,7 +1,7 @@
.histogramboxprimitives-border {
border: 3px;
border-style: solid;
- border-color: #282828;
+ border-color: white;
pointer-events: none;
position: absolute;
}
@@ -21,5 +21,6 @@
}
.histogramboxprimitives-line {
position: absolute;
- background: lightgray;
+ background: darkGray;
+ opacity: 0.4;
} \ No newline at end of file
diff --git a/src/client/views/nodes/HistogramBoxPrimitives.tsx b/src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx
index f15cb5689..d2f1be4fd 100644
--- a/src/client/views/nodes/HistogramBoxPrimitives.tsx
+++ b/src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx
@@ -1,10 +1,11 @@
import React = require("react")
-import { computed, observable, runInAction, trace } from "mobx";
+import { computed, observable, runInAction } from "mobx";
import { observer } from "mobx-react";
import { Utils as DashUtils } from '../../../Utils';
import { AttributeTransformationModel } from "../../northstar/core/attribute/AttributeTransformationModel";
+import { FilterModel } from "../../northstar/core/filter/FilterModel";
import { ChartType } from '../../northstar/model/binRanges/VisualBinRange';
-import { AggregateFunction, Bin, Brush, HistogramResult, MarginAggregateParameters, MarginAggregateResult, BinLabel } from "../../northstar/model/idea/idea";
+import { AggregateFunction, Bin, Brush, HistogramResult, MarginAggregateParameters, MarginAggregateResult } from "../../northstar/model/idea/idea";
import { ModelHelpers } from "../../northstar/model/ModelHelpers";
import { ArrayUtil } from "../../northstar/utils/ArrayUtil";
import { LABColor } from '../../northstar/utils/LABcolor';
@@ -12,8 +13,6 @@ import { PIXIRectangle } from "../../northstar/utils/MathUtil";
import { StyleConstants } from "../../northstar/utils/StyleContants";
import { HistogramBox, HistogramPrimitivesProps } from "./HistogramBox";
import "./HistogramBoxPrimitives.scss";
-import { HistogramOperation } from "../../northstar/operations/HistogramOperation";
-import { FilterModel } from "../../northstar/core/filter/FilterModel";
@observer
@@ -31,11 +30,9 @@ export class HistogramBoxPrimitives extends React.Component<HistogramPrimitivesP
let allBrushIndex = ModelHelpers.AllBrushIndex(histoResult);
return Object.keys(histoResult.bins).reduce((prims, key) => {
let drawPrims = new HistogramBinPrimitiveCollection(histoResult!.bins![key], this.props.HistoBox);
- let filterModel = ModelHelpers.GetBinFilterModel(histoResult!.bins![key], allBrushIndex, histoResult!, this.histoOp!.X, this.histoOp!.Y);
-
- this.props.HistoBox.HitTargets.setValue(drawPrims.HitGeom, filterModel);
- let toggle = this.getSelectionToggle(drawPrims.BinPrimitives, allBrushIndex, filterModel);
+ let toggle = this.getSelectionToggle(drawPrims.BinPrimitives, allBrushIndex,
+ ModelHelpers.GetBinFilterModel(histoResult!.bins![key], allBrushIndex, histoResult!, this.histoOp.X, this.histoOp.Y));
drawPrims.BinPrimitives.filter(bp => bp.DataValue && bp.BrushIndex !== allBrushIndex).map(bp =>
prims.push(...[{ r: bp.Rect, c: bp.Color }, { r: bp.MarginRect, c: StyleConstants.MARGIN_BARS_COLOR }].map(pair => this.drawRect(pair.r, bp.BarAxis, pair.c, "bar", toggle))));
return prims;
@@ -45,13 +42,13 @@ export class HistogramBoxPrimitives extends React.Component<HistogramPrimitivesP
private getSelectionToggle(binPrimitives: HistogramBinPrimitive[], allBrushIndex: number, filterModel: FilterModel) {
let allBrushPrim = ArrayUtil.FirstOrDefault(binPrimitives, bp => bp.BrushIndex == allBrushIndex);
return !allBrushPrim ? () => { } : () => runInAction(() => {
- if (ArrayUtil.Contains(this.histoOp!.FilterModels, filterModel)) {
+ if (ArrayUtil.Contains(this.histoOp.FilterModels, filterModel)) {
this._selectedPrims.splice(this._selectedPrims.indexOf(allBrushPrim!), 1);
- this.histoOp!.RemoveFilterModels([filterModel]);
+ this.histoOp.RemoveFilterModels([filterModel]);
}
else {
this._selectedPrims.push(allBrushPrim!);
- this.histoOp!.AddFilterModels([filterModel]);
+ this.histoOp.AddFilterModels([filterModel]);
}
})
}
@@ -92,6 +89,14 @@ export class HistogramBoxPrimitives extends React.Component<HistogramPrimitivesP
}
drawRect(r: PIXIRectangle, barAxis: number, color: number | undefined, classExt: string, tapHandler: () => void = () => { }) {
+ if (r.height < 0) {
+ r.y += r.height;
+ r.height = -r.height;
+ }
+ if (r.width < 0) {
+ r.x += r.width;
+ r.width = -r.width;
+ }
let widthPercent = r.width / this.renderDimension * 100;
let heightPercent = r.height / this.renderDimension * 100;
let rect = (<div className={`histogramboxprimitives-${classExt}`} onPointerDown={(e: React.PointerEvent) => { if (e.button == 0) tapHandler() }}
@@ -136,7 +141,7 @@ export class HistogramBinPrimitiveCollection {
private static TOLERANCE: number = 0.0001;
private _histoBox: HistogramBox;
- private get histoOp() { return this._histoBox.HistoOp!; }
+ private get histoOp() { return this._histoBox.HistoOp; }
private get histoResult() { return this.histoOp.Result as HistogramResult; }
private get sizeConverter() { return this._histoBox.SizeConverter!; }
public BinPrimitives: Array<HistogramBinPrimitive> = new Array<HistogramBinPrimitive>();
@@ -205,7 +210,7 @@ export class HistogramBinPrimitiveCollection {
}
private createHeatmapBinPrimitives(bin: Bin, brush: Brush, brushFactorSum: number): number {
- let unNormalizedValue = this.histoOp!.getValue(2, bin, this.histoResult, brush.brushIndex!);
+ let unNormalizedValue = this.histoOp.getValue(2, bin, this.histoResult, brush.brushIndex!);
if (unNormalizedValue == undefined)
return brushFactorSum;
@@ -215,8 +220,8 @@ export class HistogramBinPrimitiveCollection {
let allUnNormalizedValue = this.histoOp.getValue(2, bin, this.histoResult, ModelHelpers.AllBrushIndex(this.histoResult))
// bcz: are these calls needed?
- let [xFrom, xTo] = this.sizeConverter.DataToScreenAxisRange(this._histoBox.VisualBinRanges, 0, bin);
- let [yFrom, yTo] = this.sizeConverter.DataToScreenAxisRange(this._histoBox.VisualBinRanges, 1, bin);
+ let [xFrom, xTo] = this.sizeConverter.DataToScreenXAxisRange(this._histoBox.VisualBinRanges, 0, bin);
+ let [yFrom, yTo] = this.sizeConverter.DataToScreenYAxisRange(this._histoBox.VisualBinRanges, 1, bin);
var returnBrushFactorSum = brushFactorSum;
if (allUnNormalizedValue != undefined) {
@@ -247,10 +252,10 @@ export class HistogramBinPrimitiveCollection {
}
private createSinglePointChartBinPrimitives(bin: Bin, brush: Brush): number {
- let unNormalizedValue = this._histoBox.HistoOp!.getValue(2, bin, this.histoResult, brush.brushIndex!);
+ let unNormalizedValue = this._histoBox.HistoOp.getValue(2, bin, this.histoResult, brush.brushIndex!);
if (unNormalizedValue != undefined) {
- let [xFrom, xTo] = this.sizeConverter.DataToScreenPointRange(0, bin, ModelHelpers.CreateAggregateKey(this.histoOp.X, this.histoResult, brush.brushIndex!));
- let [yFrom, yTo] = this.sizeConverter.DataToScreenPointRange(1, bin, ModelHelpers.CreateAggregateKey(this.histoOp.Y, this.histoResult, brush.brushIndex!));
+ let [xFrom, xTo] = this.sizeConverter.DataToScreenPointRange(0, bin, ModelHelpers.CreateAggregateKey(this.histoOp.Schema!.distinctAttributeParameters, this.histoOp.X, this.histoResult, brush.brushIndex!));
+ let [yFrom, yTo] = this.sizeConverter.DataToScreenPointRange(1, bin, ModelHelpers.CreateAggregateKey(this.histoOp.Schema!.distinctAttributeParameters, this.histoOp.Y, this.histoResult, brush.brushIndex!));
if (xFrom != undefined && yFrom != undefined && xTo != undefined && yTo != undefined)
this.createBinPrimitive(-1, brush, PIXIRectangle.EMPTY, 0, xFrom, xTo, yFrom, yTo, this.baseColorFromBrush(brush), 1, unNormalizedValue);
@@ -262,7 +267,7 @@ export class HistogramBinPrimitiveCollection {
let dataValue = this.histoOp.getValue(1, bin, this.histoResult, brush.brushIndex!);
if (dataValue != undefined) {
let [yFrom, yValue, yTo] = this.sizeConverter.DataToScreenNormalizedRange(dataValue, normalization, 1, binBrushMaxAxis);
- let [xFrom, xTo] = this.sizeConverter.DataToScreenAxisRange(this._histoBox.VisualBinRanges, 0, bin);
+ let [xFrom, xTo] = this.sizeConverter.DataToScreenXAxisRange(this._histoBox.VisualBinRanges, 0, bin);
var yMarginAbsolute = this.getMargin(bin, brush, this.histoOp.Y);
var marginRect = new PIXIRectangle(xFrom + (xTo - xFrom) / 2.0 - 1,
@@ -279,7 +284,7 @@ export class HistogramBinPrimitiveCollection {
let dataValue = this.histoOp.getValue(0, bin, this.histoResult, brush.brushIndex!);
if (dataValue != undefined) {
let [xFrom, xValue, xTo] = this.sizeConverter.DataToScreenNormalizedRange(dataValue, normalization, 0, binBrushMaxAxis);
- let [yFrom, yTo] = this.sizeConverter.DataToScreenAxisRange(this._histoBox.VisualBinRanges, 1, bin);
+ let [yFrom, yTo] = this.sizeConverter.DataToScreenYAxisRange(this._histoBox.VisualBinRanges, 1, bin);
var xMarginAbsolute = this.sizeConverter.IsSmall ? 0 : this.getMargin(bin, brush, this.histoOp.X);
var marginRect = new PIXIRectangle(this.sizeConverter.DataToScreenX(xValue - xMarginAbsolute),
@@ -297,7 +302,7 @@ export class HistogramBinPrimitiveCollection {
private getMargin(bin: Bin, brush: Brush, axis: AttributeTransformationModel) {
var marginParams = new MarginAggregateParameters();
marginParams.aggregateFunction = axis.AggregateFunction;
- var marginAggregateKey = ModelHelpers.CreateAggregateKey(axis, this.histoResult, brush.brushIndex!, marginParams);
+ var marginAggregateKey = ModelHelpers.CreateAggregateKey(this.histoOp.Schema!.distinctAttributeParameters, axis, this.histoResult, brush.brushIndex!, marginParams);
var marginResult = ModelHelpers.GetAggregateResult(bin, marginAggregateKey) as MarginAggregateResult;
return !marginResult ? 0 : marginResult.absolutMargin!;
}
diff --git a/src/client/views/nodes/HistogramLabelPrimitives.scss b/src/client/northstar/dash-nodes/HistogramLabelPrimitives.scss
index d8ee88d72..304d33771 100644
--- a/src/client/views/nodes/HistogramLabelPrimitives.scss
+++ b/src/client/northstar/dash-nodes/HistogramLabelPrimitives.scss
@@ -3,6 +3,7 @@
position:absolute;
transform-origin: left top;
font-size: 11;
+ color:white;
}
.histogramLabelPrimitives-placer {
position:absolute;
diff --git a/src/client/views/nodes/HistogramLabelPrimitives.tsx b/src/client/northstar/dash-nodes/HistogramLabelPrimitives.tsx
index 7f365e45b..45b23874d 100644
--- a/src/client/views/nodes/HistogramLabelPrimitives.tsx
+++ b/src/client/northstar/dash-nodes/HistogramLabelPrimitives.tsx
@@ -2,11 +2,11 @@ import React = require("react")
import { action, computed, reaction } from "mobx";
import { observer } from "mobx-react";
import { Utils as DashUtils } from '../../../Utils';
-import { NominalVisualBinRange } from "../../northstar/model/binRanges/NominalVisualBinRange";
-import { StyleConstants } from "../../northstar/utils/StyleContants";
-import "./../../northstar/utils/Extensions";
-import "./HistogramLabelPrimitives.scss";
+import { NominalVisualBinRange } from "../model/binRanges/NominalVisualBinRange";
+import "../utils/Extensions";
+import { StyleConstants } from "../utils/StyleContants";
import { HistogramBox, HistogramPrimitivesProps } from "./HistogramBox";
+import "./HistogramLabelPrimitives.scss";
@observer
export class HistogramLabelPrimitives extends React.Component<HistogramPrimitivesProps> {
diff --git a/src/client/northstar/model/ModelHelpers.ts b/src/client/northstar/model/ModelHelpers.ts
index 8de0bd260..d0711fb69 100644
--- a/src/client/northstar/model/ModelHelpers.ts
+++ b/src/client/northstar/model/ModelHelpers.ts
@@ -13,11 +13,11 @@ import { CurrentUserUtils } from "../../../server/authentication/models/current_
export class ModelHelpers {
- public static CreateAggregateKey(atm: AttributeTransformationModel, histogramResult: HistogramResult,
+ public static CreateAggregateKey(distinctAttributeParameters: AttributeParameters | undefined, atm: AttributeTransformationModel, histogramResult: HistogramResult,
brushIndex: number, aggParameters?: SingleDimensionAggregateParameters): AggregateKey {
{
if (aggParameters == undefined) {
- aggParameters = ModelHelpers.GetAggregateParameter(atm);
+ aggParameters = ModelHelpers.GetAggregateParameter(distinctAttributeParameters, atm);
}
else {
aggParameters.attributeParameters = ModelHelpers.GetAttributeParameters(atm.AttributeModel);
@@ -34,40 +34,40 @@ export class ModelHelpers {
return ArrayUtil.IndexOfWithEqual(histogramResult.aggregateParameters!, aggParameters);
}
- public static GetAggregateParameter(atm: AttributeTransformationModel): AggregateParameters | undefined {
+ public static GetAggregateParameter(distinctAttributeParameters: AttributeParameters | undefined, atm: AttributeTransformationModel): AggregateParameters | undefined {
var aggParam: AggregateParameters | undefined;
if (atm.AggregateFunction === AggregateFunction.Avg) {
var avg = new AverageAggregateParameters();
avg.attributeParameters = ModelHelpers.GetAttributeParameters(atm.AttributeModel);
- avg.distinctAttributeParameters = CurrentUserUtils.ActiveSchema!.distinctAttributeParameters;
+ avg.distinctAttributeParameters = distinctAttributeParameters;
aggParam = avg;
}
else if (atm.AggregateFunction === AggregateFunction.Count) {
var cnt = new CountAggregateParameters();
cnt.attributeParameters = ModelHelpers.GetAttributeParameters(atm.AttributeModel);
- cnt.distinctAttributeParameters = CurrentUserUtils.ActiveSchema!.distinctAttributeParameters;
+ cnt.distinctAttributeParameters = distinctAttributeParameters;
aggParam = cnt;
}
else if (atm.AggregateFunction === AggregateFunction.Sum) {
var sum = new SumAggregateParameters();
sum.attributeParameters = ModelHelpers.GetAttributeParameters(atm.AttributeModel);
- sum.distinctAttributeParameters = CurrentUserUtils.ActiveSchema!.distinctAttributeParameters;
+ sum.distinctAttributeParameters = distinctAttributeParameters;
aggParam = sum;
}
return aggParam;
}
- public static GetAggregateParametersWithMargins(atms: Array<AttributeTransformationModel>): Array<AggregateParameters> {
+ public static GetAggregateParametersWithMargins(distinctAttributeParameters: AttributeParameters | undefined, atms: Array<AttributeTransformationModel>): Array<AggregateParameters> {
var aggregateParameters = new Array<AggregateParameters>();
atms.forEach(agg => {
- var aggParams = ModelHelpers.GetAggregateParameter(agg);
+ var aggParams = ModelHelpers.GetAggregateParameter(distinctAttributeParameters, agg);
if (aggParams) {
aggregateParameters.push(aggParams);
var margin = new MarginAggregateParameters()
margin.aggregateFunction = agg.AggregateFunction;
margin.attributeParameters = ModelHelpers.GetAttributeParameters(agg.AttributeModel);
- margin.distinctAttributeParameters = CurrentUserUtils.ActiveSchema!.distinctAttributeParameters;
+ margin.distinctAttributeParameters = distinctAttributeParameters;
aggregateParameters.push(margin);
}
});
diff --git a/src/client/northstar/model/binRanges/VisualBinRangeHelper.ts b/src/client/northstar/model/binRanges/VisualBinRangeHelper.ts
index 9eae39800..53d585bb4 100644
--- a/src/client/northstar/model/binRanges/VisualBinRangeHelper.ts
+++ b/src/client/northstar/model/binRanges/VisualBinRangeHelper.ts
@@ -1,4 +1,4 @@
-import { BinRange, NominalBinRange, QuantitativeBinRange, Exception, AlphabeticBinRange, DateTimeBinRange, AggregateBinRange, DoubleValueAggregateResult, HistogramResult } from "../idea/idea";
+import { BinRange, NominalBinRange, QuantitativeBinRange, Exception, AlphabeticBinRange, DateTimeBinRange, AggregateBinRange, DoubleValueAggregateResult, HistogramResult, AttributeParameters } from "../idea/idea";
import { VisualBinRange, ChartType } from "./VisualBinRange";
import { NominalVisualBinRange } from "./NominalVisualBinRange";
import { QuantitativeVisualBinRange } from "./QuantitativeVisualBinRange";
@@ -30,13 +30,13 @@ export class VisualBinRangeHelper {
throw new Exception()
}
- public static GetVisualBinRange(dataBinRange: BinRange, histoResult: HistogramResult, attr: AttributeTransformationModel, chartType: ChartType): VisualBinRange {
+ public static GetVisualBinRange(distinctAttributeParameters: AttributeParameters | undefined, dataBinRange: BinRange, histoResult: HistogramResult, attr: AttributeTransformationModel, chartType: ChartType): VisualBinRange {
if (!(dataBinRange instanceof AggregateBinRange)) {
return VisualBinRangeHelper.GetNonAggregateVisualBinRange(dataBinRange);
}
else {
- var aggregateKey = ModelHelpers.CreateAggregateKey(attr, histoResult, ModelHelpers.AllBrushIndex(histoResult));
+ var aggregateKey = ModelHelpers.CreateAggregateKey(distinctAttributeParameters, attr, histoResult, ModelHelpers.AllBrushIndex(histoResult));
var minValue = Number.MAX_VALUE;
var maxValue = Number.MIN_VALUE;
for (var b = 0; b < histoResult.brushes!.length; b++) {
diff --git a/src/client/northstar/operations/BaseOperation.ts b/src/client/northstar/operations/BaseOperation.ts
index 7db6fcb91..94e0849af 100644
--- a/src/client/northstar/operations/BaseOperation.ts
+++ b/src/client/northstar/operations/BaseOperation.ts
@@ -10,9 +10,9 @@ export abstract class BaseOperation {
@observable public Error: string = "";
@observable public OverridingFilters: FilterModel[] = [];
- @observable public Result: Result | undefined;
+ @observable public Result?: Result = undefined;
@observable public ComputationStarted: boolean = false;
- public OperationReference: OperationReference | undefined = undefined;
+ public OperationReference?: OperationReference = undefined;
private static _nextId = 0;
public RequestSalt: string = "";
diff --git a/src/client/northstar/operations/HistogramOperation.ts b/src/client/northstar/operations/HistogramOperation.ts
index 6c7288d42..8a0f648f6 100644
--- a/src/client/northstar/operations/HistogramOperation.ts
+++ b/src/client/northstar/operations/HistogramOperation.ts
@@ -27,6 +27,8 @@ export class HistogramOperation extends BaseOperation implements IBaseFilterCons
@observable public V: AttributeTransformationModel;
@observable public BrusherModels: BrushLinkModel<HistogramOperation>[] = [];
@observable public BrushableModels: BrushLinkModel<HistogramOperation>[] = [];
+ @observable public SchemaName: string;
+ @computed public get Schema() { return CurrentUserUtils.GetNorthstarSchema(this.SchemaName); }
@action
public AddFilterModels(filterModels: FilterModel[]): void {
@@ -38,23 +40,24 @@ export class HistogramOperation extends BaseOperation implements IBaseFilterCons
}
public getValue(axis: number, bin: Bin, result: HistogramResult, brushIndex: number) {
- var aggregateKey = ModelHelpers.CreateAggregateKey(axis == 0 ? this.X : axis == 1 ? this.Y : this.V, result, brushIndex);
+ var aggregateKey = ModelHelpers.CreateAggregateKey(this.Schema!.distinctAttributeParameters, axis == 0 ? this.X : axis == 1 ? this.Y : this.V, result, brushIndex);
let dataValue = ModelHelpers.GetAggregateResult(bin, aggregateKey) as DoubleValueAggregateResult;
return dataValue != null && dataValue.hasResult ? dataValue.result : undefined;
}
- public static Empty = new HistogramOperation(new AttributeTransformationModel(new ColumnAttributeModel(new Attribute())), new AttributeTransformationModel(new ColumnAttributeModel(new Attribute())), new AttributeTransformationModel(new ColumnAttributeModel(new Attribute())));
+ public static Empty = new HistogramOperation("-empty schema-", new AttributeTransformationModel(new ColumnAttributeModel(new Attribute())), new AttributeTransformationModel(new ColumnAttributeModel(new Attribute())), new AttributeTransformationModel(new ColumnAttributeModel(new Attribute())));
Equals(other: Object): boolean {
throw new Error("Method not implemented.");
}
- constructor(x: AttributeTransformationModel, y: AttributeTransformationModel, v: AttributeTransformationModel, normalized?: number) {
+ constructor(schemaName: string, x: AttributeTransformationModel, y: AttributeTransformationModel, v: AttributeTransformationModel, normalized?: number) {
super();
this.X = x;
this.Y = y;
this.V = v;
this.Normalization = normalized ? normalized : -1;
+ this.SchemaName = schemaName;
}
@computed
@@ -93,7 +96,7 @@ export class HistogramOperation extends BaseOperation implements IBaseFilterCons
allAttributes = ArrayUtil.Distinct(allAttributes.filter(a => a.AggregateFunction !== AggregateFunction.None));
let numericDataTypes = [DataType.Int, DataType.Double, DataType.Float];
- let perBinAggregateParameters: AggregateParameters[] = ModelHelpers.GetAggregateParametersWithMargins(allAttributes);
+ let perBinAggregateParameters: AggregateParameters[] = ModelHelpers.GetAggregateParametersWithMargins(this.Schema!.distinctAttributeParameters, allAttributes);
let globalAggregateParameters: AggregateParameters[] = [];
[histoX, histoY]
.filter(a => a.AggregateFunction === AggregateFunction.None && ArrayUtil.Contains(numericDataTypes, a.AttributeModel.DataType))
@@ -112,7 +115,7 @@ export class HistogramOperation extends BaseOperation implements IBaseFilterCons
let [perBinAggregateParameters, globalAggregateParameters] = this.GetAggregateParameters(this.X, this.Y, this.V);
return new HistogramOperationParameters({
enableBrushComputation: true,
- adapterName: CurrentUserUtils.ActiveSchema!.displayName,
+ adapterName: this.SchemaName,
filter: this.FilterString,
brushes: this.BrushString,
binningParameters: [ModelHelpers.GetBinningParameters(this.X, SETTINGS_X_BINS, this.QRange ? this.QRange.minValue : undefined, this.QRange ? this.QRange.maxValue : undefined),
diff --git a/src/client/northstar/utils/SizeConverter.ts b/src/client/northstar/utils/SizeConverter.ts
index ffd162a83..30627dfd5 100644
--- a/src/client/northstar/utils/SizeConverter.ts
+++ b/src/client/northstar/utils/SizeConverter.ts
@@ -68,10 +68,14 @@ export class SizeConverter {
return [undefined, undefined];
}
- public DataToScreenAxisRange(visualBinRanges: VisualBinRange[], index: number, bin: Bin) {
+ public DataToScreenXAxisRange(visualBinRanges: VisualBinRange[], index: number, bin: Bin) {
var value = visualBinRanges[0].GetValueFromIndex(bin.binIndex!.indices![index]);
return [this.DataToScreenX(value), this.DataToScreenX(visualBinRanges[index].AddStep(value))]
}
+ public DataToScreenYAxisRange(visualBinRanges: VisualBinRange[], index: number, bin: Bin) {
+ var value = visualBinRanges[1].GetValueFromIndex(bin.binIndex!.indices![index]);
+ return [this.DataToScreenY(value), this.DataToScreenY(visualBinRanges[index].AddStep(value))]
+ }
public DataToScreenX(x: number): number {
return ((x - this.DataMins[0]) / this.DataRanges[0]) * this.RenderDimension;
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index 09778ac77..2f20b102c 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -58,7 +58,7 @@ export class Main extends React.Component {
@observable private mainfreeform?: Document;
@observable public pwidth: number = 0;
@observable public pheight: number = 0;
- private _northstarColumns: Document[] = [];
+ private _northstarSchemas: Document[] = [];
@computed private get mainContainer(): Document | undefined {
let doc = this.userDocument.GetT(KeyStore.ActiveWorkspace, Document);
@@ -245,7 +245,7 @@ export class Main extends React.Component {
let addTextNode = action(() => Documents.TextDocument({ width: 200, height: 200, title: "a text note" }))
let addColNode = action(() => Documents.FreeformDocument([], { width: 200, height: 200, title: "a freeform collection" }));
let addSchemaNode = action(() => Documents.SchemaDocument([], { width: 200, height: 200, title: "a schema collection" }));
- let addTreeNode = action(() => Documents.TreeDocument(this._northstarColumns, { width: 200, height: 200, title: "a tree collection" }));
+ let addTreeNode = action(() => Documents.TreeDocument(this._northstarSchemas, { width: 100, height: 400, title: "northstar schemas" }));
let addVideoNode = action(() => Documents.VideoDocument(videourl, { width: 200, height: 200, title: "video node" }));
let addPDFNode = action(() => Documents.PdfDocument(pdfurl, { width: 200, height: 200, title: "a schema collection" }));
let addImageNode = action(() => Documents.ImageDocument(imgurl, { width: 200, height: 200, title: "an image of a cat" }));
@@ -334,24 +334,27 @@ export class Main extends React.Component {
// --------------- Northstar hooks ------------- /
@action SetNorthstarCatalog(ctlog: Catalog) {
+ CurrentUserUtils.NorthstarDBCatalog = ctlog;
if (ctlog && ctlog.schemas) {
- CurrentUserUtils.ActiveSchema = ArrayUtil.FirstOrDefault<Schema>(ctlog.schemas!, (s: Schema) => s.displayName === "mimic");
- CurrentUserUtils.GetAllNorthstarColumnAttributes().map(attr => {
- Server.GetField(attr.displayName!, action((field: Opt<Field>) => {
- if (field instanceof Document) {
- this._northstarColumns.push(field);
- } else {
- var atmod = new ColumnAttributeModel(attr);
- let histoOp = new HistogramOperation(
- new AttributeTransformationModel(atmod, AggregateFunction.None),
- new AttributeTransformationModel(atmod, AggregateFunction.Count),
- new AttributeTransformationModel(atmod, AggregateFunction.Count));
- this._northstarColumns.push(Documents.HistogramDocument(histoOp, { width: 200, height: 200, title: attr.displayName!, northstarSchema: CurrentUserUtils.ActiveSchema!.displayName! }, attr.displayName!));
- }
- }));
+ this._northstarSchemas = 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 => {
+ Server.GetField(attr.displayName!, action((field: Opt<Field>) => {
+ if (field instanceof Document) {
+ schemaDocuments.push(field);
+ } else {
+ var atmod = new ColumnAttributeModel(attr);
+ let histoOp = new HistogramOperation(schema!.displayName!,
+ new AttributeTransformationModel(atmod, AggregateFunction.None),
+ new AttributeTransformationModel(atmod, AggregateFunction.Count),
+ new AttributeTransformationModel(atmod, AggregateFunction.Count));
+ schemaDocuments.push(Documents.HistogramDocument(histoOp, { width: 200, height: 200, title: attr.displayName! }, attr.displayName!));
+ }
+ }));
+ });
+ return schemaDoc;
})
- console.log("Activating schema " + CurrentUserUtils.ActiveSchema!.displayName!)
- CurrentUserUtils.ActiveSchemaName = CurrentUserUtils.ActiveSchema!.displayName!;
}
}
async initializeNorthstar(): Promise<void> {
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index b54744337..77551649c 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -19,8 +19,7 @@ import { KeyValueBox } from "./KeyValueBox";
import { PDFBox } from "./PDFBox";
import { VideoBox } from "./VideoBox";
import { WebBox } from "./WebBox";
-import { HistogramBox } from "./HistogramBox";
-import { HistogramBoxPrimitives } from "./HistogramBoxPrimitives";
+import { HistogramBox } from "../../northstar/dash-nodes/HistogramBox";
import React = require("react");
const JsxParser = require('react-jsx-parser').default; //TODO Why does this need to be imported like this?
@@ -54,7 +53,7 @@ export class DocumentContentsView extends React.Component<DocumentViewProps & {
return <p>Error loading layout keys</p>;
}
return <JsxParser
- components={{ FormattedTextBox, ImageBox, CollectionFreeFormView, CollectionDockingView, CollectionSchemaView, CollectionView, CollectionPDFView, CollectionVideoView, WebBox, KeyValueBox, PDFBox, VideoBox, AudioBox, HistogramBox, HistogramBoxPrimitives }}
+ components={{ FormattedTextBox, ImageBox, CollectionFreeFormView, CollectionDockingView, CollectionSchemaView, CollectionView, CollectionPDFView, CollectionVideoView, WebBox, KeyValueBox, PDFBox, VideoBox, AudioBox, HistogramBox }}
bindings={this.CreateBindings()}
jsx={this.layout}
showWarnings={true}
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 769d893f3..71613ca4f 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -120,9 +120,6 @@ export class DocumentView extends React.Component<DocumentViewProps> {
}
private dropDisposer?: DragManager.DragDropDisposer;
- protected createDropTarget = (ele: HTMLDivElement) => {
-
- }
componentDidMount() {
if (this._mainCont.current) {
diff --git a/src/client/views/nodes/HistogramBox.scss b/src/client/views/nodes/HistogramBox.scss
deleted file mode 100644
index 2660b1b75..000000000
--- a/src/client/views/nodes/HistogramBox.scss
+++ /dev/null
@@ -1,22 +0,0 @@
-.histogrambox-container {
- padding: 0vw;
- position: absolute;
- text-align: center;
- width: 100%;
- height: 100%;
- }
- .histogrambox-xaxislabel {
- position:absolute;
- width:100%;
- text-align: center;
- bottom:0;
- font-size: 14;
- font-weight: bold;
- }
-
- .histogrambox-container {
- position:absolute;
- width:100%;
- height: 100%;
- }
- \ No newline at end of file
diff --git a/src/fields/HistogramField.ts b/src/fields/HistogramField.ts
deleted file mode 100644
index bb0014ab3..000000000
--- a/src/fields/HistogramField.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import { BasicField } from "./BasicField";
-import { Field, FieldId } from "./Field";
-import { Types } from "../server/Message";
-import { HistogramOperation } from "../client/northstar/operations/HistogramOperation";
-import { action } from "mobx";
-import { AttributeTransformationModel } from "../client/northstar/core/attribute/AttributeTransformationModel";
-import { ColumnAttributeModel } from "../client/northstar/core/attribute/AttributeModel";
-import { CurrentUserUtils } from "../server/authentication/models/current_user_utils";
-
-
-export class HistogramField extends BasicField<HistogramOperation> {
- constructor(data?: HistogramOperation, id?: FieldId, save: boolean = true) {
- super(data ? data : HistogramOperation.Empty, save, id);
- }
-
- toString(): string {
- return JSON.stringify(this.Data);
- }
-
- Copy(): Field {
- return new HistogramField(this.Data);
- }
-
- ToScriptString(): string {
- return `new HistogramField("${this.Data}")`;
- }
-
- ToJson(): { type: Types, data: string, _id: string } {
- return {
- type: Types.HistogramOp,
- data: JSON.stringify(this.Data),
- _id: this.Id
- }
- }
-
- @action
- static FromJson(id: string, data: any): HistogramField {
- let jp = JSON.parse(data);
- let X: AttributeTransformationModel | undefined;
- let Y: AttributeTransformationModel | undefined;
- let V: AttributeTransformationModel | undefined;
-
- CurrentUserUtils.GetAllNorthstarColumnAttributes().map(attr => {
- if (attr.displayName == jp.X.AttributeModel.Attribute.DisplayName) {
- X = new AttributeTransformationModel(new ColumnAttributeModel(attr), jp.X.AggregateFunction);
- }
- if (attr.displayName == jp.Y.AttributeModel.Attribute.DisplayName) {
- Y = new AttributeTransformationModel(new ColumnAttributeModel(attr), jp.Y.AggregateFunction);
- }
- if (attr.displayName == jp.V.AttributeModel.Attribute.DisplayName) {
- V = new AttributeTransformationModel(new ColumnAttributeModel(attr), jp.V.AggregateFunction);
- }
- });
- if (X && Y && V) {
- return new HistogramField(new HistogramOperation(X, Y, V, jp.Normalization), id, false);
- }
- return new HistogramField(HistogramOperation.Empty, id, false);
- }
-} \ No newline at end of file
diff --git a/src/fields/KeyStore.ts b/src/fields/KeyStore.ts
index 09dddf962..aa0b9ce92 100644
--- a/src/fields/KeyStore.ts
+++ b/src/fields/KeyStore.ts
@@ -44,5 +44,4 @@ export namespace KeyStore {
export const Archives = new Key("Archives");
export const Updated = new Key("Updated");
export const Workspaces = new Key("Workspaces");
- export const NorthstarSchema = new Key("NorthstarSchema");
}
diff --git a/src/server/ServerUtil.ts b/src/server/ServerUtil.ts
index f958df04b..98a7a1451 100644
--- a/src/server/ServerUtil.ts
+++ b/src/server/ServerUtil.ts
@@ -17,8 +17,7 @@ import { VideoField } from '../fields/VideoField';
import { InkField } from '../fields/InkField';
import { PDFField } from '../fields/PDFField';
import { TupleField } from '../fields/TupleField';
-import { HistogramField } from '../fields/HistogramField';
-
+import { HistogramField } from '../client/northstar/dash-fields/HistogramField';
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index 4b42e40b6..0ac85b446 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -7,8 +7,9 @@ import { Document } from "../../../fields/Document";
import { KeyStore } from "../../../fields/KeyStore";
import { ListField } from "../../../fields/ListField";
import { Documents } from "../../../client/documents/Documents";
-import { Schema, Attribute, AttributeGroup } from "../../../client/northstar/model/idea/idea";
+import { Schema, Attribute, AttributeGroup, Catalog } from "../../../client/northstar/model/idea/idea";
import { observable, computed, action } from "mobx";
+import { ArrayUtil } from "../../../client/northstar/utils/ArrayUtil";
export class CurrentUserUtils {
private static curr_email: string;
@@ -16,8 +17,7 @@ export class CurrentUserUtils {
private static user_document: Document;
//TODO tfs: these should be temporary...
private static mainDocId: string | undefined;
- private static activeSchema: Schema | undefined;
- @observable public static ActiveSchemaName: string = "";
+ @observable private static catalog?: Catalog;
public static get email(): string {
return this.curr_email;
@@ -39,12 +39,18 @@ export class CurrentUserUtils {
this.mainDocId = id;
}
-
- public static get ActiveSchema(): Schema | undefined {
- return this.activeSchema;
+ @computed public static get NorthstarDBCatalog(): Catalog | undefined {
+ return this.catalog;
+ }
+ public static set NorthstarDBCatalog(ctlog: Catalog | undefined) {
+ this.catalog = ctlog;
}
- public static GetAllNorthstarColumnAttributes() {
- if (!this.ActiveSchema || !this.ActiveSchema.rootAttributeGroup) {
+ public static GetNorthstarSchema(name: string): Schema | undefined {
+ return !this.catalog || !this.catalog.schemas ? undefined :
+ ArrayUtil.FirstOrDefault<Schema>(this.catalog.schemas, (s: Schema) => s.displayName === name);
+ }
+ public static GetAllNorthstarColumnAttributes(schema: Schema) {
+ if (!schema || !schema.rootAttributeGroup) {
return [];
}
const recurs = (attrs: Attribute[], g: AttributeGroup) => {
@@ -56,13 +62,10 @@ export class CurrentUserUtils {
}
};
const allAttributes: Attribute[] = new Array<Attribute>();
- recurs(allAttributes, this.ActiveSchema.rootAttributeGroup);
+ recurs(allAttributes, schema.rootAttributeGroup);
return allAttributes;
}
- public static set ActiveSchema(id: Schema | undefined) {
- this.activeSchema = id;
- }
private static createUserDocument(id: string): Document {
let doc = new Document(id);