4a91a7d2e2
* fix repo in api client Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: re-organise files to match their interface Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * core: include version in script tags Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * cleanup maybe broken Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * revert rename Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: get rid of Client.ts Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * move more to common Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * more moving Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * format Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * unfuck files that vscode fucked, thanks Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * move more Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * finish moving (maybe) Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * ok more moving Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix more stuff that vs code destroyed Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * get rid "web" prefix for virtual package Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix locales Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * use custom base element Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix css file Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * don't run autoDetectLanguage when importing locale Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix circular dependencies Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: fix build Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
96 lines
3.2 KiB
TypeScript
96 lines
3.2 KiB
TypeScript
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
|
import { uiConfig } from "@goauthentik/common/ui/config";
|
|
import { first } from "@goauthentik/common/utils";
|
|
import { PFColor } from "@goauthentik/elements/Label";
|
|
import "@goauthentik/elements/buttons/SpinnerButton";
|
|
import { PaginatedResponse } from "@goauthentik/elements/table/Table";
|
|
import { TableColumn } from "@goauthentik/elements/table/Table";
|
|
import { TableModal } from "@goauthentik/elements/table/TableModal";
|
|
|
|
import { t } from "@lingui/macro";
|
|
|
|
import { TemplateResult, html } from "lit";
|
|
import { customElement, property } from "lit/decorators.js";
|
|
|
|
import { CoreApi, User } from "@goauthentik/api";
|
|
|
|
@customElement("ak-group-member-select-table")
|
|
export class MemberSelectTable extends TableModal<User> {
|
|
checkbox = true;
|
|
checkboxChip = true;
|
|
|
|
searchEnabled(): boolean {
|
|
return true;
|
|
}
|
|
|
|
@property()
|
|
confirm!: (selectedItems: User[]) => Promise<unknown>;
|
|
|
|
order = "username";
|
|
|
|
async apiEndpoint(page: number): Promise<PaginatedResponse<User>> {
|
|
return new CoreApi(DEFAULT_CONFIG).coreUsersList({
|
|
ordering: this.order,
|
|
page: page,
|
|
pageSize: (await uiConfig()).pagination.perPage,
|
|
search: this.search || "",
|
|
});
|
|
}
|
|
|
|
columns(): TableColumn[] {
|
|
return [
|
|
new TableColumn(t`Name`, "username"),
|
|
new TableColumn(t`Active`, "active"),
|
|
new TableColumn(t`Last login`, "last_login"),
|
|
];
|
|
}
|
|
|
|
row(item: User): TemplateResult[] {
|
|
return [
|
|
html`<div>
|
|
<div>${item.username}</div>
|
|
<small>${item.name}</small>
|
|
</div>`,
|
|
html` <ak-label color=${item.isActive ? PFColor.Green : PFColor.Orange}>
|
|
${item.isActive ? t`Yes` : t`No`}
|
|
</ak-label>`,
|
|
html`${first(item.lastLogin?.toLocaleString(), t`-`)}`,
|
|
];
|
|
}
|
|
|
|
renderSelectedChip(item: User): TemplateResult {
|
|
return html`${item.username}`;
|
|
}
|
|
|
|
renderModalInner(): TemplateResult {
|
|
return html`<section class="pf-c-modal-box__header pf-c-page__main-section pf-m-light">
|
|
<div class="pf-c-content">
|
|
<h1 class="pf-c-title pf-m-2xl">${t`Select users to add`}</h1>
|
|
</div>
|
|
</section>
|
|
<section class="pf-c-modal-box__body pf-c-page__main-section pf-m-light">
|
|
${this.renderTable()}
|
|
</section>
|
|
<footer class="pf-c-modal-box__footer">
|
|
<ak-spinner-button
|
|
.callAction=${() => {
|
|
return this.confirm(this.selectedElements).then(() => {
|
|
this.open = false;
|
|
});
|
|
}}
|
|
class="pf-m-primary"
|
|
>
|
|
${t`Add`} </ak-spinner-button
|
|
>
|
|
<ak-spinner-button
|
|
.callAction=${async () => {
|
|
this.open = false;
|
|
}}
|
|
class="pf-m-secondary"
|
|
>
|
|
${t`Cancel`}
|
|
</ak-spinner-button>
|
|
</footer>`;
|
|
}
|
|
}
|