web: set document title on navigation

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-03-18 14:47:13 +01:00
parent a57d524273
commit 01fc63fc98
3 changed files with 21 additions and 0 deletions

View file

@ -100,6 +100,7 @@ class FlowViewSet(ModelViewSet):
},
)
@action(detail=True)
# pylint: disable=unused-argument
def export(self, request: Request, slug: str) -> Response:
"""Export flow to .akflow file"""
flow = self.get_object()

View file

@ -6,6 +6,9 @@ import AKGlobal from "../../authentik.css";
import "../../pages/generic/SiteShell";
import "./Router404";
import { Page } from "../Page";
export const TITLE_SUFFIX = "authentik";
@customElement("ak-router-outlet")
export class RouterOutlet extends LitElement {
@ -40,6 +43,19 @@ export class RouterOutlet extends LitElement {
this.navigate();
}
updated(): void {
if (!this.shadowRoot) return;
Array.from(this.shadowRoot?.children).forEach((el) => {
console.log("pageTitle" in el);
if ("pageTitle" in el) {
const title = (el as Page).pageTitle();
document.title = `${title} - ${TITLE_SUFFIX}`;
} else {
document.title = TITLE_SUFFIX;
}
});
}
navigate(): void {
let activeUrl = window.location.hash.slice(1, Infinity);
if (activeUrl === "") {

View file

@ -86,6 +86,10 @@ export class LibraryPage extends LitElement {
@property({attribute: false})
apps?: AKResponse<Application>;
pageTitle(): string {
return gettext("Applications");
}
static get styles(): CSSResult[] {
return [PFBase, PFEmptyState, PFTitle, PFPage, PFContent, PFGallery, AKGlobal].concat(css`
:host,