diff options
Diffstat (limited to 'src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx')
-rw-r--r-- | src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx | 60 |
1 files changed, 2 insertions, 58 deletions
diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx index 2324006f7..7b28a06a3 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx @@ -241,18 +241,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { componentDidMount() { document.addEventListener('pointerdown', this.onPointerDown, true); document.addEventListener('pointerup', this.onPointerUp); - //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.layout = reaction( - // () => this._layout, - // layout => { this.updateRenderedDocCollection(); } - // ); - //this._disposers.fields = reaction(() => this._dataViz?.axes, cols => this._selectedCols = cols?.map(col => { return {title: col, type: '', desc: ''}})) } componentWillUnmount() { @@ -391,38 +379,11 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { }; editTemplate = (doc: Doc) => { - //this.closeMenu(); DocumentViewInternal.addDocTabFunc(doc, OpenWhere.addRight); DocumentView.DeselectAll(); Doc.UnBrushDoc(doc); }; - testTemplate = async () => { - - //console.log(this.templateManager.templates) - - const mainCollection = this._dataViz?.DocumentView?.().containerViewPath?.().lastElement()?.ComponentView as CollectionFreeFormView; - - this.templateManager.templates.forEach(template => { - const doc = template.mainField.renderedDoc(); - mainCollection.addDocument(doc); - }) - - this.forceUpdate(); - - // try { - // const res = await gptImageCall('Image of panda eating a cookie'); - - // if (res) { - // const result = await Networking.PostToServer('/uploadRemoteImage', { sources: res }); - - // console.log(result); - // } - // } catch (e) { - // console.log(e); - // } - }; - @action addField = () => { const newFields: Col[] = this._userCreatedFields.concat([{ title: '', type: TemplateFieldType.UNSET, desc: '', sizes: [] }]); this._userCreatedFields = newFields; @@ -490,8 +451,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { }; generateGPTImage = async (prompt: string): Promise<string | undefined> => { - console.log(prompt); - try { const res = await gptImageCall(prompt); @@ -526,8 +485,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { await Promise.all(promises); } - console.log(GPTIMGCalls) - if (GPTIMGCalls.length) { const promises = GPTIMGCalls.map(async ([fieldNum, col]) => { return this.renderGPTImageCall(template, col, Number(fieldNum)); @@ -589,7 +546,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { const col = this.getColByTitle(colTitle); if (!this._userCreatedFields.includes(col)){ // do the following for any fields not added by the user; will change in the future, for now only GPT content works with user-added fields const field = template.getFieldByID(Number(fieldID)); - //console.log(field); field.setContent(col.defaultContent ?? '', col.type === TemplateFieldType.VISUAL ? FieldContentType.IMAGE : FieldContentType.STRING); field.setTitle(col.title); } else { @@ -632,7 +588,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { renderGPTImageCall = async (template: Template, col: Col, fieldNum: number): Promise<boolean> => { const generateAndLoadImage = async (fieldNum: string, col: Col, prompt: string) => { const url = await this.generateGPTImage(prompt); - console.log('url: ', url) const field: Field = template.getFieldByID(Number(fieldNum)); field.setContent(url ?? '', FieldContentType.IMAGE); @@ -684,8 +639,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { const res = await gptAPICall(`${++this._callCount}: ${prompt}`, GPTCallType.FILL); - console.log('prompt: ', prompt, ' response: ', res); - if (res) { const assignments: { [title: string]: { number: string; content: string } } = JSON.parse(res); Object.entries(assignments).forEach(([title, info]) => { @@ -705,7 +658,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { createDocsFromTemplate = async (template: Template) => { const dv = this._dataViz; - console.log('dataviz: ', dv); + if (!dv) return; this._docsRendering = true; @@ -837,8 +790,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { const GPTOptions = <div></div>; - //<img className='docCreatorMenu-preview-image expanded' src={this._expandedPreview.icon!.url.href.replace(".png", "_o.png")} /> - return ( <div className={`docCreatorMenu-templates-view`}> {this._expandedPreview ? ( @@ -924,7 +875,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { </button> </div> <div className="docCreatorMenu-templates-preview-window" style={{ justifyContent: this._menuDimensions.width > 400 ? 'center' : '' }}> - <div className="docCreatorMenu-preview-window empty" onPointerDown={e => this.testTemplate()}> + <div className="docCreatorMenu-preview-window empty"> <FontAwesomeIcon icon="plus" color="rgb(160, 160, 160)" /> </div> {this._userTemplates @@ -1027,10 +978,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { } } - // doc = () => { - // return Docs.Create.FreeformDocument([], { _height: 200, _width: 200, title: 'title'}); - // } - screenToLocalTransform = () => this._props.ScreenToLocalTransform(); applyLayout = (collection: Doc, docs: Doc[]) => { @@ -1092,7 +1039,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { if (!this._fullyRenderedDocs) return; const { horizontalSpan, verticalSpan } = this.previewInfo; - //const largerSpan: number = horizontalSpan > verticalSpan ? horizontalSpan : verticalSpan; const collectionFactory = (): (docs: Doc[], options: DocumentOptions) => Doc => { switch (this._layout.type) { @@ -1162,8 +1108,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { }; get optionsMenuContents() { - const layoutEquals = (layout: DataVizTemplateLayout) => {}; //TODO: ADD LATER - const layoutOption = (option: LayoutType, optStyle?: {}, specialFunc?: Function) => { return ( <div |