2021-02-19 17:59:24 +00:00
|
|
|
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/Dropdown";
|
2021-02-19 18:33:58 +00:00
|
|
|
import "../../elements/buttons/TokenCopyButton";
|
2021-02-19 17:59:24 +00:00
|
|
|
import { TableColumn } from "../../elements/table/Table";
|
|
|
|
import { Token } from "../../api/Tokens";
|
|
|
|
|
|
|
|
@customElement("ak-token-list")
|
|
|
|
export class TokenListPage extends TablePage<Token> {
|
|
|
|
searchEnabled(): boolean {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
pageTitle(): string {
|
|
|
|
return gettext("Tokens");
|
|
|
|
}
|
|
|
|
pageDescription(): string {
|
|
|
|
return gettext("Tokens are used throughout authentik for Email validation stages, Recovery keys and API access.");
|
|
|
|
}
|
|
|
|
pageIcon(): string {
|
|
|
|
return gettext("pf-icon pf-icon-security");
|
|
|
|
}
|
|
|
|
|
|
|
|
@property()
|
|
|
|
order = "expires";
|
|
|
|
|
|
|
|
apiEndpoint(page: number): Promise<AKResponse<Token>> {
|
|
|
|
return Token.list({
|
|
|
|
ordering: this.order,
|
|
|
|
page: page,
|
|
|
|
search: this.search || "",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
columns(): TableColumn[] {
|
|
|
|
return [
|
|
|
|
new TableColumn("Identifier", "identifier"),
|
|
|
|
new TableColumn("User", "user"),
|
|
|
|
new TableColumn("Expires?", "expiring"),
|
|
|
|
new TableColumn("Expiry date", "expires"),
|
|
|
|
new TableColumn(""),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
row(item: Token): TemplateResult[] {
|
|
|
|
return [
|
|
|
|
html`${item.identifier}`,
|
|
|
|
html`${item.user.username}`,
|
|
|
|
html`${item.expiring ? "Yes" : "No"}`,
|
2021-02-19 18:33:58 +00:00
|
|
|
html`${item.expiring ? new Date(item.expires * 1000).toLocaleString() : "-"}`,
|
2021-02-19 17:59:24 +00:00
|
|
|
html`
|
2021-02-19 23:20:01 +00:00
|
|
|
<ak-modal-button href="${Token.adminUrl(`${item.identifier}/delete/`)}">
|
2021-02-19 17:59:24 +00:00
|
|
|
<ak-spinner-button slot="trigger" class="pf-m-danger">
|
2021-02-19 18:33:58 +00:00
|
|
|
${gettext("Delete")}
|
2021-02-19 17:59:24 +00:00
|
|
|
</ak-spinner-button>
|
|
|
|
<div slot="modal"></div>
|
|
|
|
</ak-modal-button>
|
|
|
|
<ak-token-copy-button identifier="${item.identifier}">
|
2021-02-19 18:33:58 +00:00
|
|
|
${gettext("Copy Key")}
|
2021-02-19 17:59:24 +00:00
|
|
|
</ak-token-copy-button>
|
|
|
|
`,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|