diff --git a/Pipfile.lock b/Pipfile.lock index c7bdbea65..b91967c2b 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -74,17 +74,17 @@ }, "boto3": { "hashes": [ - "sha256:58a440f4c96a1f2f076577c7085237854ba6db41a7c91e4a33fb30068f8d4692" + "sha256:1a282c1cd7d5028cbb3a75d747df32162295253f55d263ac85840e264830963b" ], "index": "pypi", - "version": "==1.17.1" + "version": "==1.17.2" }, "botocore": { "hashes": [ - "sha256:9488ba35e2d4d17375f67b8fd300df5ec2f8317a2924032901009c999d563b59", - "sha256:e533b1da7af2e4d69d314375ec7052d95271a878a6040c3af1facd59bfbb7f3b" + "sha256:7442fdbbdc841bfac7f94f92ecb807de070e32ed205743eb72d4ea27c5e8e778", + "sha256:bf587b044983a91a0124cc133ff167b8528c19fbbc8f0b956d9a1ac256cad7d7" ], - "version": "==1.20.1" + "version": "==1.20.2" }, "cachetools": { "hashes": [ @@ -1293,10 +1293,11 @@ }, "autopep8": { "hashes": [ - "sha256:d21d3901cb0da6ebd1e83fc9b0dfbde8b46afc2ede4fe32fbda0c7c6118ca094" + "sha256:9e136c472c475f4ee4978b51a88a494bfcd4e3ed17950a44a988d9e434837bea", + "sha256:cae4bc0fb616408191af41d062d7ec7ef8679c7f27b068875ca3a9e2878d5443" ], "index": "pypi", - "version": "==1.5.4" + "version": "==1.5.5" }, "bandit": { "hashes": [ diff --git a/authentik/events/models.py b/authentik/events/models.py index 81e3a8b25..3ab92c2de 100644 --- a/authentik/events/models.py +++ b/authentik/events/models.py @@ -272,17 +272,24 @@ class NotificationTransport(models.Model): def send_email(self, notification: "Notification") -> list[str]: """Send notification via global email configuration""" - body_trunc = ( - (notification.body[:75] + "..") - if len(notification.body) > 75 - else notification.body - ) + subject = "authentik Notification: " + key_value = {} + if notification.event: + subject += notification.event.action + for key, value in notification.event.context.items(): + if not isinstance(value, str): + continue + key_value[key] = value + else: + subject += notification.body[:75] mail = TemplateEmailMessage( - subject=f"authentik Notification: {body_trunc}", + subject=subject, template_name="email/generic.html", to=[notification.user.email], template_context={ + "title": subject, "body": notification.body, + "key_value": key_value, }, ) # Email is sent directly here, as the call to send() should have been from a task. diff --git a/authentik/providers/oauth2/errors.py b/authentik/providers/oauth2/errors.py index 89f2416f0..8e79b8f6e 100644 --- a/authentik/providers/oauth2/errors.py +++ b/authentik/providers/oauth2/errors.py @@ -23,11 +23,12 @@ class OAuth2Error(SentryIgnoredException): def __repr__(self) -> str: return self.error - def to_event(self, message: Optional[str] = None) -> Event: + def to_event(self, message: Optional[str] = None, **kwargs) -> Event: """Create configuration_error Event and save it.""" return Event.new( EventAction.CONFIGURATION_ERROR, message=message or self.description, + **kwargs, ) @@ -49,10 +50,11 @@ class RedirectUriError(OAuth2Error): self.provided_uri = provided_uri self.allowed_uris = allowed_uris - def to_event(self) -> Event: + def to_event(self, **kwargs) -> Event: return super().to_event( f"Invalid redirect URI was used. Client used '{self.provided_uri}'. " - f"Allowed redirect URIs are {','.join(self.allowed_uris)}" + f"Allowed redirect URIs are {','.join(self.allowed_uris)}", + **kwargs, ) @@ -68,8 +70,10 @@ class ClientIdError(OAuth2Error): super().__init__() self.client_id = client_id - def to_event(self) -> Event: - return super().to_event(f"Invalid client identifier: {self.client_id}.") + def to_event(self, **kwargs) -> Event: + return super().to_event( + f"Invalid client identifier: {self.client_id}.", **kwargs + ) class UserAuthError(OAuth2Error): diff --git a/authentik/providers/oauth2/views/authorize.py b/authentik/providers/oauth2/views/authorize.py index 36106ddf7..c5dbda69e 100644 --- a/authentik/providers/oauth2/views/authorize.py +++ b/authentik/providers/oauth2/views/authorize.py @@ -256,12 +256,12 @@ class OAuthFulfillmentStage(StageView): ).from_http(self.request) return redirect(self.create_response_uri()) except (ClientIdError, RedirectUriError) as error: - error.to_event().from_http(request) + error.to_event(application=application).from_http(request) self.executor.stage_invalid() # pylint: disable=no-member return bad_request_message(request, error.description, title=error.error) except AuthorizeError as error: - error.to_event().from_http(request) + error.to_event(application=application).from_http(request) self.executor.stage_invalid() return redirect(error.create_uri()) @@ -379,7 +379,7 @@ class AuthorizationFlowInitView(PolicyAccessView): try: self.params = OAuthAuthorizationParams.from_request(self.request) except AuthorizeError as error: - error.to_event().from_http(self.request) + error.to_event(redirect_uri=error.redirect_uri).from_http(self.request) raise RequestValidationError(redirect(error.create_uri())) except OAuth2Error as error: error.to_event().from_http(self.request) @@ -396,7 +396,7 @@ class AuthorizationFlowInitView(PolicyAccessView): self.params.grant_type, self.params.state, ) - error.to_event().from_http(self.request) + error.to_event(redirect_uri=error.redirect_uri).from_http(self.request) raise RequestValidationError(redirect(error.create_uri())) def resolve_provider_application(self): diff --git a/authentik/stages/email/templates/email/generic.html b/authentik/stages/email/templates/email/generic.html index 01a242111..2d853b390 100644 --- a/authentik/stages/email/templates/email/generic.html +++ b/authentik/stages/email/templates/email/generic.html @@ -1,5 +1,7 @@ {% extends "email/base.html" %} +{% load i18n %} + {% block content %} @@ -14,6 +16,29 @@ {{ body }} + {% if key_value %} + + + + + + + + + +
{% trans "Additional Information" %}
+ + {% for key, value in key_value.items %} + + + + + {% endfor %} +
{{ key }}{{ value }}
+
+ + + {% endif %} diff --git a/web/package-lock.json b/web/package-lock.json index 8802e39a5..ee3a5ca22 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -144,27 +144,27 @@ } }, "@sentry/browser": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-6.0.4.tgz", - "integrity": "sha512-DrlH53IPNZmW6XWT0Za7vGtIyKpm45An662xvXavI8LQQH0qhPU9mb7NcvecwDfs6jXEV2w5Y8rKjuu/J4QxAA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-6.1.0.tgz", + "integrity": "sha512-t3y2TLXDWgvfknyH8eKj/9mghJfSEqItFyp74zPu1Src6kOPjkd4Sa7o4+bdkNgA8dIIOrDAhRUbB2sq4sWMCA==", "requires": { - "@sentry/core": "6.0.4", - "@sentry/types": "6.0.4", - "@sentry/utils": "6.0.4", + "@sentry/core": "6.1.0", + "@sentry/types": "6.1.0", + "@sentry/utils": "6.1.0", "tslib": "^1.9.3" }, "dependencies": { "@sentry/types": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.0.4.tgz", - "integrity": "sha512-VqmnhJPpPmsu4gMzSZw8UHgYlP1QSikMZ5X6E3q6zwmbWu+2oniQHD6xGB6PXv6uTo5zg2NseQEiWnEjJRUYWw==" + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.1.0.tgz", + "integrity": "sha512-kIaN52Fw5K+2mKRaHE2YluJ+F/qMGSUzZXIFDNdC6OUMXQ4TM8gZTrITXs8CLDm7cK8iCqFCtzKOjKK6KyOKAg==" }, "@sentry/utils": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.0.4.tgz", - "integrity": "sha512-UOAz5p5IIntmIcmX04Cjk7l7+EwnuBn2S/rhNN92I1vDCaL010OmUZOHGHJExoXBE75zVh/LDssAPQTKXo0F+g==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.1.0.tgz", + "integrity": "sha512-6JAplzUOS6bEwfX0PDRZBbYRvn9EN22kZfcL0qGHtM9L0QQ5ybjbbVwOpbXgRkiZx++dQbzLFtelxnDhsbFG+Q==", "requires": { - "@sentry/types": "6.0.4", + "@sentry/types": "6.1.0", "tslib": "^1.9.3" } }, @@ -176,48 +176,48 @@ } }, "@sentry/core": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-6.0.4.tgz", - "integrity": "sha512-5+Xnk3jb0nkKYvgBV/kKWUqrNsNeM38r98ZRqfHrl69WoSrv+ynTsj8gn0tZO+VvhxUDRLOYvDha+QZgkYZt/w==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-6.1.0.tgz", + "integrity": "sha512-57mXkp3NoyxRycXrL+Ec6bYS6UYJZp9tYX0lUp5Ry2M0FxDZ3Q4drkjr8MIQOhBaQXP2ukSX4QTVLGMPm60zMw==", "requires": { - "@sentry/hub": "6.0.4", - "@sentry/minimal": "6.0.4", - "@sentry/types": "6.0.4", - "@sentry/utils": "6.0.4", + "@sentry/hub": "6.1.0", + "@sentry/minimal": "6.1.0", + "@sentry/types": "6.1.0", + "@sentry/utils": "6.1.0", "tslib": "^1.9.3" }, "dependencies": { "@sentry/hub": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.0.4.tgz", - "integrity": "sha512-gutuxH8M3CdElSbwqNq9G29MiNuGsPESB22w4k4wx+pc632bi6w0v53+BLjGO6wh2EMfHVWptgAYmojEk5yKQg==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.1.0.tgz", + "integrity": "sha512-JnBSCgNg3VHiMojUl5tCHU8iWPVuE+qqENIzG9A722oJms1kKWBvWl+yQzhWBNdgk5qeAY3F5UzKWJZkbJ6xow==", "requires": { - "@sentry/types": "6.0.4", - "@sentry/utils": "6.0.4", + "@sentry/types": "6.1.0", + "@sentry/utils": "6.1.0", "tslib": "^1.9.3" } }, "@sentry/minimal": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.0.4.tgz", - "integrity": "sha512-COL0tjznrCaatOPH2eGgT1Y9vUUKJw+W0srCn5V1dHgRu3t00rGFXrcyOXQmHfEWmBaagt9lXEJCFaN7yMucVQ==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.1.0.tgz", + "integrity": "sha512-g6sfNKenL7wnsr/tibp8nFiMv/XRH0s0Pt4p151npmNI+SmjuUz3GGYEXk8ChCyaKldYKilkNOFdVXJxUf5gZw==", "requires": { - "@sentry/hub": "6.0.4", - "@sentry/types": "6.0.4", + "@sentry/hub": "6.1.0", + "@sentry/types": "6.1.0", "tslib": "^1.9.3" } }, "@sentry/types": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.0.4.tgz", - "integrity": "sha512-VqmnhJPpPmsu4gMzSZw8UHgYlP1QSikMZ5X6E3q6zwmbWu+2oniQHD6xGB6PXv6uTo5zg2NseQEiWnEjJRUYWw==" + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.1.0.tgz", + "integrity": "sha512-kIaN52Fw5K+2mKRaHE2YluJ+F/qMGSUzZXIFDNdC6OUMXQ4TM8gZTrITXs8CLDm7cK8iCqFCtzKOjKK6KyOKAg==" }, "@sentry/utils": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.0.4.tgz", - "integrity": "sha512-UOAz5p5IIntmIcmX04Cjk7l7+EwnuBn2S/rhNN92I1vDCaL010OmUZOHGHJExoXBE75zVh/LDssAPQTKXo0F+g==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.1.0.tgz", + "integrity": "sha512-6JAplzUOS6bEwfX0PDRZBbYRvn9EN22kZfcL0qGHtM9L0QQ5ybjbbVwOpbXgRkiZx++dQbzLFtelxnDhsbFG+Q==", "requires": { - "@sentry/types": "6.0.4", + "@sentry/types": "6.1.0", "tslib": "^1.9.3" } }, @@ -229,12 +229,12 @@ } }, "@sentry/hub": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.0.4.tgz", - "integrity": "sha512-gutuxH8M3CdElSbwqNq9G29MiNuGsPESB22w4k4wx+pc632bi6w0v53+BLjGO6wh2EMfHVWptgAYmojEk5yKQg==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.1.0.tgz", + "integrity": "sha512-JnBSCgNg3VHiMojUl5tCHU8iWPVuE+qqENIzG9A722oJms1kKWBvWl+yQzhWBNdgk5qeAY3F5UzKWJZkbJ6xow==", "requires": { - "@sentry/types": "6.0.4", - "@sentry/utils": "6.0.4", + "@sentry/types": "6.1.0", + "@sentry/utils": "6.1.0", "tslib": "^1.9.3" }, "dependencies": { @@ -246,12 +246,12 @@ } }, "@sentry/minimal": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.0.4.tgz", - "integrity": "sha512-COL0tjznrCaatOPH2eGgT1Y9vUUKJw+W0srCn5V1dHgRu3t00rGFXrcyOXQmHfEWmBaagt9lXEJCFaN7yMucVQ==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.1.0.tgz", + "integrity": "sha512-g6sfNKenL7wnsr/tibp8nFiMv/XRH0s0Pt4p151npmNI+SmjuUz3GGYEXk8ChCyaKldYKilkNOFdVXJxUf5gZw==", "requires": { - "@sentry/hub": "6.0.4", - "@sentry/types": "6.0.4", + "@sentry/hub": "6.1.0", + "@sentry/types": "6.1.0", "tslib": "^1.9.3" }, "dependencies": { @@ -263,14 +263,14 @@ } }, "@sentry/tracing": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-6.0.4.tgz", - "integrity": "sha512-/da81kbkpiA17kAVjW8ZdpASwgsdYUXZg3jdOfbV07HK/6aFkfOF8/sHKMjVG2Iy4oaRel/F7l6/wf+XlKbBMw==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-6.1.0.tgz", + "integrity": "sha512-s6a4Ra3hHn4awiNz4fOEK6TCV2w2iLcxdppijcYEB7S/1rJpmqZgHWDicqufbOmVMOLmyKLEQ7w+pZq3TR3WgQ==", "requires": { - "@sentry/hub": "6.0.4", - "@sentry/minimal": "6.0.4", - "@sentry/types": "6.0.4", - "@sentry/utils": "6.0.4", + "@sentry/hub": "6.1.0", + "@sentry/minimal": "6.1.0", + "@sentry/types": "6.1.0", + "@sentry/utils": "6.1.0", "tslib": "^1.9.3" }, "dependencies": { @@ -282,16 +282,16 @@ } }, "@sentry/types": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.0.4.tgz", - "integrity": "sha512-VqmnhJPpPmsu4gMzSZw8UHgYlP1QSikMZ5X6E3q6zwmbWu+2oniQHD6xGB6PXv6uTo5zg2NseQEiWnEjJRUYWw==" + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.1.0.tgz", + "integrity": "sha512-kIaN52Fw5K+2mKRaHE2YluJ+F/qMGSUzZXIFDNdC6OUMXQ4TM8gZTrITXs8CLDm7cK8iCqFCtzKOjKK6KyOKAg==" }, "@sentry/utils": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.0.4.tgz", - "integrity": "sha512-UOAz5p5IIntmIcmX04Cjk7l7+EwnuBn2S/rhNN92I1vDCaL010OmUZOHGHJExoXBE75zVh/LDssAPQTKXo0F+g==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.1.0.tgz", + "integrity": "sha512-6JAplzUOS6bEwfX0PDRZBbYRvn9EN22kZfcL0qGHtM9L0QQ5ybjbbVwOpbXgRkiZx++dQbzLFtelxnDhsbFG+Q==", "requires": { - "@sentry/types": "6.0.4", + "@sentry/types": "6.1.0", "tslib": "^1.9.3" }, "dependencies": { diff --git a/web/package.json b/web/package.json index 4ffc84f55..8a109562f 100644 --- a/web/package.json +++ b/web/package.json @@ -12,8 +12,8 @@ "dependencies": { "@fortawesome/fontawesome-free": "^5.15.2", "@patternfly/patternfly": "^4.80.3", - "@sentry/browser": "^6.0.4", - "@sentry/tracing": "^6.0.4", + "@sentry/browser": "^6.1.0", + "@sentry/tracing": "^6.1.0", "@types/chart.js": "^2.9.30", "@types/codemirror": "0.0.108", "chart.js": "^2.9.4", diff --git a/web/src/api/Client.ts b/web/src/api/Client.ts index 583e2946c..3556b0c88 100644 --- a/web/src/api/Client.ts +++ b/web/src/api/Client.ts @@ -13,7 +13,9 @@ export class Client { if (query) { const queryString = Object.keys(query) .filter((k) => query[k] !== null) - .map((k) => encodeURIComponent(k) + "=" + encodeURIComponent(query[k])) + // we default to a string in query[k] as we've filtered out the null above + // this is just for type-hinting + .map((k) => encodeURIComponent(k) + "=" + encodeURIComponent(query[k] || "")) .join("&"); builtUrl += `?${queryString}`; } diff --git a/web/src/authentik.css b/web/src/authentik.css index 7672cc32e..9d5c6d468 100644 --- a/web/src/authentik.css +++ b/web/src/authentik.css @@ -169,6 +169,13 @@ select[multiple] { .pf-c-table__toggle-icon { color: var(--ak-dark-foreground); } + /* expandable elements */ + .pf-c-expandable-section__toggle-text { + color: var(--ak-dark-foreground); + } + .pf-c-expandable-section__toggle-icon { + color: var(--ak-dark-foreground); + } /* inputs */ .pf-c-input-group { --pf-c-input-group--BackgroundColor: transparent; diff --git a/web/src/elements/Expand.ts b/web/src/elements/Expand.ts new file mode 100644 index 000000000..3cb684702 --- /dev/null +++ b/web/src/elements/Expand.ts @@ -0,0 +1,36 @@ +import { gettext } from "django"; +import { CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; +import { COMMON_STYLES } from "../common/styles"; + +@customElement("ak-expand") +export class Expand extends LitElement { + + @property({ type: Boolean }) + expanded = false; + + @property() + textOpen = "Show less"; + + @property() + textClosed = "Show more"; + + static get styles(): CSSResult[] { + return COMMON_STYLES; + } + + render(): TemplateResult { + console.log(this.expanded); + return html`
+ + +
`; + } + +} diff --git a/web/src/elements/router/Route.ts b/web/src/elements/router/Route.ts index 3a52b3559..cafbb7740 100644 --- a/web/src/elements/router/Route.ts +++ b/web/src/elements/router/Route.ts @@ -2,6 +2,7 @@ import { html, TemplateResult } from "lit-html"; export const SLUG_REGEX = "[-a-zA-Z0-9_]+"; export const ID_REGEX = "\\d+"; +export const UUID_REGEX = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"; export class Route { url: RegExp; diff --git a/web/src/elements/table/TablePage.ts b/web/src/elements/table/TablePage.ts index 70644f24d..143b6fca8 100644 --- a/web/src/elements/table/TablePage.ts +++ b/web/src/elements/table/TablePage.ts @@ -1,3 +1,4 @@ +import { gettext } from "django"; import { html, TemplateResult } from "lit-html"; import { ifDefined } from "lit-html/directives/if-defined"; import { Table } from "./Table"; @@ -26,9 +27,9 @@ export abstract class TablePage extends Table {

- ${this.pageTitle()} + ${gettext(this.pageTitle())}

- ${description ? html`

${description}

` : html``} + ${description ? html`

${gettext(description)}

` : html``}
diff --git a/web/src/pages/events/EventInfo.ts b/web/src/pages/events/EventInfo.ts index af88adf85..2a1f73c22 100644 --- a/web/src/pages/events/EventInfo.ts +++ b/web/src/pages/events/EventInfo.ts @@ -5,6 +5,7 @@ import { Event, EventContext } from "../../api/Events"; import { Flow } from "../../api/Flows"; import { COMMON_STYLES } from "../../common/styles"; import "../../elements/Spinner"; +import "../../elements/Expand"; import { SpinnerSize } from "../../elements/Spinner"; @customElement("ak-event-info") @@ -76,21 +77,21 @@ export class EventInfo extends LitElement {

${gettext("Using flow")}

${until(Flow.list({ - flow_uuid: this.event.context.flow as string, - }).then(resp => { - return html`${resp.results[0].name}`; - }), html``)} + flow_uuid: this.event.context.flow as string, + }).then(resp => { + return html`${resp.results[0].name}`; + }), html``)} +
`; case "login_failed": return html`

${gettext(`Attempted to log in as ${this.event.context.username}`)}

- `; + ${this.defaultResponse()}`; case "token_view": return html`

${gettext("Token:")}


- ${this.getModelInfo(this.event.context.token as EventContext)} - `; + ${this.getModelInfo(this.event.context.token as EventContext)}`; case "property_mapping_exception": return html`
@@ -101,7 +102,8 @@ export class EventInfo extends LitElement {

${gettext("Expression")}

${this.event.context.expression}
-
`; + + ${this.defaultResponse()}`; case "policy_exception": return html`
@@ -119,7 +121,8 @@ export class EventInfo extends LitElement {

${gettext("Exception")}

${this.event.context.message || this.event.context.error}
-
`; + + ${this.defaultResponse()}`; case "policy_execution": return html`
@@ -140,21 +143,23 @@ export class EventInfo extends LitElement {
  • ${gettext("Messages")}:
      ${((this.event.context.result as EventContext).messages as string[]).map(msg => { - return html`
    • ${msg}
    • `; - })} + return html`
    • ${msg}
    • `; + })}
  • -
    `; + + ${this.defaultResponse()}`; case "configuration_error": - return html`

    ${this.event.context.message}

    `; + return html`

    ${this.event.context.message}

    + ${this.defaultResponse()}`; case "update_available": return html`

    ${gettext("New version available!")}

    ${this.event.context.new_version} `; - // Action types which typically don't record any extra context. - // If context is not empty, we fall to the default response. + // Action types which typically don't record any extra context. + // If context is not empty, we fall to the default response. case "login": if ("using_source" in this.event.context) { return html`
    diff --git a/web/src/pages/events/EventInfoPage.ts b/web/src/pages/events/EventInfoPage.ts new file mode 100644 index 000000000..aa11e9294 --- /dev/null +++ b/web/src/pages/events/EventInfoPage.ts @@ -0,0 +1,48 @@ +import { gettext } from "django"; +import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; +import { Event } from "../../api/Events"; +import { COMMON_STYLES } from "../../common/styles"; +import "./EventInfo"; + +@customElement("ak-event-info-page") +export class EventInfoPage extends LitElement { + @property() + set args(value: { [key: string]: string }) { + this.eventID = value.id; + } + + @property() + set eventID(value: string) { + Event.get(value).then((e) => (this.event = e)); + } + + @property({ attribute: false }) + event?: Event; + + static get styles(): CSSResult[] { + return COMMON_STYLES.concat(css` + .pf-c-card { + color: var(--ak-dark-foreground); + } + `); + } + + render(): TemplateResult { + return html`
    +
    +

    + + ${gettext(`Event ${this.event?.pk || ""}`)} +

    +
    +
    +
    +
    +
    + +
    +
    +
    `; + } + +} diff --git a/web/src/routes.ts b/web/src/routes.ts index b09c81951..32c97b71b 100644 --- a/web/src/routes.ts +++ b/web/src/routes.ts @@ -1,5 +1,5 @@ import { html } from "lit-html"; -import { Route, SLUG_REGEX, ID_REGEX } from "./elements/router/Route"; +import { Route, SLUG_REGEX, ID_REGEX, UUID_REGEX } from "./elements/router/Route"; import "./pages/LibraryPage"; import "./pages/admin-overview/AdminOverviewPage"; @@ -8,6 +8,7 @@ import "./pages/applications/ApplicationViewPage"; import "./pages/sources/SourceViewPage"; import "./pages/flows/FlowViewPage"; import "./pages/events/EventListPage"; +import "./pages/events/EventInfoPage"; import "./pages/events/TransportListPage"; import "./pages/events/RuleListPage"; import "./pages/providers/ProviderListPage"; @@ -35,6 +36,9 @@ export const ROUTES: Route[] = [ return html``; }), new Route(new RegExp("^/events/log$"), html``), + new Route(new RegExp(`^/events/log/(?${UUID_REGEX})$`)).then((args) => { + return html``; + }), new Route(new RegExp("^/events/transports$"), html``), new Route(new RegExp("^/events/rules$"), html``), new Route(new RegExp("^/property-mappings$"), html``),