import "@goauthentik/admin/admin-overview/TopApplicationsTable"; import "@goauthentik/admin/admin-overview/cards/AdminStatusCard"; import "@goauthentik/admin/admin-overview/cards/FipsStatusCard"; import "@goauthentik/admin/admin-overview/cards/RecentEventsCard"; import "@goauthentik/admin/admin-overview/cards/SystemStatusCard"; import "@goauthentik/admin/admin-overview/cards/VersionStatusCard"; import "@goauthentik/admin/admin-overview/cards/WorkerStatusCard"; import "@goauthentik/admin/admin-overview/charts/AdminLoginAuthorizeChart"; import "@goauthentik/admin/admin-overview/charts/OutpostStatusChart"; import "@goauthentik/admin/admin-overview/charts/SyncStatusChart"; import { VERSION } from "@goauthentik/common/constants"; import { me } from "@goauthentik/common/users"; import { AKElement } from "@goauthentik/elements/Base"; import { WithLicenseSummary } from "@goauthentik/elements/Interface/licenseSummaryProvider.js"; import "@goauthentik/elements/PageHeader"; import "@goauthentik/elements/cards/AggregatePromiseCard"; import "@goauthentik/elements/cards/QuickActionsCard.js"; import type { QuickAction } from "@goauthentik/elements/cards/QuickActionsCard.js"; import { paramURL } from "@goauthentik/elements/router/RouterOutlet"; import { msg, str } from "@lit/localize"; import { CSSResult, TemplateResult, css, html, nothing } from "lit"; import { customElement, state } from "lit/decorators.js"; import { classMap } from "lit/directives/class-map.js"; import { map } from "lit/directives/map.js"; import { when } from "lit/directives/when.js"; import PFContent from "@patternfly/patternfly/components/Content/content.css"; import PFDivider from "@patternfly/patternfly/components/Divider/divider.css"; import PFPage from "@patternfly/patternfly/components/Page/page.css"; import PFGrid from "@patternfly/patternfly/layouts/Grid/grid.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; import { SessionUser } from "@goauthentik/api"; export function versionFamily(): string { const parts = VERSION.split("."); parts.pop(); return parts.join("."); } const RELEASE = `${VERSION.split(".").slice(0, -1).join(".")}#fixed-in-${VERSION.replaceAll( ".", "", )}`; const AdminOverviewBase = WithLicenseSummary(AKElement); type Renderer = () => TemplateResult | typeof nothing; @customElement("ak-admin-overview") export class AdminOverviewPage extends AdminOverviewBase { static get styles(): CSSResult[] { return [ PFBase, PFGrid, PFPage, PFContent, PFDivider, css` .pf-l-grid__item { height: 100%; } .pf-l-grid__item.big-graph-container { height: 35em; } .card-container { max-height: 10em; } .ak-external-link { display: inline-block; margin-left: 0.175rem; vertical-align: super; line-height: normal; font-size: var(--pf-global--icon--FontSize--sm); } `, ]; } quickActions: QuickAction[] = [ [msg("Create a new application"), paramURL("/core/applications", { createForm: true })], [msg("Check the logs"), paramURL("/events/log")], [msg("Explore integrations"), "https://goauthentik.io/integrations/", true], [msg("Manage users"), paramURL("/identity/users")], [msg("Check the release notes"), `https://goauthentik.io/docs/releases/${RELEASE}`, true], ]; @state() user?: SessionUser; async firstUpdated(): Promise { this.user = await me(); } render(): TemplateResult { const name = this.user?.user.name ?? this.user?.user.username; return html` ${msg(str`Welcome, ${name || ""}.`)}

${this.renderCards()}

`; } renderCards() { const isEnterprise = this.hasEnterpriseLicense; const classes = { "card-container": true, "pf-l-grid__item": true, "pf-m-6-col": true, "pf-m-4-col-on-md": !isEnterprise, "pf-m-4-col-on-xl": !isEnterprise, "pf-m-3-col-on-md": isEnterprise, "pf-m-3-col-on-xl": isEnterprise, }; return html`
${isEnterprise ? html`
` : nothing} `; } renderActions() { const release = `${versionFamily()}#fixed-in-${VERSION.replaceAll(".", "")}`; const quickActions: [string, string][] = [ [msg("Create a new application"), paramURL("/core/applications", { createForm: true })], [msg("Check the logs"), paramURL("/events/log")], [msg("Explore integrations"), "https://goauthentik.io/integrations/"], [msg("Manage users"), paramURL("/identity/users")], [msg("Check the release notes"), `https://goauthentik.io/docs/releases/${release}`], ]; const action = ([label, url]: [string, string]) => { const isExternal = url.startsWith("https://"); const ex = (truecase: Renderer, falsecase: Renderer) => when(isExternal, truecase, falsecase); const content = html`${label}${ex( () => html``, () => nothing, )}`; return html`
  • ${ex( () => html`${content}`, () => html`${content}`, )}
  • `; }; return html`${map(quickActions, action)}`; } } declare global { interface HTMLElementTagNameMap { "ak-admin-overview": AdminOverviewPage; } }