aboutsummaryrefslogtreecommitdiff
path: root/src/client/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views')
-rw-r--r--src/client/views/collections/CollectionCardDeckView.tsx70
-rw-r--r--src/client/views/global/globalScripts.ts8
-rw-r--r--src/client/views/nodes/PDFBox.tsx1
3 files changed, 73 insertions, 6 deletions
diff --git a/src/client/views/collections/CollectionCardDeckView.tsx b/src/client/views/collections/CollectionCardDeckView.tsx
index 7af6eb614..561b9f806 100644
--- a/src/client/views/collections/CollectionCardDeckView.tsx
+++ b/src/client/views/collections/CollectionCardDeckView.tsx
@@ -4,7 +4,7 @@ import * as React from 'react';
import { Utils, returnFalse, returnTrue, returnZero } from '../../../Utils';
import { Doc, DocListCast, Field, StrListCast } from '../../../fields/Doc';
import { Id } from '../../../fields/FieldSymbols';
-import { NumCast, ScriptCast, StrCast, BoolCast, DocCast, RTFCast } from '../../../fields/Types';
+import { NumCast, ScriptCast, StrCast, BoolCast, DocCast, RTFCast, Cast} from '../../../fields/Types';
import { DragManager } from '../../util/DragManager';
import { SelectionManager } from '../../util/SelectionManager';
import { StyleProp } from '../StyleProvider';
@@ -18,6 +18,9 @@ import { DocumentType } from '../../documents/DocumentTypes';
import { forEach } from 'lodash';
import { SnappingManager } from '../../util/SnappingManager';
import { List } from '../../../fields/List';
+import { gptAPICall } from '../../apis/gpt/GPT';
+import { GPTCallType } from '../../apis/gpt/GPT';
+import { ImageField } from '../../../fields/URLField';
@observer
export class CollectionCardView extends CollectionSubView() {
@@ -249,6 +252,11 @@ export class CollectionCardView extends CollectionSubView() {
// console.log('hiiiii');
return this.sort(sorted, 'custom', desc);
+ case 'chat':
+ this.smartSort()
+ docs = this.myChildLayoutPairs;
+ return {docs}
+
default:
docs = this.myChildLayoutPairs;
return { docs };
@@ -306,7 +314,7 @@ export class CollectionCardView extends CollectionSubView() {
// console.log(typeA + "A")
typeB = this.customGroupDictionary[NumCast(this._props.Document.customSortNumber)].get(docs.indexOf(docB)) ?? '9999';
// console.log(typeB + 'b')
- break;
+ break;
default:
typeA = docA.layout.type ?? ''; // If docA.type is undefined, use an empty string
@@ -468,6 +476,8 @@ export class CollectionCardView extends CollectionSubView() {
});
}
+
+
@@ -476,10 +486,62 @@ export class CollectionCardView extends CollectionSubView() {
this.customGroupDictionary[NumCast(this._props.Document.customSortNumber)].set(childPairIndex, buttonID);
this._props.Document.customHashMap = this.mapToField
- // const queryText = RTFCast(DocCast(this.dataDoc[this.fieldKey + '_1']));
- // console.log(queryText)
+ // Cast(selected.Document.data, WebField, null)?.url?.href)
+
+ // StrCast(selected.Document.data, Cast(selected.Document.data, WebField, null)?.url?.href)
+
+
+
+ // const
+ const imgurlperchance = Cast(this.childDocs[1].data, ImageField, null)?.url;
+
+ console.log('Print Front of cards: ' + RTFCast(DocCast(this.dataDoc[this.fieldKey + '_0']).text)?.Text);
+ console.log('Print Back of cards: ' + RTFCast(DocCast(this.dataDoc[this.fieldKey + '_1']).text)?.Text);
+
+
+ // const queryText = (RTFCast(this.myChildLayoutPairs[0].layout.text)).Text;
+ // const queryText = RTFCast(DocCast(this.dataDoc[this.fieldKey + '_1']).text)?.Text;
+
+ console.log(imgurlperchance ?? "sad")
}
+ childPairStringList () {
+ let string = ""
+ for (let i=0; i < this.myChildLayoutPairs.length; i++){
+ string += StrCast((RTFCast(this.myChildLayoutPairs[i].layout.text)).Text) + ", "
+ }
+ return string
+ }
+
+ @observable isLoading = false
+
+ @action async smartSort() {
+ this.isLoading = true;
+ console.log("loading")
+ let prompt= ""
+
+ if (this.childPairStringList() == ""){
+ console.log("no child pairs :(")
+ }
+
+ else{
+ console.log(this.childPairStringList() + "og list")
+ prompt = "Sort this list of strings by shared content " + this.childPairStringList()
+ }
+
+
+ let res = await gptAPICall(prompt, GPTCallType.SORT);
+ this.isLoading = false;
+ if (res == 'Error connecting with API.') {
+ // If GPT call failed
+ console.error('GPT call failed');
+ } else if (res != null) {
+ // If GPT call succeeded, set htmlCode;;; TODO: check if valid html
+ console.log(res)
+ }
+ this.isLoading = false;
+ };
+
renderButtons(childPairIndex: number) {
const buttons = []; // Array to hold the button elements
diff --git a/src/client/views/global/globalScripts.ts b/src/client/views/global/globalScripts.ts
index 30602ea0b..14f83beb6 100644
--- a/src/client/views/global/globalScripts.ts
+++ b/src/client/views/global/globalScripts.ts
@@ -107,10 +107,10 @@ ScriptingGlobals.add(function toggleOverlay(checkResult?: boolean) {
-ScriptingGlobals.add(function showFreeform(attr: 'flashcards' | 'center' | 'grid' | 'snaplines' | 'clusters' | 'arrange' | 'viewAll' | 'fitOnce' | 'time' | 'docType' | 'color' | 'links' | 'custom1' | 'custom2' | 'custom3', checkResult?: boolean, persist?: boolean, customNumber?: number) {
+ScriptingGlobals.add(function showFreeform(attr: 'flashcards' | 'center' | 'grid' | 'snaplines' | 'clusters' | 'arrange' | 'viewAll' | 'fitOnce' | 'time' | 'docType' | 'color' | 'links' | 'custom1' | 'custom2' | 'custom3'| 'chat', checkResult?: boolean, persist?: boolean, customNumber?: number) {
const selected = SelectionManager.Docs.lastElement();
// prettier-ignore
- const map: Map<'flashcards' | 'center' |'grid' | 'snaplines' | 'clusters' | 'arrange'| 'viewAll' | 'fitOnce' | 'time' | 'docType' | 'color' | 'links' | 'custom1' | 'custom2' | 'custom3', { waitForRender?: boolean, checkResult: (doc:Doc) => any; setDoc: (doc:Doc, dv:DocumentView) => void;}> = new Map([
+ const map: Map<'flashcards' | 'center' |'grid' | 'snaplines' | 'clusters' | 'arrange'| 'viewAll' | 'fitOnce' | 'time' | 'docType' | 'color' | 'links' | 'custom1' | 'custom2' | 'custom3'| 'chat', { waitForRender?: boolean, checkResult: (doc:Doc) => any; setDoc: (doc:Doc, dv:DocumentView) => void;}> = new Map([
['grid', {
checkResult: (doc:Doc) => BoolCast(doc?._freeform_backgroundGrid, false),
setDoc: (doc:Doc,dv:DocumentView) => doc._freeform_backgroundGrid = !doc._freeform_backgroundGrid,
@@ -180,6 +180,10 @@ ScriptingGlobals.add(function showFreeform(attr: 'flashcards' | 'center' | 'grid
doc.cardSort = "custom";
doc.customSortNumber = 2;
} }],
+ ['chat', {
+ checkResult: (doc:Doc) => StrCast(doc?.cardSort),
+ setDoc: (doc:Doc,dv:DocumentView) => doc.cardSort = "chat",
+ }],
]);
if (checkResult) {
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index 1274220b6..90d6133e4 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -33,6 +33,7 @@ import { FocusViewOptions, FieldView, FieldViewProps } from './FieldView';
import { ImageBox } from './ImageBox';
import './PDFBox.scss';
import { PinProps, PresBox } from './trails';
+import { Networking } from '../../Network';
@observer
export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps>() implements ViewBoxInterface {