Search in sources :

Example 1 with SuggestCapabilitiesAutoComplete

use of org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete 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();
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) FinishRemove(org.jboss.hal.ballroom.form.Form.FinishRemove) StatementContext(org.jboss.hal.meta.StatementContext) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) FinishReset(org.jboss.hal.ballroom.form.Form.FinishReset) RequireAtLeastOneAttributeValidation(org.jboss.hal.core.mbui.form.RequireAtLeastOneAttributeValidation) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) ModelNodeHelper.asNamedNodes(org.jboss.hal.dmr.ModelNodeHelper.asNamedNodes) CrudOperations(org.jboss.hal.core.CrudOperations) ModelNodeHelper.move(org.jboss.hal.dmr.ModelNodeHelper.move) NameToken(com.gwtplatform.mvp.client.annotations.NameToken) ComplexAttributeOperations(org.jboss.hal.core.ComplexAttributeOperations) FinderPath(org.jboss.hal.core.finder.FinderPath) PathsAutoComplete(org.jboss.hal.core.configuration.PathsAutoComplete) List(java.util.List) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Finder(org.jboss.hal.core.finder.Finder) ValidationResult(org.jboss.hal.ballroom.form.ValidationResult) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SupportsExpertMode(org.jboss.hal.core.mvp.SupportsExpertMode) ModelNode(org.jboss.hal.dmr.ModelNode) ProxyPlace(com.gwtplatform.mvp.client.proxy.ProxyPlace) Inject(javax.inject.Inject) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) SafeHtmlUtils(com.google.gwt.safehtml.shared.SafeHtmlUtils) Requires(org.jboss.hal.spi.Requires) ProxyCodeSplit(com.gwtplatform.mvp.client.annotations.ProxyCodeSplit) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) AddressTemplates(org.jboss.hal.client.configuration.subsystem.elytron.AddressTemplates) FinderPathFactory(org.jboss.hal.core.finder.FinderPathFactory) EventBus(com.google.web.bindery.event.shared.EventBus) Consumer(java.util.function.Consumer) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) FormItem(org.jboss.hal.ballroom.form.FormItem) NameTokens(org.jboss.hal.meta.token.NameTokens) MbuiPresenter(org.jboss.hal.core.mbui.MbuiPresenter) Resources(org.jboss.hal.resources.Resources) SuggestCapabilitiesAutoComplete(org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete) MbuiView(org.jboss.hal.core.mbui.MbuiView) NamedNode(org.jboss.hal.dmr.NamedNode) Collections(java.util.Collections) Form(org.jboss.hal.ballroom.form.Form) SuggestCapabilitiesAutoComplete(org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Metadata(org.jboss.hal.meta.Metadata) ModelNode(org.jboss.hal.dmr.ModelNode) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm)

Example 2 with SuggestCapabilitiesAutoComplete

use of org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete in project console by hal.

the class DefaultFormItemProvider method checkCapabilityReference.

private void checkCapabilityReference(ModelNode attributeDescription, FormItem<?> formItem) {
    SuggestHandler suggestHandler = null;
    if (attributeDescription.hasDefined(CAPABILITY_REFERENCE)) {
        Dispatcher dispatcher = Core.INSTANCE.dispatcher();
        StatementContext statementContext = Core.INSTANCE.statementContext();
        String reference = attributeDescription.get(CAPABILITY_REFERENCE).asString();
        Capabilities capabilities = metadata.getCapabilities();
        if (capabilities.supportsSuggestions()) {
            suggestHandler = new SuggestCapabilitiesAutoComplete(dispatcher, statementContext, reference, metadata.getTemplate());
        } else if (capabilities.contains(reference)) {
            suggestHandler = new ReadChildrenAutoComplete(dispatcher, statementContext, capabilities.lookup(reference));
        }
    }
    if (suggestHandler != null) {
        formItem.registerSuggestHandler(suggestHandler);
    }
}
Also used : SuggestCapabilitiesAutoComplete(org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete) Capabilities(org.jboss.hal.meta.capabilitiy.Capabilities) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) SuggestHandler(org.jboss.hal.ballroom.form.SuggestHandler) ReadChildrenAutoComplete(org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete) StatementContext(org.jboss.hal.meta.StatementContext)

Example 3 with SuggestCapabilitiesAutoComplete

use of org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete in project console by hal.

the class StoresPresenter method obtainCertificate.

void obtainCertificate(Metadata metadata, String name) {
    metadata = metadata.forOperation(OBTAIN_CERTIFICATE);
    String id = Ids.build(KEY_STORE, OBTAIN_CERTIFICATE, FORM);
    String title = new LabelBuilder().label(OBTAIN_CERTIFICATE);
    Form<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).build();
    form.setSaveCallback((form1, changedValues) -> {
        ResourceAddress address = KEY_STORE_TEMPLATE.resolve(statementContext, name);
        Operation operation = new Operation.Builder(address, OBTAIN_CERTIFICATE).payload(form.getModel()).build();
        String alias = form.getModel().get(ALIAS).asString();
        dispatcher.execute(operation, result -> MessageEvent.fire(getEventBus(), Message.success(resources.messages().obtainCertificateSuccess(alias, name))), (operation1, failure) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().obtainCertificateError(alias, name, failure))), (operation1, ex) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().obtainCertificateError(alias, name, ex.getMessage()))));
    });
    Dialog dialog = new Dialog.Builder(title).add(p().textContent(metadata.getDescription().getDescription()).element()).add(form.element()).primary(resources.constants().obtain(), form::save).size(Dialog.Size.MEDIUM).closeOnEsc(true).cancel().build();
    dialog.registerAttachable(form);
    if (!environment.isStandalone()) {
        // the capability reference the /profile=* resource and the template attached to the metadata
        // points to the {selected.host}/{selected.server}, so we need to register the template to the profile
        String capability = metadata.getDescription().get(ATTRIBUTES).get(CERTIFICATE_AUTHORITY_ACCOUNT).get(CAPABILITY_REFERENCE).asString();
        form.getFormItem(CERTIFICATE_AUTHORITY_ACCOUNT).registerSuggestHandler(new SuggestCapabilitiesAutoComplete(dispatcher, statementContext, capability, ELYTRON_PROFILE_TEMPLATE));
    }
    dialog.show();
    form.edit(new ModelNode());
}
Also used : SuggestCapabilitiesAutoComplete(org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Operation(org.jboss.hal.dmr.Operation) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Dialog(org.jboss.hal.ballroom.dialog.Dialog) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 4 with SuggestCapabilitiesAutoComplete

use of org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete in project console by hal.

the class StoresPresenter method revokeCertificate.

void revokeCertificate(Metadata metadata, String name, String alias) {
    metadata = metadata.forOperation(REVOKE_CERTIFICATE);
    String id = Ids.build(KEY_STORE, REVOKE_CERTIFICATE, FORM);
    String title = new LabelBuilder().label(CERTIFICATE_AUTHORITY_ACCOUNT);
    Form<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).build();
    form.setSaveCallback((form1, changedValues) -> {
        ResourceAddress address = KEY_STORE_TEMPLATE.resolve(statementContext, name);
        Operation operation = new Operation.Builder(address, REVOKE_CERTIFICATE).payload(form.getModel()).build();
        dispatcher.execute(operation, result -> MessageEvent.fire(getEventBus(), Message.success(resources.messages().revokeCertificateSuccess(alias, name))), (operation1, failure) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().revokeCertificateError(alias, name, failure))), (operation1, ex) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().revokeCertificateError(alias, name, ex.getMessage()))));
    });
    Dialog dialog = new Dialog.Builder(title).add(p().textContent(metadata.getDescription().getDescription()).element()).add(form.element()).primary(resources.constants().revoke(), form::save).size(Dialog.Size.MEDIUM).closeOnEsc(true).cancel().build();
    dialog.registerAttachable(form);
    ModelNode model = new ModelNode();
    model.get(ALIAS).set(alias);
    form.getFormItem(ALIAS).setEnabled(false);
    if (!environment.isStandalone()) {
        // the capability reference the /profile=* resource and the template attached to the metadata
        // points to the {selected.host}/{selected.server}, so we need to register the template to the profile
        String capability = metadata.getDescription().get(ATTRIBUTES).get(CERTIFICATE_AUTHORITY_ACCOUNT).get(CAPABILITY_REFERENCE).asString();
        form.getFormItem(CERTIFICATE_AUTHORITY_ACCOUNT).registerSuggestHandler(new SuggestCapabilitiesAutoComplete(dispatcher, statementContext, capability, ELYTRON_PROFILE_TEMPLATE));
    }
    dialog.show();
    form.edit(model);
}
Also used : SuggestCapabilitiesAutoComplete(org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Operation(org.jboss.hal.dmr.Operation) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Dialog(org.jboss.hal.ballroom.dialog.Dialog) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) ModelNode(org.jboss.hal.dmr.ModelNode)

Aggregations

SuggestCapabilitiesAutoComplete (org.jboss.hal.ballroom.autocomplete.SuggestCapabilitiesAutoComplete)4 LabelBuilder (org.jboss.hal.ballroom.LabelBuilder)3 AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)3 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)3 ModelNode (org.jboss.hal.dmr.ModelNode)3 Operation (org.jboss.hal.dmr.Operation)3 Dialog (org.jboss.hal.ballroom.dialog.Dialog)2 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)2 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 SafeHtmlUtils (com.google.gwt.safehtml.shared.SafeHtmlUtils)1 EventBus (com.google.web.bindery.event.shared.EventBus)1 NameToken (com.gwtplatform.mvp.client.annotations.NameToken)1 ProxyCodeSplit (com.gwtplatform.mvp.client.annotations.ProxyCodeSplit)1 ProxyPlace (com.gwtplatform.mvp.client.proxy.ProxyPlace)1 Arrays.asList (java.util.Arrays.asList)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Consumer (java.util.function.Consumer)1 Inject (javax.inject.Inject)1