web: add confirmation form for simple write-requests

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-03-23 15:07:45 +01:00
parent 3c2d541d60
commit 56344cadeb
4 changed files with 128 additions and 32 deletions

View File

@ -1,9 +1,9 @@
import { gettext } from "django";
import { customElement, html, TemplateResult } from "lit-element";
import { AdminStatus, AdminStatusCard } from "./AdminStatusCard";
import "../../../elements/buttons/ModalButton";
import { FlowsApi } from "authentik-api";
import { DEFAULT_CONFIG } from "../../../api/Config";
import "../../../elements/forms/ConfirmationForm";
@customElement("ak-admin-status-card-flow-cache")
export class FlowCacheStatusCard extends AdminStatusCard<number> {
@ -28,12 +28,25 @@ export class FlowCacheStatusCard extends AdminStatusCard<number> {
}
renderHeaderLink(): TemplateResult {
return html`<ak-modal-button href="/administration/overview/cache/flow/">
<a slot="trigger">
<i class="fa fa-trash"> </i>
</a>
<div slot="modal"></div>
</ak-modal-button>`;
return html`<ak-forms-confirm
successMessage="Successfully cleared flow cache"
errorMessage="Failed to delete flow cache"
action="Clear cache"
.onConfirm=${() => {
return new FlowsApi(DEFAULT_CONFIG).flowsInstancesCacheClear();
}}>
<span slot="header">
${gettext("Clear Flow cache")}
</span>
<p slot="body">
${gettext(`Are you sure you want to clear the flow cache?
This will cause all flows to be re-evaluated on their next usage.`)}
</p>
<a slot="trigger">
<i class="fa fa-trash"> </i>
</a>
<div slot="modal"></div>
</ak-forms-confirm>`;
}
}

View File

@ -2,9 +2,9 @@ import { gettext } from "django";
import { customElement } from "lit-element";
import { TemplateResult, html } from "lit-html";
import { AdminStatusCard, AdminStatus } from "./AdminStatusCard";
import "../../../elements/buttons/ModalButton";
import { PoliciesApi } from "authentik-api";
import { DEFAULT_CONFIG } from "../../../api/Config";
import "../../../elements/forms/ConfirmationForm";
@customElement("ak-admin-status-card-policy-cache")
export class PolicyCacheStatusCard extends AdminStatusCard<number> {
@ -29,12 +29,25 @@ export class PolicyCacheStatusCard extends AdminStatusCard<number> {
}
renderHeaderLink(): TemplateResult {
return html`<ak-modal-button href="/administration/overview/cache/policy/">
<a slot="trigger">
<i class="fa fa-trash"> </i>
</a>
<div slot="modal"></div>
</ak-modal-button>`;
return html`<ak-forms-confirm
successMessage="Successfully cleared policy cache"
errorMessage="Failed to delete policy cache"
action="Clear cache"
.onConfirm=${() => {
return new PoliciesApi(DEFAULT_CONFIG).policiesAllCacheClear();
}}>
<span slot="header">
${gettext("Clear Policy cache")}
</span>
<p slot="body">
${gettext(`Are you sure you want to clear the policy cache?
This will cause all policies to be re-evaluated on their next usage.`)}
</p>
<a slot="trigger">
<i class="fa fa-trash"> </i>
</a>
<div slot="modal"></div>
</ak-forms-confirm>`;
}
}