import "../elements/messages/MessageContainer"; import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; import { me } from "../api/Users"; import { ID_REGEX, SLUG_REGEX, UUID_REGEX } from "../elements/router/Route"; import "./locale"; import "../elements/sidebar/SidebarItem"; import { t } from "@lingui/macro"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; import PFPage from "@patternfly/patternfly/components/Page/page.css"; import PFButton from "@patternfly/patternfly/components/Button/button.css"; import PFDrawer from "@patternfly/patternfly/components/Drawer/drawer.css"; import "../elements/router/RouterOutlet"; import "../elements/messages/MessageContainer"; import "../elements/notifications/NotificationDrawer"; import "../elements/sidebar/Sidebar"; import { until } from "lit-html/directives/until"; import { EVENT_NOTIFICATION_TOGGLE, EVENT_SIDEBAR_TOGGLE, VERSION } from "../constants"; import { AdminApi } from "authentik-api"; import { DEFAULT_CONFIG } from "../api/Config"; @customElement("ak-interface-admin") export class AdminInterface extends LitElement { @property({type: Boolean}) sidebarOpen = true; @property({type: Boolean}) notificationOpen = false; static get styles(): CSSResult[] { return [PFBase, PFPage, PFButton, PFDrawer, css` .pf-c-page__main, .pf-c-drawer__content, .pf-c-page__drawer { z-index: auto !important; } `]; } constructor() { super(); this.sidebarOpen = window.innerWidth >= 1280; window.addEventListener("resize", () => { this.sidebarOpen = window.innerWidth >= 1280; }); window.addEventListener(EVENT_SIDEBAR_TOGGLE, () => { this.sidebarOpen = !this.sidebarOpen; }); window.addEventListener(EVENT_NOTIFICATION_TOGGLE, () => { this.notificationOpen = !this.notificationOpen; }); } render(): TemplateResult { return html`
${this.renderSidebarItems()}
`; } renderSidebarItems(): TemplateResult { const superUserCondition = () => { return me().then(u => u.user.isSuperuser || false); }; return html` ${until(new AdminApi(DEFAULT_CONFIG).adminVersionRetrieve().then(version => { if (version.versionCurrent !== VERSION) { return html` ${t`A newer version of the frontend is available.`} `; } return html``; }))} ${until(me().then((u) => { if (u.original) { return html` ${t`You're currently impersonating ${u.user.username}. Click to stop.`} `; } return html``; }))} ${t`Library`} ${t`Monitor`} ${t`Overview`} ${t`System Tasks`} ${t`Resources`} ${SLUG_REGEX})$`]}> ${t`Applications`} ${SLUG_REGEX})$`]}> ${t`Sources`} ${ID_REGEX})$`]}> ${t`Providers`} ${t`Tenants`} ${t`Outposts`} ${t`Outposts`} ${t`Service Connections`} ${t`Events`} ${UUID_REGEX})$`]}> ${t`Logs`} ${t`Notification Rules`} ${t`Notification Transports`} ${t`Customisation`} ${t`Policies`} ${t`Reputation policy - IPs`} ${t`Reputation policy - Users`} ${t`Property Mappings`} ${t`Flows`} ${SLUG_REGEX})$`]}> ${t`Flows`} ${t`Stages`} ${t`Prompts`} ${t`Invitations`} ${t`Identity & Cryptography`} ${ID_REGEX})$`]}> ${t`Users`} ${t`Groups`} ${t`Certificates`} ${t`Tokens`} `; } }