[notification] Ignore notifications for missing plugins, identify plugins by ID rather then name.
This commit is contained in:
parent
59920e23a5
commit
53951daa25
|
@ -103,24 +103,22 @@ export const useMainStore = defineStore({
|
||||||
},
|
},
|
||||||
|
|
||||||
async loadNotifications(flaschengeist: FG_Plugin.Flaschengeist) {
|
async loadNotifications(flaschengeist: FG_Plugin.Flaschengeist) {
|
||||||
const params =
|
const { data } = await api.get<FG.Notification[]>('/notifications', {
|
||||||
this.notifications.length > 0
|
params:
|
||||||
? { from: this.notifications[this.notifications.length - 1].time }
|
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) => {
|
data.forEach((n) => {
|
||||||
n.time = new Date(n.time);
|
n.time = new Date(n.time);
|
||||||
notifications.push(
|
const plugin = flaschengeist?.plugins.filter((p) => p.id === n.plugin)[0];
|
||||||
(flaschengeist?.plugins.filter((p) => p.name === n.plugin)[0]?.notification)(
|
if (!plugin) console.debug('Could not find a parser for this notification', n);
|
||||||
/*||
|
else notes.push(plugin.notification(n));
|
||||||
translateNotification*/
|
|
||||||
n
|
|
||||||
)
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
this.notifications.push(...notifications);
|
this.notifications.push(...notes);
|
||||||
return notifications;
|
return notes;
|
||||||
},
|
},
|
||||||
|
|
||||||
async removeNotification(id: number) {
|
async removeNotification(id: number) {
|
||||||
|
|
|
@ -231,7 +231,7 @@ function loadPlugin(
|
||||||
backend: Backend
|
backend: Backend
|
||||||
) {
|
) {
|
||||||
// Check if already loaded
|
// 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
|
// 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.name}: Backend modules not satisfied`);
|
console.error(`Plugin ${plugin.id}: Backend modules not satisfied`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,11 +266,12 @@ function loadPlugin(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.widgets.length > 0) {
|
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);
|
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,
|
||||||
|
@ -315,13 +316,13 @@ export default boot(async ({ router, app }) => {
|
||||||
|
|
||||||
const BreakError = {};
|
const BreakError = {};
|
||||||
try {
|
try {
|
||||||
PLUGINS.plugins.forEach((plugin, name) => {
|
PLUGINS.plugins.forEach((plugin, id) => {
|
||||||
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-${name}!`,
|
message: `Fehler beim Laden: Bitte wende dich an den Admin (error: PNF-${id}!`,
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
progress: true,
|
progress: true,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue