Skip to content

Commit

Permalink
TAB-481 electron
Browse files Browse the repository at this point in the history
  • Loading branch information
evandor committed Jan 24, 2024
1 parent 26f798e commit a8577a4
Show file tree
Hide file tree
Showing 16 changed files with 254 additions and 137 deletions.
Binary file modified src-electron/icons/icon.icns
Binary file not shown.
Binary file modified src-electron/icons/icon.ico
Binary file not shown.
Binary file modified src-electron/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ onAuthStateChanged(auth, (user) => {
if (user) {
// User is signed in, see docs for a list of available properties
// https://firebase.google.com/docs/reference/js/auth.user
console.log("onAuthStateChanged: logged in")
console.log("%conAuthStateChanged: logged in", "border:1px solid green")
useAuthStore().setUser(user)
getDoc(doc(firestore, "users", user.uid))
Expand Down Expand Up @@ -79,7 +79,7 @@ onAuthStateChanged(auth, (user) => {
} else {
// User is signed out
console.log("onAuthStateChanged: logged out")
console.log("%conAuthStateChanged: logged out", "border:1px solid green")
useAuthStore().setUser(undefined)
}
});
Expand Down
4 changes: 4 additions & 0 deletions src/layouts/DefaultLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
</q-btn>
<q-menu :offset="[0, 7]">
<q-list style="min-width: 200px">
<q-item v-if="!useAuthStore().isAuthenticated()" clickable @click="router.push('/login')">Login</q-item>
<q-item v-else clickable @click="router.push('/logout')">Logout</q-item>

<q-item clickable @click="router.push('/settings')">Settings</q-item>
<q-item clickable @click="tabsClicked(DrawerTabs.FEATURES)" v-close-popup>
Activate more Features
Expand Down Expand Up @@ -204,6 +207,7 @@ import {useSuggestionsStore} from "src/stores/suggestionsStore";
import {FeatureIdent} from "src/models/AppFeature";
import {useSettingsStore} from "src/stores/settingsStore"
import ToolbarButton from "components/widgets/ToolbarButton.vue";
import {useAuthStore} from "stores/authStore";
const $q = useQuasar()
const router = useRouter()
Expand Down
3 changes: 3 additions & 0 deletions src/layouts/FullPageLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@
</q-btn>
<q-menu :offset="[0, 7]">
<q-list style="min-width: 200px">
<q-item v-if="!useAuthStore().isAuthenticated()" clickable @click="router.push('/login')">Login</q-item>
<q-item v-else clickable @click="router.push('/logout')">Logout</q-item>
<q-item clickable @click="router.push('/settings')">Settings</q-item>
<q-item clickable @click="tabsClicked(DrawerTabs.FEATURES)" v-close-popup>
Activate more Features
Expand Down Expand Up @@ -235,6 +237,7 @@ import {FeatureIdent} from "src/models/AppFeature";
import {useSettingsStore} from "src/stores/settingsStore"
import ToolbarButton from "components/widgets/ToolbarButton.vue";
import {FirebaseCall} from "src/services/firebase/FirebaseCall";
import {useAuthStore} from "stores/authStore";
const $q = useQuasar()
const router = useRouter()
Expand Down
3 changes: 2 additions & 1 deletion src/models/Suggestion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export enum SuggestionType {
REDIRECT_HAPPENED_FOR_BOOKMARK = "REDIRECT_HAPPENED_FOR_BOOKMARK",
CONTENT_CHANGE = "CONTENT_CHANGE",
FEATURE = "FEATURE",
URL = "URL"
URL = "URL",
RESTART="RESTART"
}

export enum StaticSuggestionIdent {
Expand Down
54 changes: 32 additions & 22 deletions src/pages/SettingsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@
<q-tab name="appearance" label="Appearance"/>
<q-tab name="account" label="Account"/>
<q-tab name="subscription" label="Subscription" icon="o_shopping_bag"/>
<q-tab name="sharing" label="Sharing" :class="useAuthStore().userMayAccess(AccessItem.SHARE) ? 'text-black':'text-grey'"/>
<q-tab name="syncing" label="Syncing" :class="useAuthStore().userMayAccess(AccessItem.SYNC) ? 'text-black':'text-grey'"/>
<q-tab name="sharing" label="Sharing"
:class="useAuthStore().userMayAccess(AccessItem.SHARE) ? 'text-black':'text-grey'"/>
<q-tab name="syncing" label="Syncing"
:class="useAuthStore().userMayAccess(AccessItem.SYNC) ? 'text-black':'text-grey'"/>
<q-tab name="thirdparty" label="Third Party Services"/>
<!-- <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="importExport" label="Import/Export"/>
<q-tab name="internals" label="Internals" v-if="devEnabled"/>
<q-tab name="featureToggles" label="Feature Toggles" v-if="useAuthStore().userMayAccess(AccessItem.FEATURE_TOGGLES)"/>
<q-tab name="featureToggles" label="Feature Toggles"
:class="useAuthStore().userMayAccess(AccessItem.FEATURE_TOGGLES) ? 'text-black':'text-grey'"/>
</q-tabs>
</div>

Expand Down Expand Up @@ -77,7 +80,8 @@

</div>

<div class="row items-baseline q-ma-md q-gutter-md" v-if="usePermissionsStore().hasFeature(FeatureIdent.AUTO_TAB_SWITCHER)">
<div class="row items-baseline q-ma-md q-gutter-md"
v-if="usePermissionsStore().hasFeature(FeatureIdent.AUTO_TAB_SWITCHER)">
<div class="col-3">
Tab Switching Time in seconds
</div>
Expand Down Expand Up @@ -107,7 +111,8 @@
</div>
</div>

<div class="row items-baseline q-ma-md q-gutter-md" v-if="usePermissionsStore().hasFeature(FeatureIdent.OPENTABS_THRESHOLD)">
<div class="row items-baseline q-ma-md q-gutter-md"
v-if="usePermissionsStore().hasFeature(FeatureIdent.OPENTABS_THRESHOLD)">
<div class="col-3">
Warning Thresholds
</div>
Expand Down Expand Up @@ -169,7 +174,7 @@
</div>

<div v-if="tab === 'account'">
<AccountSettings />
<AccountSettings/>
</div>

<div v-if="tab === 'subscription'">
Expand Down Expand Up @@ -381,24 +386,29 @@

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

<q-banner rounded class="bg-grey-1 text-primary">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 v-if="!useAuthStore().userMayAccess(AccessItem.FEATURE_TOGGLES)" rounded class="bg-grey-1 text-primary">
To use feature toggles, you need to have a (free) account.
</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"/>
<template v-else>
<q-banner rounded class="bg-grey-1 text-primary">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"/>
</div>
</div>
</div>

</template>
</div>

</div>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/SidePanelPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
{{ toolbarTitle(tabsets as Tabset[]) }}
<q-icon v-if="LocalStorage.getItem(SYNC_TYPE) as SyncType === SyncType.GITHUB"
class="q-ml-none" name="sync" size="12px">
<q-tooltip class="tooltip-small">Tabsets are being synced</q-tooltip>
<q-tooltip class="tooltip-small">Tabsets synced via {{LocalStorage.getItem(SYNC_GITHUB_URL)}}</q-tooltip>
</q-icon>
<q-icon v-if="LocalStorage.getItem(SYNC_TYPE) as SyncType === SyncType.MANAGED_GIT"
class="q-ml-none" name="sync" size="12px">
Expand Down Expand Up @@ -293,7 +293,7 @@ import {useVOnboarding, VOnboardingStep, VOnboardingWrapper} from 'v-onboarding'
import {FirebaseCall} from "src/services/firebase/FirebaseCall";
import getScrollTarget = scroll.getScrollTarget;
import InfoMessageWidget from "components/widgets/InfoMessageWidget.vue";
import {SYNC_TYPE, TITLE_IDENT} from "boot/constants";
import {SYNC_GITHUB_URL, SYNC_TYPE, TITLE_IDENT} from "boot/constants";
import {collection, getDoc, doc, onSnapshot, setDoc, addDoc, getDocs} from "firebase/firestore";
import {firestore} from "boot/firebase";
import {Account} from "src/models/Account";
Expand Down
7 changes: 4 additions & 3 deletions src/pages/helper/SubscriptionSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ import {getFirestore} from "firebase/firestore";
import {collection, setDoc, doc, getDocs} from "firebase/firestore";
import userHasClaim from "src/services/stripe/isUserPremium";
import {createCheckoutSession} from "src/services/stripe/createCheckoutSession";
import {useAuthStore} from "stores/authStore";
const {inBexMode} = useUtils()
Expand Down Expand Up @@ -120,9 +121,9 @@ watchEffect(() => {
const subscribe = async () => {
if (userCredentials.value) {
console.log("xxx", userCredentials.value?.user?.uid)
await createCheckoutSession(userCredentials.value.user?.uid || '')
if (useAuthStore().isAuthenticated()) {
console.log("xxx", useAuthStore().user.uid)
await createCheckoutSession(useAuthStore().user.uid)
}
}
Expand Down
17 changes: 13 additions & 4 deletions src/pages/helper/SyncingSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
<script setup lang="ts">
import {SyncType} from "stores/appStore";
import {ref, watchEffect} from "vue";
import {LocalStorage} from "quasar";
import {LocalStorage, uid} from "quasar";
import {
SUBSCRIPTION_ID_IDENT,
SYNC_COUCHDB_PASSWORD,
Expand All @@ -305,12 +305,15 @@ import {
SYNC_GITHUB_TOKEN,
SYNC_GITHUB_URL,
SYNC_GITLAB_TOKEN,
SYNC_GITLAB_URL, SYNC_TYPE
SYNC_GITLAB_URL,
SYNC_TYPE
} from "boot/constants";
import GitPersistentService from "src/services/persistence/GitPersistentService";
import {FirebaseCall} from "src/services/firebase/FirebaseCall";
import {Tabset, TabsetSharing} from "src/models/Tabset";
import {useTabsetService} from "src/services/TabsetService2";
import {useSuggestionsStore} from "stores/suggestionsStore";
import {Suggestion, SuggestionType} from "src/models/Suggestion";
const emits = defineEmits(['wasClicked'])
Expand Down Expand Up @@ -397,8 +400,14 @@ const testDbConnection = async () => {
}
}
const startGitSyncing = () => LocalStorage.set(SYNC_TYPE, tempSyncOption.value)
const stopGitSyncing = () => LocalStorage.set(SYNC_TYPE, SyncType.NONE)
const startGitSyncing = () => {
LocalStorage.set(SYNC_TYPE, tempSyncOption.value)
useSuggestionsStore().addSuggestion(new Suggestion(uid(),"Restart Required", "Please restart tabsets by clicking the button","",SuggestionType.RESTART))
}
const stopGitSyncing = () => {
LocalStorage.set(SYNC_TYPE, SyncType.NONE)
useSuggestionsStore().addSuggestion(new Suggestion(uid(),"Restart Required", "Please restart tabsets by clicking the button","",SuggestionType.RESTART))
}
const startSyncMessage = (targetType: SyncType) => testResult.value === 'success' &&
(!syncType.value || syncType.value === SyncType.NONE) &&
Expand Down
144 changes: 144 additions & 0 deletions src/pages/mainpanel/FullPageLoginPage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<template>
<div class="q-ma-xl row justify-center items-center">
<div class="col-12 text-right text-black" style="max-width:500px;margin-top:200px;">
<template v-if="!mailSent">
<div class="row q-ma-xs">
<div class="col-7">
<q-input outlined type="email" v-model="email" label="Your email address" dense/>
</div>
<div class="col-5">
<q-btn :label="(!email || email.length === 0) ? 'Sign in' : (password.length > 0 ? 'Sign in':'Send Link')"
color="primary"
style="width:110px"
:loading="password.length === 0 && loading"
:disable="mailSent"
@click="signin(false)"/>
</div>
</div>
<div class="row q-ma-xs">
<div class="col-7">
<q-input outlined type="password" v-model="password" label="Password" dense/>
</div>
<div class="col-5">
<q-btn label="Sign Up" color="bg-primary text-black"
style="width:110px"
:loading="password.length > 0 && loading"
:disable="mailSent || password.length === 0"
@click="signin(true)"/>
</div>
</div>
<div class="row q-ma-xs q-ml-none">
<div class="col-7 q-ml-xs text-body2 text-grey-7 text-left" style="font-size:smaller">
<span
v-if="(!email || email.trim().length === 0) && password.length === 0">Or keep using tabsets w/o account...</span>
<span v-else-if="password.length === 0">We'll send a link to sign in/up</span>
<span v-else></span>
</div>
<div class="col" style="font-size:smaller">
<span class="q-mr-md cursor-pointer text-blue-5"
@click="NavigationService.openSingleTab('')">What's that?</span>
</div>
</div>

<div class="row q-ma-xs">
<q-btn flat label="Home" @click="goto('/tabsets')"/>
</div>
</template>
<Transition name="bounceInLeft" appear v-else>
<div class="text-caption text-black text-left">
please check your mail... (and maybe spam folder)<br>
<span class="text-warning">Make sure to open the link in <b>this</b> window</span>
</div>

</Transition>
</div>
</div>
</template>

<script lang="ts" setup>
import NavigationService from "src/services/NavigationService";
import {ref} from "vue";
import {LocalStorage} from "quasar";
import {CURRENT_USER_EMAIL, EMAIL_LINK_REDIRECT_DOMAIN} from "boot/constants";
import {
createUserWithEmailAndPassword,
getAuth,
sendSignInLinkToEmail,
signInWithEmailAndPassword,
UserCredential
} from "firebase/auth";
import {useAuthStore} from "stores/authStore";
import {NotificationType, useNotificationHandler} from "src/services/ErrorHandler";
import {useUtils} from "src/services/Utils";
import {useRouter} from "vue-router";
const {handleError} = useNotificationHandler()
const {sendMsg} = useUtils()
const emits = defineEmits(['hideLogin'])
const router = useRouter()
const email = ref(LocalStorage.getItem(CURRENT_USER_EMAIL) as string)
const password = ref('')
const loading = ref<boolean>(false)
const mailSent = ref<boolean>(false)
const actionCodeSettings = {
// URL must be in the authorized domains list in the Firebase Console.
//url: 'http://localhost:9000',
url: EMAIL_LINK_REDIRECT_DOMAIN,
handleCodeInApp: true,
};
const signin = async (newUser: boolean) => {
loading.value = true
const auth = getAuth();
if (email.value && password.value) {
try {
let userCredential: UserCredential = null as unknown as UserCredential
if (newUser) {
userCredential = await createUserWithEmailAndPassword(auth, email.value, password.value)
} else {
userCredential = await signInWithEmailAndPassword(auth, email.value, password.value)
}
const user = userCredential.user;
LocalStorage.set(CURRENT_USER_EMAIL, email.value);
console.log("user!!!", user)
useAuthStore().setUser(user)
loading.value = false
emits('hideLogin')
} catch (error) {
//console.error("error", error)
handleError(error, NotificationType.TOAST)
loading.value = false
}
} else {
console.log("actionCodeSettings", actionCodeSettings)
sendSignInLinkToEmail(auth, email.value, actionCodeSettings)
.then(() => {
loading.value = false
mailSent.value = true
setTimeout(() => {
mailSent.value = false
emits('hideLogin')
}, 5000
)
window.localStorage.setItem(CURRENT_USER_EMAIL, email.value);
sendMsg('SET_EMAIL_FOR_SIGN_IN', {"email": email.value})
})
.catch((error) => {
//console.error("error", error)
handleError(error, NotificationType.TOAST)
loading.value = false
mailSent.value = false
});
}
}
const goto = (where: string) => router.push(where)
</script>
5 changes: 5 additions & 0 deletions src/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ const routes: RouteRecordRaw[] = [
component: () => import('layouts/PlainLayout.vue'),
children: [{path: '', component: () => import('pages/StartPage.vue')}],
},
{
path: '/login',
component: () => import('layouts/PlainLayout.vue'),
children: [{path: '', component: () => import('pages/mainpanel/FullPageLoginPage.vue')}],
},
{
path: '/fullpage',
component: () => import('layouts/PlainLayout.vue'),
Expand Down
Loading

0 comments on commit a8577a4

Please sign in to comment.