use of org.jboss.hal.ballroom.form.Form in project console by hal.
the class MapperDecoderView method init.
@PostConstruct
void init() {
Metadata metadata = mbuiContext.metadataRegistry().lookup(CONSTANT_PERMISSION_MAPPER_TEMPLATE);
constantPermissionMapperElement = new ResourceElement.Builder(Ids.ELYTRON_CONSTANT_PERMISSION_MAPPER, CONSTANT_PERMISSION_MAPPER, metadata, mbuiContext).column(NAME, (cell, type, row, meta) -> row.getName()).setComplexListAttribute(PERMISSIONS, asList(CLASS_NAME, MODULE), asList(CLASS_NAME, MODULE), modelNode -> build(modelNode.get(CLASS_NAME).asString(), modelNode.get(MODULE).asString())).onCrud(() -> presenter.reload(CONSTANT_PERMISSION_MAPPER, this::updateConstantPermissionMapper)).build();
navigation.insertSecondary("mappers-decoders-permission-mapper-item", build(Ids.ELYTRON_CONSTANT_PERMISSION_MAPPER, ITEM), "mappers-decoders-custom-permission-mapper-item", "Constant Permission Mapper", constantPermissionMapperElement.element());
registerAttachable(constantPermissionMapperElement);
// =========
String mappedId = "mappers-decoders-mapped-role-mapper";
Metadata mappedMetadata = mbuiContext.metadataRegistry().lookup(MAPPED_ROLE_MAPPER_TEMPLATE);
LabelBuilder labelBuilder = new LabelBuilder();
String title = labelBuilder.label(MAPPED_ROLE_MAPPER);
mappedRoleMapperTable = new ModelNodeTable.Builder<NamedNode>(build(mappedId, TABLE), mappedMetadata).button(mbuiContext.tableButtonFactory().add(MAPPED_ROLE_MAPPER_TEMPLATE, table -> presenter.addMappedRoleMapper())).button(mbuiContext.tableButtonFactory().remove(title, MAPPED_ROLE_MAPPER_TEMPLATE, table -> table.selectedRow().getName(), () -> presenter.reload())).column(NAME, (cell, type, row, meta) -> row.getName()).build();
mappedRoleMapperForm = new ModelNodeForm.Builder<NamedNode>(build(mappedId, FORM), mappedMetadata).customFormItem(ROLE_MAP, desc -> new RoleMapListItem(ROLE_MAP, labelBuilder.label(ROLE_MAP))).onSave((form, changedValues) -> {
String name = form.getModel().getName();
ResourceAddress address = MAPPED_ROLE_MAPPER_TEMPLATE.resolve(mbuiContext.statementContext(), name);
saveForm(title, name, address, changedValues, mappedMetadata);
}).build();
HTMLElement mappedSection = section().add(h(1).textContent(Names.SIMPLE_PERMISSION_MAPPER)).add(p().textContent(metadata.getDescription().getDescription())).add(mappedRoleMapperTable).add(mappedRoleMapperForm).element();
registerAttachable(mappedRoleMapperTable, mappedRoleMapperForm);
navigation.insertSecondary("mappers-decoders-role-mappers", build(mappedId, ITEM), null, title, mappedSection);
// =========
Metadata spmMetadata = mbuiContext.metadataRegistry().lookup(AddressTemplates.SIMPLE_PERMISSION_MAPPER_TEMPLATE);
simplePermissionMapperElement = new SimplePermissionMapperElement(spmMetadata, mbuiContext.tableButtonFactory());
navigation.insertSecondary("mappers-decoders-permission-mapper-item", build(Ids.ELYTRON_SIMPLE_PERMISSION_MAPPER, ITEM), "mappers-decoders-simple-permission-mapper-item", "Simple Permission Mapper", simplePermissionMapperElement.element());
registerAttachable(simplePermissionMapperElement);
}
use of org.jboss.hal.ballroom.form.Form in project console by hal.
the class OtherSettingsPresenter method addSecurityDomain.
// -------------------------------------------- Security Domain
void addSecurityDomain() {
Metadata metadata = metadataRegistry.lookup(SECURITY_DOMAIN_TEMPLATE);
// emulate capability-reference on default-realm
String capabilityReference = metadata.getDescription().findAttribute(ATTRIBUTES + "/" + REALMS + "/" + VALUE_TYPE, REALM).getValue().get(CAPABILITY_REFERENCE).asString();
String id = Ids.build(Ids.ELYTRON_SECURITY_DOMAIN, Ids.ADD);
NameItem nameItem = new NameItem();
ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).addOnly().unboundFormItem(nameItem, 0).include(DEFAULT_REALM).unsorted().build();
form.getFormItem(DEFAULT_REALM).setRequired(true);
form.getFormItem(DEFAULT_REALM).registerSuggestHandler(new SuggestCapabilitiesAutoComplete(dispatcher, statementContext, capabilityReference, metadata.getTemplate()));
new AddResourceDialog(resources.messages().addResourceTitle(Names.SECURITY_DOMAIN), form, (name, model) -> {
if (model != null) {
// add the default-realm in the list of realms
ModelNode realm = new ModelNode();
realm.get(REALM).set(model.get(DEFAULT_REALM).asString());
model.get(REALMS).add(realm);
}
ResourceAddress address = SECURITY_DOMAIN_TEMPLATE.resolve(statementContext, nameItem.getValue());
crud.add(Names.SECURITY_DOMAIN, name, address, model, (n, a) -> reload(SECURITY_DOMAIN, nodes -> getView().updateResourceElement(SECURITY_DOMAIN, nodes)));
}).show();
}
use of org.jboss.hal.ballroom.form.Form in project console by hal.
the class OtherSettingsPresenter method addKeyManager.
// ------------------------------------------------------ key manager
void addKeyManager() {
Metadata metadata = metadataRegistry.lookup(KEY_MANAGER_TEMPLATE);
Metadata crMetadata = metadata.forComplexAttribute(CREDENTIAL_REFERENCE, true);
crMetadata.copyComplexAttributeAttributes(asList(STORE, ALIAS, TYPE, CLEAR_TEXT), metadata);
String id = Ids.build(Ids.ELYTRON_KEY_MANAGER, Ids.ADD);
NameItem nameItem = new NameItem();
ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).addOnly().unboundFormItem(nameItem, 0).include(STORE, ALIAS, TYPE, CLEAR_TEXT).unsorted().build();
form.addFormValidation(new RequireAtLeastOneAttributeValidation<>(asList(STORE, CLEAR_TEXT), resources));
new AddResourceDialog(resources.messages().addResourceTitle(Names.KEY_MANAGER), form, (name, model) -> {
if (model != null) {
move(model, STORE, CREDENTIAL_REFERENCE + "/" + STORE);
move(model, ALIAS, CREDENTIAL_REFERENCE + "/" + ALIAS);
move(model, TYPE, CREDENTIAL_REFERENCE + "/" + TYPE);
move(model, CLEAR_TEXT, CREDENTIAL_REFERENCE + "/" + CLEAR_TEXT);
}
ResourceAddress address = KEY_MANAGER_TEMPLATE.resolve(statementContext, nameItem.getValue());
crud.add(Names.KEY_MANAGER, name, address, model, (n, a) -> reload(KEY_MANAGER, nodes -> getView().updateResourceElement(KEY_MANAGER, nodes)));
}).show();
}
use of org.jboss.hal.ballroom.form.Form in project console by hal.
the class OtherSettingsPresenter method addNewItemTemplate.
void addNewItemTemplate(String ldapKeyStore) {
Metadata metadata = metadataRegistry.lookup(AddressTemplates.LDAP_KEY_STORE_TEMPLATE).forComplexAttribute(NEW_ITEM_TEMPLATE);
String id = Ids.build(Ids.ELYTRON_LDAP_KEY_STORE, NEW_ITEM_TEMPLATE, Ids.ADD);
Form<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).include(NEW_ITEM_PATH, NEW_ITEM_RDN, NEW_ITEM_ATTRIBUTES).customFormItem(NEW_ITEM_ATTRIBUTES, (attributeDescription) -> new MultiValueListItem(NEW_ITEM_ATTRIBUTES)).unsorted().addOnly().build();
String type = new LabelBuilder().label(NEW_ITEM_TEMPLATE);
new AddResourceDialog(resources.messages().addResourceTitle(type), form, (name, model) -> ca.add(ldapKeyStore, NEW_ITEM_TEMPLATE, Names.NEW_ITEM_TEMPLATE, AddressTemplates.LDAP_KEY_STORE_TEMPLATE, model, this::reloadLdapKeyStores)).show();
}
use of org.jboss.hal.ballroom.form.Form in project console by hal.
the class OtherSettingsPresenter method addServerSslSniContext.
// -------------------------------------------- server ssl sni context
void addServerSslSniContext() {
Metadata metadata = metadataRegistry.lookup(AddressTemplates.SERVER_SSL_SNI_CONTEXT_TEMPLATE);
String id = Ids.build(Ids.ELYTRON_SERVER_SSL_SNI_CONTEXT, Ids.ADD);
Form<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).unboundFormItem(new NameItem(), 0).unsorted().addOnly().build();
// "host-context-map" is not required in r-r-d for "add" operation
// but the resource fails to add without this parameter, see https://issues.jboss.org/browse/WFCORE-4223
form.getFormItem("host-context-map").setRequired(true);
String type = new LabelBuilder().label(SERVER_SSL_SNI_CONTEXT);
new AddResourceDialog(resources.messages().addResourceTitle(type), form, (name, model) -> {
crud.add(type, name, AddressTemplates.SERVER_SSL_SNI_CONTEXT_TEMPLATE, model, (name1, address) -> reload(SERVER_SSL_SNI_CONTEXT, nodes -> getView().updateResourceElement(SERVER_SSL_SNI_CONTEXT, nodes)));
}).show();
}
Aggregations