From 4d11d82c6e5879556ab5de6e5d4ee53866e64d92 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 11 May 2021 11:55:25 +0200 Subject: [PATCH] web/admin: migrate more forms Signed-off-by: Jens Langhammer --- .../pages/crypto/CertificateKeyPairForm.ts | 26 ++++++----- .../crypto/CertificateKeyPairListPage.ts | 2 +- web/src/pages/events/RuleForm.ts | 30 +++++++------ web/src/pages/events/RuleListPage.ts | 2 +- web/src/pages/events/TransportForm.ts | 32 ++++++++------ web/src/pages/events/TransportListPage.ts | 2 +- web/src/pages/flows/BoundStagesList.ts | 2 +- web/src/pages/flows/FlowForm.ts | 44 ++++++++++--------- web/src/pages/flows/FlowListPage.ts | 2 +- web/src/pages/flows/StageBindingForm.ts | 34 +++++++------- 10 files changed, 98 insertions(+), 78 deletions(-) diff --git a/web/src/pages/crypto/CertificateKeyPairForm.ts b/web/src/pages/crypto/CertificateKeyPairForm.ts index fa2b36980..e466c268d 100644 --- a/web/src/pages/crypto/CertificateKeyPairForm.ts +++ b/web/src/pages/crypto/CertificateKeyPairForm.ts @@ -7,15 +7,19 @@ import { Form } from "../../elements/forms/Form"; import { ifDefined } from "lit-html/directives/if-defined"; import "../../elements/forms/HorizontalFormElement"; import "../../elements/CodeMirror"; +import { ModelForm } from "../../elements/forms/ModelForm"; @customElement("ak-crypto-certificate-form") -export class CertificateKeyPairForm extends Form { +export class CertificateKeyPairForm extends ModelForm { - @property({attribute: false}) - keyPair?: CertificateKeyPair; + loadInstance(pk: string): Promise { + return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsRead({ + kpUuid: pk, + }); + } getSuccessMessage(): string { - if (this.keyPair) { + if (this.instance) { return t`Successfully updated certificate-key pair.`; } else { return t`Successfully created certificate-key pair.`; @@ -23,9 +27,9 @@ export class CertificateKeyPairForm extends Form { } send = (data: CertificateKeyPair): Promise => { - if (this.keyPair) { + if (this.instance) { return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsPartialUpdate({ - kpUuid: this.keyPair.pk || "", + kpUuid: this.instance.pk || "", data: data }); } else { @@ -41,21 +45,21 @@ export class CertificateKeyPairForm extends Form { label=${t`Name`} name="name" ?required=${true}> - + - +

${t`PEM-encoded Certificate data.`}

- +

${t`Optional Private Key. If this is set, you can use this keypair for encryption.`}

`; diff --git a/web/src/pages/crypto/CertificateKeyPairListPage.ts b/web/src/pages/crypto/CertificateKeyPairListPage.ts index 5add00041..06e39bdac 100644 --- a/web/src/pages/crypto/CertificateKeyPairListPage.ts +++ b/web/src/pages/crypto/CertificateKeyPairListPage.ts @@ -70,7 +70,7 @@ export class CertificateKeyPairListPage extends TablePage { ${t`Update Certificate-Key Pair`} - +