From 02eb7da95df283606d4275a22d9451cef371c3b5 Mon Sep 17 00:00:00 2001 From: srichman333 Date: Tue, 5 Dec 2023 17:09:58 -0500 Subject: immediate updates --- src/client/views/nodes/DataVizBox/DataVizBox.tsx | 48 +++--------------------- 1 file changed, 5 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/DataVizBox/DataVizBox.tsx b/src/client/views/nodes/DataVizBox/DataVizBox.tsx index 7a2715667..4eb241380 100644 --- a/src/client/views/nodes/DataVizBox/DataVizBox.tsx +++ b/src/client/views/nodes/DataVizBox/DataVizBox.tsx @@ -47,6 +47,7 @@ export class DataVizBox extends ViewBoxAnnotatableComponent() { private _annotationLayer: React.RefObject = React.createRef(); anchorMenuClick?: () => undefined | ((anchor: Doc) => void); crop: ((region: Doc | undefined, addCrop?: boolean) => Doc | undefined) | undefined; + @observable schemaDataVizChildren: any; @observable _marqueeing: number[] | undefined; @observable _savedAnnotations = new ObservableMap(); @computed get annotationLayer() { @@ -322,50 +323,12 @@ export class DataVizBox extends ViewBoxAnnotatableComponent() { GPTPopup.Instance.addDoc = this.sidebarAddDocument; }; - datavizContextMenu = (e: React.MouseEvent): void => { - const cm = ContextMenu.Instance; - const options = cm.findByDescription('Options...'); - const optionItems = options && 'subitems' in options ? options.subitems : []; - optionItems.push({ description: `Ask GPT`, event: () => {this.askGPT()}, icon: 'lightbulb' }); - !options && cm.addItem({ description: 'Options...', subitems: optionItems, icon: 'eye' }); - }; - - async askGPT() { - let image_urls = await gptImageCall(Object.keys(this.records[0])[0]); - if (image_urls && image_urls[0]) { - const [result] = await Networking.PostToServer('/uploadRemoteImage', { sources: [image_urls[0]] }); - const source = Utils.prepend(result.accessPaths.agnostic.client); - //this.setImgUrls([[image_urls[0], source]]); - const anchor = this.rootDoc; - if (!anchor) return; - const newDoc = Docs.Create.ImageDocument(source, { - x: NumCast(anchor.x) + NumCast(anchor._width) + 10, - y: NumCast(anchor.y), - _height: 200, - _width: 200, - data_nativeWidth: 1024, - data_nativeHeight: 1024, - }); - if (Doc.IsInMyOverlay(anchor)) { - newDoc.overlayX = anchor.x; - newDoc.overlayY = NumCast(anchor.y) + NumCast(anchor._height); - Doc.AddToMyOverlay(newDoc); - } else { - this.props.addDocument?.(newDoc); - } - DocUtils.MakeLink(anchor, newDoc, { link_relationship: 'GPT Data Prompt' }); - } - } - @action updateSchemaViz = () => { - if (this.layoutDoc.dataViz_asSchema && DocCast(this.layoutDoc.dataViz_asSchema)){ - const getFrom = DocCast(this.layoutDoc.dataViz_asSchema) const keys = Cast(getFrom.schema_columnKeys, listSpec('string'))?.filter(key => key!="text"); if (!keys) return; const children = DocListCast(getFrom[Doc.LayoutFieldKey(getFrom)]); - var current: {[key: string]: string}[] = [] for (let i=1; i() { } current.push(row) } - DataVizBox.dataset.set(CsvCast(this.rootDoc[this.fieldKey]).url.href, current ) } -} - render() { - this.updateSchemaViz(); + if (this.layoutDoc && this.layoutDoc.dataViz_asSchema){ + this.schemaDataVizChildren = DocListCast(DocCast(this.layoutDoc.dataViz_asSchema)[Doc.LayoutFieldKey(DocCast(this.layoutDoc.dataViz_asSchema))]).length + this.updateSchemaViz(); + } const scale = this.props.NativeDimScaling?.() || 1; return !this.records.length ? ( @@ -404,7 +367,6 @@ export class DataVizBox extends ViewBoxAnnotatableComponent() { }} onWheel={e => e.stopPropagation()} ref={this._mainCont} - onContextMenu={this.datavizContextMenu} >
(this.layoutDoc._dataViz = DataVizView.TABLE)} toggleStatus={this.layoutDoc._dataViz === DataVizView.TABLE} /> -- cgit v1.2.3-70-g09d2