This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/web/src/elements/table/TablePagination.ts

60 lines
2.7 KiB
TypeScript
Raw Normal View History

import { CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
import { AKPagination } from "../../api/Client";
import { t } from "@lingui/macro";
import PFBase from "@patternfly/patternfly/patternfly-base.css";
import PFButton from "@patternfly/patternfly/components/Button/button.css";
import PFPagination from "@patternfly/patternfly/components/Pagination/pagination.css";
import AKGlobal from "../../authentik.css";
2020-12-05 21:08:42 +00:00
@customElement("ak-table-pagination")
export class TablePagination extends LitElement {
2020-12-02 14:44:40 +00:00
@property({attribute: false})
pages?: AKPagination;
2020-12-05 21:08:42 +00:00
@property({attribute: false})
// eslint-disable-next-line
pageChangeHandler: (page: number) => void = (page: number) => {}
static get styles(): CSSResult[] {
return [PFBase, PFButton, PFPagination, AKGlobal];
}
render(): TemplateResult {
return html` <div class="pf-c-pagination pf-m-compact pf-m-hidden pf-m-visible-on-md">
<div class="pf-c-pagination pf-m-compact pf-m-compact pf-m-hidden pf-m-visible-on-md">
<div class="pf-c-options-menu">
<div class="pf-c-options-menu__toggle pf-m-text pf-m-plain">
<span class="pf-c-options-menu__toggle-text">
${this.pages?.startIndex} -
${this.pages?.endIndex} of
2020-12-05 21:08:42 +00:00
${this.pages?.count}
</span>
</div>
</div>
<nav class="pf-c-pagination__nav" aria-label="Pagination">
<div class="pf-c-pagination__nav-control pf-m-prev">
<button
class="pf-c-button pf-m-plain"
2020-12-05 21:08:42 +00:00
@click=${() => { this.pageChangeHandler(this.pages?.previous || 0); }}
?disabled="${(this.pages?.previous || 0) < 1}"
aria-label="${t`Go to previous page`}"
>
<i class="fas fa-angle-left" aria-hidden="true"></i>
</button>
</div>
<div class="pf-c-pagination__nav-control pf-m-next">
<button
class="pf-c-button pf-m-plain"
2020-12-05 21:08:42 +00:00
@click=${() => { this.pageChangeHandler(this.pages?.next || 0); }}
2021-02-19 17:59:24 +00:00
?disabled="${(this.pages?.next || 0) <= 0}"
aria-label="${t`Go to next page`}"
>
<i class="fas fa-angle-right" aria-hidden="true"></i>
</button>
</div>
</nav>
</div>
</div>`;
}
}