import { t } from "@lingui/macro"; import { CSSResult, customElement, html, property, TemplateResult } from "lit-element"; import { AKResponse } from "../../api/Client"; import { TablePage } from "../../elements/table/TablePage"; import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css"; import { CryptoApi, CertificateKeyPair } from "authentik-api"; import "../../elements/forms/ModalForm"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteForm"; import "./CertificateKeyPairForm"; import "./CertificateGenerateForm"; import { TableColumn } from "../../elements/table/Table"; import { PAGE_SIZE } from "../../constants"; import { DEFAULT_CONFIG } from "../../api/Config"; @customElement("ak-crypto-certificate-list") export class CertificateKeyPairListPage extends TablePage { expandable = true; searchEnabled(): boolean { return true; } pageTitle(): string { return t`Certificate-Key Pairs`; } pageDescription(): string { return t`Import certificates of external providers or create certificates to sign requests with.`; } pageIcon(): string { return "pf-icon pf-icon-key"; } @property() order = "name"; static get styles(): CSSResult[] { return super.styles.concat(PFDescriptionList); } 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(t`Name`, "name"), new TableColumn(t`Private key available?`), new TableColumn(t`Expiry date`), new TableColumn(""), ]; } row(item: CertificateKeyPair): TemplateResult[] { return [ html`${item.name}`, html`${item.privateKeyAvailable ? t`Yes` : t`No`}`, html`${item.certExpiry?.toLocaleString()}`, html` ${t`Update`} ${t`Update Certificate-Key Pair`} { return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsDelete({ kpUuid: item.pk || "" }); }}> `, ]; } renderExpanded(item: CertificateKeyPair): TemplateResult { return html`
${t`Certificate Fingerprint`}
${item.fingerprint}
${t`Certificate Subjet`}
${item.certSubject}
`; } renderToolbar(): TemplateResult { return html` ${t`Create`} ${t`Create Certificate-Key Pair`} ${t`Generate`} ${t`Generate Certificate-Key Pair`} ${super.renderToolbar()} `; } }