From 10ae244338383662992350b2b6f6ef80106558c3 Mon Sep 17 00:00:00 2001 From: aidahosa1 Date: Fri, 17 May 2024 14:28:09 -0400 Subject: yay git add -A --- src/client/views/pdf/GPTPopup/GPTPopup.scss | 33 +++++++ src/client/views/pdf/GPTPopup/GPTPopup.tsx | 138 +++++++++++++++++++++++++++- 2 files changed, 169 insertions(+), 2 deletions(-) (limited to 'src/client/views/pdf/GPTPopup') diff --git a/src/client/views/pdf/GPTPopup/GPTPopup.scss b/src/client/views/pdf/GPTPopup/GPTPopup.scss index 5d966395c..4425cf158 100644 --- a/src/client/views/pdf/GPTPopup/GPTPopup.scss +++ b/src/client/views/pdf/GPTPopup/GPTPopup.scss @@ -60,6 +60,17 @@ $highlightedText: #82e0ff; display: flex; justify-content: space-between; align-items: center; + transform: translateY(30px); + + + .searchBox-input{ + transform: translateY(-15px); + height: 50px; + border-radius: 10px; + border-color: #5b97ff; + } + + .summarizing { display: flex; @@ -111,6 +122,28 @@ $highlightedText: #82e0ff; } } +.loading-spinner { + display: flex; + justify-content: center; + align-items: center; + height: 100px; + font-size: 20px; + font-weight: bold; + color: #666; +} + + + + + +@keyframes spin { + to { + transform: rotate(360deg); + } +} + + + .image-content-wrapper { display: flex; flex-direction: column; diff --git a/src/client/views/pdf/GPTPopup/GPTPopup.tsx b/src/client/views/pdf/GPTPopup/GPTPopup.tsx index 29b1ca365..faf66af85 100644 --- a/src/client/views/pdf/GPTPopup/GPTPopup.tsx +++ b/src/client/views/pdf/GPTPopup/GPTPopup.tsx @@ -21,6 +21,7 @@ export enum GPTPopupMode { EDIT, IMAGE, DATA, + SORT } interface GPTPopupProps {} @@ -94,10 +95,21 @@ 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 + + @action + public setSortDone = (done: boolean) => { + console.log("HIIIIIIIII") + this.sortDone = done; + }; + + // change what can be a ref into a ref @observable private sidebarId: string = ''; @@ -120,9 +132,61 @@ export class GPTPopup extends ObservableReactComponent { this.textAnchor = anchor; }; + @observable + public sortPrompt: string = ''; + @action + public setSortPrompt = ((e: React.ChangeEvent) => { + this.sortPrompt = e.target.value; + }); + + @observable + public sortText: string = '' + @action + public setSortText = (t: string) => { + this.sortText = t + } + + @observable + public sortDesc: string = '' + + @action public setSortDesc = (t:string) => { + this.sortDesc = t + } + + @observable onSortComplete?: (sortResult: string) => void; + + + + + + public addDoc: (doc: Doc | Doc[], sidebarKey?: string | undefined) => boolean = () => false; public addToCollection: ((doc: Doc | Doc[], annotationKey?: string | undefined) => boolean) | undefined; + + generateSort = async () => { + this.setLoading(true); + this.setSortDone(false); + + try { + const res = await gptAPICall(this.sortPrompt + this.sortDesc, GPTCallType.SORT); + this.setSortText(res || 'Something went wrong :('); + + // Trigger the callback with the result + if (this.onSortComplete) { + this.onSortComplete(res || 'Something went wrong :('); + } + } catch (err) { + console.error(err); + this.setSortText('Something went wrong :('); + } + + this.setLoading(false); + this.setSortDone(true); + } + + + /** * Generates a Dalle image and uploads it to the server. */ @@ -243,6 +307,74 @@ export class GPTPopup extends ObservableReactComponent { } }; + sortBox = () => ( + <> +
+ {this.heading("SORTING")} + {this.loading ? ( +
+
+ + Loading... +
+
+ ) : !this.sortDone && ( +
+ { + if (e.key === 'Enter') { + this.generateSort(); + } + e.stopPropagation(); + }} + type="text" + placeholder="Enter sorting instructions..." + id="search-input" + className="searchBox-input" + style={{ width: "100%" }} + /> +
+ )} + + {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)} + /> + +
+
+ )} +
+ + ); + + + + +// <> +//