From 35724d24821132ab5c6df398447db4e9760155cb Mon Sep 17 00:00:00 2001 From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:25:22 -0400 Subject: dashbord updates properly --- src/client/views/nodes/DataVizBox/DataVizBox.tsx | 14 ++++++++-- .../views/nodes/DataVizBox/DocCreatorMenu.tsx | 32 +++++++++++++--------- 2 files changed, 30 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/DataVizBox/DataVizBox.tsx b/src/client/views/nodes/DataVizBox/DataVizBox.tsx index eaf5c1758..cef7f62b1 100644 --- a/src/client/views/nodes/DataVizBox/DataVizBox.tsx +++ b/src/client/views/nodes/DataVizBox/DataVizBox.tsx @@ -64,6 +64,7 @@ export class DataVizBox extends ViewBoxAnnotatableComponent() { @observable _savedAnnotations = new ObservableMap(); @observable _specialHighlightedRow: number | undefined = undefined; @observable GPTSummary: ObservableMap | undefined = undefined; + @observable colDescriptions: ObservableMap = new ObservableMap(); @observable fieldTypes: ObservableMap = new ObservableMap(); @observable _GPTLoading: boolean = false; @@ -150,12 +151,20 @@ export class DataVizBox extends ViewBoxAnnotatableComponent() { this.fieldTypes?.set(field, type); } + @action setFieldDesc = (field: string, desc: string) => { + if (!desc) { + this.colDescriptions.set(field, this.GPTSummary?.get(field) ?? ''); + } else { + this.colDescriptions.set(field, desc); + } + } + getFieldType = (field: string): string => { return this.fieldTypes?.get(field) ?? ''; } getFieldDescription = (field: string): string => { - return this.GPTSummary?.get(field) ?? ''; + return this.colDescriptions?.get(field) ?? ''; } @action // pinned / linked anchor doc includes selected rows, graph titles, and graph colors @@ -533,9 +542,9 @@ export class DataVizBox extends ViewBoxAnnotatableComponent() { const descs: {[col: string]: string} = JSON.parse(res); for (const [key, val] of Object.entries(descs)) { this.GPTSummary.set(key, val); + if (!this.colDescriptions.get(key)) this.colDescriptions.set(key, val); } - console.log(res, descs); } } catch (err) { console.error(err); @@ -549,7 +558,6 @@ export class DataVizBox extends ViewBoxAnnotatableComponent() { const colTitles: string[] = Object.keys(this.records[0]); for (let i = 0; i < colTitles.length; ++i){ if (colTitles[i] === title) { - console.log(true); return true; } } diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx index 50d6b7fe0..7df445b88 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx @@ -49,8 +49,8 @@ export class DocCreatorMenu extends ObservableReactComponent {return {title: field, type: this._dataViz?.getFieldType(field) ?? '', id: Math.random() * 100000}}).concat(this._fields); + @computed get fieldsInfos(): {title: string, type: string, desc: string}[] { + return this.selectedFields.map(field => {return {title: field, type: this._dataViz?.getFieldType(field) ?? '', desc: this._dataViz?.getFieldDescription(field) ?? ''}}).concat(this._fields); } @computed get canMakeDocs(){ @@ -197,7 +197,7 @@ export class DocCreatorMenu extends ObservableReactComponent 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.fields = reaction(() => this._dataViz?.axes, cols => this._selectedCols = cols?.map(col => { return {title: col, type: '', id: Math.random() * 100000}})) + //this._disposers.fields = reaction(() => this._dataViz?.axes, cols => this._selectedCols = cols?.map(col => { return {title: col, type: '', desc: ''}})) } componentWillUnmount() { @@ -346,7 +346,6 @@ export class DocCreatorMenu extends ObservableReactComponent prompt += ` ${field},`) prompt += ` (-----NOT A FIELD-----) Additional prompt: ${inputText}`; - console.log(prompt) this._GPTLoading = true; @@ -375,7 +374,6 @@ export class DocCreatorMenu extends ObservableReactComponent { - const newFields: {title: string, type: string, id: number}[] = this._fields.concat([{title: '', type: '', id: Math.random() * 100000}]) + const newFields: {title: string, type: string, desc: string}[] = this._fields.concat([{title: '', type: '', desc: ''}]) this._fields = newFields; } - @action removeField = (field: {title: string, type: string, id: number}) => { + @action removeField = (field: {title: string, type: string, desc: string}) => { if (this._dataViz?.axes.includes(field.title)) { this._dataViz.selectAxes(this._dataViz.axes.filter(col => col !== field.title)); } else { - const toRemove = this._fields.filter(f => f.id === field.id); + const toRemove = this._fields.filter(f => f === field); if (!toRemove) return; if (toRemove.length > 1) { @@ -795,7 +792,7 @@ export class DocCreatorMenu extends ObservableReactComponent { + setFieldType = (field: {title: string, type: string, desc: string}, type: string) => { if (this.selectedFields.includes(field.title)) { this._dataViz?.setFieldType(field.title, type); } else { @@ -804,6 +801,15 @@ export class DocCreatorMenu extends ObservableReactComponent { + if (this.selectedFields.includes(field.title)) { + this._dataViz?.setFieldDesc(field.title, desc); + } else { + field.desc = desc; + } + this.forceUpdate(); + } + get dashboardContents(){ return (
@@ -827,7 +833,7 @@ export class DocCreatorMenu extends ObservableReactComponent
-