From d5e4571b733d8d2cc8a1f6e101d65a7a265fb732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Fri, 13 Nov 2020 18:48:50 +0100 Subject: [PATCH] =?UTF-8?q?[Plugin]=20Errorpage=20wenn=20Plugins=20nicht?= =?UTF-8?q?=20verf=C3=BCgbar=20sind.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/boot/plugins.ts | 20 ++++++++++---------- src/pages/PluginError.vue | 34 ++++++++++++++++++++++++++++++++++ src/router/routes.ts | 7 ++++++- 3 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 src/pages/PluginError.vue diff --git a/src/boot/plugins.ts b/src/boot/plugins.ts index 382a85f..6a3b597 100644 --- a/src/boot/plugins.ts +++ b/src/boot/plugins.ts @@ -1,12 +1,12 @@ import {boot} from 'quasar/wrappers'; import {RouteConfig} from 'vue-router'; +import {VueRouter} from "vue-router/types/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 !! @@ -148,7 +148,8 @@ function loadPlugin( modules: string[], backendpromise: Promise, plugins: Plugin[], - store: Store + store: Store, + router: VueRouter ): FG_Plugin.LoadedPlugins { modules.forEach(requiredModule => { const plugin = plugins.find(plugin => { @@ -159,15 +160,13 @@ function loadPlugin( console.log(backend) if (backend) { const missedPlugins: string[] = [] - plugin.requiredBackendModules.every(requiredBackendModule => { + plugin.requiredBackendModules.every((requiredBackendModule: string) => { 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' + router.push({name: 'error'}). + catch(err => { + console.warn(err) }) } return requiredBackendModule in backend.plugins @@ -269,9 +268,10 @@ export default boot>(({Vue, router, store}) => { config.requiredModules, backendPromise, plugins, - store + store, + router ); - loadedPlugins = loadPlugin(loadedPlugins, config.loadModules, backendPromise, plugins, store); + loadedPlugins = loadPlugin(loadedPlugins, config.loadModules, backendPromise, plugins, store, router); loadedPlugins.widgets.sort((a, b) => b.priority - a.priority); diff --git a/src/pages/PluginError.vue b/src/pages/PluginError.vue new file mode 100644 index 0000000..8e456a3 --- /dev/null +++ b/src/pages/PluginError.vue @@ -0,0 +1,34 @@ + + + + + diff --git a/src/router/routes.ts b/src/router/routes.ts index 9d45aac..2c45c4b 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -22,7 +22,7 @@ const routes: RouteConfig[] = [ path: '/main', redirect: 'dashboard', component: () => import('layouts/MainLayout.vue'), - meta: { permissions: ['user']}, + meta: { permissions: ['user'] }, children: [ { name: 'dashboard', @@ -38,6 +38,11 @@ const routes: RouteConfig[] = [ } ] }, + { + path: '/error', + name: 'error', + component: () => import('pages/PluginError.vue') + }, // Always leave this as last one, // but you can also remove it