import { gettext } from "django"; import { customElement, html, property, TemplateResult } from "lit-element"; import { AKResponse } from "../../api/Client"; import { TablePage } from "../../elements/table/TablePage"; import "../../elements/buttons/ModalButton"; import "../../elements/buttons/SpinnerButton"; import { TableColumn } from "../../elements/table/Table"; import { CertificateKeyPair } from "../../api/CertificateKeyPair"; @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 CertificateKeyPair.list({ ordering: this.order, page: page, 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.private_key_available ? "Yes" : "No")}`, html`${new Date(item.cert_expiry * 1000).toLocaleString()}`, html` ${gettext("Edit")}
  ${gettext("Delete")}
`, ]; } renderExpanded(item: CertificateKeyPair): TemplateResult { return html`
${gettext("Certificate Fingerprint")}
${item.fingerprint}
${gettext("Certificate Subjet")}
${item.cert_subject}
`; } renderToolbar(): TemplateResult { return html` ${gettext("Create")}
  ${gettext("Generate")}
${super.renderToolbar()} `; } }