* fix repo in api client Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: re-organise files to match their interface Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * core: include version in script tags Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * cleanup maybe broken Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * revert rename Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: get rid of Client.ts Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * move more to common Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * more moving Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * format Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * unfuck files that vscode fucked, thanks Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * move more Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * finish moving (maybe) Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * ok more moving Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix more stuff that vs code destroyed Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * get rid "web" prefix for virtual package Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix locales Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * use custom base element Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix css file Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * don't run autoDetectLanguage when importing locale Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix circular dependencies Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: fix build Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
107 lines
3.5 KiB
TypeScript
107 lines
3.5 KiB
TypeScript
import { tenant } from "@goauthentik/common/api/config";
|
|
import { EVENT_SIDEBAR_TOGGLE } from "@goauthentik/common/constants";
|
|
import { configureSentry } from "@goauthentik/common/sentry";
|
|
import { first } from "@goauthentik/common/utils";
|
|
import { AKElement } from "@goauthentik/elements/Base";
|
|
|
|
import { CSSResult, TemplateResult, css, html } from "lit";
|
|
import { customElement, property } from "lit/decorators.js";
|
|
|
|
import AKGlobal from "@goauthentik/common/styles/authentik.css";
|
|
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
|
import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
|
import PFGlobal from "@patternfly/patternfly/patternfly-base.css";
|
|
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
|
|
|
import { CurrentTenant } from "@goauthentik/api";
|
|
|
|
// If the viewport is wider than MIN_WIDTH, the sidebar
|
|
// is shown besides the content, and not overlaid.
|
|
export const MIN_WIDTH = 1200;
|
|
|
|
export const DefaultTenant: CurrentTenant = {
|
|
brandingLogo: "/static/dist/assets/icons/icon_left_brand.svg",
|
|
brandingFavicon: "/static/dist/assets/icons/icon.png",
|
|
brandingTitle: "authentik",
|
|
uiFooterLinks: [],
|
|
matchedDomain: "",
|
|
defaultLocale: "",
|
|
};
|
|
|
|
@customElement("ak-sidebar-brand")
|
|
export class SidebarBrand extends AKElement {
|
|
@property({ attribute: false })
|
|
tenant: CurrentTenant = DefaultTenant;
|
|
|
|
static get styles(): CSSResult[] {
|
|
return [
|
|
PFBase,
|
|
PFGlobal,
|
|
PFPage,
|
|
PFButton,
|
|
AKGlobal,
|
|
css`
|
|
:host {
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
height: 114px;
|
|
min-height: 114px;
|
|
}
|
|
.pf-c-brand img {
|
|
width: 100%;
|
|
padding: 0 0.5rem;
|
|
height: 42px;
|
|
}
|
|
button.pf-c-button.sidebar-trigger {
|
|
background-color: transparent;
|
|
border-radius: 0px;
|
|
height: 100%;
|
|
color: var(--ak-dark-foreground);
|
|
}
|
|
`,
|
|
];
|
|
}
|
|
|
|
constructor() {
|
|
super();
|
|
window.addEventListener("resize", () => {
|
|
this.requestUpdate();
|
|
});
|
|
}
|
|
|
|
firstUpdated(): void {
|
|
configureSentry(true);
|
|
tenant().then((tenant) => (this.tenant = tenant));
|
|
}
|
|
|
|
render(): TemplateResult {
|
|
return html` ${window.innerWidth <= MIN_WIDTH
|
|
? html`
|
|
<button
|
|
class="sidebar-trigger pf-c-button"
|
|
@click=${() => {
|
|
this.dispatchEvent(
|
|
new CustomEvent(EVENT_SIDEBAR_TOGGLE, {
|
|
bubbles: true,
|
|
composed: true,
|
|
}),
|
|
);
|
|
}}
|
|
>
|
|
<i class="fas fa-bars"></i>
|
|
</button>
|
|
`
|
|
: html``}
|
|
<a href="#/" class="pf-c-page__header-brand-link">
|
|
<div class="pf-c-brand ak-brand">
|
|
<img
|
|
src="${first(this.tenant.brandingLogo, DefaultTenant.brandingLogo)}"
|
|
alt="authentik icon"
|
|
loading="lazy"
|
|
/>
|
|
</div>
|
|
</a>`;
|
|
}
|
|
}
|