web/admin: add Admin in titlebar for admin interface

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-12-24 20:04:21 +01:00
parent 884c546f32
commit 10110deae5
5 changed files with 32 additions and 20 deletions

View File

@ -45,14 +45,8 @@ export function configureSentry(canDoPpi: boolean = false): Promise<Config> {
}); });
Sentry.setTag(TAG_SENTRY_CAPABILITIES, config.capabilities.join(",")); Sentry.setTag(TAG_SENTRY_CAPABILITIES, config.capabilities.join(","));
if (window.location.pathname.includes("if/")) { if (window.location.pathname.includes("if/")) {
// Get the interface name from URL Sentry.setTag(TAG_SENTRY_COMPONENT, `web/${currentInterface()}`);
const pathMatches = window.location.pathname.match(/.+if\/(\w+)\//); Sentry.configureScope((scope) => scope.setTransactionName(`authentik.web.if.${currentInterface()}`));
let currentInterface = "unknown";
if (pathMatches && pathMatches.length >= 2) {
currentInterface = pathMatches[1];
}
Sentry.setTag(TAG_SENTRY_COMPONENT, `web/${currentInterface}`);
Sentry.configureScope((scope) => scope.setTransactionName(`authentik.web.if.${currentInterface}`));
} }
if (config.errorReporting.sendPii && canDoPpi) { if (config.errorReporting.sendPii && canDoPpi) {
me().then(user => { me().then(user => {
@ -66,3 +60,13 @@ export function configureSentry(canDoPpi: boolean = false): Promise<Config> {
return config; return config;
}); });
} }
// Get the interface name from URL
export function currentInterface(): string {
const pathMatches = window.location.pathname.match(/.+if\/(\w+)\//);
let currentInterface = "unknown";
if (pathMatches && pathMatches.length >= 2) {
currentInterface = pathMatches[1];
}
return currentInterface;
}

View File

@ -1,3 +1,5 @@
import { t } from "@lingui/macro";
import { CSSResult, LitElement, TemplateResult, css, html } from "lit"; import { CSSResult, LitElement, TemplateResult, css, html } from "lit";
import { customElement, property } from "lit/decorators.js"; import { customElement, property } from "lit/decorators.js";
@ -10,6 +12,7 @@ import PFBase from "@patternfly/patternfly/patternfly-base.css";
import { EventsApi } from "@goauthentik/api"; import { EventsApi } from "@goauthentik/api";
import { DEFAULT_CONFIG, tenant } from "../api/Config"; import { DEFAULT_CONFIG, tenant } from "../api/Config";
import { currentInterface } from "../api/Sentry";
import { import {
EVENT_API_DRAWER_TOGGLE, EVENT_API_DRAWER_TOGGLE,
EVENT_NOTIFICATION_DRAWER_TOGGLE, EVENT_NOTIFICATION_DRAWER_TOGGLE,
@ -32,11 +35,15 @@ export class PageHeader extends LitElement {
@property() @property()
set header(value: string) { set header(value: string) {
tenant().then((tenant) => { tenant().then((tenant) => {
if (value !== "") { const currentIf = currentInterface();
document.title = `${value} - ${tenant.brandingTitle}`; let title = tenant.brandingTitle || TITLE_DEFAULT;
} else { if (currentIf === "admin") {
document.title = tenant.brandingTitle || TITLE_DEFAULT; title = `${t`Admin`} - ${title}`;
} }
if (value !== "") {
title = `${value} - ${title}`;
}
document.title = title;
}); });
this._header = value; this._header = value;
} }

View File

@ -224,9 +224,9 @@ msgstr "Additional settings"
msgid "Additional user DN, prepended to the Base DN." msgid "Additional user DN, prepended to the Base DN."
msgstr "Additional user DN, prepended to the Base DN." msgstr "Additional user DN, prepended to the Base DN."
#: #: src/elements/PageHeader.ts
#~ msgid "Admin" msgid "Admin"
#~ msgstr "Admin" msgstr "Admin"
#: src/interfaces/UserInterface.ts #: src/interfaces/UserInterface.ts
msgid "Admin interface" msgid "Admin interface"

View File

@ -229,8 +229,9 @@ msgstr "Paramètres supplémentaire"
msgid "Additional user DN, prepended to the Base DN." msgid "Additional user DN, prepended to the Base DN."
msgstr "DN à préfixer au DN de base pour les utilisateurs" msgstr "DN à préfixer au DN de base pour les utilisateurs"
#~ msgid "Admin" #: src/elements/PageHeader.ts
#~ msgstr "Administrateur" msgid "Admin"
msgstr "Administrateur"
#: src/interfaces/UserInterface.ts #: src/interfaces/UserInterface.ts
msgid "Admin interface" msgid "Admin interface"

View File

@ -224,9 +224,9 @@ msgstr ""
msgid "Additional user DN, prepended to the Base DN." msgid "Additional user DN, prepended to the Base DN."
msgstr "" msgstr ""
#: #: src/elements/PageHeader.ts
#~ msgid "Admin" msgid "Admin"
#~ msgstr "" msgstr ""
#: src/interfaces/UserInterface.ts #: src/interfaces/UserInterface.ts
msgid "Admin interface" msgid "Admin interface"