From ed88af4bdc68b22c247a2030e8bdc5775293bfe6 Mon Sep 17 00:00:00 2001 From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> Date: Wed, 21 Aug 2024 18:39:25 -0400 Subject: work on fields dashboard --- src/client/views/nodes/DataVizBox/DataVizBox.tsx | 19 +++++++-- .../views/nodes/DataVizBox/DocCreatorMenu.scss | 14 ++++--- .../views/nodes/DataVizBox/DocCreatorMenu.tsx | 47 +++++++++++++++------- 3 files changed, 57 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/DataVizBox/DataVizBox.tsx b/src/client/views/nodes/DataVizBox/DataVizBox.tsx index 808bc182a..eaf5c1758 100644 --- a/src/client/views/nodes/DataVizBox/DataVizBox.tsx +++ b/src/client/views/nodes/DataVizBox/DataVizBox.tsx @@ -63,7 +63,8 @@ export class DataVizBox extends ViewBoxAnnotatableComponent() { @observable _marqueeing: number[] | undefined = undefined; @observable _savedAnnotations = new ObservableMap(); @observable _specialHighlightedRow: number | undefined = undefined; - @observable _GPTSummary: ObservableMap | undefined = undefined; + @observable GPTSummary: ObservableMap | undefined = undefined; + @observable fieldTypes: ObservableMap = new ObservableMap(); @observable _GPTLoading: boolean = false; constructor(props: FieldViewProps) { @@ -145,6 +146,18 @@ export class DataVizBox extends ViewBoxAnnotatableComponent() { this._specialHighlightedRow = row; } + @action setFieldType = (field: string, type: string) => { + this.fieldTypes?.set(field, type); + } + + getFieldType = (field: string): string => { + return this.fieldTypes?.get(field) ?? ''; + } + + getFieldDescription = (field: string): string => { + return this.GPTSummary?.get(field) ?? ''; + } + @action // pinned / linked anchor doc includes selected rows, graph titles, and graph colors restoreView = (data: Doc) => { // const changedView = data.config_dataViz && this.dataVizView !== data.config_dataViz && (this.layoutDoc._dataViz = data.config_dataViz); @@ -516,10 +529,10 @@ export class DataVizBox extends ViewBoxAnnotatableComponent() { const res = await gptAPICall(prompt, GPTCallType.VIZSUM); if (res) { - this._GPTSummary = new ObservableMap(); + this.GPTSummary = new ObservableMap(); const descs: {[col: string]: string} = JSON.parse(res); for (const [key, val] of Object.entries(descs)) { - this._GPTSummary.set(key, val); + this.GPTSummary.set(key, val); } console.log(res, descs); diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu.scss b/src/client/views/nodes/DataVizBox/DocCreatorMenu.scss index 9b3a02e0f..c93798979 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu.scss +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu.scss @@ -783,11 +783,19 @@ background-color: rgb(40, 40, 40); border: 1px solid rgb(100, 100, 100); border-radius: 3px; - width: 30%; + width: 31%; height: 25px; padding-left: 3px; color: whitesmoke; + .placeholder { + color: gray; + } + + &:hover .placeholder { + display: none; + } + .bubbles { display: none; } @@ -797,10 +805,6 @@ margin-bottom: 5px; } - &:hover { - width: 30% + 8; - } - &:hover .bubbles { display: flex; flex-direction: row; diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx index 3218b9765..50d6b7fe0 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx @@ -50,6 +50,7 @@ export class DocCreatorMenu extends ObservableReactComponent {return {title: field, type: '', id: Math.random() * 100000}}).concat(this._fields); + return this.selectedFields.map(field => {return {title: field, type: this._dataViz?.getFieldType(field) ?? '', id: Math.random() * 100000}}).concat(this._fields); } @computed get canMakeDocs(){ @@ -195,7 +196,8 @@ export class DocCreatorMenu extends ObservableReactComponent this._templateDocs.slice(), (docs) => docs.map(this.getIcon)); this._disposers.gpt = reaction(() => this._GPTTemplates.slice(), (docs) => docs.map(this.getIcon)); //this._disposers.columns = reaction(() => this._dataViz?.layoutDoc._dataViz_axes, () => {this.generateTemplates('')}) - this._disposers.lightbox = reaction(() => LightboxView.LightboxDoc(), doc => { doc ? this._shouldDisplay && this.closeMenu() : !this._shouldDisplay && this.openMenu()}) + this._disposers.lightbox = reaction(() => LightboxView.LightboxDoc(), doc => { doc ? this._shouldDisplay && this.closeMenu() : !this._shouldDisplay && this.openMenu()}); + this._disposers.fields = reaction(() => this._dataViz?.axes, cols => this._selectedCols = cols?.map(col => { return {title: col, type: '', id: Math.random() * 100000}})) } componentWillUnmount() { @@ -206,6 +208,11 @@ export class DocCreatorMenu extends ObservableReactComponent { docs.map(this.getIcon) } + @action + updateSelectedCols = (cols: string[]) => { + this._selectedCols + } + @action toggleDisplay = (x: number, y: number) => { if (this._shouldDisplay) { @@ -414,7 +421,7 @@ export class DocCreatorMenu extends ObservableReactComponent { + if (this.selectedFields.includes(field.title)) { + this._dataViz?.setFieldType(field.title, type); + } else { + field.type = type; + } + this.forceUpdate(); + } + get dashboardContents(){ return (
@@ -801,24 +817,25 @@ export class DocCreatorMenu extends ObservableReactComponent
- Type:  - {field.type ? field.type === 'text' ? 'Text' : 'File' : ''} + {field.type ? null : Select media type} + {field.type ? field.type === 'text' ? 'Text Field' : 'File Field' : ''}
- {field.type = 'text'; this.forceUpdate()}}/> + {this.setFieldType(field, 'text')}}/>
Text
- {field.type = 'visual'; this.forceUpdate()}}/> + {this.setFieldType(field, 'visual')}}/>
File
-