diff --git a/src/components/widgets/PanelTabListElementWidget.vue b/src/components/widgets/PanelTabListElementWidget.vue index e44bb9a9..247658df 100644 --- a/src/components/widgets/PanelTabListElementWidget.vue +++ b/src/components/widgets/PanelTabListElementWidget.vue @@ -515,9 +515,11 @@ watchEffect(() => { watchEffect(() => { if (props.tab) { const t = props.tab + //console.log("placeholders", t.placeholders) if (t.placeholders && t.placeholders.type === PlaceholdersType.URL_SUBSTITUTION) { const subs = t.placeholders.config Object.entries(subs).forEach(e => { + console.log("got e", e) const name = e[0] const val = e[1] val.split(",").forEach((v: string) => { @@ -535,6 +537,7 @@ watchEffect(() => { }) } } + //console.log("===>", placeholders.value) }) watchEffect(async () => { diff --git a/src/components/widgets/helper/PanelTabListContextMenu.vue b/src/components/widgets/helper/PanelTabListContextMenu.vue index 11799beb..e8ec9e3b 100644 --- a/src/components/widgets/helper/PanelTabListContextMenu.vue +++ b/src/components/widgets/helper/PanelTabListContextMenu.vue @@ -38,7 +38,8 @@ - + Monitoring Changes... @@ -49,15 +50,15 @@ - - - - - - - - - + + + + + + + + + + + @@ -108,7 +121,6 @@ import {Tab} from "src/models/Tab"; import {DeleteTabCommand} from "src/domain/tabs/DeleteTabCommand"; import {useRouter} from "vue-router"; import {useSettingsStore} from "stores/settingsStore"; -import {CopyToClipboardCommand} from "src/domain/commands/CopyToClipboard"; import NavigationService from "src/services/NavigationService"; import {Tabset, TabsetType} from "src/models/Tabset"; import {usePermissionsStore} from "stores/permissionsStore"; @@ -121,6 +133,13 @@ import ColorSelector from "components/dialogues/helper/ColorSelector.vue"; import {UpdateTabColorCommand} from "src/domain/tabs/UpdateTabColor"; import MonitoringDialog from "components/dialogues/MonitoringDialog.vue"; import CommentDialog from "components/dialogues/CommentDialog.vue"; +import {api} from "boot/axios"; +import _ from "lodash" +import {useAuthStore} from "stores/authStore"; +import {NotificationType, useNotificationHandler} from "src/services/ErrorHandler"; +import {ExecutionResult} from "src/domain/ExecutionResult"; + +const {handleSuccess, handleError} = useNotificationHandler() const props = defineProps({ tab: {type: Object as PropType, required: true}, @@ -146,6 +165,25 @@ async function tabToUse(tab: Tab) { return useTab; } +const openSimilar = async () => { + console.log("finding similar websites for", props.tab.url) + try { + const url = new URL(props.tab.url || '') + const hostname = url.hostname + const res = await api.post("https://us-central1-tabsets-dev.cloudfunctions.net/app/ra/similar", {"domain": hostname}) + const data = res.data + console.log("res", res, data['similar_sites']) + if (data['similar_sites']) { + const urls = _.map(data['similar_sites'], u => "https://" + u) + NavigationService.openOrCreateTab(urls) + handleSuccess(new ExecutionResult("done", "opening " + urls.length + " similar page(s)")) + } + } catch (err) { + console.log("got error", err) + handleError("not able to find similar pages", NotificationType.TOAST) + } +} + const deleteTab = async () => { const useTab = await tabToUse(props.tab) useCommandExecutor().executeFromUi(new DeleteTabCommand(useTab, props.tabset)) @@ -157,8 +195,8 @@ const deleteTab = async () => { title: res.length === 1 ? 'Found Bookmark with same URL' : 'Found Bookmarks with same URL', cancel: true, message: res.length === 1 ? - 'Do you want to delete this bookmark as well?' : - 'Do you want to delete these ' + res.length + ' bookmarks as well?' + 'Do you want to delete this bookmark as well?' : + 'Do you want to delete these ' + res.length + ' bookmarks as well?' }).onOk(() => { res.forEach(bm => { chrome.bookmarks.remove(bm.id) @@ -192,14 +230,14 @@ const showTabDetails = async (tab: Tab) => { } const showTabDetailsMenuEntry = (tab: Tab) => - useSettingsStore().isEnabled('dev') + useSettingsStore().isEnabled('dev') //&& !(tab.placeholders?.type === PlaceholdersType.URL_SUBSTITUTION) const deleteTabLabel = (tab: Tab) => - (tab.placeholders && tab.placeholders.type === PlaceholdersType.URL_SUBSTITUTION) ? - 'Delete all' - : - 'Delete Tab' + (tab.placeholders && tab.placeholders.type === PlaceholdersType.URL_SUBSTITUTION) ? + 'Delete all' + : + 'Delete Tab' const editURL = async (tab: Tab) => { diff --git a/src/domain/tabs/AddTabToTabset.ts b/src/domain/tabs/AddTabToTabsetCommand.ts similarity index 88% rename from src/domain/tabs/AddTabToTabset.ts rename to src/domain/tabs/AddTabToTabsetCommand.ts index b18c171e..de81ff2c 100644 --- a/src/domain/tabs/AddTabToTabset.ts +++ b/src/domain/tabs/AddTabToTabsetCommand.ts @@ -11,6 +11,9 @@ import {useSearchStore} from "stores/searchStore"; import {uid, useQuasar} from "quasar"; import {useGroupsStore} from "stores/groupsStore"; import PlaceholderUtils from "src/utils/PlaceholderUtils"; +import {useAuthStore} from "stores/authStore"; +import {collection, deleteDoc, doc, getDoc, getDocs, setDoc, updateDoc} from "firebase/firestore"; +import FirebaseServices from "src/services/firebase/FirebaseServices"; const {saveTabset} = useTabsetService() const {sendMsg} = useUtils() @@ -54,6 +57,12 @@ export class AddTabToTabsetCommand implements Command { const tabset: Tabset = await useTabsetService().addToTabset(tabsetOrFolder, this.tab, 0) + // Analysis + if (useAuthStore().isAuthenticated() && this.tab.url?.startsWith("https://")) { + const userId = useAuthStore().user.uid + setDoc(doc(FirebaseServices.getFirestore(), "users", userId, "queue", uid()),{"event": "new-tab", "url": this.tab.url}) + } + // Sharing if (tabset.sharedId && tabset.sharing === TabsetSharing.PUBLIC_LINK && !this.activeFolder) { tabset.sharing = TabsetSharing.PUBLIC_LINK_OUTDATED diff --git a/src/pages/SidePanelPage.vue b/src/pages/SidePanelPage.vue index 8ac26d25..39709ab5 100644 --- a/src/pages/SidePanelPage.vue +++ b/src/pages/SidePanelPage.vue @@ -175,17 +175,29 @@ @mouseover="hoveredTabset = tabset.id" @mouseleave="hoveredTabset = undefined"> - - + + + + + + + + + + + + +
Add Tab
+ +
{{ @@ -367,7 +379,7 @@ import {useDB} from "src/services/usePersistenceService"; import {useBookmarksStore} from "stores/bookmarksStore"; import {useSuggestionsStore} from "stores/suggestionsStore"; import SidePanelPageTabList from "components/layouts/SidePanelPageTabList.vue"; -import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabset"; +import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabsetCommand" import {CopyToClipboardCommand} from "src/domain/commands/CopyToClipboard"; import ShareTabsetPubliclyDialog from "components/dialogues/ShareTabsetPubliclyDialog.vue"; import {FirebaseCall} from "src/services/firebase/FirebaseCall"; diff --git a/src/pages/SidePanelTabsetPage.vue b/src/pages/SidePanelTabsetPage.vue index 208bdfd2..0e5c766a 100644 --- a/src/pages/SidePanelTabsetPage.vue +++ b/src/pages/SidePanelTabsetPage.vue @@ -101,7 +101,7 @@ import {uid, useQuasar} from "quasar"; import SidePanelPageTabList from "components/layouts/SidePanelPageTabList.vue"; import {useTabsetService} from "src/services/TabsetService2"; import {useCommandExecutor} from "src/services/CommandExecutor"; -import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabset"; +import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabsetCommand" import {usePermissionsStore} from "stores/permissionsStore"; import {FeatureIdent} from "src/models/AppFeature"; import ContextMenuItem from "pages/sidepanel/helper/ContextMenuItem.vue"; diff --git a/src/pages/contentscript/ContentScriptPage.vue b/src/pages/contentscript/ContentScriptPage.vue index a0efc8ed..8e27b494 100644 --- a/src/pages/contentscript/ContentScriptPage.vue +++ b/src/pages/contentscript/ContentScriptPage.vue @@ -40,7 +40,7 @@ import {onMounted, ref, watchEffect} from "vue"; import {useTabsStore} from "stores/tabsStore"; import {useTabsetService} from "src/services/TabsetService2"; import {useCommandExecutor} from "src/services/CommandExecutor"; -import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabset"; +import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabsetCommand" import {Tab} from "src/models/Tab"; import {uid} from "quasar"; import {Tabset} from "src/models/Tabset"; diff --git a/src/pages/mainpanel/MainPanelSpacesPage.vue b/src/pages/mainpanel/MainPanelSpacesPage.vue index f3e12763..6b7370a0 100644 --- a/src/pages/mainpanel/MainPanelSpacesPage.vue +++ b/src/pages/mainpanel/MainPanelSpacesPage.vue @@ -65,8 +65,7 @@ import {useSpacesStore} from "src/stores/spacesStore"; import {onMounted, ref, watchEffect} from "vue" import _ from "lodash" import {Space} from "src/models/Space" -import {Tabset} from "src/models/Tabset"; -import {useRouter} from "vue-router"; +import {Tabset, TabsetStatus} from "src/models/Tabset"; import {useTabsetService} from "src/services/TabsetService2"; import Analytics from "src/utils/google-analytics"; import {useUtils} from "src/services/Utils"; @@ -134,9 +133,11 @@ watchEffect(() => { console.log("watching effect tabsets") rows.value = [] _.forEach(sortedTabsets.value as Tabset[], (ts: Tabset) => { - rows.value.push({ - tabset: ts.name, - }) + if (ts.status !== TabsetStatus.DELETED) { + rows.value.push({ + tabset: ts.name, + }) + } }) }) diff --git a/src/pages/sidepanel/helper/FirstToolbarHelper.vue b/src/pages/sidepanel/helper/FirstToolbarHelper.vue index 68967221..f814befc 100644 --- a/src/pages/sidepanel/helper/FirstToolbarHelper.vue +++ b/src/pages/sidepanel/helper/FirstToolbarHelper.vue @@ -71,14 +71,24 @@ size="10px" class="q-ml-sm"/> - + + + + + + + + + + diff --git a/src/services/ErrorHandler.ts b/src/services/ErrorHandler.ts index c9bbb218..f78faa16 100644 --- a/src/services/ErrorHandler.ts +++ b/src/services/ErrorHandler.ts @@ -12,12 +12,13 @@ export function useNotificationHandler() { const {info, error} = useLogger() - const handleError = (error: any, type: NotificationType = NotificationType.TOAST) => { - console.log("showing error message: ", error ? error.toString() : 'unknown error') + const handleError = (err: any, type: NotificationType = NotificationType.TOAST) => { + const errorMsg = err ? err.toString() : 'unknown error' + console.log("showing error message: ", errorMsg) console.trace() //logtail.error(error ? error.toString() : 'unknown error', error) - error(error ? error.toString() : 'unknown error', error) + error(errorMsg /** todo pass actual error */) switch (type) { case NotificationType.NOTIFY: @@ -26,11 +27,11 @@ export function useNotificationHandler() { color: 'red-5', textColor: 'white', icon: 'error', - message: error ? error.toString() : 'unknown error' + message: errorMsg }) break; default: - useUiStore().createErrorToast(error ? error.toString() : 'unknown error') + useUiStore().createErrorToast(errorMsg) } } diff --git a/test/vitest/__tests__/domain/tabs/AddTabToTabset.test.ts b/test/vitest/__tests__/domain/tabs/AddTabToTabset.test.ts index 2d032c00..f3b73c8d 100644 --- a/test/vitest/__tests__/domain/tabs/AddTabToTabset.test.ts +++ b/test/vitest/__tests__/domain/tabs/AddTabToTabset.test.ts @@ -3,7 +3,7 @@ import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest'; import {createPinia, setActivePinia} from "pinia"; import ChromeApi from "src/services/ChromeApi"; import IndexedDbPersistenceService from "src/services/IndexedDbPersistenceService"; -import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabset"; +import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabsetCommand" import {Tab} from "src/models/Tab"; import {CreateTabsetCommand} from "src/domain/tabsets/CreateTabset"; import {useTabsetService} from "src/services/TabsetService2"; diff --git a/test/vitest/__tests__/domain/tabs/UpdateTabUrl.test.ts b/test/vitest/__tests__/domain/tabs/UpdateTabUrl.test.ts index ac6248b9..5dc74cae 100644 --- a/test/vitest/__tests__/domain/tabs/UpdateTabUrl.test.ts +++ b/test/vitest/__tests__/domain/tabs/UpdateTabUrl.test.ts @@ -3,7 +3,7 @@ import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest'; import {createPinia, setActivePinia} from "pinia"; import ChromeApi from "src/services/ChromeApi"; import IndexedDbPersistenceService from "src/services/IndexedDbPersistenceService"; -import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabset"; +import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabsetCommand" import {Tab} from "src/models/Tab"; import {CreateTabsetCommand} from "src/domain/tabsets/CreateTabset"; import {useTabsetService} from "src/services/TabsetService2"; diff --git a/test/vitest/__tests__/domain/tabsets/CreateTabset.test.ts b/test/vitest/__tests__/domain/tabsets/CreateTabset.test.ts index ee8a09d8..3ee5c92a 100644 --- a/test/vitest/__tests__/domain/tabsets/CreateTabset.test.ts +++ b/test/vitest/__tests__/domain/tabsets/CreateTabset.test.ts @@ -2,7 +2,6 @@ import {installQuasarPlugin} from '@quasar/quasar-app-extension-testing-unit-vit import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest'; import {createPinia, setActivePinia} from "pinia"; import IndexedDbPersistenceService from "src/services/IndexedDbPersistenceService"; -import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabset"; import {CreateTabsetCommand} from "src/domain/tabsets/CreateTabset"; import {useDB} from "src/services/usePersistenceService"; import {useTabsStore} from "stores/tabsStore";