release v2.0.0 #4
|
@ -15,7 +15,6 @@
|
||||||
"lint": "eslint --ext .js,.ts,.vue ./src ./api"
|
"lint": "eslint --ext .js,.ts,.vue ./src ./api"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capacitor/storage": "^1.2.3",
|
|
||||||
"@flaschengeist/api": "file:./api",
|
"@flaschengeist/api": "file:./api",
|
||||||
"@flaschengeist/users": "^1.0.0-alpha.1",
|
"@flaschengeist/users": "^1.0.0-alpha.1",
|
||||||
"axios": "^0.24.0",
|
"axios": "^0.24.0",
|
||||||
|
@ -23,7 +22,8 @@
|
||||||
"quasar": "^2.3.3"
|
"quasar": "^2.3.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@flaschengeist/types": "^1.0.0-alpha.6",
|
"@capacitor/core": "^3.3.2",
|
||||||
|
"@capacitor/storage": "^1.2.3",
|
||||||
"@quasar/app": "^3.2.3",
|
"@quasar/app": "^3.2.3",
|
||||||
"@quasar/extras": "^1.12.1",
|
"@quasar/extras": "^1.12.1",
|
||||||
"@types/node": "^14.17.34",
|
"@types/node": "^14.17.34",
|
||||||
|
|
|
@ -31,7 +31,7 @@ module.exports = configure(function (/* ctx */) {
|
||||||
// app boot file (/src/boot)
|
// app boot file (/src/boot)
|
||||||
// --> boot files are part of "main.js"
|
// --> boot files are part of "main.js"
|
||||||
// https://quasar.dev/quasar-cli/boot-files
|
// https://quasar.dev/quasar-cli/boot-files
|
||||||
boot: ['axios', 'store', 'plugins', 'loading', 'login'],
|
boot: ['axios', 'store', 'plugins', 'login'],
|
||||||
|
|
||||||
// https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-css
|
// https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-css
|
||||||
css: ['app.scss'],
|
css: ['app.scss'],
|
||||||
|
|
|
@ -1,18 +1,31 @@
|
||||||
|
/**
|
||||||
|
* This boot file registers interceptors for axios
|
||||||
|
*/
|
||||||
import { useMainStore, api } from '@flaschengeist/api';
|
import { useMainStore, api } from '@flaschengeist/api';
|
||||||
import { AxiosError } from 'axios';
|
import { AxiosError } from 'axios';
|
||||||
import { boot } from 'quasar/wrappers';
|
import { boot } from 'quasar/wrappers';
|
||||||
import config from 'src/config';
|
import config from 'src/config';
|
||||||
import { clone } from '@flaschengeist/api';
|
import { clone } from '@flaschengeist/api';
|
||||||
|
|
||||||
function minify(o: unknown, cloned = false) {
|
/**
|
||||||
if (!cloned) o = clone(o);
|
* Minify data sent to backend server
|
||||||
|
*
|
||||||
|
* Drop unneeded entities which can be identified by ID.
|
||||||
|
*
|
||||||
|
* @param obj Object to minify
|
||||||
|
* @param cloned If this entity is already cloned (JSON En+Decoded)
|
||||||
|
* @returns Minified object (some types are converted, like a Date object is now a ISO string)
|
||||||
|
*/
|
||||||
|
function minify(entity: unknown, cloned = false) {
|
||||||
|
if (!cloned) entity = clone(entity);
|
||||||
|
|
||||||
if (typeof o === 'object') {
|
if (typeof entity === 'object') {
|
||||||
const obj = o as { [index: string]: unknown };
|
const obj = entity as { [index: string]: unknown };
|
||||||
|
|
||||||
for (const prop in obj) {
|
for (const prop in obj) {
|
||||||
if (obj.hasOwnProperty(prop) && !!obj[prop]) {
|
if (obj.hasOwnProperty(prop) && !!obj[prop]) {
|
||||||
if (Array.isArray(obj[prop])) {
|
if (Array.isArray(obj[prop])) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||||
obj[prop] = (<Array<unknown>>obj[prop]).map((v) => minify(v, true));
|
obj[prop] = (<Array<unknown>>obj[prop]).map((v) => minify(v, true));
|
||||||
} else if (
|
} else if (
|
||||||
typeof obj[prop] === 'object' &&
|
typeof obj[prop] === 'object' &&
|
||||||
|
@ -26,12 +39,12 @@ function minify(o: unknown, cloned = false) {
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
return o;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default boot(({ router }) => {
|
export default boot(({ router }) => {
|
||||||
// Persisted value is read in plugins.ts boot file!
|
// Persisted value is read in plugins.ts boot file!
|
||||||
api.defaults.baseURL = config.baseURL;
|
if (api.defaults.baseURL === undefined) api.defaults.baseURL = config.baseURL;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Intercept requests
|
* Intercept requests
|
||||||
|
@ -93,5 +106,3 @@ export default boot(({ router }) => {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export { api };
|
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
import { boot } from 'quasar/wrappers';
|
|
||||||
import { Loading } from 'quasar';
|
|
||||||
//import DarkCircularProgress from 'components/loading/DarkCircularProgress.vue';
|
|
||||||
|
|
||||||
// "async" is optional;
|
|
||||||
// more info on params: https://quasar.dev/quasar-cli/cli-documentation/boot-files#Anatomy-of-a-boot-file
|
|
||||||
export default boot(() => {
|
|
||||||
Loading.setDefaults({
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-ignore
|
|
||||||
// spinner: DarkCircularProgress,
|
|
||||||
// TODO : Das funktioniert wohl erstmal nicht mehr... gibt ne exception
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
/**
|
||||||
|
* This boot file registers login / authentification related axios interceptors
|
||||||
|
*/
|
||||||
import { useMainStore, hasPermissions } from '@flaschengeist/api';
|
import { useMainStore, hasPermissions } from '@flaschengeist/api';
|
||||||
import { boot } from 'quasar/wrappers';
|
import { boot } from 'quasar/wrappers';
|
||||||
import { RouteRecord } from 'vue-router';
|
import { RouteRecord } from 'vue-router';
|
||||||
|
@ -6,9 +9,11 @@ export default boot(({ router }) => {
|
||||||
router.beforeResolve((to, from, next) => {
|
router.beforeResolve((to, from, next) => {
|
||||||
const store = useMainStore();
|
const store = useMainStore();
|
||||||
|
|
||||||
|
// Skip if same path
|
||||||
if (to.path == from.path) return next();
|
if (to.path == from.path) return next();
|
||||||
|
|
||||||
if (to.path.startsWith('/main')) {
|
// Check if secured area or public
|
||||||
|
if (to.path.startsWith('/in')) {
|
||||||
// Secured area (LOGIN REQUIRED)
|
// Secured area (LOGIN REQUIRED)
|
||||||
// Check login is ok
|
// Check login is ok
|
||||||
if (!store.session || store.session.expires <= new Date()) {
|
if (!store.session || store.session.expires <= new Date()) {
|
||||||
|
@ -30,6 +35,7 @@ export default boot(({ router }) => {
|
||||||
return next({ name: 'login', query: { redirect: to.fullPath } });
|
return next({ name: 'login', query: { redirect: to.fullPath } });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Public space just handle login loops
|
||||||
if (to.name == 'login' && store.user && !to.params['logout']) {
|
if (to.name == 'login' && store.user && !to.params['logout']) {
|
||||||
// Called login while already logged in
|
// Called login while already logged in
|
||||||
return next({ name: 'dashboard' });
|
return next({ name: 'dashboard' });
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
|
import { FG_Plugin } from '@flaschengeist/types';
|
||||||
|
import { api, PersistentStorage } from '@flaschengeist/api';
|
||||||
|
import { RouteRecordRaw } from 'vue-router';
|
||||||
import { Notify, Platform } from 'quasar';
|
import { Notify, Platform } from 'quasar';
|
||||||
import { api } from 'src/boot/axios';
|
|
||||||
import { boot } from 'quasar/wrappers';
|
import { boot } from 'quasar/wrappers';
|
||||||
import routes from 'src/router/routes';
|
import routes from 'src/router/routes';
|
||||||
import { RouteRecordRaw } from 'vue-router';
|
|
||||||
import { FG_Plugin } from '@flaschengeist/types';
|
|
||||||
import { PersistentStorage } from '@flaschengeist/api';
|
|
||||||
|
|
||||||
/****************************************************
|
/****************************************************
|
||||||
******** Internal area for some magic **************
|
******** Internal area for some magic **************
|
||||||
|
@ -265,10 +264,9 @@ function loadPlugin(
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadBaseUrl() {
|
async function loadBaseUrl() {
|
||||||
return PersistentStorage.get<string>('baseURL').then((url) => {
|
const url = await PersistentStorage.get<string>('baseURL');
|
||||||
if (url !== null) api.defaults.baseURL = url;
|
if (url !== null) api.defaults.baseURL = url;
|
||||||
console.log('loaded: ', url, api.defaults.baseURL);
|
return url;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Loading backend information
|
* Loading backend information
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { notEmpty, PersistentStorage } from '@flaschengeist/api';
|
import { notEmpty, PersistentStorage } from '@flaschengeist/api';
|
||||||
import { defineComponent, ref } from 'vue';
|
import { defineComponent, ref } from 'vue';
|
||||||
import { api } from 'boot/axios';
|
import { api } from '@flaschengeist/api';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'PageBackend',
|
name: 'PageBackend',
|
||||||
|
|
Loading…
Reference in New Issue