Compare commits
2 Commits
5952c9b7f2
...
53951daa25
Author | SHA1 | Date |
---|---|---|
Ferdinand Thiessen | 53951daa25 | |
Ferdinand Thiessen | 59920e23a5 |
|
@ -103,24 +103,22 @@ export const useMainStore = defineStore({
|
|||
},
|
||||
|
||||
async loadNotifications(flaschengeist: FG_Plugin.Flaschengeist) {
|
||||
const params =
|
||||
const { data } = await api.get<FG.Notification[]>('/notifications', {
|
||||
params:
|
||||
this.notifications.length > 0
|
||||
? { from: this.notifications[this.notifications.length - 1].time }
|
||||
: {};
|
||||
const { data } = await api.get<FG.Notification[]>('/notifications', { params: params });
|
||||
const notifications: FG_Plugin.Notification[] = [];
|
||||
: {},
|
||||
});
|
||||
|
||||
const notes = [] as FG_Plugin.Notification[];
|
||||
data.forEach((n) => {
|
||||
n.time = new Date(n.time);
|
||||
notifications.push(
|
||||
(flaschengeist?.plugins.filter((p) => p.name === n.plugin)[0]?.notification)(
|
||||
/*||
|
||||
translateNotification*/
|
||||
n
|
||||
)
|
||||
);
|
||||
const plugin = flaschengeist?.plugins.filter((p) => p.id === n.plugin)[0];
|
||||
if (!plugin) console.debug('Could not find a parser for this notification', n);
|
||||
else notes.push(plugin.notification(n));
|
||||
});
|
||||
this.notifications.push(...notifications);
|
||||
return notifications;
|
||||
this.notifications.push(...notes);
|
||||
return notes;
|
||||
},
|
||||
|
||||
async removeNotification(id: number) {
|
||||
|
|
|
@ -40,10 +40,10 @@ module.exports = configure(function (/* ctx */) {
|
|||
extras: [
|
||||
// 'eva-icons',
|
||||
// 'fontawesome-v5',
|
||||
// 'ionicons-v4',
|
||||
// 'ionicons-v5',
|
||||
// 'line-awesome',
|
||||
// 'material-icons',
|
||||
'mdi-v5',
|
||||
'mdi-v6',
|
||||
// 'themify',
|
||||
|
||||
// 'roboto-font-latin-ext', // this or either 'roboto-font', NEVER both!
|
||||
|
@ -110,7 +110,7 @@ module.exports = configure(function (/* ctx */) {
|
|||
|
||||
// https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-framework
|
||||
framework: {
|
||||
iconSet: 'mdi-v5', // Quasar icon set
|
||||
iconSet: 'mdi-v6', // Quasar icon set
|
||||
lang: 'de', // Quasar language pack
|
||||
config: {
|
||||
dark: 'auto',
|
||||
|
|
|
@ -231,7 +231,7 @@ function loadPlugin(
|
|||
backend: Backend
|
||||
) {
|
||||
// Check if already loaded
|
||||
if (loadedPlugins.plugins.findIndex((p) => p.name === plugin.name) !== -1) return true;
|
||||
if (loadedPlugins.plugins.findIndex((p) => p.id === plugin.id) !== -1) return true;
|
||||
|
||||
// Check backend dependencies
|
||||
if (
|
||||
|
@ -242,7 +242,7 @@ function loadPlugin(
|
|||
true) /* validate the version, semver440 from python is... tricky on node*/
|
||||
)
|
||||
) {
|
||||
console.error(`Plugin ${plugin.name}: Backend modules not satisfied`);
|
||||
console.error(`Plugin ${plugin.id}: Backend modules not satisfied`);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -266,11 +266,12 @@ function loadPlugin(
|
|||
}
|
||||
|
||||
if (plugin.widgets.length > 0) {
|
||||
plugin.widgets.forEach((widget) => (widget.name = plugin.name + '_' + widget.name));
|
||||
plugin.widgets.forEach((widget) => (widget.name = plugin.id + '.' + widget.name));
|
||||
Array.prototype.push.apply(loadedPlugins.widgets, plugin.widgets);
|
||||
}
|
||||
|
||||
loadedPlugins.plugins.push({
|
||||
id: plugin.id,
|
||||
name: plugin.name,
|
||||
version: plugin.version,
|
||||
notification: plugin.notification?.bind({}) || translateNotification,
|
||||
|
@ -315,13 +316,13 @@ export default boot(async ({ router, app }) => {
|
|||
|
||||
const BreakError = {};
|
||||
try {
|
||||
PLUGINS.plugins.forEach((plugin, name) => {
|
||||
PLUGINS.plugins.forEach((plugin, id) => {
|
||||
if (!loadPlugin(loadedPlugins, plugin, backend)) {
|
||||
void router.push({ name: 'error' });
|
||||
|
||||
Notify.create({
|
||||
type: 'negative',
|
||||
message: `Fehler beim Laden: Bitte wende dich an den Admin (error: PNF-${name}!`,
|
||||
message: `Fehler beim Laden: Bitte wende dich an den Admin (error: PNF-${id}!`,
|
||||
timeout: 10000,
|
||||
progress: true,
|
||||
});
|
||||
|
|
|
@ -19,7 +19,11 @@
|
|||
{{ notifications.length }}
|
||||
</q-badge>
|
||||
<q-menu style="max-height: 400px; overflow: auto">
|
||||
<q-btn v-if="useNative && noPermission" label="Benachrichtigungen erlauben" @click="requestPermission" />
|
||||
<q-btn
|
||||
v-if="useNative && noPermission"
|
||||
label="Benachrichtigungen erlauben"
|
||||
@click="requestPermission"
|
||||
/>
|
||||
<template v-if="notifications.length > 0">
|
||||
<Notification
|
||||
v-for="(notification, index) in notifications"
|
||||
|
@ -40,7 +44,13 @@
|
|||
</q-toolbar>
|
||||
</q-header>
|
||||
|
||||
<q-drawer v-model="leftDrawer" side="left" bordered :mini="leftDrawerMini" @click.capture="openMenu">
|
||||
<q-drawer
|
||||
v-model="leftDrawer"
|
||||
side="left"
|
||||
bordered
|
||||
:mini="leftDrawerMini"
|
||||
@click.capture="openMenu"
|
||||
>
|
||||
<!-- Plugins -->
|
||||
<essential-expansion-link
|
||||
v-for="(entry, index) in mainLinks"
|
||||
|
@ -49,7 +59,11 @@
|
|||
@add-short-cut="addShortcut"
|
||||
/>
|
||||
<q-separator />
|
||||
<essential-link v-for="(entry, index) in essentials" :key="'essential' + index" :entry="entry" />
|
||||
<essential-link
|
||||
v-for="(entry, index) in essentials"
|
||||
:key="'essential' + index"
|
||||
:entry="entry"
|
||||
/>
|
||||
</q-drawer>
|
||||
<q-page-container>
|
||||
<router-view />
|
||||
|
@ -91,7 +105,7 @@ export default defineComponent({
|
|||
const router = useRouter();
|
||||
const mainStore = useMainStore();
|
||||
const flaschengeist = inject<FG_Plugin.Flaschengeist>('flaschengeist');
|
||||
const leftDrawer = ref(true);
|
||||
const leftDrawer = ref(false);
|
||||
const leftDrawerMini = ref(false);
|
||||
const mainLinks = flaschengeist?.menuLinks || [];
|
||||
const notifications = computed(() => mainStore.notifications.slice().reverse());
|
||||
|
@ -129,11 +143,15 @@ export default defineComponent({
|
|||
}
|
||||
|
||||
function requestPermission() {
|
||||
void window.Notification.requestPermission().then((p) => (noPermission.value = p !== 'granted'));
|
||||
void window.Notification.requestPermission().then(
|
||||
(p) => (noPermission.value = p !== 'granted')
|
||||
);
|
||||
}
|
||||
|
||||
function pollNotification() {
|
||||
void mainStore.loadNotifications(<FG_Plugin.Flaschengeist>flaschengeist).then((notifications) => {
|
||||
void mainStore
|
||||
.loadNotifications(<FG_Plugin.Flaschengeist>flaschengeist)
|
||||
.then((notifications) => {
|
||||
if (useNative && !noPermission.value)
|
||||
notifications.forEach(
|
||||
(notif) =>
|
||||
|
|
|
@ -19,9 +19,9 @@ export default defineComponent({
|
|||
name: 'PageDashboard',
|
||||
setup() {
|
||||
const flaschengeist = inject<FG_Plugin.Flaschengeist>('flaschengeist');
|
||||
const widgets = computed(() => {
|
||||
return flaschengeist?.widgets.filter((widget) => hasPermissions(widget.permissions));
|
||||
});
|
||||
const widgets = computed(() =>
|
||||
flaschengeist?.widgets.filter((widget) => hasPermissions(widget.permissions))
|
||||
);
|
||||
|
||||
return {
|
||||
widgets,
|
||||
|
|
Loading…
Reference in New Issue