web/admin: add modelform as base, start migrating
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
@ -3,27 +3,22 @@ import { t } from "@lingui/macro";
|
||||
import { customElement, property } from "lit-element";
|
||||
import { html, TemplateResult } from "lit-html";
|
||||
import { DEFAULT_CONFIG } from "../../api/Config";
|
||||
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-property-mapping-ldap-form")
|
||||
export class PropertyMappingLDAPForm extends Form<LDAPPropertyMapping> {
|
||||
export class PropertyMappingLDAPForm extends ModelForm<LDAPPropertyMapping, string> {
|
||||
|
||||
set mappingUUID(value: string) {
|
||||
new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsLdapRead({
|
||||
pmUuid: value,
|
||||
}).then(mapping => {
|
||||
this.mapping = mapping;
|
||||
loadInstance(pk: string): Promise<LDAPPropertyMapping> {
|
||||
return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsLdapRead({
|
||||
pmUuid: pk,
|
||||
});
|
||||
}
|
||||
|
||||
@property({attribute: false})
|
||||
mapping?: LDAPPropertyMapping;
|
||||
|
||||
getSuccessMessage(): string {
|
||||
if (this.mapping) {
|
||||
if (this.instance) {
|
||||
return t`Successfully updated mapping.`;
|
||||
} else {
|
||||
return t`Successfully created mapping.`;
|
||||
@ -31,9 +26,9 @@ export class PropertyMappingLDAPForm extends Form<LDAPPropertyMapping> {
|
||||
}
|
||||
|
||||
send = (data: LDAPPropertyMapping): Promise<LDAPPropertyMapping> => {
|
||||
if (this.mapping) {
|
||||
if (this.instance) {
|
||||
return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsLdapUpdate({
|
||||
pmUuid: this.mapping.pk || "",
|
||||
pmUuid: this.instance.pk || "",
|
||||
data: data
|
||||
});
|
||||
} else {
|
||||
@ -49,20 +44,20 @@ export class PropertyMappingLDAPForm extends Form<LDAPPropertyMapping> {
|
||||
label=${t`Name`}
|
||||
?required=${true}
|
||||
name="name">
|
||||
<input type="text" value="${ifDefined(this.mapping?.name)}" class="pf-c-form-control" required>
|
||||
<input type="text" value="${ifDefined(this.instance?.name)}" class="pf-c-form-control" required>
|
||||
</ak-form-element-horizontal>
|
||||
<ak-form-element-horizontal
|
||||
label=${t`Object field`}
|
||||
?required=${true}
|
||||
name="objectField">
|
||||
<input type="text" value="${ifDefined(this.mapping?.objectField)}" class="pf-c-form-control" required>
|
||||
<input type="text" value="${ifDefined(this.instance?.objectField)}" class="pf-c-form-control" required>
|
||||
<p class="pf-c-form__helper-text">${t`Field of the user object this value is written to.`}</p>
|
||||
</ak-form-element-horizontal>
|
||||
<ak-form-element-horizontal
|
||||
label=${t`Expression`}
|
||||
?required=${true}
|
||||
name="expression">
|
||||
<ak-codemirror mode="python" value="${ifDefined(this.mapping?.expression)}">
|
||||
<ak-codemirror mode="python" value="${ifDefined(this.instance?.expression)}">
|
||||
</ak-codemirror>
|
||||
<p class="pf-c-form__helper-text">
|
||||
${t`Expression using Python.`}
|
||||
|
||||
@ -3,27 +3,21 @@ import { t } from "@lingui/macro";
|
||||
import { customElement, property } from "lit-element";
|
||||
import { html, TemplateResult } from "lit-html";
|
||||
import { DEFAULT_CONFIG } from "../../api/Config";
|
||||
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-property-mapping-saml-form")
|
||||
export class PropertyMappingLDAPForm extends Form<SAMLPropertyMapping> {
|
||||
|
||||
set mappingUUID(value: string) {
|
||||
new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsSamlRead({
|
||||
pmUuid: value,
|
||||
}).then(mapping => {
|
||||
this.mapping = mapping;
|
||||
export class PropertyMappingLDAPForm extends ModelForm<SAMLPropertyMapping, string> {
|
||||
loadInstance(pk: string): Promise<SAMLPropertyMapping> {
|
||||
return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsSamlRead({
|
||||
pmUuid: pk,
|
||||
});
|
||||
}
|
||||
|
||||
@property({attribute: false})
|
||||
mapping?: SAMLPropertyMapping;
|
||||
|
||||
getSuccessMessage(): string {
|
||||
if (this.mapping) {
|
||||
if (this.instance) {
|
||||
return t`Successfully updated mapping.`;
|
||||
} else {
|
||||
return t`Successfully created mapping.`;
|
||||
@ -31,9 +25,9 @@ export class PropertyMappingLDAPForm extends Form<SAMLPropertyMapping> {
|
||||
}
|
||||
|
||||
send = (data: SAMLPropertyMapping): Promise<SAMLPropertyMapping> => {
|
||||
if (this.mapping) {
|
||||
if (this.instance) {
|
||||
return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsSamlUpdate({
|
||||
pmUuid: this.mapping.pk || "",
|
||||
pmUuid: this.instance.pk || "",
|
||||
data: data
|
||||
});
|
||||
} else {
|
||||
@ -49,13 +43,13 @@ export class PropertyMappingLDAPForm extends Form<SAMLPropertyMapping> {
|
||||
label=${t`Name`}
|
||||
?required=${true}
|
||||
name="name">
|
||||
<input type="text" value="${ifDefined(this.mapping?.name)}" class="pf-c-form-control" required>
|
||||
<input type="text" value="${ifDefined(this.instance?.name)}" class="pf-c-form-control" required>
|
||||
</ak-form-element-horizontal>
|
||||
<ak-form-element-horizontal
|
||||
label=${t`SAML Attribute Name`}
|
||||
?required=${true}
|
||||
name="samlName">
|
||||
<input type="text" value="${ifDefined(this.mapping?.samlName)}" class="pf-c-form-control" required>
|
||||
<input type="text" value="${ifDefined(this.instance?.samlName)}" class="pf-c-form-control" required>
|
||||
<p class="pf-c-form__helper-text">
|
||||
${t`Attribute name used for SAML Assertions. Can be a URN OID, a schema reference, or a any other string. If this property mapping is used for NameID Property, this field is discarded.`}
|
||||
</p>
|
||||
@ -63,7 +57,7 @@ export class PropertyMappingLDAPForm extends Form<SAMLPropertyMapping> {
|
||||
<ak-form-element-horizontal
|
||||
label=${t`Friendly Name`}
|
||||
name="friendlyName">
|
||||
<input type="text" value="${ifDefined(this.mapping?.friendlyName || "")}" class="pf-c-form-control">
|
||||
<input type="text" value="${ifDefined(this.instance?.friendlyName || "")}" class="pf-c-form-control">
|
||||
<p class="pf-c-form__helper-text">
|
||||
${t`Optionally set the 'FriendlyName' value of the Assertion attribute.`}
|
||||
</p>
|
||||
@ -72,7 +66,7 @@ export class PropertyMappingLDAPForm extends Form<SAMLPropertyMapping> {
|
||||
label=${t`Expression`}
|
||||
?required=${true}
|
||||
name="expression">
|
||||
<ak-codemirror mode="python" value="${ifDefined(this.mapping?.expression)}">
|
||||
<ak-codemirror mode="python" value="${ifDefined(this.instance?.expression)}">
|
||||
</ak-codemirror>
|
||||
<p class="pf-c-form__helper-text">
|
||||
${t`Expression using Python.`}
|
||||
|
||||
@ -3,27 +3,22 @@ import { t } from "@lingui/macro";
|
||||
import { customElement, property } from "lit-element";
|
||||
import { html, TemplateResult } from "lit-html";
|
||||
import { DEFAULT_CONFIG } from "../../api/Config";
|
||||
import { Form } from "../../elements/forms/Form";
|
||||
import { ModelForm } from "../../elements/forms/ModelForm";
|
||||
import { ifDefined } from "lit-html/directives/if-defined";
|
||||
import "../../elements/forms/HorizontalFormElement";
|
||||
import "../../elements/CodeMirror";
|
||||
|
||||
@customElement("ak-property-mapping-scope-form")
|
||||
export class PropertyMappingScopeForm extends Form<ScopeMapping> {
|
||||
export class PropertyMappingScopeForm extends ModelForm<ScopeMapping, string> {
|
||||
|
||||
set mappingUUID(value: string) {
|
||||
new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsScopeRead({
|
||||
pmUuid: value,
|
||||
}).then(mapping => {
|
||||
this.mapping = mapping;
|
||||
loadInstance(pk: string): Promise<ScopeMapping> {
|
||||
return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsScopeRead({
|
||||
pmUuid: pk,
|
||||
});
|
||||
}
|
||||
|
||||
@property({attribute: false})
|
||||
mapping?: ScopeMapping;
|
||||
|
||||
getSuccessMessage(): string {
|
||||
if (this.mapping) {
|
||||
if (this.instance) {
|
||||
return t`Successfully updated mapping.`;
|
||||
} else {
|
||||
return t`Successfully created mapping.`;
|
||||
@ -31,9 +26,9 @@ export class PropertyMappingScopeForm extends Form<ScopeMapping> {
|
||||
}
|
||||
|
||||
send = (data: ScopeMapping): Promise<ScopeMapping> => {
|
||||
if (this.mapping) {
|
||||
if (this.instance) {
|
||||
return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsScopeUpdate({
|
||||
pmUuid: this.mapping.pk || "",
|
||||
pmUuid: this.instance.pk || "",
|
||||
data: data
|
||||
});
|
||||
} else {
|
||||
@ -49,27 +44,27 @@ export class PropertyMappingScopeForm extends Form<ScopeMapping> {
|
||||
label=${t`Name`}
|
||||
?required=${true}
|
||||
name="name">
|
||||
<input type="text" value="${ifDefined(this.mapping?.name)}" class="pf-c-form-control" required>
|
||||
<input type="text" value="${ifDefined(this.instance?.name)}" class="pf-c-form-control" required>
|
||||
</ak-form-element-horizontal>
|
||||
<ak-form-element-horizontal
|
||||
label=${t`Scope name`}
|
||||
?required=${true}
|
||||
name="scopeName">
|
||||
<input type="text" value="${ifDefined(this.mapping?.scopeName)}" class="pf-c-form-control" required>
|
||||
<input type="text" value="${ifDefined(this.instance?.scopeName)}" class="pf-c-form-control" required>
|
||||
<p class="pf-c-form__helper-text">${t`Scope which the client can specify to access these properties.`}</p>
|
||||
</ak-form-element-horizontal>
|
||||
<ak-form-element-horizontal
|
||||
label=${t`Description`}
|
||||
?required=${true}
|
||||
name="description">
|
||||
<input type="text" value="${ifDefined(this.mapping?.description)}" class="pf-c-form-control" required>
|
||||
<input type="text" value="${ifDefined(this.instance?.description)}" class="pf-c-form-control" required>
|
||||
<p class="pf-c-form__helper-text">${t`Description shown to the user when consenting. If left empty, the user won't be informed.`}</p>
|
||||
</ak-form-element-horizontal>
|
||||
<ak-form-element-horizontal
|
||||
label=${t`Expression`}
|
||||
?required=${true}
|
||||
name="expression">
|
||||
<ak-codemirror mode="python" value="${ifDefined(this.mapping?.expression)}">
|
||||
<ak-codemirror mode="python" value="${ifDefined(this.instance?.expression)}">
|
||||
</ak-codemirror>
|
||||
<p class="pf-c-form__helper-text">
|
||||
${t`Expression using Python.`}
|
||||
|
||||
Reference in New Issue
Block a user