34ae9e6dab
* core: add used_by API to show what objects are affected before deletion Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web/elements: add support for used_by API Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * core: add authentik_used_by_shadows to shadow other models Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: implement used_by API Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * *: fix duplicate imports Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * core: add action field to used_by api Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: add UI for used_by action Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: add notice to tenant form Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * core: fix naming in used_by Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: check length for used_by Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * core: fix used_by for non-pk models Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * *: improve __str__ on models Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * core: add support for many to many in used_by Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import { t } from "@lingui/macro";
|
|
import { customElement, html, property, TemplateResult } from "lit-element";
|
|
import { AKResponse } from "../../api/Client";
|
|
import { Table, TableColumn } from "../table/Table";
|
|
|
|
import "../forms/DeleteForm";
|
|
import { PAGE_SIZE } from "../../constants";
|
|
import { CoreApi, UserConsent } from "authentik-api";
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
|
|
|
@customElement("ak-user-consent-list")
|
|
export class UserConsentList extends Table<UserConsent> {
|
|
@property({ type: Number })
|
|
userId?: number;
|
|
|
|
apiEndpoint(page: number): Promise<AKResponse<UserConsent>> {
|
|
return new CoreApi(DEFAULT_CONFIG).coreUserConsentList({
|
|
user: this.userId,
|
|
ordering: this.order,
|
|
page: page,
|
|
pageSize: PAGE_SIZE,
|
|
});
|
|
}
|
|
|
|
order = "-expires";
|
|
|
|
columns(): TableColumn[] {
|
|
return [
|
|
new TableColumn(t`Application`, "application"),
|
|
new TableColumn(t`Expires`, "expires"),
|
|
new TableColumn(""),
|
|
];
|
|
}
|
|
|
|
row(item: UserConsent): TemplateResult[] {
|
|
return [
|
|
html`${item.application.name}`,
|
|
html`${item.expires?.toLocaleString()}`,
|
|
html`
|
|
<ak-forms-delete
|
|
.obj=${item}
|
|
objectLabel=${t`Consent`}
|
|
.usedBy=${() => {
|
|
return new CoreApi(DEFAULT_CONFIG).coreUserConsentUsedByList({
|
|
id: item.pk
|
|
});
|
|
}}
|
|
.delete=${() => {
|
|
return new CoreApi(DEFAULT_CONFIG).coreUserConsentDestroy({
|
|
id: item.pk,
|
|
});
|
|
}}>
|
|
<button slot="trigger" class="pf-c-button pf-m-danger">
|
|
${t`Delete Consent`}
|
|
</button>
|
|
</ak-forms-delete>`,
|
|
];
|
|
}
|
|
|
|
}
|