diff --git a/web/.eslintrc.json b/web/.eslintrc.json index 6963ffa91..39bca2824 100644 --- a/web/.eslintrc.json +++ b/web/.eslintrc.json @@ -18,7 +18,7 @@ "lit" ], "rules": { - "indent": ["error", 4], + "indent": "off", "linebreak-style": ["error", "unix"], "quotes": ["error", "double"], "semi": ["error", "always"], diff --git a/web/src/api/EventNotification.ts b/web/src/api/EventNotification.ts index a8dac67f3..6df9677c1 100644 --- a/web/src/api/EventNotification.ts +++ b/web/src/api/EventNotification.ts @@ -21,4 +21,10 @@ export class Notification { return DefaultClient.fetch>(["events", "notifications"], filter); } + static markSeen(pk: string): Promise { + return DefaultClient.update(["events", "notifications", pk], { + "seen": true + }); + } + } diff --git a/web/src/elements/buttons/ActionButton.ts b/web/src/elements/buttons/ActionButton.ts index 4e2e8e2e7..12a6047c1 100644 --- a/web/src/elements/buttons/ActionButton.ts +++ b/web/src/elements/buttons/ActionButton.ts @@ -15,11 +15,6 @@ export class ActionButton extends SpinnerButton { } this.setLoading(); const csrftoken = getCookie("authentik_csrf"); - if (!csrftoken) { - console.debug("No csrf token in cookie"); - this.setDone(ERROR_CLASS); - return; - } const request = new Request(this.url, { headers: { "X-CSRFToken": csrftoken }, }); diff --git a/web/src/elements/notifications/NotificationDrawer.ts b/web/src/elements/notifications/NotificationDrawer.ts index f82479263..50ad51546 100644 --- a/web/src/elements/notifications/NotificationDrawer.ts +++ b/web/src/elements/notifications/NotificationDrawer.ts @@ -30,9 +30,12 @@ export class NotificationDrawer extends LitElement { } firstUpdated(): void { - Notification.list().then(r => { + Notification.list({ + seen: false, + ordering: "-created" + }).then(r => { this.notifications = r; - this.unread = r.results.filter((n) => !n.seen).length; + this.unread = r.results.length; }); } @@ -63,6 +66,15 @@ export class NotificationDrawer extends LitElement { ${item.event?.action} +
+ +

${item.body}

${age} `; diff --git a/web/src/utils.ts b/web/src/utils.ts index 36d6c300b..f8639647e 100644 --- a/web/src/utils.ts +++ b/web/src/utils.ts @@ -1,8 +1,8 @@ import { html, TemplateResult } from "lit-html"; import { SpinnerSize } from "./elements/Spinner"; -export function getCookie(name: string): string | undefined { - let cookieValue = undefined; +export function getCookie(name: string): string { + let cookieValue = ""; if (document.cookie && document.cookie !== "") { const cookies = document.cookie.split(";"); for (let i = 0; i < cookies.length; i++) {