diff --git a/authentik/root/messages/storage.py b/authentik/root/messages/storage.py index e9204527e..cdbc92627 100644 --- a/authentik/root/messages/storage.py +++ b/authentik/root/messages/storage.py @@ -27,6 +27,7 @@ class ChannelsStorage(BaseStorage): uid, { "type": "event.update", + "message_type": "message", "level": message.level_tag, "tags": message.tags, "message": message.message, diff --git a/web/src/common/ws.ts b/web/src/common/ws.ts index d9dc5004e..ffd1689a3 100644 --- a/web/src/common/ws.ts +++ b/web/src/common/ws.ts @@ -4,7 +4,7 @@ import { MessageLevel } from "../elements/messages/Message"; import { showMessage } from "../elements/messages/MessageContainer"; export interface WSMessage { - type: string; + message_type: string; } export class WebsocketClient { diff --git a/web/src/elements/PageHeader.ts b/web/src/elements/PageHeader.ts index 1ec36d1cb..b3dd34b58 100644 --- a/web/src/elements/PageHeader.ts +++ b/web/src/elements/PageHeader.ts @@ -4,8 +4,10 @@ import PFContent from "@patternfly/patternfly/components/Content/content.css"; import AKGlobal from "../authentik.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; import PFButton from "@patternfly/patternfly/components/Button/button.css"; -import { EVENT_SIDEBAR_TOGGLE, TITLE_DEFAULT } from "../constants"; -import { tenant } from "../api/Config"; +import { EVENT_NOTIFICATION_TOGGLE, EVENT_SIDEBAR_TOGGLE, TITLE_DEFAULT } from "../constants"; +import { DEFAULT_CONFIG, tenant } from "../api/Config"; +import { until } from "lit-html/directives/until"; +import { EventsApi } from "../../api/dist"; @customElement("ak-page-header") export class PageHeader extends LitElement { @@ -44,12 +46,12 @@ export class PageHeader extends LitElement { flex-direction: row; min-height: 114px; } - button.pf-c-button.pf-m-plain.sidebar-trigger { + .pf-c-button.pf-m-plain { background-color: var(--pf-c-page__main-section--m-light--BackgroundColor); border-radius: 0px; } .pf-c-page__main-section { - width: 100%; + flex-grow: 1; display: flex; flex-direction: column; justify-content: center; @@ -57,6 +59,13 @@ export class PageHeader extends LitElement { img.pf-icon { max-height: 24px; } + .sidebar-trigger, + .notification-trigger { + font-size: 24px; + } + .notification-trigger.has-notifications { + color: #2B9AF3; + } `]; } @@ -92,7 +101,26 @@ export class PageHeader extends LitElement { ${this.description ? html`

${this.description}

` : html``} - `; + + ${until(new EventsApi(DEFAULT_CONFIG).eventsNotificationsList({ + seen: false, + ordering: "-created", + pageSize: 1, + }).then(r => { + return html` + `; + }))}`; } } diff --git a/web/src/elements/messages/MessageContainer.ts b/web/src/elements/messages/MessageContainer.ts index 6cbc105c8..a036d2f11 100644 --- a/web/src/elements/messages/MessageContainer.ts +++ b/web/src/elements/messages/MessageContainer.ts @@ -33,7 +33,7 @@ export class MessageContainer extends LitElement { constructor() { super(); this.addEventListener(EVENT_WS_MESSAGE, ((e: CustomEvent) => { - if (e.detail.type !== WS_MSG_TYPE_MESSAGE) return; + if (e.detail.message_type !== WS_MSG_TYPE_MESSAGE) return; this.addMessage(e.detail as unknown as APIMessage); }) as EventListener); } diff --git a/web/src/elements/notifications/NotificationDrawer.ts b/web/src/elements/notifications/NotificationDrawer.ts index 0185aa111..16b1f0043 100644 --- a/web/src/elements/notifications/NotificationDrawer.ts +++ b/web/src/elements/notifications/NotificationDrawer.ts @@ -23,6 +23,15 @@ export class NotificationDrawer extends LitElement { static get styles(): CSSResult[] { return [PFBase, PFButton, PFNotificationDrawer, PFContent, PFDropdown, AKGlobal].concat( css` + .pf-c-notification-drawer__header { + height: 114px; + align-items: center; + } + .pf-c-notification-drawer__header-action, + .pf-c-notification-drawer__header-action-close, + .pf-c-notification-drawer__header-action-close > .pf-c-button.pf-m-plain { + height: 100%; + } .pf-c-notification-drawer__list-item-description { white-space: pre-wrap; } @@ -95,12 +104,14 @@ export class NotificationDrawer extends LitElement { return html`
-

- ${t`Notifications`} -

- - ${t`${this.unread} unread`} - +
+

+ ${t`Notifications`} +

+ + ${t`${this.unread} unread`} + +