events: add user filter to notifications
as superuser all notifications are returned regardless of permission so we need to filter Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
@ -13,6 +13,7 @@ import { EventsApi } from "@goauthentik/api";
|
||||
|
||||
import { DEFAULT_CONFIG, tenant } from "../api/Config";
|
||||
import { currentInterface } from "../api/Sentry";
|
||||
import { me } from "../api/Users";
|
||||
import {
|
||||
EVENT_API_DRAWER_TOGGLE,
|
||||
EVENT_NOTIFICATION_DRAWER_TOGGLE,
|
||||
@ -102,15 +103,18 @@ export class PageHeader extends LitElement {
|
||||
}
|
||||
|
||||
firstUpdated(): void {
|
||||
new EventsApi(DEFAULT_CONFIG)
|
||||
.eventsNotificationsList({
|
||||
seen: false,
|
||||
ordering: "-created",
|
||||
pageSize: 1,
|
||||
})
|
||||
.then((r) => {
|
||||
this.hasNotifications = r.pagination.count > 0;
|
||||
});
|
||||
me().then((user) => {
|
||||
new EventsApi(DEFAULT_CONFIG)
|
||||
.eventsNotificationsList({
|
||||
seen: false,
|
||||
ordering: "-created",
|
||||
pageSize: 1,
|
||||
user: user.user.pk,
|
||||
})
|
||||
.then((r) => {
|
||||
this.hasNotifications = r.pagination.count > 0;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
renderIcon(): TemplateResult {
|
||||
|
@ -14,6 +14,7 @@ import { EventsApi, Notification } from "@goauthentik/api";
|
||||
|
||||
import { AKResponse } from "../../api/Client";
|
||||
import { DEFAULT_CONFIG } from "../../api/Config";
|
||||
import { me } from "../../api/Users";
|
||||
import { EVENT_NOTIFICATION_DRAWER_TOGGLE, EVENT_REFRESH } from "../../constants";
|
||||
import { ActionToLabel } from "../../pages/events/utils";
|
||||
import { MessageLevel } from "../messages/Message";
|
||||
@ -53,15 +54,18 @@ export class NotificationDrawer extends LitElement {
|
||||
}
|
||||
|
||||
firstUpdated(): void {
|
||||
new EventsApi(DEFAULT_CONFIG)
|
||||
.eventsNotificationsList({
|
||||
seen: false,
|
||||
ordering: "-created",
|
||||
})
|
||||
.then((r) => {
|
||||
this.notifications = r;
|
||||
this.unread = r.results.length;
|
||||
});
|
||||
me().then((user) => {
|
||||
new EventsApi(DEFAULT_CONFIG)
|
||||
.eventsNotificationsList({
|
||||
seen: false,
|
||||
ordering: "-created",
|
||||
user: user.user.pk,
|
||||
})
|
||||
.then((r) => {
|
||||
this.notifications = r;
|
||||
this.unread = r.results.length;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
renderItem(item: Notification): TemplateResult {
|
||||
|
@ -123,15 +123,18 @@ export class UserInterface extends LitElement {
|
||||
}
|
||||
|
||||
firstUpdated(): void {
|
||||
new EventsApi(DEFAULT_CONFIG)
|
||||
.eventsNotificationsList({
|
||||
seen: false,
|
||||
ordering: "-created",
|
||||
pageSize: 1,
|
||||
})
|
||||
.then((r) => {
|
||||
this.notificationsCount = r.pagination.count;
|
||||
});
|
||||
me().then((user) => {
|
||||
new EventsApi(DEFAULT_CONFIG)
|
||||
.eventsNotificationsList({
|
||||
seen: false,
|
||||
ordering: "-created",
|
||||
pageSize: 1,
|
||||
user: user.user.pk,
|
||||
})
|
||||
.then((r) => {
|
||||
this.notificationsCount = r.pagination.count;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
render(): TemplateResult {
|
||||
|
Reference in New Issue
Block a user