diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/apis/gpt/GPT.ts | 8 | ||||
-rw-r--r-- | src/client/views/nodes/DataVizBox/components/TableBox.tsx | 55 | ||||
-rw-r--r-- | src/client/views/nodes/formattedText/FormattedTextBox.tsx | 6 | ||||
-rw-r--r-- | src/client/views/pdf/GPTPopup/GPTPopup.tsx | 16 |
4 files changed, 50 insertions, 35 deletions
diff --git a/src/client/apis/gpt/GPT.ts b/src/client/apis/gpt/GPT.ts index fc4347a64..8f58ec364 100644 --- a/src/client/apis/gpt/GPT.ts +++ b/src/client/apis/gpt/GPT.ts @@ -35,8 +35,8 @@ let lastResp = ''; * @param inputText Text to process * @returns AI Output */ -const gptAPICall = async (inputText: string, callType: GPTCallType, prompt?: any) => { - if (callType === GPTCallType.SUMMARY) inputText += '.'; +const gptAPICall = async (inputTextIn: string, callType: GPTCallType, prompt?: any) => { + const inputText = callType === GPTCallType.SUMMARY ? inputTextIn + '.' : inputTextIn; const opts: GPTCallOpts = callTypeMap[callType]; if (lastCall === inputText) return lastResp; try { @@ -47,8 +47,8 @@ const gptAPICall = async (inputText: string, callType: GPTCallType, prompt?: any lastCall = inputText; const openai = new OpenAI(configuration); - let usePrompt = prompt ? opts.prompt + prompt : opts.prompt; - let messages: ChatCompletionMessageParam[] = [ + const usePrompt = prompt ? opts.prompt + prompt : opts.prompt; + const messages: ChatCompletionMessageParam[] = [ { role: 'system', content: usePrompt }, { role: 'user', content: inputText }, ]; diff --git a/src/client/views/nodes/DataVizBox/components/TableBox.tsx b/src/client/views/nodes/DataVizBox/components/TableBox.tsx index b0176f992..8038b2cd4 100644 --- a/src/client/views/nodes/DataVizBox/components/TableBox.tsx +++ b/src/client/views/nodes/DataVizBox/components/TableBox.tsx @@ -16,6 +16,7 @@ import { ObservableReactComponent } from '../../../ObservableReactComponent'; import { DocumentView } from '../../DocumentView'; import { DataVizView } from '../DataVizBox'; import './Chart.scss'; + const { DATA_VIZ_TABLE_ROW_HEIGHT } = require('../../../global/globalCssVariables.module.scss'); // prettier-ignore interface TableBoxProps { @@ -124,7 +125,7 @@ export class TableBox extends ObservableReactComponent<TableBoxProps> { selected.splice(selected.indexOf(rowId), 1); } else selected?.push(rowId); e.stopPropagation(); - this.hasRowsToFilter = selected.length > 0 ? true : false; + this.hasRowsToFilter = selected.length > 0; }; columnPointerDown = (e: React.PointerEvent, col: string) => { @@ -164,10 +165,10 @@ export class TableBox extends ObservableReactComponent<TableBoxProps> { return false; }, emptyFunction, - action(e => { - if (e.shiftKey || this.settingTitle) { + action(moveEv => { + if (moveEv.shiftKey || this.settingTitle) { if (this.settingTitle) this.settingTitle = false; - if (this._props.titleCol == col) this._props.titleCol = ''; + if (this._props.titleCol === col) this._props.titleCol = ''; else this._props.titleCol = col; this._props.selectTitleCol(this._props.titleCol); } else { @@ -185,16 +186,16 @@ export class TableBox extends ObservableReactComponent<TableBoxProps> { * These functions handle the filtering popup for when the "filter" button is pressed to select rows */ filter = undoable((e: any) => { - var start: any; - var end: any; - if (this.filteringType == 'Range') { + let start: any; + let end: any; + if (this.filteringType === 'Range') { start = (this.filteringVal[0] as Number) ? Number(this.filteringVal[0]) : this.filteringVal[0]; end = (this.filteringVal[1] as Number) ? Number(this.filteringVal[1]) : this.filteringVal[0]; } this._tableDataIds.forEach(rowID => { - if (this.filteringType == 'Value') { - if (this._props.records[rowID][this.filteringColumn] == this.filteringVal[0]) { + if (this.filteringType === 'Value') { + if (this._props.records[rowID][this.filteringColumn] === this.filteringVal[0]) { if (!NumListCast(this._props.layoutDoc.dataViz_selectedRows).includes(rowID)) { this.tableRowClick(e, rowID); } @@ -231,12 +232,12 @@ export class TableBox extends ObservableReactComponent<TableBoxProps> { this.filteringVal[1] = e.target.value; }); @computed get renderFiltering() { - if (this.filteringColumn === '') this.filteringColumn = this.columns[0]; + if (this.filteringColumn === '') [this.filteringColumn] = this.columns; return ( <div className="tableBox-filterPopup" style={{ right: this._props.width * 0.05 }}> <div className="tableBox-filterPopup-selectColumn"> Column: - <select className="tableBox-filterPopup-selectColumn-each" value={this.filteringColumn != '' ? this.filteringColumn : this.columns[0]} onChange={e => this.setFilterColumn(e)}> + <select className="tableBox-filterPopup-selectColumn-each" value={this.filteringColumn !== '' ? this.filteringColumn : this.columns[0]} onChange={e => this.setFilterColumn(e)}> {this.columns.map(column => ( <option className="" key={column} value={column}> {' '} @@ -247,17 +248,17 @@ export class TableBox extends ObservableReactComponent<TableBoxProps> { </div> <div className="tableBox-filterPopup-setValue"> <select className="tableBox-filterPopup-setValue-each" value={this.filteringType} onChange={e => this.setFilterType(e)}> - <option className="" key={'Value'} value={'Value'}> + <option className="" key="Value" value="Value"> {' '} {'Value'}{' '} </option> - <option className="" key={'Range'} value={'Range'}> + <option className="" key="Range" value="Range"> {' '} {'Range'}{' '} </option> </select> : - {this.filteringType == 'Value' ? ( + {this.filteringType === 'Value' ? ( <input className="tableBox-filterPopup-setValue-input" defaultValue="" @@ -303,7 +304,7 @@ export class TableBox extends ObservableReactComponent<TableBoxProps> { )} </div> <div className="tableBox-filterPopup-setFilter"> - <Button onClick={action(e => this.filter(e))} text="Set Filter" type={Type.SEC} color={'black'} /> + <Button onClick={action(e => this.filter(e))} text="Set Filter" type={Type.SEC} color="black" /> </div> </div> ); @@ -324,11 +325,25 @@ export class TableBox extends ObservableReactComponent<TableBoxProps> { }}> <div className="tableBox-selectButtons"> <div className="tableBox-selectTitle"> - <Button onClick={action(() => (this.settingTitle = !this.settingTitle))} text="Select Title Column" type={Type.SEC} color={'black'} /> + <Button + onClick={action(() => { + this.settingTitle = !this.settingTitle; + })} + text="Select Title Column" + type={Type.SEC} + color="black" + /> </div> <div className="tableBox-filtering"> {this.filtering ? this.renderFiltering : null} - <Button onClick={action(() => (this.filtering = !this.filtering))} text="Filter" type={Type.SEC} color={'black'} /> + <Button + onClick={action(() => { + this.filtering = !this.filtering; + })} + text="Filter" + type={Type.SEC} + color="black" + /> <div className="tableBox-filterAll"> {this.hasRowsToFilter ? ( <Button @@ -338,7 +353,7 @@ export class TableBox extends ObservableReactComponent<TableBoxProps> { })} text="Deselect All" type={Type.SEC} - color={'black'} + color="black" tooltip="Select rows to be displayed in any DataViz boxes dragged off of this one." /> ) : ( @@ -349,7 +364,7 @@ export class TableBox extends ObservableReactComponent<TableBoxProps> { })} text="Select All" type={Type.SEC} - color={'black'} + color="black" tooltip="Select rows to be displayed in any DataViz boxes dragged off of this one." /> )} @@ -402,7 +417,7 @@ export class TableBox extends ObservableReactComponent<TableBoxProps> { ? '#E3fbdb' : this._props.axes.length > 2 && this._props.axes.lastElement() === col ? '#Fbdbdb' - : this._props.axes.lastElement() === col || (this._props.axes.length > 2 && this._props.axes[1] == col) + : this._props.axes.lastElement() === col || (this._props.axes.length > 2 && this._props.axes[1] === col) ? '#c6ebf7' : undefined, fontWeight: 'bolder', diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx index b6d2a9967..3cd8b8b58 100644 --- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx +++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx @@ -1033,7 +1033,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB breakupDictation = () => { if (this._editorView && this._recordingDictation) { - this.stopDictation(true); + this.stopDictation(/* true */); this._break = true; const { state } = this._editorView; const { to } = state.selection; @@ -1054,7 +1054,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB } }); }; - stopDictation = (abort: boolean) => DictationManager.Controls.stop(/* !abort */); + stopDictation = (/* abort: boolean */) => DictationManager.Controls.stop(/* !abort */); setDictationContent = (value: string) => { if (this._editorView && this._recordingStart) { @@ -1323,7 +1323,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB this._disposers.record = reaction( () => this._recordingDictation, () => { - this.stopDictation(true); + this.stopDictation(/* true */); this._recordingDictation && this.recordDictation(); }, { fireImmediately: true } diff --git a/src/client/views/pdf/GPTPopup/GPTPopup.tsx b/src/client/views/pdf/GPTPopup/GPTPopup.tsx index 560f2fd27..56ff2959c 100644 --- a/src/client/views/pdf/GPTPopup/GPTPopup.tsx +++ b/src/client/views/pdf/GPTPopup/GPTPopup.tsx @@ -61,7 +61,7 @@ export class GPTPopup extends ObservableReactComponent<GPTPopupProps> { public dataChatPrompt: string | null = null; @action public setDataJson = (text: string) => { - if (text == '') this.dataChatPrompt = ''; + if (text === '') this.dataChatPrompt = ''; this.dataJson = text; }; @@ -134,14 +134,14 @@ export class GPTPopup extends ObservableReactComponent<GPTPopupProps> { this.setLoading(true); try { - const image_urls = await gptImageCall(this.imgDesc); - console.log('Image urls: ', image_urls); - if (image_urls && image_urls[0]) { - const [result] = await Networking.PostToServer('/uploadRemoteImage', { sources: [image_urls[0]] }); + const imageUrls = await gptImageCall(this.imgDesc); + console.log('Image urls: ', imageUrls); + if (imageUrls && imageUrls[0]) { + const [result] = await Networking.PostToServer('/uploadRemoteImage', { sources: [imageUrls[0]] }); console.log('Upload result: ', result); const source = ClientUtils.prepend(result.accessPaths.agnostic.client); console.log('Upload source: ', source); - this.setImgUrls([[image_urls[0], source]]); + this.setImgUrls([[imageUrls[0], source]]); } } catch (err) { console.error(err); @@ -168,7 +168,7 @@ export class GPTPopup extends ObservableReactComponent<GPTPopupProps> { GPTPopup.Instance.setVisible(true); GPTPopup.Instance.setLoading(true); try { - let res = await gptAPICall(this.dataJson, GPTCallType.DATA, this.dataChatPrompt); + const res = await gptAPICall(this.dataJson, GPTCallType.DATA, this.dataChatPrompt); GPTPopup.Instance.setText(res || 'Something went wrong.'); } catch (err) { console.error(err); @@ -396,7 +396,7 @@ export class GPTPopup extends ObservableReactComponent<GPTPopupProps> { render() { return ( <div className="summary-box" style={{ display: this.visible ? 'flex' : 'none' }}> - {this.mode === GPTPopupMode.SUMMARY ? this.summaryBox() : this.mode === GPTPopupMode.DATA ? this.dataAnalysisBox() : this.mode === GPTPopupMode.IMAGE ? this.imageBox() : <></>} + {this.mode === GPTPopupMode.SUMMARY ? this.summaryBox() : this.mode === GPTPopupMode.DATA ? this.dataAnalysisBox() : this.mode === GPTPopupMode.IMAGE ? this.imageBox() : null} </div> ); } |