import { t } from "@lingui/macro"; import { CSSResult, TemplateResult, css, html } from "lit"; import { customElement, property } from "lit/decorators.js"; import PFAvatar from "@patternfly/patternfly/components/Avatar/avatar.css"; import { Application, CoreApi } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; import { uiConfig } from "../../common/config"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteBulkForm"; import "../../elements/forms/ModalForm"; import { TableColumn } from "../../elements/table/Table"; import { TablePage } from "../../elements/table/TablePage"; import "./ApplicationForm"; @customElement("ak-application-list") export class ApplicationListPage extends TablePage { searchEnabled(): boolean { return true; } pageTitle(): string { return t`Applications`; } pageDescription(): string { return t`External Applications which use authentik as Identity-Provider, utilizing protocols like OAuth2 and SAML. All applications are shown here, even ones you cannot access.`; } pageIcon(): string { return "pf-icon pf-icon-applications"; } checkbox = true; @property() order = "name"; async apiEndpoint(page: number): Promise> { return new CoreApi(DEFAULT_CONFIG).coreApplicationsList({ ordering: this.order, page: page, pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", superuserFullList: true, }); } static get styles(): CSSResult[] { return super.styles.concat( PFAvatar, css` tr td:first-child { width: auto; min-width: 0px; text-align: center; vertical-align: middle; } `, ); } columns(): TableColumn[] { return [ new TableColumn(""), new TableColumn(t`Name`, "name"), new TableColumn(t`Slug`, "slug"), new TableColumn(t`Provider`), new TableColumn(t`Provider Type`), new TableColumn(t`Actions`), ]; } renderToolbarSelected(): TemplateResult { const disabled = this.selectedElements.length < 1; return html` { return new CoreApi(DEFAULT_CONFIG).coreApplicationsUsedByList({ slug: item.slug, }); }} .delete=${(item: Application) => { return new CoreApi(DEFAULT_CONFIG).coreApplicationsDestroy({ slug: item.slug, }); }} > `; } row(item: Application): TemplateResult[] { return [ item.metaIcon ? html`${t`Application Icon`}` : html``, html`
${item.name}
${item.metaPublisher ? html`${item.metaPublisher}` : html``}
`, html`${item.slug}`, item.provider ? html` ${item.providerObj?.name} ` : html`-`, html`${item.providerObj?.verboseName || t`-`}`, html` ${t`Update`} ${t`Update Application`} ${item.launchUrl ? html` ` : html``}`, ]; } renderToolbar(): TemplateResult { return html` ${t`Create`} ${t`Create Application`} ${super.renderToolbar()} `; } }