Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
evandor committed Feb 18, 2024
1 parent fa54564 commit f48f47f
Show file tree
Hide file tree
Showing 36 changed files with 293 additions and 387 deletions.
50 changes: 7 additions & 43 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@

<script setup lang="ts">
import {LocalStorage, setCssVar, useQuasar} from "quasar";
import {setCssVar, useQuasar} from "quasar";
import AppService from "src/services/AppService";
import {useAuthStore} from "stores/authStore";
import {EventEmitter} from "events";
import {logtail} from "boot/logtail";
import {getAuth, isSignInWithEmailLink, onAuthStateChanged, signInWithEmailLink, UserCredential} from "firebase/auth";
import {CURRENT_USER_EMAIL, CURRENT_USER_ID} from "boot/constants";
import {useSuggestionsStore} from "stores/suggestionsStore";
import {StaticSuggestionIdent, Suggestion} from "src/models/Suggestion";
import {onAuthStateChanged} from "firebase/auth";
import {CURRENT_USER_ID} from "boot/constants";
import {useRouter} from "vue-router";
import {collection, doc, getDoc, getDocs} from "firebase/firestore";
import {Account, UserData} from "src/models/Account";
import FirebaseService from "src/services/firebase/FirebaseService";
import FirebaseServices from "src/services/firebase/FirebaseServices";
import {useNotificationHandler} from "src/services/ErrorHandler";
const $q = useQuasar()
Expand All @@ -28,8 +23,8 @@ const {handleError} = useNotificationHandler()
const emitter = new EventEmitter()
emitter.setMaxListeners(12)
FirebaseService.init()
const auth = FirebaseService.getAuth()
FirebaseServices.init()
const auth = FirebaseServices.getAuth()
onAuthStateChanged(auth, async (user) => {
if (user) {
Expand Down Expand Up @@ -58,31 +53,6 @@ onAuthStateChanged(auth, async (user) => {
}
});
if (isSignInWithEmailLink(auth, window.location.href)) {
console.log("%cfound sign-in-with-email-link location", window.location.href)
const emailForSignIn = LocalStorage.getItem(CURRENT_USER_EMAIL) as string
console.log(">>> isSignInWithEmailLink", emailForSignIn)
signInWithEmailLink(auth, emailForSignIn, window.location.href)
.then((result: UserCredential) => {
console.log(">>> result", result)
//chrome.runtime.sendMessage({ type: 'SET_EMAIL_FOR_SIGN_IN', "email":"email" });
useAuthStore().setUser(result.user)
//useAuthStore().authenticated = true
logtail.info("found email link redirection")
})
.catch((error) => {
console.error("error in email link redirection", error)
logtail.error("error in email link redirection", error)
useSuggestionsStore().addSuggestion(Suggestion.getStaticSuggestion(StaticSuggestionIdent.RESTART_SUGGESTED))
});
}
const useDarkMode: string = $q.localStorage.getItem('darkMode') || "false" as string
if (useDarkMode === "true") {
$q.dark.set(true)
Expand All @@ -109,20 +79,14 @@ if (currentUser) {
console.log("current user id found, waiting for auto-login")
// we should be logged in any second
} else {
setTimeout(() => {
// triggers, but app should already have been started, no restart enforced
console.debug("app start fallback after 2000ms")
AppService.init($q, router, false)
}, 2000)
}
logtail.info("tabsets started", {
"mode": process.env.MODE,
"version": import.meta.env.PACKAGE_VERSION,
})
logtail.info(`tabsets started: mode=${process.env.MODE}, version=${import.meta.env.PACKAGE_VERSION}`)
</script>
2 changes: 1 addition & 1 deletion src/boot/firebaseConnection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//import FirebaseService from '../services/firebase/FirebaseService'

import FirebaseService from "src/services/firebase/FirebaseService";
import FirebaseService from "src/services/firebase/FirebaseServices";
import {boot} from "quasar/wrappers";

// export default async () => {
Expand Down
5 changes: 3 additions & 2 deletions src/components/SidePanelFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
</q-menu>
</span>

<span class="q-my-xs q-ml-xs q-mr-none cursor-pointer" v-if="authStore.isAuthenticated()">
<span class="q-my-xs q-ml-xs q-mr-none cursor-pointer" v-if="authStore.isAuthenticated() && useSettingsStore().isEnabled('dev')">
<q-avatar size="18px" v-if="authStore.user?.photoURL">
<q-img :src="authStore.user.photoURL"/>
<q-tooltip :delay="2000" anchor="center left" self="center right" class="tooltip-small">You're logged in as {{
Expand Down Expand Up @@ -149,7 +149,7 @@

</q-menu>
</span>
<q-btn v-else
<q-btn v-else-if="useSettingsStore().isEnabled('dev')"
icon="login"
:class="rightButtonClass()"
flat
Expand Down Expand Up @@ -189,6 +189,7 @@ import SidePanelLoginWidget from "components/helper/SidePanelLoginWidget.vue";
import SidePanelWindowMarkupTable from "components/helper/SidePanelWindowMarkupTable.vue";
import SidePanelStatsMarkupTable from "components/helper/SidePanelStatsMarkupTable.vue"
import {Window} from "src/models/Window"
import {useSettingsStore} from "stores/settingsStore";
const {handleSuccess, handleError} = useNotificationHandler()
Expand Down
43 changes: 27 additions & 16 deletions src/components/helper/SidePanelStatsMarkupTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@
<span v-if="!statsSnapshot"
class="cursor-pointer"
@click="saveStatsSnapshot()"><q-icon name="save" class="q-mr-xs"/>Save snapshot
<q-tooltip class="tooltip-small">
Store the current numbers for comparison
</q-tooltip>
</span>
<span v-else
class="cursor-pointer"><q-icon name="restart_alt" class="q-mr-xs cursor-pointer"
@click="saveStatsSnapshot()"/>{{ snapshotDate() }}
<span v-else>
<span class="cursor-pointer">
<q-icon name="restart_alt" class="q-mr-xs cursor-pointer" @click="saveStatsSnapshot()">
<q-tooltip class="tooltip-small">Reset Snapshot Counters</q-tooltip>
</q-icon>
</span>{{ snapshotDate() }}
</span>
</th>
<th style="max-width:20px">
Expand All @@ -23,7 +29,7 @@
</thead>

<tbody>
<tr v-for="row in rows" style="max-height:15px">
<tr v-for="row in rows" :key="row['id' as keyof object]" style="max-height:15px">
<td class="text-left">
<span class="cursor-pointer" :data-testid="'windowDataColumn_name_' + row['id' as keyof object]">
{{ row['name' as keyof object] }}
Expand Down Expand Up @@ -82,15 +88,15 @@ const devMode = ref<boolean>(settingsStore.isEnabled('dev'))
onMounted(() => {
statsSnapshot.value = localstorage.getItem("stats") as object || undefined
rows.value = calcWindowRows()
rows.value = calcStatsRows()
})
watch(() => useWindowsStore().currentChromeWindows, (newWindows, oldWindows) => {
rows.value = calcWindowRows()
rows.value = calcStatsRows()
})
watch(() => useTabsStore().allTabsCount, (a,b) => {
rows.value = calcWindowRows()
rows.value = calcStatsRows()
})
Expand All @@ -102,14 +108,14 @@ watchEffect(() => {
})
watch(() => useTabsStore().tabsCount, (a, b) => {
rows.value = calcWindowRows()
rows.value = calcStatsRows()
})
watch(() => useWindowsStore().currentChromeWindows, (a, b) => {
rows.value = calcWindowRows()
rows.value = calcStatsRows()
})
const calcWindowRows = () => {
const calcStatsRows = () => {
return [
{name: 'Tabs', count: useTabsStore().allTabsCount, snapshot: getFromSnapshot('Tabs')},
{name: 'Tabsets', count: useTabsStore().tabsets.size, snapshot: getFromSnapshot('Tabsets')},
Expand All @@ -127,11 +133,13 @@ const calcWindowRows = () => {
}
const saveStatsSnapshot = () => {
localstorage.set("stats", {
const newStats = {
date: new Date().getTime().toString(),
values: calcWindowRows()
})
rows.value = calcWindowRows()
values: calcStatsRows()
}
localstorage.set("stats", newStats)
statsSnapshot.value = newStats
rows.value = calcStatsRows()
}
const getFromSnapshot = (ident: string) => {
Expand All @@ -150,8 +158,11 @@ const getFromSnapshot = (ident: string) => {
}
const snapshotDate = () => {
const tstamp: string = statsSnapshot.value['date' as keyof object] as string
return date.formatDate(Number(tstamp), 'DD.MM.YY HH:mm')
if (statsSnapshot.value) {
const tstamp: string = statsSnapshot.value['date' as keyof object] as string
return date.formatDate(Number(tstamp), 'DD.MM.YY HH:mm')
}
return "---"
}
</script>
Expand Down
4 changes: 2 additions & 2 deletions src/models/AppFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {AppFeature, FeatureIdent, FeatureType} from "src/models/AppFeature"

export class AppFeatures {
features: AppFeature[] = [
new AppFeature(FeatureIdent.HELP, FeatureType.EXPERIMENTAL, 'Help Pages', 'o_help', ['bex']),
//new AppFeature(FeatureIdent.HELP, FeatureType.EXPERIMENTAL, 'Help Pages', 'o_help', ['bex']),

new AppFeature(FeatureIdent.BOOKMARKS, FeatureType.OPTIONAL, 'Bookmarks', 'o_bookmarks', ['bex'])
.setActivateCommands([new GrantPermissionCommand('bookmarks')])
Expand Down Expand Up @@ -75,7 +75,7 @@ export class AppFeatures {
new AppFeature(FeatureIdent.TAB_HELPER, FeatureType.EXPERIMENTAL, 'Tab Helper', 'o_article', ['bex']),

new AppFeature(FeatureIdent.AUTO_TAB_SWITCHER, FeatureType.EXPERIMENTAL, 'Auto Tab Switcher', 'o_switch_left', ['bex']),
new AppFeature(FeatureIdent.TABS_AS_TREE, FeatureType.EXPERIMENTAL, 'Tabs in Tree View', 'o_account_tree', ['all']),
//new AppFeature(FeatureIdent.TABS_AS_TREE, FeatureType.EXPERIMENTAL, 'Tabs in Tree View', 'o_account_tree', ['all']),
new AppFeature(FeatureIdent.TABSET_SUBFOLDER, FeatureType.EXPERIMENTAL, 'Subfolder for Tabsets', 'o_folder', ['all']),
new AppFeature(FeatureIdent.TABSETS_SHARING, FeatureType.EXPERIMENTAL, 'Sharing Tabsets', 'o_ios_share', ['all'])
]
Expand Down
52 changes: 9 additions & 43 deletions src/pages/SettingsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
<!-- <q-tab name="ignored" label="Ignored Urls"/>-->
<q-tab name="archived" label="Archived Tabsets"
v-if="usePermissionsStore().hasFeature(FeatureIdent.ARCHIVE_TABSET)"/>
<q-tab name="search" label="Search Engine" v-if="devEnabled"/>
<q-tab name="search" label="Search Engine" v-if="useSettingsStore().isEnabled('dev')"/>
<q-tab name="importExport" label="Import/Export"/>
<q-tab name="internals" label="Internals" v-if="devEnabled"/>
<q-tab name="featureToggles" label="Feature Toggles"
:class="useAuthStore().userMayAccess(AccessItem.FEATURE_TOGGLES) ? 'text-primary':'text-grey'"/>
<q-tab name="internals" label="Internals" v-if="useSettingsStore().isEnabled('dev')"/>
<!-- <q-tab name="featureToggles" label="Feature Toggles"-->
<!-- :class="useAuthStore().userMayAccess(AccessItem.FEATURE_TOGGLES) ? 'text-primary':'text-grey'"/>-->
<q-tab name="featureToggles" label="Feature Toggles" />
</q-tabs>
</div>

Expand Down Expand Up @@ -147,7 +148,7 @@
</div>
</div>

<div class="row items-baseline q-ma-md q-gutter-md" v-if="devEnabled">
<div class="row items-baseline q-ma-md q-gutter-md" v-if="useSettingsStore().isEnabled('dev')">
<div class="col-3">
New Version Simulation
</div>
Expand All @@ -159,7 +160,7 @@
</div>
</div>

<div class="row items-baseline q-ma-md q-gutter-md" v-if="devEnabled">
<div class="row items-baseline q-ma-md q-gutter-md" v-if="useSettingsStore().isEnabled('dev')">
<div class="col-3">
New Suggestion Simulation
</div>
Expand Down Expand Up @@ -385,34 +386,7 @@
</div>

<div v-if="tab === 'featureToggles'">

<div class="q-pa-md q-gutter-sm">

<q-banner v-if="!useAuthStore().userMayAccess(AccessItem.FEATURE_TOGGLES)" rounded style="border:1px solid orange">
To use feature toggles, you need to have a (free) account.
</q-banner>
<template v-else>
<q-banner rounded style="border:1px solid orange">Switch on experimental features (or off). These feature toggles
are meant for developers
only as they might break functionality and/or destroy data. Once they are considered 'safe enough', they will
be
available at the
"experimental features" view on the left.
</q-banner>

<div class="row q-pa-md">
<div class="col-3"><b>Developer Mode</b></div>
<div class="col-3">activates a couple of experimental features and debug insights. You should only use this
if you can live with loosing data.
</div>
<div class="col-1"></div>
<div class="col-5">
<q-toggle v-model="devEnabled" @click="updateSettings('dev', devEnabled)"/>
</div>
</div>
</template>
</div>

<FeatureToggleSettings />
</div>

</template>
Expand Down Expand Up @@ -461,6 +435,7 @@ import {AccessItem, useAuthStore} from "stores/authStore";
import SharingSettings from "pages/helper/SharingSettings.vue";
import AccountSettings from "pages/helper/AccountSettings.vue";
import InfoLine from "pages/helper/InfoLine.vue";
import FeatureToggleSettings from "pages/helper/FeatureToggleSettings.vue";
const {sendMsg, inBexMode} = useUtils()
Expand All @@ -477,7 +452,6 @@ useUiStore().rightDrawerSetActiveTab(DrawerTabs.FEATURES)
const view = ref('grid')
const indexSize = ref(0)
const devEnabled = ref<boolean>(settingsStore.isEnabled('dev'))
const ddgEnabled = ref<boolean>(!settingsStore.isEnabled('noDDG'))
const ignoreExtensionsEnabled = ref<boolean>(!settingsStore.isEnabled('extensionsAsTabs'))
const permissionsList = ref<string[]>([])
Expand Down Expand Up @@ -526,7 +500,6 @@ let suggestionsCounter = 0
watchEffect(() => {
//console.log("watching settingsStore.activeToggles...", settingsStore.activeToggles)
devEnabled.value = settingsStore.isEnabled('dev')
ddgEnabled.value = settingsStore.isEnabled('noDDG')
ignoreExtensionsEnabled.value = settingsStore.isEnabled('extensionsAsTabs')
})
Expand Down Expand Up @@ -669,12 +642,5 @@ const simulateStaticSuggestion = () => {
const setTab = (a: any) => tab.value = a['tab' as keyof object]
const updateSettings = (ident: string, val: boolean) => {
console.log("settings updated to", ident, val)
settingsStore.setFeatureToggle(ident, val)
}
const stageIdentifier = () => process.env.TABSETS_STAGE !== 'PRD' ? '(' + process.env.TABSETS_STAGE + ')' : ''
</script>

Loading

0 comments on commit f48f47f

Please sign in to comment.