use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.
the class ProfileColumn method cloneProfile.
private void cloneProfile(String from) {
ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(Ids.PROFILE_CLONE, Metadata.empty()).unboundFormItem(new NameItem()).build();
AddResourceDialog dialog = new AddResourceDialog(resources.constants().cloneProfile(), form, (to, model) -> {
Operation operation = new Operation.Builder(new ResourceAddress().add(PROFILE, from), CLONE).param(TO_PROFILE, to).build();
dispatcher.execute(operation, result -> {
MessageEvent.fire(eventBus, Message.success(resources.messages().cloneProfileSuccess(from, to)));
refresh(to);
});
});
dialog.show();
}
use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.
the class ServerColumn method addServer.
private void addServer(boolean browseByHost) {
if (browseByHost) {
AddressTemplate template = serverConfigTemplate(statementContext.selectedHost());
String id = Ids.build(HOST, statementContext.selectedHost(), SERVER, Ids.ADD);
List<String> attributes = asList(AUTO_START, GROUP, SOCKET_BINDING_DEFAULT_INTERFACE, SOCKET_BINDING_GROUP, SOCKET_BINDING_PORT_OFFSET, UPDATE_AUTO_START_WITH_SERVER_STATUS);
crud.add(id, Names.SERVER, template, attributes, createUniqueValidation(), (name, address) -> refresh(RESTORE_SELECTION));
} else {
// load all available hosts to show in the copy dialog
Operation operation = new Operation.Builder(ResourceAddress.root(), READ_CHILDREN_NAMES_OPERATION).param(CHILD_TYPE, HOST).build();
dispatcher.execute(operation, result -> {
List<String> hosts = new ArrayList<>();
result.asList().forEach(m -> hosts.add(m.asString()));
// get the first host, only to retrieve the r-r-d for server-config
// as /host=*/server-config=*:read-operation-description(name=add) does not work
AddressTemplate template = serverConfigTemplate(hosts.get(0));
metadataProcessor.lookup(template, progress.get(), new SuccessfulMetadataCallback(eventBus, resources) {
@Override
public void onMetadata(Metadata metadata) {
String id = Ids.build(SERVER_GROUP, statementContext.selectedServerGroup(), SERVER, FORM);
SingleSelectBoxItem hostFormItem = new SingleSelectBoxItem(HOST, Names.HOST, hosts, false);
hostFormItem.setRequired(true);
NameItem nameItem = new NameItem();
ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).unboundFormItem(nameItem, 0).unboundFormItem(hostFormItem, 1, resources.messages().addServerHostHelp()).customFormItem(GROUP, attributeDescription -> {
TextBoxItem groupItem = new TextBoxItem(GROUP, resources.constants().group());
groupItem.setEnabled(false);
return groupItem;
}).fromRequestProperties().build();
AddResourceDialog dialog = new AddResourceDialog(resources.messages().addServerTitle(), form, (resource, payload) -> {
payload.get(GROUP).set(statementContext.selectedServerGroup());
String serverName = nameItem.getValue();
ResourceAddress address = serverConfigTemplate(hostFormItem.getValue()).resolve(statementContext, serverName);
crud.add(serverName, address, payload, resources.messages().addResourceSuccess(Names.SERVER, serverName), (name, address1) -> refresh(RESTORE_SELECTION));
});
dialog.getForm().<String>getFormItem(NAME).addValidationHandler(createUniqueValidation());
dialog.show();
form.<String>getFormItem(GROUP).setValue(statementContext.selectedServerGroup());
}
});
});
}
}
use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.
the class RealmsPresenter method addLdapRealm.
void addLdapRealm() {
Metadata metadata = metadataRegistry.lookup(LDAP_REALM_TEMPLATE);
Metadata imMetadata = metadata.forComplexAttribute(IDENTITY_MAPPING, true);
imMetadata.copyComplexAttributeAttributes(asList(RDN_IDENTIFIER, SEARCH_BASE_DN, USE_RECURSIVE_SEARCH), metadata);
NameItem nameItem = new NameItem();
String id = Ids.build(Ids.ELYTRON_LDAP_REALM, Ids.ADD);
Form<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).addOnly().unboundFormItem(nameItem, 0).include(DIR_CONTEXT, DIRECT_VERIFICATION, ALLOW_BLANK_PASSWORD, RDN_IDENTIFIER, SEARCH_BASE_DN, USE_RECURSIVE_SEARCH).build();
new AddResourceDialog(resources.messages().addResourceTitle(Names.LDAP_REALM), form, (name, model) -> {
if (model != null) {
move(model, RDN_IDENTIFIER, IDENTITY_MAPPING + "/" + RDN_IDENTIFIER);
move(model, SEARCH_BASE_DN, IDENTITY_MAPPING + "/" + SEARCH_BASE_DN);
// only pass USE_RECURSIVE_SEARCH if true (not default-value)
if (failSafeBoolean(model, USE_RECURSIVE_SEARCH)) {
move(model, USE_RECURSIVE_SEARCH, IDENTITY_MAPPING + "/" + USE_RECURSIVE_SEARCH);
} else {
model.remove(USE_RECURSIVE_SEARCH);
}
}
ResourceAddress address = LDAP_REALM_TEMPLATE.resolve(statementContext, nameItem.getValue());
crud.add(Names.IDENTITY_ATTRIBUTE_MAPPING, name, address, model, (n, a) -> reloadLdapRealms());
}).show();
}
use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.
the class OtherSettingsPresenter method addJaspiConfiguration.
// -------------------------------------------- JASPI Configuration
void addJaspiConfiguration() {
Metadata metadata = metadataRegistry.lookup(AddressTemplates.JASPI_CONFIGURATION_TEMPLATE);
Metadata metaServerAuth = metadata.forComplexAttribute(SERVER_AUTH_MODULES, true);
metaServerAuth.copyComplexAttributeAttributes(asList(CLASS_NAME, MODULE, FLAG), metadata);
String id = Ids.build(Ids.ELYTRON_JASPI, Ids.ADD);
Form<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).unboundFormItem(new NameItem(), 0).unsorted().addOnly().build();
String type = new LabelBuilder().label(JASPI_CONFIGURATION);
form.getFormItem(CLASS_NAME).setRequired(true);
new AddResourceDialog(resources.messages().addResourceTitle(type), form, (name, model) -> {
ModelNode serverAuthModule = new ModelNode();
serverAuthModule.get(CLASS_NAME).set(model.remove(CLASS_NAME));
if (model.hasDefined(MODULE)) {
serverAuthModule.get(MODULE).set(model.remove(MODULE));
}
if (model.hasDefined(FLAG)) {
serverAuthModule.get(FLAG).set(model.remove(FLAG));
}
model.get(SERVER_AUTH_MODULES).add(serverAuthModule);
crud.add(type, name, AddressTemplates.JASPI_CONFIGURATION_TEMPLATE, model, (name1, address) -> {
reload(JASPI_CONFIGURATION, nodes -> getView().updateResourceElement(JASPI_CONFIGURATION, nodes));
});
}).show();
}
use of org.jboss.hal.core.mbui.dialog.NameItem in project console by hal.
the class OtherSettingsPresenter method addCredentialStore.
// -------------------------------------------- Credential Store
void addCredentialStore() {
Metadata metadata = metadataRegistry.lookup(CREDENTIAL_STORE_TEMPLATE);
SafeHtml typeHelp = SafeHtmlUtils.fromString(metadata.getDescription().get(ATTRIBUTES).get(TYPE).get(DESCRIPTION).asString());
Metadata crMetadata = metadata.forComplexAttribute(CREDENTIAL_REFERENCE, true);
crMetadata.copyComplexAttributeAttributes(asList(STORE, ALIAS, TYPE, CLEAR_TEXT), metadata);
TextBoxItem typeItem = new TextBoxItem("type-", resources.constants().type());
String id = Ids.build(Ids.ELYTRON_CREDENTIAL_STORE, Ids.ADD);
NameItem nameItem = new NameItem();
ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).addOnly().unboundFormItem(nameItem, 0).include(CREATE, PATH, RELATIVE_TO, STORE, ALIAS, TYPE, CLEAR_TEXT).unboundFormItem(typeItem, 3, typeHelp).unsorted().build();
form.getFormItem(RELATIVE_TO).registerSuggestHandler(new PathsAutoComplete());
form.addFormValidation(new RequireAtLeastOneAttributeValidation<>(asList(STORE, CLEAR_TEXT), resources));
form.addFormValidation(form1 -> {
ValidationResult result = ValidationResult.OK;
String typeValue = typeItem.getValue();
FormItem<String> locationAttr = form1.getFormItem(PATH);
boolean invalidLocation = locationAttr.isEmpty() && (typeItem.isEmpty() || Collections.binarySearch(FILE_BASED_CS, typeValue) > -1);
if (invalidLocation) {
form1.getFormItem(PATH).showError(resources.constants().requiredField());
result = ValidationResult.invalid(resources.messages().pathRequired());
}
return result;
});
new AddResourceDialog(resources.messages().addResourceTitle(Names.CREDENTIAL_STORE), 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);
}
if (!typeItem.isEmpty()) {
model.get(TYPE).set(typeItem.getValue());
}
ResourceAddress address = CREDENTIAL_STORE_TEMPLATE.resolve(statementContext, nameItem.getValue());
crud.add(Names.CREDENTIAL_STORE, name, address, model, (n, a) -> reload(CREDENTIAL_STORE, nodes -> getView().updateResourceElement(CREDENTIAL_STORE, nodes)));
}).show();
}
Aggregations