From 85f4755be129ce95076cbaae3ad9173114aaace9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carsten=20Gr=C3=A4f?= Date: Mon, 14 Oct 2024 21:49:12 +0200 Subject: [PATCH] wip --- src-bex/tabsets-content-script.ts | 4 + src/app/BrowserApi.ts | 16 +++- src/app/listeners/BrowserListeners.ts | 21 +++++- src/boot/constants.ts | 8 +- src/notes | 2 +- src/pages/SettingsPage.vue | 50 ++----------- src/pages/SidePanelPage.vue | 29 ++++---- src/pages/helper/BackupSettings.vue | 90 +++++++++++++++++++++++ src/pages/helper/ImportExportSettings.vue | 59 +++++++++++++++ src/tabsets | 2 +- src/thumbnails | 2 +- src/ui | 2 +- 12 files changed, 218 insertions(+), 67 deletions(-) create mode 100644 src/pages/helper/BackupSettings.vue create mode 100644 src/pages/helper/ImportExportSettings.vue diff --git a/src-bex/tabsets-content-script.ts b/src-bex/tabsets-content-script.ts index 42972000..be923335 100644 --- a/src-bex/tabsets-content-script.ts +++ b/src-bex/tabsets-content-script.ts @@ -13,6 +13,10 @@ export default bexContent((bridge: any) => { } console.log("tabsets: initializing content script for tab analysis...") + // chrome.storage.local.get(["excalidraw"], (res) => { + // console.log("res", res) + // }) + // chrome.storage.local.set({"test": "test"}) // @ts-ignore window.contentScriptAnalysisAlredyCalled = true diff --git a/src/app/BrowserApi.ts b/src/app/BrowserApi.ts index 999bfcae..c95d58b3 100644 --- a/src/app/BrowserApi.ts +++ b/src/app/BrowserApi.ts @@ -1,18 +1,19 @@ import {Tabset} from "src/tabsets/models/Tabset"; -import {CLEANUP_PERIOD_IN_MINUTES, MONITORING_PERIOD_IN_MINUTES} from "boot/constants"; +import {CLEANUP_PERIOD_IN_MINUTES, GITHUB_AUTO_BACKUP, MONITORING_PERIOD_IN_MINUTES} from "boot/constants"; import _ from "lodash" import NavigationService from "src/services/NavigationService"; import IndexedDbPersistenceService from "src/services/IndexedDbPersistenceService"; import {Tab} from "src/tabsets/models/Tab"; -import {uid} from "quasar"; +import {LocalStorage, uid} from "quasar"; import {FeatureIdent} from "src/app/models/FeatureIdent"; import {useWindowsStore} from "src/windows/stores/windowsStore"; import {Router} from "vue-router"; import {useTabsetsStore} from "src/tabsets/stores/tabsetsStore"; import {useTabsetService} from "src/tabsets/services/TabsetService2"; import {useFeaturesStore} from "src/features/stores/featuresStore"; -import IndexedDbRequestPersistence from "src/requests/persistence/IndexedDbRequestPersistence"; import {useRequestsService} from "src/requests/services/ContentService"; +import {useCommandExecutor} from "src/core/services/CommandExecutor"; +import {GithubBackupCommand} from "src/tabsets/commands/GithubBackupCommand"; function runHousekeeping() { @@ -49,6 +50,9 @@ class BrowserApi { console.debug(" ...initializing ChromeApi") chrome.alarms.create("housekeeping", {periodInMinutes: CLEANUP_PERIOD_IN_MINUTES}) + + chrome.alarms.create("hourlyTasks", {periodInMinutes: 30}) + chrome.alarms.create("monitoring", {periodInMinutes: MONITORING_PERIOD_IN_MINUTES}) chrome.alarms.onAlarm.addListener( @@ -61,6 +65,10 @@ class BrowserApi { // if (useFeaturesStore().hasFeature(FeatureIdent.MONITORING)) { // checkMonitors(router) // } + } else if (alarm.name === "hourlyTasks") { + if (LocalStorage.getItem(GITHUB_AUTO_BACKUP) as boolean) { + useCommandExecutor().execute(new GithubBackupCommand()); + } } else { console.log("unknown alarm", alarm) } @@ -137,7 +145,7 @@ class BrowserApi { // contexts: ['all'] // }) //} - // console.debug(" > context menu: save_to_currentTS") + // console.debug(" > context menu: save_to_currentTS") chrome.contextMenus.create({ id: 'save_to_currentTS', parentId: 'tabset_extension', diff --git a/src/app/listeners/BrowserListeners.ts b/src/app/listeners/BrowserListeners.ts index 7947b09e..2a7dcaea 100644 --- a/src/app/listeners/BrowserListeners.ts +++ b/src/app/listeners/BrowserListeners.ts @@ -7,7 +7,6 @@ import NavigationService from "src/services/NavigationService"; import ContentUtils from "src/core/utils/ContentUtils"; import {EMAIL_LINK_REDIRECT_DOMAIN} from "boot/constants"; import {useUiStore} from "src/ui/stores/uiStore"; -import {Tabset, TabsetType} from "src/tabsets/models/Tabset"; import {useWindowsStore} from "src/windows/stores/windowsStore"; import {Tab} from "src/tabsets/models/Tab"; import {useTabsetService} from "src/tabsets/services/TabsetService2"; @@ -272,6 +271,7 @@ class BrowserListeners { if (tab.url && tab.url.startsWith("https://shared.tabsets.net")) { return } + BrowserApi.addIndicatorIcon(tab.id, tab.url) } @@ -294,6 +294,25 @@ class BrowserListeners { await setCurrentTab() + // debugger + // //const fromPageLocalStore = await chrome.scripting.executeScript({ target: { tabId: info.tabId }}, () => {localStorage['excalidraw']}); + // const returned = await chrome.scripting.executeScript({ + // target: {tabId: info.tabId}, + // func: (items) => { + // //Object.keys(items).forEach((key) => { + // localStorage.setItem("tabsetkey", "tabsetvalue") + // const res = localStorage.getItem("excalidraw") + // console.log("got res", res) + // return res + // //}) + // }, + // args: ['excalidraw'] // pass any parameters to function + // }) + // console.log("returned", returned) + + + //console.log("fromPage", fromPageLocalStore) + chrome.tabs.get(info.tabId, tab => { if (chrome.runtime.lastError) { console.warn("got runtime error:" + chrome.runtime.lastError); diff --git a/src/boot/constants.ts b/src/boot/constants.ts index 6678cdc6..6af8af10 100644 --- a/src/boot/constants.ts +++ b/src/boot/constants.ts @@ -39,6 +39,11 @@ const CURRENT_USER_EMAIL = "current.user.email" const UI_WINDOWS_ITEMS_PER_PAGE = 'ui.windows.itemsPerPage' +const GITHUB_USERNAME = "github.username" +const GITHUB_REPONAME = "github.reponame" +const GITHUB_TOKEN = "github.token" +const GITHUB_AUTO_BACKUP = "github.autobackup" + export default boot(({}) => { }) @@ -59,6 +64,7 @@ export { EMAIL_LINK_REDIRECT_DOMAIN, CURRENT_USER_ID, CURRENT_USER_EMAIL, - UI_WINDOWS_ITEMS_PER_PAGE + UI_WINDOWS_ITEMS_PER_PAGE, + GITHUB_USERNAME, GITHUB_REPONAME, GITHUB_TOKEN, GITHUB_AUTO_BACKUP } diff --git a/src/notes b/src/notes index c36333c7..751a8d72 160000 --- a/src/notes +++ b/src/notes @@ -1 +1 @@ -Subproject commit c36333c7cfe0df8fae8a8e1b2d6b83d9ca24f0da +Subproject commit 751a8d7255b8996a91f49d4fb638230a6ecf07da diff --git a/src/pages/SettingsPage.vue b/src/pages/SettingsPage.vue index 9ecbf39e..233e8e32 100644 --- a/src/pages/SettingsPage.vue +++ b/src/pages/SettingsPage.vue @@ -26,6 +26,7 @@ v-if="useFeaturesStore().hasFeature(FeatureIdent.ARCHIVE_TABSET)"/> + @@ -341,45 +342,12 @@
-
- - You can export your data in various formats and re-import them - from json. Please - note that it is not guaranteed that older exports can be imported with newer versions of the tabsets - extension. - - -
-
Export
-
json or as bookmarks
-
-
- - Export your tabsets - -
-
- -
-
Import
-
- from json
- You might need to restart tabsets. -
-
-
- - Import your tabsets backup - -
-
+ -
+
+
+
@@ -418,7 +386,6 @@ import { STRIP_CHARS_IN_USER_INPUT, TITLE_IDENT } from "boot/constants"; -import {useAuthStore} from "stores/authStore"; import InfoLine from "pages/helper/InfoLine.vue"; import FeatureToggleSettings from "pages/helper/FeatureToggleSettings.vue"; import {useI18n} from "vue-i18n"; @@ -426,11 +393,11 @@ import {useTabsetsStore} from "src/tabsets/stores/tabsetsStore"; import {useFeaturesStore} from "src/features/stores/featuresStore"; import VueJsonPretty from "vue-json-pretty"; import 'vue-json-pretty/lib/styles.css'; -import ExportDialog from "src/tabsets/dialogues/ExportDialog.vue"; -import ImportDialog from "src/tabsets/dialogues/ImportDialog.vue"; import {useGroupsStore} from "../tabsets/stores/groupsStore"; import OpenRightDrawerWidget from "src/ui/widgets/OpenRightDrawerWidget.vue"; import {usePermissionsStore} from "stores/usePermissionsStore"; +import BackupSettings from "pages/helper/BackupSettings.vue"; +import ImportExportSettings from "pages/helper/ImportExportSettings.vue"; const { t } = useI18n() @@ -588,9 +555,6 @@ const simulateNewVersion = (version: string) => NavigationService.updateAvailabl const restoreHints = () => useUiStore().restoreHints() -const showExportDialog = () => $q.dialog({component: ExportDialog, componentProps: {inSidePanel: true}}) -const showImportDialog = () => $q.dialog({component: ImportDialog, componentProps: {inSidePanel: true}}) - const simulateStaticSuggestion = () => { const suggestions: [Suggestion] = [ // @ts-ignore diff --git a/src/pages/SidePanelPage.vue b/src/pages/SidePanelPage.vue index 6f1ada5e..3b6889b9 100644 --- a/src/pages/SidePanelPage.vue +++ b/src/pages/SidePanelPage.vue @@ -280,23 +280,24 @@ if (inBexMode()) { useUiStore().draggingTab(message.data.tabId, null as unknown as any) } else if (message.name === "note-changed") { // TODO needed? - const tabset = useTabsetsStore().getTabset(message.data.tabsetId) as Tabset - if (message.data.noteId) { - console.log("updating note", message.data.noteId) - const res = useTabsetsStore().getTabAndTabsetId(message.data.noteId) - //.then((res: TabAndTabsetId | undefined) => { - if (res) { - const note = res.tab - note.title = message.data.tab.title - note.description = message.data.tab.description - note.longDescription = message.data.tab.longDescription - } - useTabsetService().saveTabset(tabset) + //const tabset = useTabsetsStore().getTabset(message.data.tabsetId) as Tabset + if (message.data.notebookId) { + console.log("updating notebook/tabset", message.data.notebookId, message.data.tabsetId) + useTabsetService().reloadTabset(message.data.tabsetId) + // const res = useTabsetsStore().getTabAndTabsetId(message.data.noteId) + // //.then((res: TabAndTabsetId | undefined) => { + // if (res) { + // const note = res.tab + // note.title = message.data.tab.title + // note.description = message.data.tab.description + // note.longDescription = message.data.tab.longDescription + // } + // useTabsetService().saveTabset(tabset) // }) } else { console.log("adding tab", message.data.tab) - tabset.tabs.push(message.data.tab) - useTabsetService().saveTabset(tabset) + //tabset.tabs.push(message.data.tab) + //useTabsetService().saveTabset(tabset) } } else if (message.name === "tab-added") { // hmm - getting this twice... diff --git a/src/pages/helper/BackupSettings.vue b/src/pages/helper/BackupSettings.vue new file mode 100644 index 00000000..c4966797 --- /dev/null +++ b/src/pages/helper/BackupSettings.vue @@ -0,0 +1,90 @@ + + + diff --git a/src/pages/helper/ImportExportSettings.vue b/src/pages/helper/ImportExportSettings.vue new file mode 100644 index 00000000..b1384bd8 --- /dev/null +++ b/src/pages/helper/ImportExportSettings.vue @@ -0,0 +1,59 @@ + + + diff --git a/src/tabsets b/src/tabsets index ff16fc74..2920c557 160000 --- a/src/tabsets +++ b/src/tabsets @@ -1 +1 @@ -Subproject commit ff16fc7462ad0d9857073e4fbc9b800cfb4510d3 +Subproject commit 2920c557a3ce7ece528e16a1b0e8af7430d59717 diff --git a/src/thumbnails b/src/thumbnails index b9d95444..962c4f5f 160000 --- a/src/thumbnails +++ b/src/thumbnails @@ -1 +1 @@ -Subproject commit b9d95444969ef1e4b4b6faff8293dfe25d858f50 +Subproject commit 962c4f5fc3f6db0c57ba34747df8b19ba1dd4180 diff --git a/src/ui b/src/ui index 03f2c8fe..4734cce5 160000 --- a/src/ui +++ b/src/ui @@ -1 +1 @@ -Subproject commit 03f2c8fedeec26b2bf6774f34d212845a26e8cf1 +Subproject commit 4734cce5f22f13ff4d6397dfc28f2c0c16a5030b