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"; import { TableColumn } from "../../elements/table/Table"; import { User } from "../../api/Users"; @customElement("ak-user-list") export class UserListPage extends TablePage { searchEnabled(): boolean { return true; } pageTitle(): string { return gettext("Users"); } pageDescription(): string { return ""; } pageIcon(): string { return gettext("pf-icon pf-icon-user"); } @property() order = "username"; apiEndpoint(page: number): Promise> { return User.list({ ordering: this.order, page: page, search: this.search || "", }); } columns(): TableColumn[] { return [ new TableColumn("Name", "username"), new TableColumn("Active", "active"), new TableColumn("Last login", "last_login"), new TableColumn(""), ]; } row(item: User): TemplateResult[] { return [ html`
${item.username}
${item.name}
`, html`${item.is_active ? "Yes" : "No"}`, html`${new Date(item.last_login * 1000).toLocaleString()}`, html` ${gettext("Edit")}
${gettext("Reset Password")} ${gettext("Impersonate")} `, ]; } renderToolbar(): TemplateResult { return html` ${gettext("Create")}
${super.renderToolbar()} `; } }