[Dashboard] Fixed display of widgets

This commit is contained in:
Ferdinand Thiessen 2021-03-19 17:36:34 +01:00
parent 51fcc6f9be
commit 9469cda4b0
1 changed files with 5 additions and 8 deletions

View File

@ -5,25 +5,22 @@
class="fit row justify-around items-start q-col-gutter-sm" class="fit row justify-around items-start q-col-gutter-sm"
> >
<div v-for="(item, index) in widgets" :key="index" class="col-4 full-height col-sm-6 col-xs-12"> <div v-for="(item, index) in widgets" :key="index" class="col-4 full-height col-sm-6 col-xs-12">
<component :is="item" /> <component :is="item.widget" />
</div> </div>
</q-page> </q-page>
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, defineComponent, onMounted, inject, markRaw } from 'vue'; import { computed, defineComponent, inject } from 'vue';
import { hasPermissions } from 'src/utils/permission'; import { hasPermissions } from 'src/utils/permission';
import { FG_Plugin } from 'src/plugins'; import { FG_Plugin } from 'src/plugins';
export default defineComponent({ export default defineComponent({
name: 'Dashboard', name: 'Dashboard',
setup() { setup() {
const widgets = markRaw<Array<Component>>([]);
const flaschengeist = inject<FG_Plugin.Flaschengeist>('flaschengeist'); const flaschengeist = inject<FG_Plugin.Flaschengeist>('flaschengeist');
const widgets = computed(() => {
onMounted(() => { return flaschengeist?.widgets.filter((widget) => hasPermissions(widget.permissions));
flaschengeist?.widgets.forEach((widget) => {
if (hasPermissions(widget.permissions)) widgets.push(widget.widget);
});
}); });
return { return {