From 3a9f081e1b8549b71bbb5851e6be619eb481e25e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 26 May 2021 12:08:11 +0200 Subject: [PATCH] web/admin: improve persistence for test forms Signed-off-by: Jens Langhammer --- web/src/pages/policies/PolicyTestForm.ts | 10 +++++++--- .../pages/property-mappings/PropertyMappingTestForm.ts | 9 +++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/web/src/pages/policies/PolicyTestForm.ts b/web/src/pages/policies/PolicyTestForm.ts index 2ca9a6747..be521adf5 100644 --- a/web/src/pages/policies/PolicyTestForm.ts +++ b/web/src/pages/policies/PolicyTestForm.ts @@ -5,10 +5,10 @@ import { html, TemplateResult } from "lit-html"; import { DEFAULT_CONFIG } from "../../api/Config"; import { Form } from "../../elements/forms/Form"; import { until } from "lit-html/directives/until"; -import { ifDefined } from "lit-html/directives/if-defined"; import "../../elements/forms/HorizontalFormElement"; import "../../elements/CodeMirror"; import YAML from "yaml"; +import { first } from "../../utils"; @customElement("ak-policy-test-form") export class PolicyTestForm extends Form { @@ -19,11 +19,15 @@ export class PolicyTestForm extends Form { @property({ attribute: false}) result?: PolicyTestResult; + @property({ attribute: false}) + request?: PolicyTestRequest; + getSuccessMessage(): string { return t`Successfully sent test-request.`; } send = (data: PolicyTestRequest): Promise => { + this.request = data; return new PoliciesApi(DEFAULT_CONFIG).policiesAllTestCreate({ policyUuid: this.policy?.pk || "", policyTestRequest: data @@ -67,7 +71,7 @@ export class PolicyTestForm extends Form { ordering: "username", }).then(users => { return users.results.map(user => { - return html``; + return html``; }); }), html``)} @@ -75,7 +79,7 @@ export class PolicyTestForm extends Form { - > + >

${t`Set custom attributes using YAML or JSON.`}

diff --git a/web/src/pages/property-mappings/PropertyMappingTestForm.ts b/web/src/pages/property-mappings/PropertyMappingTestForm.ts index d66a32b13..298988b2c 100644 --- a/web/src/pages/property-mappings/PropertyMappingTestForm.ts +++ b/web/src/pages/property-mappings/PropertyMappingTestForm.ts @@ -9,6 +9,7 @@ import { ifDefined } from "lit-html/directives/if-defined"; import "../../elements/forms/HorizontalFormElement"; import "../../elements/CodeMirror"; import YAML from "yaml"; +import { first } from "../../utils"; @customElement("ak-property-mapping-test-form") export class PolicyTestForm extends Form { @@ -19,11 +20,15 @@ export class PolicyTestForm extends Form { @property({ attribute: false}) result?: PropertyMappingTestResult; + @property({ attribute: false }) + request?: PolicyTestRequest; + getSuccessMessage(): string { return t`Successfully sent test-request.`; } send = (data: PolicyTestRequest): Promise => { + this.request = data; return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsAllTestCreate({ pmUuid: this.mapping?.pk || "", policyTestRequest: data, @@ -57,7 +62,7 @@ export class PolicyTestForm extends Form { ordering: "username", }).then(users => { return users.results.map(user => { - return html``; + return html``; }); }), html``)} @@ -65,7 +70,7 @@ export class PolicyTestForm extends Form { - + > ${this.result ? this.renderResult(): html``}