release v2.0.0 #4

Merged
crimsen merged 481 commits from develop into master 2024-01-18 15:15:08 +00:00
8 changed files with 78 additions and 14 deletions
Showing only changes of commit 5f7c515228 - Show all commits

View File

@ -1,4 +1,4 @@
module.exports = {
singleQuote: true,
semi: false
}
semi: true
};

View File

@ -24,7 +24,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: ['composition-api', 'axios', 'filter', 'login', 'plugins', 'loading'],
boot: ['composition-api', 'axios', 'plugins', 'loading', 'filter', 'login'],
// https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-css
css: ['app.scss'],
@ -89,7 +89,7 @@ module.exports = configure(function(ctx) {
iconSet: 'material-icons', // Quasar icon set
lang: 'de', // Quasar language pack
config: {
dark: 'auto'
dark: 'auto'
},
// Possible values for "importStrategy":
@ -105,7 +105,7 @@ module.exports = configure(function(ctx) {
// directives: [],
// Quasar plugins
plugins: ['LocalStorage', 'SessionStorage', 'Loading']
plugins: ['LocalStorage', 'SessionStorage', 'Loading', 'Notify']
},
// animations: 'all', // --- includes all animations

View File

@ -1,9 +1,12 @@
import { boot } from 'quasar/wrappers';
import { RouteConfig } from 'vue-router';
import { Store } from 'vuex';
import { StateInterface } from 'src/store';
import { FG_Plugin } from 'src/plugins';
import {boot} from 'quasar/wrappers';
import {RouteConfig} from 'vue-router';
import {Store} from 'vuex';
import {StateInterface} from 'src/store';
import {FG_Plugin} from 'src/plugins';
import routes from 'src/router/routes';
import {axios} from 'boot/axios';
import {AxiosResponse} from 'axios';
import {Notify} from 'quasar';
const config = {
// Do not change required Modules !!
@ -16,6 +19,22 @@ const config = {
// combine routes from source to target
interface BackendPlugin {
permissions: string[];
version: string;
}
interface BackendPlugins {
[key: string]: BackendPlugin
}
interface Backend {
plugins: [key: string];
version: string;
}
export {Backend}
function combineRoutes(
target: RouteConfig[],
source: FG_Plugin.PluginRouteConfig[],
@ -127,6 +146,7 @@ function loadShortCuts(
function loadPlugin(
loadedPlugins: FG_Plugin.LoadedPlugins,
modules: string[],
backendpromise: Promise<Backend | null>,
plugins: Plugin[],
store: Store<any>
): FG_Plugin.LoadedPlugins {
@ -135,6 +155,29 @@ function loadPlugin(
return plugin.name == requiredModule;
});
if (plugin) {
backendpromise.then((backend) => {
console.log(backend)
if (backend) {
const missedPlugins: string[] = []
plugin.requiredBackendModules.every(requiredBackendModule => {
if (!(requiredBackendModule in backend.plugins)) {
missedPlugins.push(requiredBackendModule)
console.error(`Plugin ${requiredBackendModule} not activated in backend.`)
Notify.create({
message: `Plugin ${requiredBackendModule} not activated in backend.`,
position: 'bottom',
timeout: 5000,
type: 'negative'
})
}
return requiredBackendModule in backend.plugins
})
}
})
.catch(e => {
console.error(e)
})
if (plugin.mainRoutes) {
loadedPlugins.routes = combineRoutes(
loadedPlugins.routes,
@ -184,10 +227,26 @@ function loadPlugin(
return loadedPlugins;
}
async function getBackend(): Promise<Backend | null> {
let backend: Backend | null = null;
try {
const response: AxiosResponse<Backend> = await axios.get('/');
backend = response.data;
} catch (e) {
console.log(e);
return null;
} finally {
return backend;
}
}
// "async" is optional;
// more info on params: https://quasar.dev/quasar-cli/cli-documentation/boot-files#Anatomy-of-a-boot-file
export default boot<Store<StateInterface>>(({ Vue, router, store }) => {
export default boot<Store<StateInterface>>(({Vue, router, store}) => {
const plugins: Plugin[] = [];
const backendPromise = getBackend();
let loadedPlugins: FG_Plugin.LoadedPlugins = {
routes,
plugins: [],
@ -208,10 +267,11 @@ export default boot<Store<StateInterface>>(({ Vue, router, store }) => {
loadedPlugins = loadPlugin(
loadedPlugins,
config.requiredModules,
backendPromise,
plugins,
store
);
loadedPlugins = loadPlugin(loadedPlugins, config.loadModules, plugins, store);
loadedPlugins = loadPlugin(loadedPlugins, config.loadModules, backendPromise, plugins, store);
loadedPlugins.widgets.sort((a, b) => b.priority - a.priority);

1
src/plugins.d.ts vendored
View File

@ -30,6 +30,7 @@ declare namespace FG_Plugin {
version: string;
widgets: Widget[];
requiredModules: string[];
requiredBackendModules: string[];
mainRoutes?: PluginRouteConfig[];
outRoutes?: PluginRouteConfig[];
store?: Map<string, Module<any, StateInterface>>;

View File

@ -8,6 +8,7 @@ const plugin: FG_Plugin.Plugin = {
name: 'Balance',
mainRoutes,
requiredModules: ['User'],
requiredBackendModules: ['balance'],
version: '0.0.1',
store: new Map<string, Module<BalanceInterface, StateInterface>>([
['balance', balance]

View File

@ -3,6 +3,7 @@ import { FG_Plugin } from 'src/plugins';
const plugin: FG_Plugin.Plugin = {
name: 'Schedule',
requiredModules: [],
requiredBackendModules: ['schedule'],
version: '0.0.1',
widgets: [
{

View File

@ -9,6 +9,7 @@ const plugin: FG_Plugin.Plugin = {
name: 'User',
mainRoutes: routes,
requiredModules: [],
requiredBackendModules: ['auth'],
version: '0.0.1',
store: new Map<string, Module<any, StateInterface>>([
['user', userStore],

View File

@ -113,7 +113,7 @@ const actions: ActionTree<UserStateInterface, StateInterface> = {
setUser({ commit, state, dispatch }, data: FG.User) {
commit('setLoading');
axios
.post(`users`, data)
.post('users', data)
.then(() => {
if (state.currentUser && state.currentUser.userid === data.userid)
void dispatch('getCurrentUser');
@ -138,7 +138,7 @@ const actions: ActionTree<UserStateInterface, StateInterface> = {
.finally(() => commit('setLoading', false));
},
updateRole({ commit, state }, data: FG.Role) {
updateRole({ commit }, data: FG.Role) {
commit('setLoading');
axios
.put(`/roles/${data.id}`, data)