import { gettext } from "django"; import { customElement, html, property, TemplateResult } from "lit-element"; import { AKResponse } from "../../api/Client"; import { TablePage } from "../../elements/table/TablePage"; import { CryptoApi, CertificateKeyPair } from "authentik-api"; import "../../elements/buttons/ModalButton"; import "../../elements/buttons/SpinnerButton"; import { TableColumn } from "../../elements/table/Table"; import { PAGE_SIZE } from "../../constants"; import { AdminURLManager } from "../../api/legacy"; import { DEFAULT_CONFIG } from "../../api/Config"; @customElement("ak-crypto-certificatekeypair-list") export class CertificateKeyPairListPage extends TablePage { expandable = true; searchEnabled(): boolean { return true; } pageTitle(): string { return gettext("Certificate-Key Pairs"); } pageDescription(): string { return gettext("Import certificates of external providers or create certificates to sign requests with."); } pageIcon(): string { return gettext("pf-icon pf-icon-key"); } @property() order = "name"; apiEndpoint(page: number): Promise> { return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsList({ ordering: this.order, page: page, pageSize: PAGE_SIZE, search: this.search || "", }); } columns(): TableColumn[] { return [ new TableColumn("Name", "name"), new TableColumn("Private key available?"), new TableColumn("Expiry date"), new TableColumn(""), ]; } row(item: CertificateKeyPair): TemplateResult[] { return [ html`${item.name}`, html`${gettext(item.privateKeyAvailable ? "Yes" : "No")}`, html`${item.certExpiry?.toLocaleString()}`, html` ${gettext("Edit")}
${gettext("Delete")}
`, ]; } renderExpanded(item: CertificateKeyPair): TemplateResult { return html`
${gettext("Certificate Fingerprint")}
${item.fingerprint}
${gettext("Certificate Subjet")}
${item.certSubject}
`; } renderToolbar(): TemplateResult { return html` ${gettext("Create")}
${gettext("Generate")}
${super.renderToolbar()} `; } }