use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.
the class ServerGroupActions method copy.
public void copy(ServerGroup serverGroup, FormItemValidation<String> nameItemValidator) {
NameItem newNameItem = new NameItem();
newNameItem.setValue(serverGroup.getName() + "_" + COPY);
newNameItem.addValidationHandler(nameItemValidator);
ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(COPY, serverGroup.getName(), Ids.FORM), Metadata.empty()).fromRequestProperties().unboundFormItem(newNameItem, 0).requiredOnly().build();
AddResourceDialog dialog = new AddResourceDialog(resources.messages().addResourceTitle(Names.SERVER_GROUP), form, (resource, payload) -> {
// read server-config recursively to retrieve nested resources
Operation opReadServerGroup = new Operation.Builder(serverGroup.getAddress(), READ_RESOURCE_OPERATION).param(RECURSIVE, true).build();
dispatcher.execute(opReadServerGroup, serverGroupModel -> {
ServerGroup newServerGroup = new ServerGroup(newNameItem.getValue(), serverGroupModel);
Operation opAddServer = new Operation.Builder(newServerGroup.getAddress(), ADD).payload(serverGroupModel).build();
Composite comp = new Composite();
comp.add(opAddServer);
addChildOperations(comp, newServerGroup, newServerGroup.getAddress(), 2);
dispatcher.execute(comp, (CompositeResult result) -> finish(serverGroup, Collections.emptyList(), Result.SUCCESS, Message.success(resources.messages().addResourceSuccess(Names.SERVER_GROUP, newNameItem.getValue()))), (operation1, failure) -> finish(serverGroup, Collections.emptyList(), Result.ERROR, Message.error(resources.messages().addResourceError(newNameItem.getValue(), failure))), (operation1, exception) -> finish(serverGroup, Collections.emptyList(), Result.ERROR, Message.error(resources.messages().addResourceError(newNameItem.getValue(), exception.getMessage()))));
});
});
dialog.show();
ModelNode model = new ModelNode();
model.get(TIMEOUT).set(0);
form.edit(model);
}
use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.
the class ServerPresenter method addLocationFilterRef.
void addLocationFilterRef() {
Metadata metadata = metadataRegistry.lookup(LOCATION_FILTER_REF_TEMPLATE);
Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.UNDERTOW_HOST_LOCATION_FILTER_REF_ADD, metadata).unboundFormItem(new NameItem(), 0).fromRequestProperties().build();
form.getFormItem(NAME).registerSuggestHandler(new ReadChildrenAutoComplete(dispatcher, statementContext, FILTER_SUGGESTIONS));
AddResourceDialog dialog = new AddResourceDialog(resources.messages().addResourceTitle(resources.constants().filter()), form, (name, model) -> {
ResourceAddress address = SELECTED_HOST_TEMPLATE.append(LOCATION + EQUALS + encodeValue(locationName)).append(FILTER_REF + EQUALS + name).resolve(statementContext);
crud.add(resources.constants().filter(), name, address, model, (n, a) -> reloadLocationFilterRef());
});
dialog.show();
}
use of org.jboss.hal.core.mbui.dialog.NameItem 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.core.mbui.dialog.NameItem 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.core.mbui.dialog.NameItem 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