Compare commits

..

No commits in common. "53951daa25a66d60c2d432ca998395d81fae5df0" and "5952c9b7f2e064dc8a65af7e724b8255b906a268" have entirely different histories.

5 changed files with 40 additions and 57 deletions

View File

@ -103,22 +103,24 @@ export const useMainStore = defineStore({
}, },
async loadNotifications(flaschengeist: FG_Plugin.Flaschengeist) { async loadNotifications(flaschengeist: FG_Plugin.Flaschengeist) {
const { data } = await api.get<FG.Notification[]>('/notifications', { const params =
params:
this.notifications.length > 0 this.notifications.length > 0
? { from: this.notifications[this.notifications.length - 1].time } ? { 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) => { data.forEach((n) => {
n.time = new Date(n.time); n.time = new Date(n.time);
const plugin = flaschengeist?.plugins.filter((p) => p.id === n.plugin)[0]; notifications.push(
if (!plugin) console.debug('Could not find a parser for this notification', n); (flaschengeist?.plugins.filter((p) => p.name === n.plugin)[0]?.notification)(
else notes.push(plugin.notification(n)); /*||
translateNotification*/
n
)
);
}); });
this.notifications.push(...notes); this.notifications.push(...notifications);
return notes; return notifications;
}, },
async removeNotification(id: number) { async removeNotification(id: number) {

View File

@ -40,10 +40,10 @@ module.exports = configure(function (/* ctx */) {
extras: [ extras: [
// 'eva-icons', // 'eva-icons',
// 'fontawesome-v5', // 'fontawesome-v5',
// 'ionicons-v5', // 'ionicons-v4',
// 'line-awesome', // 'line-awesome',
// 'material-icons', // 'material-icons',
'mdi-v6', 'mdi-v5',
// 'themify', // 'themify',
// 'roboto-font-latin-ext', // this or either 'roboto-font', NEVER both! // '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 // https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-framework
framework: { framework: {
iconSet: 'mdi-v6', // Quasar icon set iconSet: 'mdi-v5', // Quasar icon set
lang: 'de', // Quasar language pack lang: 'de', // Quasar language pack
config: { config: {
dark: 'auto', dark: 'auto',

View File

@ -231,7 +231,7 @@ function loadPlugin(
backend: Backend backend: Backend
) { ) {
// Check if already loaded // Check if already loaded
if (loadedPlugins.plugins.findIndex((p) => p.id === plugin.id) !== -1) return true; if (loadedPlugins.plugins.findIndex((p) => p.name === plugin.name) !== -1) return true;
// Check backend dependencies // Check backend dependencies
if ( if (
@ -242,7 +242,7 @@ function loadPlugin(
true) /* validate the version, semver440 from python is... tricky on node*/ true) /* validate the version, semver440 from python is... tricky on node*/
) )
) { ) {
console.error(`Plugin ${plugin.id}: Backend modules not satisfied`); console.error(`Plugin ${plugin.name}: Backend modules not satisfied`);
return false; return false;
} }
@ -266,12 +266,11 @@ function loadPlugin(
} }
if (plugin.widgets.length > 0) { if (plugin.widgets.length > 0) {
plugin.widgets.forEach((widget) => (widget.name = plugin.id + '.' + widget.name)); plugin.widgets.forEach((widget) => (widget.name = plugin.name + '_' + widget.name));
Array.prototype.push.apply(loadedPlugins.widgets, plugin.widgets); Array.prototype.push.apply(loadedPlugins.widgets, plugin.widgets);
} }
loadedPlugins.plugins.push({ loadedPlugins.plugins.push({
id: plugin.id,
name: plugin.name, name: plugin.name,
version: plugin.version, version: plugin.version,
notification: plugin.notification?.bind({}) || translateNotification, notification: plugin.notification?.bind({}) || translateNotification,
@ -316,13 +315,13 @@ export default boot(async ({ router, app }) => {
const BreakError = {}; const BreakError = {};
try { try {
PLUGINS.plugins.forEach((plugin, id) => { PLUGINS.plugins.forEach((plugin, name) => {
if (!loadPlugin(loadedPlugins, plugin, backend)) { if (!loadPlugin(loadedPlugins, plugin, backend)) {
void router.push({ name: 'error' }); void router.push({ name: 'error' });
Notify.create({ Notify.create({
type: 'negative', type: 'negative',
message: `Fehler beim Laden: Bitte wende dich an den Admin (error: PNF-${id}!`, message: `Fehler beim Laden: Bitte wende dich an den Admin (error: PNF-${name}!`,
timeout: 10000, timeout: 10000,
progress: true, progress: true,
}); });

View File

@ -19,11 +19,7 @@
{{ notifications.length }} {{ notifications.length }}
</q-badge> </q-badge>
<q-menu style="max-height: 400px; overflow: auto"> <q-menu style="max-height: 400px; overflow: auto">
<q-btn <q-btn v-if="useNative && noPermission" label="Benachrichtigungen erlauben" @click="requestPermission" />
v-if="useNative && noPermission"
label="Benachrichtigungen erlauben"
@click="requestPermission"
/>
<template v-if="notifications.length > 0"> <template v-if="notifications.length > 0">
<Notification <Notification
v-for="(notification, index) in notifications" v-for="(notification, index) in notifications"
@ -44,13 +40,7 @@
</q-toolbar> </q-toolbar>
</q-header> </q-header>
<q-drawer <q-drawer v-model="leftDrawer" side="left" bordered :mini="leftDrawerMini" @click.capture="openMenu">
v-model="leftDrawer"
side="left"
bordered
:mini="leftDrawerMini"
@click.capture="openMenu"
>
<!-- Plugins --> <!-- Plugins -->
<essential-expansion-link <essential-expansion-link
v-for="(entry, index) in mainLinks" v-for="(entry, index) in mainLinks"
@ -59,11 +49,7 @@
@add-short-cut="addShortcut" @add-short-cut="addShortcut"
/> />
<q-separator /> <q-separator />
<essential-link <essential-link v-for="(entry, index) in essentials" :key="'essential' + index" :entry="entry" />
v-for="(entry, index) in essentials"
:key="'essential' + index"
:entry="entry"
/>
</q-drawer> </q-drawer>
<q-page-container> <q-page-container>
<router-view /> <router-view />
@ -105,7 +91,7 @@ export default defineComponent({
const router = useRouter(); const router = useRouter();
const mainStore = useMainStore(); const mainStore = useMainStore();
const flaschengeist = inject<FG_Plugin.Flaschengeist>('flaschengeist'); const flaschengeist = inject<FG_Plugin.Flaschengeist>('flaschengeist');
const leftDrawer = ref(false); const leftDrawer = ref(true);
const leftDrawerMini = ref(false); const leftDrawerMini = ref(false);
const mainLinks = flaschengeist?.menuLinks || []; const mainLinks = flaschengeist?.menuLinks || [];
const notifications = computed(() => mainStore.notifications.slice().reverse()); const notifications = computed(() => mainStore.notifications.slice().reverse());
@ -143,15 +129,11 @@ export default defineComponent({
} }
function requestPermission() { function requestPermission() {
void window.Notification.requestPermission().then( void window.Notification.requestPermission().then((p) => (noPermission.value = p !== 'granted'));
(p) => (noPermission.value = p !== 'granted')
);
} }
function pollNotification() { function pollNotification() {
void mainStore void mainStore.loadNotifications(<FG_Plugin.Flaschengeist>flaschengeist).then((notifications) => {
.loadNotifications(<FG_Plugin.Flaschengeist>flaschengeist)
.then((notifications) => {
if (useNative && !noPermission.value) if (useNative && !noPermission.value)
notifications.forEach( notifications.forEach(
(notif) => (notif) =>

View File

@ -19,9 +19,9 @@ export default defineComponent({
name: 'PageDashboard', name: 'PageDashboard',
setup() { setup() {
const flaschengeist = inject<FG_Plugin.Flaschengeist>('flaschengeist'); const flaschengeist = inject<FG_Plugin.Flaschengeist>('flaschengeist');
const widgets = computed(() => const widgets = computed(() => {
flaschengeist?.widgets.filter((widget) => hasPermissions(widget.permissions)) return flaschengeist?.widgets.filter((widget) => hasPermissions(widget.permissions));
); });
return { return {
widgets, widgets,