Skip to content

Commit 6993405

Browse files
committed
rapidapi
1 parent 2b4bcb4 commit 6993405

20 files changed

+333
-136
lines changed

actionHandling/ActionHandlers.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export function useActionHandlers($q: QVueGlobals | undefined) {
3030
) {
3131
const handler = args.actionHandler
3232

33+
//console.log('handleClick', args)
34+
3335
if (args.actionContext?.clicked) {
3436
console.log('executing...')
3537
await args.actionContext.clicked.apply(null, [chromeTab, tabset, folder, { action: args.actionContext }])
@@ -38,7 +40,10 @@ export function useActionHandlers($q: QVueGlobals | undefined) {
3840

3941
if (args.actionContext?.dialog) {
4042
console.log('executing dialog...', args.actionContext)
41-
args.actionContext.dialog.apply(null, [args.actionContext.$q!])?.onOk((payload: any) => {
43+
44+
const r = await args.actionContext.dialog.apply(null, [args.actionContext.$q!])
45+
46+
r.onOk((payload: any) => {
4247
console.log('payload', payload)
4348
const onOkHandler: (payload: any) => ClickedHandler = args.actionContext!.ok!
4449
const h = onOkHandler.apply(null, [payload])

actionHandling/AddUrlToTabsetHandlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class AddUrlToTabsetHandlers {
1919
// this.handlers.push(new DynamicUrlAddUrlToTabsetHandler(this.quasar))
2020
this.handlers.push(new ExcalidrawAddUrlToTabsetHandler(this.quasar))
2121
this.handlers.push(new ObsidianApiAddUrlToTabsetHandler())
22-
this.handlers.push(new RapidApiAddUrlToTabsetHandler())
22+
this.handlers.push(new RapidApiAddUrlToTabsetHandler(this.quasar!))
2323
this.handlers.push(new MarkdownFileAddUrlToTabsetHandler(this.quasar!))
2424
this.handlers.push(new ImportFromChromeBookmarksManagerAddUrlToTabsetHandler(this.quasar!))
2525
this.handlers.push(new RssUrlAddUrlToTabsetHandler(this.quasar!))

actionHandling/SpecialUrlAddToTabsetComponent.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"
4141
class="q-ma-none q-px-none q-py-none"
4242
size="sm"
43+
:dense="handler.defaultAction()!.label.length > 10"
4344
split
4445
outline>
4546
<q-list dense style="min-width: 200px">

actionHandling/handler/DefaultAddUrlToTabsetHandler.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import { QVueGlobals, uid } from 'quasar'
2+
import { FeatureIdent } from 'src/app/models/FeatureIdent'
23
import { useContentStore } from 'src/content/stores/contentStore'
34
import { ExecutionResult } from 'src/core/domain/ExecutionResult'
45
import { useCommandExecutor } from 'src/core/services/CommandExecutor'
6+
import { useFeaturesStore } from 'src/features/stores/featuresStore'
57
import {
68
AddUrlToTabsetHandler,
79
AddUrlToTabsetHandlerAdditionalData,
810
} from 'src/tabsets/actionHandling/AddUrlToTabsetHandler'
911
import { ActionContext } from 'src/tabsets/actionHandling/model/ActionContext'
12+
import CreateNoteAction from 'src/tabsets/actions/CreateNoteAction.vue'
1013
import CreateSubfolderAction from 'src/tabsets/actions/CreateSubfolderAction.vue'
1114
import DeleteTabsetAction from 'src/tabsets/actions/DeleteTabsetAction.vue'
1215
import EditTabsetAction from 'src/tabsets/actions/EditTabsetAction.vue'
@@ -20,6 +23,7 @@ import { Component } from 'vue'
2023

2124
export class DefaultAddUrlToTabsetHandler implements AddUrlToTabsetHandler {
2225
constructor(public $q: QVueGlobals) {}
26+
2327
urlMatcher(): RegExp {
2428
return /.*/
2529
}
@@ -35,7 +39,12 @@ export class DefaultAddUrlToTabsetHandler implements AddUrlToTabsetHandler {
3539
actions(currentTabsetId: string | undefined): Component[] {
3640
const url = useContentStore().getCurrentTabUrl
3741
// const currentTabsetId = await useTabsetsStore().getCurrentTabsetId()
38-
const actions = [EditTabsetAction, CreateSubfolderAction, OpenAllInMenuAction, DeleteTabsetAction]
42+
43+
const actions = [EditTabsetAction, CreateSubfolderAction]
44+
if (useFeaturesStore().hasFeature(FeatureIdent.NOTES)) {
45+
actions.push(CreateNoteAction)
46+
}
47+
actions.push(OpenAllInMenuAction, DeleteTabsetAction)
3948

4049
if (url) {
4150
// TODO folders?

actionHandling/handler/ExcalidrawAddUrlToTabsetHandler.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { QVueGlobals, uid } from 'quasar'
1+
import { DialogChainObject, QVueGlobals, uid } from 'quasar'
22
import { ExecutionResult } from 'src/core/domain/ExecutionResult'
33
import { useCommandExecutor } from 'src/core/services/CommandExecutor'
44
import {
@@ -7,10 +7,15 @@ import {
77
} from 'src/tabsets/actionHandling/AddUrlToTabsetHandler'
88
import { ActionContext } from 'src/tabsets/actionHandling/model/ActionContext'
99
import { ExcalidrawStorage } from 'src/tabsets/actionHandling/model/ExcalidrawStorage'
10+
import CreateSubfolderAction from 'src/tabsets/actions/CreateSubfolderAction.vue'
11+
import DeleteTabsetAction from 'src/tabsets/actions/DeleteTabsetAction.vue'
12+
import EditTabsetAction from 'src/tabsets/actions/EditTabsetAction.vue'
13+
import OpenAllInMenuAction from 'src/tabsets/actions/OpenAllInMenuAction.vue'
1014
import { AddTabToTabsetCommand } from 'src/tabsets/commands/AddTabToTabsetCommand'
1115
import { Tab } from 'src/tabsets/models/Tab'
1216
import { Tabset } from 'src/tabsets/models/Tabset'
1317
import { useTabsetsStore } from 'src/tabsets/stores/tabsetsStore'
18+
import { Component } from 'vue'
1419

1520
export class ExcalidrawAddUrlToTabsetHandler implements AddUrlToTabsetHandler {
1621
constructor(public $q: QVueGlobals | undefined) {}
@@ -45,10 +50,10 @@ export class ExcalidrawAddUrlToTabsetHandler implements AddUrlToTabsetHandler {
4550
return undefined
4651
}
4752

48-
actions(): ActionContext[] {
53+
actions(): Component[] {
4954
const tabset: Tabset | undefined = useTabsetsStore().getCurrentTabset
5055
if (tabset) {
51-
var actions = (tabset.tabs as Tab[])
56+
const actions: Component[] = (tabset.tabs as Tab[])
5257
.filter((t: Tab) => t.url !== undefined)
5358
.filter((t: Tab) => t.url!.match(this.urlMatcher()))
5459
.map((t: Tab) => {
@@ -59,8 +64,9 @@ export class ExcalidrawAddUrlToTabsetHandler implements AddUrlToTabsetHandler {
5964
.concat([new ActionContext('Save as new file').withDialog(this.newFileDialog, this.$q!).onOk(this.onOk)])
6065
.concat([new ActionContext('Clear canvas')])
6166
: actions.concat([new ActionContext('Add Excalidraw').withDialog(this.newFileDialog, this.$q!).onOk(this.onOk)])
67+
} else {
68+
return [EditTabsetAction, CreateSubfolderAction, OpenAllInMenuAction, DeleteTabsetAction]
6269
}
63-
return []
6470
}
6571

6672
async clicked(
@@ -83,7 +89,7 @@ export class ExcalidrawAddUrlToTabsetHandler implements AddUrlToTabsetHandler {
8389
newTab.title = filename
8490

8591
const firstFrameReturned = returned.at(0)
86-
console.log('hier', firstFrameReturned)
92+
// console.log('hier', firstFrameReturned)
8793
if (firstFrameReturned && firstFrameReturned.result) {
8894
newTab.storage = new ExcalidrawStorage(
8995
JSON.stringify(JSON.parse(firstFrameReturned.result['excalidraw' as keyof object])),
@@ -189,7 +195,7 @@ export class ExcalidrawAddUrlToTabsetHandler implements AddUrlToTabsetHandler {
189195
})
190196
}
191197

192-
newFileDialog($q: QVueGlobals, filename: string = '') {
198+
async newFileDialog($q: QVueGlobals, filename: string = ''): Promise<DialogChainObject> {
193199
return $q!.dialog({
194200
title: 'Save as Excalidraw File',
195201
message: 'Please Provide a name (min 3 characters)',

actionHandling/handler/ImportFromChromeBookmarksManagerAddUrlToTabsetHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { QVueGlobals } from 'quasar'
1+
import { DialogChainObject, QVueGlobals } from 'quasar'
22
import { ExecutionResult } from 'src/core/domain/ExecutionResult'
33
import { useCommandExecutor } from 'src/core/services/CommandExecutor'
44
import {
@@ -99,7 +99,7 @@ export class ImportFromChromeBookmarksManagerAddUrlToTabsetHandler implements Ad
9999

100100
handleOpenedTab(browserTab: chrome.tabs.Tab, tab: Tab) {}
101101

102-
importChromeBookmarksDialog($q: QVueGlobals) {
102+
async importChromeBookmarksDialog($q: QVueGlobals): Promise<DialogChainObject> {
103103
return $q.dialog({
104104
title: 'Import Bookmarks',
105105
message: 'Click "OK" to import the selected bookmarks folder to the current tabset',

actionHandling/handler/MarkdownFileAddUrlToTabsetHandler.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ import {
77
ClickedHandler,
88
} from 'src/tabsets/actionHandling/AddUrlToTabsetHandler'
99
import { ActionContext } from 'src/tabsets/actionHandling/model/ActionContext'
10+
import CreateSubfolderAction from 'src/tabsets/actions/CreateSubfolderAction.vue'
11+
import DeleteTabsetAction from 'src/tabsets/actions/DeleteTabsetAction.vue'
12+
import EditTabsetAction from 'src/tabsets/actions/EditTabsetAction.vue'
13+
import OpenAllInMenuAction from 'src/tabsets/actions/OpenAllInMenuAction.vue'
1014
import { AddTabToTabsetCommand } from 'src/tabsets/commands/AddTabToTabsetCommand'
1115
import { LoadDynamicTabsCommand } from 'src/tabsets/commands/LoadDynamicTabsCommand'
1216
import { Tab } from 'src/tabsets/models/Tab'
1317
import { Tabset } from 'src/tabsets/models/Tabset'
18+
import { Component } from 'vue'
1419

1520
export class MarkdownFileAddUrlToTabsetHandler implements AddUrlToTabsetHandler {
1621
constructor(public $q: QVueGlobals) {}
@@ -24,11 +29,12 @@ export class MarkdownFileAddUrlToTabsetHandler implements AddUrlToTabsetHandler
2429
}
2530

2631
defaultAction(): ActionContext {
27-
return null as unknown as ActionContext
32+
return new ActionContext('Add Markdown').withDialog(this.analyseMarkdownDialog, this.$q).onOk(this.onOk)
2833
}
2934

30-
actions(): ActionContext[] {
31-
return [new ActionContext('Add Markdown Page').withDialog(this.analyseMarkdownDialog, this.$q).onOk(this.onOk)]
35+
actions(): Component[] {
36+
// return [new ActionContext('Add Markdown Page').withDialog(this.analyseMarkdownDialog, this.$q).onOk(this.onOk)]
37+
return [EditTabsetAction, CreateSubfolderAction, OpenAllInMenuAction, DeleteTabsetAction]
3238
}
3339

3440
withDialog(): DialogChainObject | undefined {
@@ -67,24 +73,20 @@ export class MarkdownFileAddUrlToTabsetHandler implements AddUrlToTabsetHandler
6773

6874
handleOpenedTab(browserTab: chrome.tabs.Tab, tab: Tab) {}
6975

70-
analyseMarkdownDialog($q: QVueGlobals, filename: string = '') {
71-
return $q.dialog({
72-
title: 'Save Markdown File',
73-
message: "The file's content can be analysed and dynamically extracted.",
74-
options: {
75-
type: 'checkbox',
76-
model: [],
77-
items: [{ label: 'Use for links', value: 'useForLinks', color: 'secondary' }],
78-
},
79-
cancel: true,
80-
persistent: true,
81-
})
82-
// ?.onOk((data: string[]) => {
83-
// console.log('data', data)
84-
// this.clicked(chromeTab, tabset, undefined, {
85-
// data: { useForLinks: data.indexOf('useForLinks') >= 0 },
86-
// })
87-
// })
76+
async analyseMarkdownDialog($q: QVueGlobals, filename: string = '') {
77+
return Promise.resolve(
78+
$q.dialog({
79+
title: 'Save Markdown File',
80+
message: "The file's content can be analysed and dynamically extracted.",
81+
options: {
82+
type: 'checkbox',
83+
model: [],
84+
items: [{ label: 'Use for links', value: 'useForLinks', color: 'secondary' }],
85+
},
86+
cancel: true,
87+
persistent: true,
88+
}),
89+
)
8890
}
8991

9092
onOk = (data: string[]): ClickedHandler => {

actionHandling/handler/ObsidianApiAddUrlToTabsetHandler.ts

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ import {
55
AddUrlToTabsetHandlerAdditionalData,
66
} from 'src/tabsets/actionHandling/AddUrlToTabsetHandler'
77
import { ActionContext } from 'src/tabsets/actionHandling/model/ActionContext'
8+
import CreateSubfolderAction from 'src/tabsets/actions/CreateSubfolderAction.vue'
9+
import DeleteTabsetAction from 'src/tabsets/actions/DeleteTabsetAction.vue'
10+
import EditTabsetAction from 'src/tabsets/actions/EditTabsetAction.vue'
11+
import OpenAllInMenuAction from 'src/tabsets/actions/OpenAllInMenuAction.vue'
812
import { Tab } from 'src/tabsets/models/Tab'
913
import { Tabset } from 'src/tabsets/models/Tabset'
1014
import { useTabsetsStore } from 'src/tabsets/stores/tabsetsStore'
15+
import { Component } from 'vue'
1116

1217
export class ObsidianApiAddUrlToTabsetHandler implements AddUrlToTabsetHandler {
1318
urlMatcher(): RegExp {
@@ -19,47 +24,43 @@ export class ObsidianApiAddUrlToTabsetHandler implements AddUrlToTabsetHandler {
1924
}
2025

2126
defaultAction(): ActionContext {
22-
return null as unknown as ActionContext
27+
return new ActionContext('Add Obsidian vault').onClicked(this.clicked)
2328
}
2429

25-
actions(): ActionContext[] {
26-
return [new ActionContext('Add Obsidian vault')]
30+
actions(): Component[] {
31+
return [EditTabsetAction, CreateSubfolderAction, OpenAllInMenuAction, DeleteTabsetAction]
2732
}
2833

29-
clicked(
34+
async clicked(
3035
browserTab: chrome.tabs.Tab,
3136
ts: Tabset,
3237
folder: Tabset | undefined,
3338
additionalData: AddUrlToTabsetHandlerAdditionalData | undefined,
3439
): Promise<ExecutionResult<any>> {
35-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
36-
console.log(`clicked ${ts}`)
37-
return Promise.reject('undefined')
40+
//console.log(`handleOpenedTab ${browserTab}, ${ts as Tabset}, ${additionalData}`)
41+
42+
const api = RestApiDefinitions.getApi('OBSIDIAN')
43+
if (api) {
44+
const tabset = await api.fetchTabset({})
45+
// tabset.folders.push(...folders)
46+
console.log('saving', tabset)
47+
await useTabsetsStore().saveTabset(tabset)
48+
return new ExecutionResult('done', 'done')
49+
}
50+
return Promise.reject('could not find API')
3851
}
3952

4053
handleOpenedTab(browserTab: chrome.tabs.Tab, tab: Tab): void {
4154
// eslint-disable-next-line @typescript-eslint/no-base-to-string
4255
console.log(`handleOpenedTab ${browserTab}`)
4356
}
4457

45-
// TODO wrong method !?!
4658
async updateInTabset(
4759
browserTab: chrome.tabs.Tab,
4860
ts: Tabset,
4961
folder?: Tabset,
5062
additionalData?: AddUrlToTabsetHandlerAdditionalData,
5163
): Promise<ExecutionResult<any>> {
52-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
53-
console.log(`handleOpenedTab ${browserTab}, ${ts as Tabset}, ${additionalData}`)
54-
55-
const api = RestApiDefinitions.getApi('OBSIDIAN')
56-
if (api) {
57-
const tabset = await api.fetchTabset({})
58-
// tabset.folders.push(...folders)
59-
console.log('saving', tabset)
60-
await useTabsetsStore().saveTabset(tabset)
61-
return new ExecutionResult('done', 'done')
62-
}
63-
return Promise.reject('could not find API')
64+
return Promise.reject('not implemented')
6465
}
6566
}

0 commit comments

Comments
 (0)