From 9badfc489f00afd10489f0dde0a3b9e21817feb5 Mon Sep 17 00:00:00 2001 From: bobzel Date: Sat, 18 May 2024 23:15:49 -0400 Subject: more cardView cleanup --- src/client/views/pdf/GPTPopup/GPTPopup.tsx | 126 ++++++++++++----------------- 1 file changed, 53 insertions(+), 73 deletions(-) (limited to 'src/client/views/pdf') diff --git a/src/client/views/pdf/GPTPopup/GPTPopup.tsx b/src/client/views/pdf/GPTPopup/GPTPopup.tsx index 4fb757d8a..0ba62d60e 100644 --- a/src/client/views/pdf/GPTPopup/GPTPopup.tsx +++ b/src/client/views/pdf/GPTPopup/GPTPopup.tsx @@ -21,7 +21,7 @@ export enum GPTPopupMode { EDIT, IMAGE, DATA, - SORT + SORT, } interface GPTPopupProps {} @@ -60,7 +60,7 @@ export class GPTPopup extends ObservableReactComponent { public dataChatPrompt: string | null = null; @action public setDataJson = (text: string) => { - if (text=="") this.dataChatPrompt = ""; + if (text == '') this.dataChatPrompt = ''; this.dataJson = text; }; @@ -95,21 +95,18 @@ export class GPTPopup extends ObservableReactComponent { private done: boolean = false; @action public setDone = (done: boolean) => { - console.log("HIIIIIIIII") 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 + 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) => { - console.log("HIIIIIIIII") this.sortDone = done; }; - // change what can be a ref into a ref @observable private sidebarId: string = ''; @@ -133,26 +130,20 @@ export class GPTPopup extends ObservableReactComponent { }; @observable - public sortDesc: string = '' + public sortDesc: string = ''; - @action public setSortDesc = (t:string) => { - this.sortDesc = t - } + @action public setSortDesc = (t: string) => { + this.sortDesc = t; + }; @observable onSortComplete?: (sortResult: string) => void; @observable cardsDoneLoading = false; @action setCardsDoneLoading(done: boolean) { - console.log(done + "HI HIHI") + console.log(done + 'HI HIHI'); this.cardsDoneLoading = done; } - - - - - - public addDoc: (doc: Doc | Doc[], sidebarKey?: string | undefined) => boolean = () => false; public addToCollection: ((doc: Doc | Doc[], annotationKey?: string | undefined) => boolean) | undefined; @@ -164,12 +155,11 @@ export class GPTPopup extends ObservableReactComponent { this.setSortDone(false); try { - const res = await gptAPICall(this.sortDesc, GPTCallType.SORT); // Trigger the callback with the result if (this.onSortComplete) { this.onSortComplete(res || 'Something went wrong :('); - console.log(res) + console.log(res); } } catch (err) { console.error(err); @@ -177,9 +167,7 @@ export class GPTPopup extends ObservableReactComponent { this.setLoading(false); this.setSortDone(true); - } - - + }; /** * Generates a Dalle image and uploads it to the server. @@ -219,7 +207,7 @@ export class GPTPopup extends ObservableReactComponent { console.error(err); } GPTPopup.Instance.setLoading(false); - } + }; generateDataAnalysis = async () => { GPTPopup.Instance.setVisible(true); @@ -231,7 +219,7 @@ export class GPTPopup extends ObservableReactComponent { console.error(err); } GPTPopup.Instance.setLoading(false); - } + }; /** * Transfers the summarization text to a sidebar annotation text document. @@ -282,7 +270,7 @@ export class GPTPopup extends ObservableReactComponent { */ private chatWithAI = () => { this.chatMode = true; - } + }; dataPromptChanged = action((e: React.ChangeEvent) => { this.dataChatPrompt = e.target.value; }); @@ -304,14 +292,14 @@ export class GPTPopup extends ObservableReactComponent { sortBox = () => ( <>
- {this.heading("SORTING")} + {this.heading('SORTING')} {this.loading ? (
-
- - Loading... +
+ + Loading... +
-
) : ( <> {!this.cardsDoneLoading ? ( @@ -334,27 +322,18 @@ export class GPTPopup extends ObservableReactComponent { width: '90%', // Almost as wide as the container textAlign: 'center', color: '#ffffff', // White text - fontSize: '16px' // Adjust font size as needed + fontSize: '16px', // Adjust font size as needed }} />
) )} - + {this.sortDone && (
-

- {this.text === "Something went wrong :(" ? - "Something went wrong :(" : - "Sorting done! Feel free to move things around / regenerate :) !"} -

- this.setSortDone(false)} - icon={} - color={StrCast(Doc.UserDoc().userVariantColor)} - /> +

{this.text === 'Something went wrong :(' ? 'Something went wrong :(' : 'Sorting done! Feel free to move things around / regenerate :) !'}

+ this.setSortDone(false)} icon={} color={StrCast(Doc.UserDoc().userVariantColor)} />
)} @@ -364,21 +343,17 @@ export class GPTPopup extends ObservableReactComponent { ); - - - - -// <> -//