release v2.0.0 #4

Merged
crimsen merged 481 commits from develop into master 2024-01-18 15:15:08 +00:00
7 changed files with 36 additions and 35 deletions
Showing only changes of commit 368ca23c56 - Show all commits

View File

@ -15,7 +15,6 @@
"lint": "eslint --ext .js,.ts,.vue ./src ./api"
},
"dependencies": {
"@capacitor/storage": "^1.2.3",
"@flaschengeist/api": "file:./api",
"@flaschengeist/users": "^1.0.0-alpha.1",
"axios": "^0.24.0",
@ -23,7 +22,8 @@
"quasar": "^2.3.3"
},
"devDependencies": {
"@flaschengeist/types": "^1.0.0-alpha.6",
"@capacitor/core": "^3.3.2",
"@capacitor/storage": "^1.2.3",
"@quasar/app": "^3.2.3",
"@quasar/extras": "^1.12.1",
"@types/node": "^14.17.34",

View File

@ -31,7 +31,7 @@ module.exports = configure(function (/* ctx */) {
// app boot file (/src/boot)
// --> boot files are part of "main.js"
// 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
css: ['app.scss'],

View File

@ -1,18 +1,31 @@
/**
* This boot file registers interceptors for axios
*/
import { useMainStore, api } from '@flaschengeist/api';
import { AxiosError } from 'axios';
import { boot } from 'quasar/wrappers';
import config from 'src/config';
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') {
const obj = o as { [index: string]: unknown };
if (typeof entity === 'object') {
const obj = entity as { [index: string]: unknown };
for (const prop in obj) {
if (obj.hasOwnProperty(prop) && !!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));
} else if (
typeof obj[prop] === 'object' &&
@ -26,12 +39,12 @@ function minify(o: unknown, cloned = false) {
}
return obj;
}
return o;
return entity;
}
export default boot(({ router }) => {
// 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
@ -93,5 +106,3 @@ export default boot(({ router }) => {
}
);
});
export { api };

View File

@ -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
});
});

View File

@ -1,3 +1,6 @@
/**
* This boot file registers login / authentification related axios interceptors
*/
import { useMainStore, hasPermissions } from '@flaschengeist/api';
import { boot } from 'quasar/wrappers';
import { RouteRecord } from 'vue-router';
@ -6,9 +9,11 @@ export default boot(({ router }) => {
router.beforeResolve((to, from, next) => {
const store = useMainStore();
// Skip if same path
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)
// Check login is ok
if (!store.session || store.session.expires <= new Date()) {
@ -30,6 +35,7 @@ export default boot(({ router }) => {
return next({ name: 'login', query: { redirect: to.fullPath } });
}
} else {
// Public space just handle login loops
if (to.name == 'login' && store.user && !to.params['logout']) {
// Called login while already logged in
return next({ name: 'dashboard' });

View File

@ -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 { api } from 'src/boot/axios';
import { boot } from 'quasar/wrappers';
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 **************
@ -265,10 +264,9 @@ function loadPlugin(
}
async function loadBaseUrl() {
return PersistentStorage.get<string>('baseURL').then((url) => {
if (url !== null) api.defaults.baseURL = url;
console.log('loaded: ', url, api.defaults.baseURL);
});
const url = await PersistentStorage.get<string>('baseURL');
if (url !== null) api.defaults.baseURL = url;
return url;
}
/**
* Loading backend information

View File

@ -18,7 +18,7 @@
import { useRouter } from 'vue-router';
import { notEmpty, PersistentStorage } from '@flaschengeist/api';
import { defineComponent, ref } from 'vue';
import { api } from 'boot/axios';
import { api } from '@flaschengeist/api';
export default defineComponent({
name: 'PageBackend',