Remove vue3-logger

This commit is contained in:
Ramon Wenger 2023-02-02 14:13:27 +01:00
parent 3afeea928f
commit 6ad1df8310
2 changed files with 148 additions and 142 deletions

View File

@ -12,7 +12,6 @@ import ME_QUERY from '@/graphql/gql/queries/meQuery.gql';
import VueModal from '@/plugins/modal';
import VueRemoveEdges from '@/plugins/edges';
import VueMatomo from 'vue-matomo';
import VueLogger from 'vuejs3-logger';
import { createApolloProvider } from '@vue/apollo-option';
import { joiningClass, loginRequired, unauthorizedAccess } from '@/router/guards';
import flavorPlugin from '@/plugins/flavor';
@ -28,24 +27,16 @@ const apolloProvider = createApolloProvider({
});
configureCompat({
MODE: 2
MODE: 2,
});
const app = createApp(App);
app.use(store);
const isProduction = process.env.NODE_ENV === 'production';
app.use(VueModal);
app.use(VueRemoveEdges);
app.use(VueVimeoPlayer);
app.use(VueLogger, {
isEnabled: true,
logLevel: isProduction ? 'error' : 'debug',
stringifyArguments: false,
showConsoleColors: true,
});
app.use(apolloProvider);
app.use(router);
@ -57,7 +48,6 @@ app.use(router);
app.directive('scroll-to', VueScrollTo);
app.use(flavorPlugin);
if (process.env.MATOMO_HOST) {
@ -73,24 +63,28 @@ app.directive('auto-grow', autoGrow);
/* guards */
function redirectUsersWithoutValidLicense() {
return privateApolloClient.query({
return privateApolloClient
.query({
query: ME_QUERY,
}).then(({data}) => data.me.expiryDate == null);
})
.then(({ data }) => data.me.expiryDate == null);
}
function redirectStudentsWithoutClass() {
return privateApolloClient.query({
return privateApolloClient
.query({
query: ME_QUERY,
}).then(({data}) => data.me.schoolClasses.length === 0 && !data.me.isTeacher);
})
.then(({ data }) => data.me.schoolClasses.length === 0 && !data.me.isTeacher);
}
function redirectUsersToOnboarding() {
return privateApolloClient.query({
return privateApolloClient
.query({
query: ME_QUERY,
}).then(({data}) => !data.me.onboardingVisited);
})
.then(({ data }) => !data.me.onboardingVisited);
}
function networkErrorCallback(statusCode) {
@ -99,7 +93,6 @@ function networkErrorCallback(statusCode) {
}
}
router.beforeEach(async (to, from, next) => {
// todo: make logger work outside vue app
// const logger = inject('vuejs3-logger');
@ -130,21 +123,27 @@ router.beforeEach(async (to, from, next) => {
return;
}
if (to.name && to.name !== 'licenseActivation' && loginRequired(to) && await redirectUsersWithoutValidLicense()) {
if (to.name && to.name !== 'licenseActivation' && loginRequired(to) && (await redirectUsersWithoutValidLicense())) {
// logger.$log.debug('redirecting to licenseActivation', to, null);
console.log('redirecting to licenseActivation', to, null);
next({ name: 'licenseActivation' });
return;
}
if (!joiningClass(to) && loginRequired(to) && await redirectStudentsWithoutClass()) {
if (!joiningClass(to) && loginRequired(to) && (await redirectStudentsWithoutClass())) {
//logger.$log.debug('redirecting to join-class', to);
//logger.$log.debug('await redirectStudentsWithoutClass()', await redirectStudentsWithoutClass());
next({ name: 'join-class' });
return;
}
if ((to.name && to.name.indexOf('onboarding') === -1) && !joiningClass(to) && loginRequired(to) && await redirectUsersToOnboarding()) {
if (
to.name &&
to.name.indexOf('onboarding') === -1 &&
!joiningClass(to) &&
loginRequired(to) &&
(await redirectUsersToOnboarding())
) {
//logger.$log.debug('redirecting to onboarding-start', to);
next({ name: 'onboarding-start' });
return;

File diff suppressed because one or more lines are too long