[Plugin] Errorpage wenn Plugins nicht verfügbar sind.

This commit is contained in:
Tim Gröger 2020-11-13 18:48:50 +01:00
parent 5f7c515228
commit d5e4571b73
3 changed files with 50 additions and 11 deletions

View File

@ -1,12 +1,12 @@
import {boot} from 'quasar/wrappers'; import {boot} from 'quasar/wrappers';
import {RouteConfig} from 'vue-router'; import {RouteConfig} from 'vue-router';
import {VueRouter} from "vue-router/types/router";
import {Store} from 'vuex'; import {Store} from 'vuex';
import {StateInterface} from 'src/store'; import {StateInterface} from 'src/store';
import {FG_Plugin} from 'src/plugins'; import {FG_Plugin} from 'src/plugins';
import routes from 'src/router/routes'; import routes from 'src/router/routes';
import {axios} from 'boot/axios'; import {axios} from 'boot/axios';
import {AxiosResponse} from 'axios'; import {AxiosResponse} from 'axios';
import {Notify} from 'quasar';
const config = { const config = {
// Do not change required Modules !! // Do not change required Modules !!
@ -148,7 +148,8 @@ function loadPlugin(
modules: string[], modules: string[],
backendpromise: Promise<Backend | null>, backendpromise: Promise<Backend | null>,
plugins: Plugin[], plugins: Plugin[],
store: Store<any> store: Store<any>,
router: VueRouter
): FG_Plugin.LoadedPlugins { ): FG_Plugin.LoadedPlugins {
modules.forEach(requiredModule => { modules.forEach(requiredModule => {
const plugin = <FG_Plugin.Plugin | undefined>plugins.find(plugin => { const plugin = <FG_Plugin.Plugin | undefined>plugins.find(plugin => {
@ -159,15 +160,13 @@ function loadPlugin(
console.log(backend) console.log(backend)
if (backend) { if (backend) {
const missedPlugins: string[] = [] const missedPlugins: string[] = []
plugin.requiredBackendModules.every(requiredBackendModule => { plugin.requiredBackendModules.every((requiredBackendModule: string) => {
if (!(requiredBackendModule in backend.plugins)) { if (!(requiredBackendModule in backend.plugins)) {
missedPlugins.push(requiredBackendModule) missedPlugins.push(requiredBackendModule)
console.error(`Plugin ${requiredBackendModule} not activated in backend.`) console.error(`Plugin ${requiredBackendModule} not activated in backend.`)
Notify.create({ router.push({name: 'error'}).
message: `Plugin ${requiredBackendModule} not activated in backend.`, catch(err => {
position: 'bottom', console.warn(err)
timeout: 5000,
type: 'negative'
}) })
} }
return requiredBackendModule in backend.plugins return requiredBackendModule in backend.plugins
@ -269,9 +268,10 @@ export default boot<Store<StateInterface>>(({Vue, router, store}) => {
config.requiredModules, config.requiredModules,
backendPromise, backendPromise,
plugins, 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); loadedPlugins.widgets.sort((a, b) => b.priority - a.priority);

34
src/pages/PluginError.vue Normal file
View File

@ -0,0 +1,34 @@
<template>
<div class="fullscreen bg-blue text-white text-center q-pa-md flex flex-center">
<div>
<div>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 292.761 292.761" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new 0 0 292.761 292.761" fill="white">
<g>
<circle cx="87.493" cy="25.907" r="25.907"/>
<path d="m194.386,209.531l-42.802-36.895c-1.825-1.573-4.001-2.683-6.345-3.237l-72.533-17.136 47.755,.703v-34.439l-46.525-26.18 50.36,14.829c4.016,1.182 8.356,0.276 11.564-2.414l38.264-32.093c1.1-0.923 2.001-1.994 2.698-3.161 2.656-4.442 2.36-10.26-1.154-14.449-4.437-5.29-12.32-5.981-17.61-1.544l-33.127,27.785-45.605-13.428 41.402,1.292 16.027-13.442-6.021-2.955-3.631,3.945-18.134,2.86h-37.216c-9.665,0-17.501,7.835-17.501,17.501v90.395l.029-.024c0.252,6.569 4.819,12.433 11.527,14.019l68.966,16.292 40.024,34.501c2.834,2.442 6.318,3.639 9.787,3.639 4.213,0 8.402-1.765 11.368-5.206 5.41-6.278 4.708-15.75-1.567-21.158z"/>
<path d="m233.888,50.21l-43.49-21.349c-2.17-1.065-4.545-1.612-6.94-1.612-0.861,0-1.724,0.071-2.581,0.213l-13.243,2.2-24.213-11.886c-6.197-3.043-13.688-0.485-16.728,5.713-3.042,6.197-0.484,13.687 5.713,16.729l14.402,7.069 3.539-2.969c4.405-3.694 9.994-5.729 15.738-5.729 7.266,0 14.11,3.192 18.777,8.756 6.702,7.991 7.61,19.371 2.258,28.32-0.529,0.884-1.127,1.717-1.759,2.523l28.035,13.762c0.916,0.45 1.914,0.664 2.967,0.664 5.79,0 13.263-6.495 18.05-16.247 5.66-11.524 5.424-23.236-0.525-26.157z"/>
<path d="m102.363,202.426l2.531,6.9-13.835,65.324c-1.716,8.105 3.463,16.065 11.567,17.782 1.048,0.222 2.092,0.328 3.122,0.328 6.936-0.001 13.165-4.839 14.66-11.896l14.265-67.357-5.513-4.752-26.797-6.329z"/>
</g>
</svg>
</div>
<div class="text-h2">
Der Admin war betrunken!!
</div>
<div>
Einige Plugins konnten nicht geladen werden.<br />Sollte diese Seite jemals auftauchen, kontaktiere einen nüchternen Admin.
</div>
</div>
</div>
</template>
<script lang="ts">
import {defineComponent} from "@vue/composition-api";
export default defineComponent({
name: "PluginError.vue"
})
</script>
<style scoped>
</style>

View File

@ -22,7 +22,7 @@ const routes: RouteConfig[] = [
path: '/main', path: '/main',
redirect: 'dashboard', redirect: 'dashboard',
component: () => import('layouts/MainLayout.vue'), component: () => import('layouts/MainLayout.vue'),
meta: { permissions: ['user']}, meta: { permissions: ['user'] },
children: [ children: [
{ {
name: 'dashboard', name: 'dashboard',
@ -38,6 +38,11 @@ const routes: RouteConfig[] = [
} }
] ]
}, },
{
path: '/error',
name: 'error',
component: () => import('pages/PluginError.vue')
},
// Always leave this as last one, // Always leave this as last one,
// but you can also remove it // but you can also remove it