diff options
Diffstat (limited to 'src/client/views/pdf')
| -rw-r--r-- | src/client/views/pdf/GPTPopup/GPTPopup.tsx | 113 |
1 files changed, 44 insertions, 69 deletions
diff --git a/src/client/views/pdf/GPTPopup/GPTPopup.tsx b/src/client/views/pdf/GPTPopup/GPTPopup.tsx index c33b81eb4..63130d056 100644 --- a/src/client/views/pdf/GPTPopup/GPTPopup.tsx +++ b/src/client/views/pdf/GPTPopup/GPTPopup.tsx @@ -1,5 +1,5 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { Button, IconButton, Type } from '@dash/components'; +import { Button, IconButton, Toggle, ToggleType, Type } from '@dash/components'; import { action, makeObservable, observable, runInAction } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; @@ -46,105 +46,70 @@ export class GPTPopup extends ObservableReactComponent<object> { @observable private chatMode: boolean = false; private correlatedColumns: string[] = []; - @observable - public visible: boolean = false; - @action - public setVisible = (vis: boolean) => { + @observable public visible: boolean = false; + @action public setVisible = (vis: boolean) => { this.visible = vis; }; - @observable - public loading: boolean = false; - @action - public setLoading = (loading: boolean) => { + @observable public loading: boolean = false; + @action public setLoading = (loading: boolean) => { this.loading = loading; }; - @observable - public text: string = ''; - @action - public setText = (text: string) => { + @observable public text: string = ''; + @action public setText = (text: string) => { this.text = text; }; - @observable - public selectedText: string = ''; - @action - public setSelectedText = (text: string) => { + @observable public selectedText: string = ''; + @action public setSelectedText = (text: string) => { this.selectedText = text; }; - @observable - public dataJson: string = ''; + @observable public dataJson: string = ''; public dataChatPrompt: string | undefined = undefined; - @action - public setDataJson = (text: string) => { + @action public setDataJson = (text: string) => { if (text === '') this.dataChatPrompt = ''; this.dataJson = text; }; - @observable - public imgDesc: string = ''; - @action - public setImgDesc = (text: string) => { + @observable public imgDesc: string = ''; + @action public setImgDesc = (text: string) => { this.imgDesc = text; }; - @observable - public imgUrls: string[][] = []; - @action - public setImgUrls = (imgs: string[][]) => { + @observable public imgUrls: string[][] = []; + @action public setImgUrls = (imgs: string[][]) => { this.imgUrls = imgs; }; - @observable - public mode: GPTPopupMode = GPTPopupMode.SUMMARY; - @action - public setMode = (mode: GPTPopupMode) => { + @observable public mode: GPTPopupMode = GPTPopupMode.SUMMARY; + @action public setMode = (mode: GPTPopupMode) => { this.mode = mode; }; - @observable - public highlightRange: number[] = []; + @observable public highlightRange: number[] = []; @action callSummaryApi = () => {}; - @observable - private done: boolean = false; - @action - public setDone = (done: boolean) => { + @observable private done: boolean = false; + @action public setDone = (done: boolean) => { this.done = done; this.chatMode = false; }; - @observable - private sortDone: boolean = false; // this is so redundant but the og done variable was causing weird unknown problems and im just a girl - - @action - public setSortDone = (done: boolean) => { - this.sortDone = done; - }; - // change what can be a ref into a ref - @observable - private sidebarId: string = ''; - @action - public setSidebarId = (id: string) => { + @observable private sidebarId: string = ''; + @action public setSidebarId = (id: string) => { this.sidebarId = id; }; - @observable - private imgTargetDoc: Doc | undefined; - @action - public setImgTargetDoc = (anchor: Doc) => { + @observable private imgTargetDoc: Doc | undefined; + @action public setImgTargetDoc = (anchor: Doc) => { this.imgTargetDoc = anchor; }; - @observable - private textAnchor: Doc | undefined; - @action - public setTextAnchor = (anchor: Doc) => { + @observable private textAnchor: Doc | undefined; + @action public setTextAnchor = (anchor: Doc) => { this.textAnchor = anchor; }; - @observable - public sortDesc: string = ''; - + @observable public sortDesc: string = ''; @action public setSortDesc = (t: string) => { this.sortDesc = t; }; @@ -153,8 +118,12 @@ export class GPTPopup extends ObservableReactComponent<object> { @observable onQuizRandom?: () => void; @observable cardsDoneLoading = false; + @observable collectionDoc: Doc | undefined = undefined; + @action setCollectionDoc(doc: Doc | undefined) { + this.collectionDoc = doc; + } + @action setCardsDoneLoading(done: boolean) { - console.log(done + 'HI HIHI'); this.cardsDoneLoading = done; } @@ -184,7 +153,6 @@ export class GPTPopup extends ObservableReactComponent<object> { */ generateQuiz = async () => { this.setLoading(true); - this.setSortDone(false); const selected = DocumentView.SelectedDocs().lastElement(); @@ -203,7 +171,6 @@ export class GPTPopup extends ObservableReactComponent<object> { this.conversationArray.push(res); this.setLoading(false); - this.setSortDone(true); } catch (err) { console.error('GPT call failed', err); } @@ -235,7 +202,8 @@ export class GPTPopup extends ObservableReactComponent<object> { * Callback function that causes the card view to update the childpair string list * @param callback */ - @action public setRegenerateCallback(callback: () => Promise<void>) { + @action public setRegenerateCallback(collectionDoc: Doc | undefined, callback: null | (() => Promise<void>)) { + this.setCollectionDoc(collectionDoc); this.regenerateCallback = callback; } @@ -254,7 +222,6 @@ export class GPTPopup extends ObservableReactComponent<object> { */ generateCard = async () => { this.setLoading(true); - this.setSortDone(false); if (this.regenerateCallback) { await this.regenerateCallback(); @@ -296,7 +263,6 @@ export class GPTPopup extends ObservableReactComponent<object> { } this.setLoading(false); - this.setSortDone(true); }; /** @@ -554,7 +520,7 @@ export class GPTPopup extends ObservableReactComponent<object> { }; sortBox = () => ( - <div style={{ height: '80%' }}> + <div className="gptPopup-sortBox" style={{ height: '80%' }}> {this.heading(this.mode === GPTPopupMode.SORT ? 'SORTING' : 'QUIZ')} <> { @@ -727,6 +693,15 @@ export class GPTPopup extends ObservableReactComponent<object> { {(this.mode === GPTPopupMode.SORT || this.mode === GPTPopupMode.QUIZ) && ( <IconButton color={StrCast(SettingsManager.userVariantColor)} tooltip="back" icon={<CgCornerUpLeft size="16px" />} onClick={() => (this.mode = GPTPopupMode.CARD)} style={{ right: '50px', position: 'absolute' }} /> )} + <Toggle + tooltip="clear filters" + toggleType={ToggleType.BUTTON} + type={Type.PRIM} + toggleStatus={this.collectionDoc?.childFilters ? true : false} + text={this.collectionDoc?.childFilters ? 'filtered' : ''} + color="red" + onClick={() => this.collectionDoc && (this.collectionDoc.childFilters = undefined)} + /> <IconButton color={StrCast(SettingsManager.userVariantColor)} tooltip="close" |
