Search in sources :

Example 6 with FORM

use of org.jboss.hal.resources.Ids.FORM 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());
                }
            });
        });
    }
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate) Provider(javax.inject.Provider) Environment(org.jboss.hal.config.Environment) ServerSelectionEvent(org.jboss.hal.core.runtime.server.ServerSelectionEvent) Constraint(org.jboss.hal.meta.security.Constraint) ItemActionFactory(org.jboss.hal.core.finder.ItemActionFactory) StatementContext(org.jboss.hal.meta.StatementContext) ItemDisplay(org.jboss.hal.core.finder.ItemDisplay) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) FinderSegment(org.jboss.hal.core.finder.FinderSegment) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) ManagementModel(org.jboss.hal.meta.ManagementModel) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) TopologyTasks(org.jboss.hal.core.runtime.TopologyTasks) AuthorisationDecision(org.jboss.hal.meta.security.AuthorisationDecision) Column(org.jboss.hal.spi.Column) HTMLElement(elemental2.dom.HTMLElement) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) PlaceManager(com.gwtplatform.mvp.client.proxy.PlaceManager) Server(org.jboss.hal.core.runtime.server.Server) Metadata(org.jboss.hal.meta.Metadata) Places(org.jboss.hal.core.mvp.Places) Names(org.jboss.hal.resources.Names) ServerActions(org.jboss.hal.core.runtime.server.ServerActions) CrudOperations(org.jboss.hal.core.CrudOperations) Collections.emptyList(java.util.Collections.emptyList) SingleSelectBoxItem(org.jboss.hal.ballroom.form.SingleSelectBoxItem) FinderPath(org.jboss.hal.core.finder.FinderPath) FORM(org.jboss.hal.resources.Ids.FORM) List(java.util.List) ServerActionHandler(org.jboss.hal.core.runtime.server.ServerActionEvent.ServerActionHandler) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) MetadataProcessor(org.jboss.hal.meta.processing.MetadataProcessor) ServerResultEvent(org.jboss.hal.core.runtime.server.ServerResultEvent) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) SecurityContextRegistry(org.jboss.hal.meta.security.SecurityContextRegistry) Flow.series(org.jboss.hal.flow.Flow.series) Optional(java.util.Optional) Finder(org.jboss.hal.core.finder.Finder) Footer(org.jboss.hal.spi.Footer) ModelNodeHelper(org.jboss.hal.dmr.ModelNodeHelper) ModelNode(org.jboss.hal.dmr.ModelNode) Iterables(com.google.common.collect.Iterables) ColumnAction(org.jboss.hal.core.finder.ColumnAction) ItemAction(org.jboss.hal.core.finder.ItemAction) SuccessfulMetadataCallback(org.jboss.hal.meta.processing.SuccessfulMetadataCallback) ElementGuard(org.jboss.hal.meta.security.ElementGuard) ServerActionEvent(org.jboss.hal.core.runtime.server.ServerActionEvent) ServerResultHandler(org.jboss.hal.core.runtime.server.ServerResultEvent.ServerResultHandler) HashMap(java.util.HashMap) FlowContext(org.jboss.hal.flow.FlowContext) Outcome(org.jboss.hal.flow.Outcome) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) TopologyTasks.serversOfHost(org.jboss.hal.core.runtime.TopologyTasks.serversOfHost) Task(org.jboss.hal.flow.Task) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) HostSelectionEvent(org.jboss.hal.core.runtime.host.HostSelectionEvent) RESTORE_SELECTION(org.jboss.hal.core.finder.FinderColumn.RefreshMode.RESTORE_SELECTION) FinderColumn(org.jboss.hal.core.finder.FinderColumn) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) Comparator.comparing(java.util.Comparator.comparing) ItemsProvider(org.jboss.hal.core.finder.ItemsProvider) ColumnActionFactory(org.jboss.hal.core.finder.ColumnActionFactory) Requires(org.jboss.hal.spi.Requires) BrowseByColumn(org.jboss.hal.client.runtime.BrowseByColumn) DomGlobal.document(elemental2.dom.DomGlobal.document) TopologyTasks.serversOfServerGroup(org.jboss.hal.core.runtime.TopologyTasks.serversOfServerGroup) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) CONFIGURATION_CHANGES_ADDRESS(org.jboss.hal.client.runtime.configurationchanges.ConfigurationChangesPresenter.CONFIGURATION_CHANGES_ADDRESS) ServerGroupSelectionEvent(org.jboss.hal.core.runtime.group.ServerGroupSelectionEvent) FinderPathFactory(org.jboss.hal.core.finder.FinderPathFactory) EventBus(com.google.web.bindery.event.shared.EventBus) PlaceRequest(com.gwtplatform.mvp.shared.proxy.PlaceRequest) ItemMonitor(org.jboss.hal.core.finder.ItemMonitor) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Collectors.toList(java.util.stream.Collectors.toList) NameTokens(org.jboss.hal.meta.token.NameTokens) Resources(org.jboss.hal.resources.Resources) ProfileSelectionEvent(org.jboss.hal.core.configuration.ProfileSelectionEvent) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) SingleSelectBoxItem(org.jboss.hal.ballroom.form.SingleSelectBoxItem) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) ArrayList(java.util.ArrayList) Metadata(org.jboss.hal.meta.Metadata) SuccessfulMetadataCallback(org.jboss.hal.meta.processing.SuccessfulMetadataCallback) Operation(org.jboss.hal.dmr.Operation) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) NameItem(org.jboss.hal.core.mbui.dialog.NameItem)

Example 7 with FORM

use of org.jboss.hal.resources.Ids.FORM in project console by hal.

the class HostPresenter method disableSslForManagementInterface.

@Override
@SuppressWarnings("DuplicatedCode")
public void disableSslForManagementInterface() {
    Constants constants = resources.constants();
    String serverName = environment.isStandalone() ? Names.STANDALONE_SERVER : Names.DOMAIN_CONTROLLER;
    String label = constants.reload() + " " + serverName;
    SwitchItem reload = new SwitchItem(RELOAD, label);
    reload.setExpressionAllowed(false);
    Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(RELOAD, FORM), Metadata.empty()).unboundFormItem(reload).build();
    form.attach();
    HTMLElement formElement = form.element();
    ModelNode model = new ModelNode();
    model.setEmptyObject();
    form.edit(model);
    ResourceAddress httpAddress = HTTP_INTERFACE_TEMPLATE.resolve(statementContext);
    DialogFactory.buildConfirmation(constants.disableSSL(), resources.messages().disableSSLManagementQuestion(serverName), formElement, Dialog.Size.MEDIUM, () -> {
        List<Task<FlowContext>> tasks = new ArrayList<>();
        // load the http-interface resource to get the port
        Task<FlowContext> loadHttpInterface = flowContext -> {
            Operation readHttpInterface = new Operation.Builder(httpAddress, READ_RESOURCE_OPERATION).build();
            return dispatcher.execute(readHttpInterface).doOnSuccess(value -> {
                if (value.hasDefined(PORT)) {
                    // only domain mode contains "port" attribute
                    String port = value.get(PORT).asString();
                    if (port.contains("$")) {
                        // if it contains an expression value, resolve it at host level
                        ResourceAddress address = AddressTemplate.of("/host=" + environment.getDomainController()).resolve(statementContext);
                        Operation readPort = new Operation.Builder(address, RESOLVE_EXPRESSION).param(EXPRESSION, port).build();
                        dispatcher.execute(readPort, portResult -> flowContext.set(PORT, portResult.asString()));
                    } else {
                        flowContext.set(PORT, port);
                    }
                }
            }).toCompletable();
        };
        tasks.add(loadHttpInterface);
        // in domain-mode read the /host=<dc> domain controller
        // it is important for later use if user wants to reload dc if in admin-mode
        Task<FlowContext> loadDc = flowContext -> {
            ResourceAddress dcAddress = AddressTemplate.of("/host=" + environment.getDomainController()).resolve(statementContext);
            Operation readDcOp = new Operation.Builder(dcAddress, READ_RESOURCE_OPERATION).param(ATTRIBUTES_ONLY, true).build();
            return dispatcher.execute(readDcOp).doOnSuccess(value -> flowContext.set(HOST, new Host(value))).toCompletable();
        };
        tasks.add(loadDc);
        // as part of the disable ssl task, undefine the secure-port, it only exists in domain mode
        Task<FlowContext> undefineSecurePortTask = flowContext -> {
            Operation op = new Operation.Builder(httpAddress, UNDEFINE_ATTRIBUTE_OPERATION).param(NAME, SECURE_PORT).build();
            return dispatcher.execute(op).toCompletable();
        };
        tasks.add(undefineSecurePortTask);
        // as part of the disable ssl task, undefine the ssl-context
        Task<FlowContext> undefineSslContextTask = flowContext -> {
            Operation op = new Operation.Builder(httpAddress, UNDEFINE_ATTRIBUTE_OPERATION).param(NAME, SSL_CONTEXT).build();
            return dispatcher.execute(op).toCompletable();
        };
        tasks.add(undefineSslContextTask);
        series(new FlowContext(progress.get()), tasks).subscribe(new SuccessfulOutcome<FlowContext>(getEventBus(), resources) {

            @Override
            public void onSuccess(FlowContext flowContext) {
                if (reload.getValue() != null && reload.getValue()) {
                    String port = flowContext.get(PORT).toString();
                    // extracts the url search path, so the reload shows the same view the use is on
                    String urlSuffix = window.location.getHref();
                    urlSuffix = urlSuffix.substring(urlSuffix.indexOf("//") + 2);
                    urlSuffix = urlSuffix.substring(urlSuffix.indexOf("/"));
                    // the location to redirect the browser to the unsecure URL
                    // TODO Replace hardcoded scheme
                    String location = "http://" + window.location.getHostname() + ":" + port + urlSuffix;
                    Host host = flowContext.get(HOST);
                    reloadServer(host, location);
                } else {
                    reloadView();
                    MessageEvent.fire(getEventBus(), Message.success(resources.messages().disableSSLManagementSuccess()));
                }
            }

            @Override
            public void onError(FlowContext context, Throwable throwable) {
                MessageEvent.fire(getEventBus(), Message.error(resources.messages().disableSSLManagementError(throwable.getMessage())));
            }
        });
    }).show();
}
Also used : INCLUDE_RUNTIME(org.jboss.hal.dmr.ModelDescriptionConstants.INCLUDE_RUNTIME) TopologyTasks.reloadBlocking(org.jboss.hal.core.runtime.TopologyTasks.reloadBlocking) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) HTTP_INTERFACE_TEMPLATE(org.jboss.hal.client.runtime.host.AddressTemplates.HTTP_INTERFACE_TEMPLATE) VALUE(org.jboss.hal.dmr.ModelDescriptionConstants.VALUE) Map(java.util.Map) UNDEFINE_ATTRIBUTE_OPERATION(org.jboss.hal.dmr.ModelDescriptionConstants.UNDEFINE_ATTRIBUTE_OPERATION) LIST_ADD_OPERATION(org.jboss.hal.dmr.ModelDescriptionConstants.LIST_ADD_OPERATION) HttpManagementInterfacePresenter(org.jboss.hal.client.runtime.managementinterface.HttpManagementInterfacePresenter) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) MANAGEMENT_INTERFACE(org.jboss.hal.dmr.ModelDescriptionConstants.MANAGEMENT_INTERFACE) CrudOperations(org.jboss.hal.core.CrudOperations) INDEX(org.jboss.hal.dmr.ModelDescriptionConstants.INDEX) PATH(org.jboss.hal.dmr.ModelDescriptionConstants.PATH) RESULT(org.jboss.hal.dmr.ModelDescriptionConstants.RESULT) CORE_SERVICE(org.jboss.hal.dmr.ModelDescriptionConstants.CORE_SERVICE) Flow.series(org.jboss.hal.flow.Flow.series) SYSTEM_PROPERTY(org.jboss.hal.dmr.ModelDescriptionConstants.SYSTEM_PROPERTY) Footer(org.jboss.hal.spi.Footer) EXPRESSION(org.jboss.hal.dmr.ModelDescriptionConstants.EXPRESSION) ATTRIBUTES_ONLY(org.jboss.hal.dmr.ModelDescriptionConstants.ATTRIBUTES_ONLY) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) KEY_STORE(org.jboss.hal.dmr.ModelDescriptionConstants.KEY_STORE) JVM(org.jboss.hal.dmr.ModelDescriptionConstants.JVM) FlowContext(org.jboss.hal.flow.FlowContext) ArrayList(java.util.ArrayList) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Task(org.jboss.hal.flow.Task) RELOAD(org.jboss.hal.dmr.ModelDescriptionConstants.RELOAD) Progress(org.jboss.hal.flow.Progress) TRUST_MANAGER(org.jboss.hal.dmr.ModelDescriptionConstants.TRUST_MANAGER) CompositeResult(org.jboss.hal.dmr.CompositeResult) EnableSSLWizard(org.jboss.hal.client.shared.sslwizard.EnableSSLWizard) SSL_CONTEXT(org.jboss.hal.dmr.ModelDescriptionConstants.SSL_CONTEXT) Operation(org.jboss.hal.dmr.Operation) EventBus(com.google.web.bindery.event.shared.EventBus) WRITE_ATTRIBUTE_OPERATION(org.jboss.hal.dmr.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION) DialogFactory(org.jboss.hal.ballroom.dialog.DialogFactory) DomGlobal.window(elemental2.dom.DomGlobal.window) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) NameTokens(org.jboss.hal.meta.token.NameTokens) READ_CHILDREN_NAMES_OPERATION(org.jboss.hal.dmr.ModelDescriptionConstants.READ_CHILDREN_NAMES_OPERATION) NamedNode(org.jboss.hal.dmr.NamedNode) ADMIN_ONLY(org.jboss.hal.dmr.ModelDescriptionConstants.ADMIN_ONLY) Form(org.jboss.hal.ballroom.form.Form) ConstantHeadersPresenter(org.jboss.hal.client.runtime.managementinterface.ConstantHeadersPresenter) Dialog(org.jboss.hal.ballroom.dialog.Dialog) LIST_REMOVE_OPERATION(org.jboss.hal.dmr.ModelDescriptionConstants.LIST_REMOVE_OPERATION) Provider(javax.inject.Provider) Environment(org.jboss.hal.config.Environment) StatementContext(org.jboss.hal.meta.StatementContext) ELYTRON_TEMPLATE(org.jboss.hal.client.runtime.host.AddressTemplates.ELYTRON_TEMPLATE) HTMLElement(elemental2.dom.HTMLElement) Message(org.jboss.hal.spi.Message) KEY_MANAGER(org.jboss.hal.dmr.ModelDescriptionConstants.KEY_MANAGER) NAME(org.jboss.hal.dmr.ModelDescriptionConstants.NAME) SECURE_PORT(org.jboss.hal.dmr.ModelDescriptionConstants.SECURE_PORT) READ_RESOURCE_OPERATION(org.jboss.hal.dmr.ModelDescriptionConstants.READ_RESOURCE_OPERATION) SOCKET_BINDING_GROUP(org.jboss.hal.dmr.ModelDescriptionConstants.SOCKET_BINDING_GROUP) PORT(org.jboss.hal.dmr.ModelDescriptionConstants.PORT) RESTART_SERVERS(org.jboss.hal.dmr.ModelDescriptionConstants.RESTART_SERVERS) ModelNodeHelper.asNamedNodes(org.jboss.hal.dmr.ModelNodeHelper.asNamedNodes) NameToken(com.gwtplatform.mvp.client.annotations.NameToken) FinderPath(org.jboss.hal.core.finder.FinderPath) FORM(org.jboss.hal.resources.Ids.FORM) Collectors(java.util.stream.Collectors) List(java.util.List) OperationFactory(org.jboss.hal.core.OperationFactory) SwitchItem(org.jboss.hal.ballroom.form.SwitchItem) Finder(org.jboss.hal.core.finder.Finder) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) HOST(org.jboss.hal.dmr.ModelDescriptionConstants.HOST) SupportsExpertMode(org.jboss.hal.core.mvp.SupportsExpertMode) ModelNode(org.jboss.hal.dmr.ModelNode) MessageEvent(org.jboss.hal.spi.MessageEvent) ProxyPlace(com.gwtplatform.mvp.client.proxy.ProxyPlace) CHILD_TYPE(org.jboss.hal.dmr.ModelDescriptionConstants.CHILD_TYPE) HashMap(java.util.HashMap) CONSTANT_HEADERS(org.jboss.hal.dmr.ModelDescriptionConstants.CONSTANT_HEADERS) READ_CHILDREN_RESOURCES_OPERATION(org.jboss.hal.dmr.ModelDescriptionConstants.READ_CHILDREN_RESOURCES_OPERATION) Inject(javax.inject.Inject) AddressTemplate(org.jboss.hal.meta.AddressTemplate) Constants(org.jboss.hal.resources.Constants) RESOLVE_EXPRESSION(org.jboss.hal.dmr.ModelDescriptionConstants.RESOLVE_EXPRESSION) INTERFACE(org.jboss.hal.dmr.ModelDescriptionConstants.INTERFACE) Requires(org.jboss.hal.spi.Requires) ProxyCodeSplit(com.gwtplatform.mvp.client.annotations.ProxyCodeSplit) Ids(org.jboss.hal.resources.Ids) FinderPathFactory(org.jboss.hal.core.finder.FinderPathFactory) Composite(org.jboss.hal.dmr.Composite) HEADERS(org.jboss.hal.dmr.ModelDescriptionConstants.HEADERS) MANAGEMENT(org.jboss.hal.dmr.ModelDescriptionConstants.MANAGEMENT) MbuiPresenter(org.jboss.hal.core.mbui.MbuiPresenter) Resources(org.jboss.hal.resources.Resources) MbuiView(org.jboss.hal.core.mbui.MbuiView) EnableSSLPresenter(org.jboss.hal.client.shared.sslwizard.EnableSSLPresenter) SERVER_SSL_CONTEXT(org.jboss.hal.dmr.ModelDescriptionConstants.SERVER_SSL_CONTEXT) Host(org.jboss.hal.core.runtime.host.Host) Task(org.jboss.hal.flow.Task) HTMLElement(elemental2.dom.HTMLElement) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Constants(org.jboss.hal.resources.Constants) Host(org.jboss.hal.core.runtime.host.Host) Operation(org.jboss.hal.dmr.Operation) FlowContext(org.jboss.hal.flow.FlowContext) ArrayList(java.util.ArrayList) List(java.util.List) ModelNode(org.jboss.hal.dmr.ModelNode) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) SwitchItem(org.jboss.hal.ballroom.form.SwitchItem)

Example 8 with FORM

use of org.jboss.hal.resources.Ids.FORM in project console by hal.

the class ServerActions method editUrl.

public void editUrl(Server server, Callback callback) {
    Alert alert = new Alert(Icons.ERROR, resources.messages().serverUrlError());
    HTMLElement info = p().element();
    TextBoxItem urlItem = new TextBoxItem(URL, Names.URL);
    Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.SERVER_URL_FORM, Metadata.empty()).unboundFormItem(urlItem).addOnly().onSave((f, changedValues) -> {
        String url = urlItem.getValue();
        if (Strings.isNullOrEmpty(url)) {
            serverUrlStorage.remove(server.getHost(), server.getName());
        } else {
            serverUrlStorage.save(server.getHost(), server.getName(), url);
        }
        callback.execute();
    }).build();
    Dialog dialog = new Dialog.Builder(resources.constants().editURL()).add(alert.element()).add(info).add(form.element()).primary(form::save).cancel().closeIcon(true).closeOnEsc(true).build();
    dialog.registerAttachable(form);
    Elements.setVisible(alert.element(), false);
    Elements.setVisible(info, false);
    readUrl(server, new AsyncCallback<ServerUrl>() {

        @Override
        public void onFailure(Throwable caught) {
            Elements.setVisible(alert.element(), true);
            show(null);
        }

        @Override
        public void onSuccess(ServerUrl serverUrl) {
            if (serverUrl.isCustom()) {
                info.innerHTML = resources.messages().serverUrlCustom().asString();
            } else {
                info.innerHTML = resources.messages().serverUrlManagementModel().asString();
            }
            Elements.setVisible(info, true);
            show(serverUrl);
        }

        private void show(ServerUrl serverUrl) {
            dialog.show();
            form.edit(new ModelNode());
            if (serverUrl != null) {
                urlItem.setValue(serverUrl.getUrl());
            }
        }
    });
}
Also used : Dialog(org.jboss.hal.ballroom.dialog.Dialog) DISABLED(org.jboss.hal.core.runtime.server.ServerConfigStatus.DISABLED) Provider(javax.inject.Provider) Elements.a(org.jboss.gwt.elemento.core.Elements.a) TimeoutHandler.repeatUntilTimeout(org.jboss.hal.dmr.dispatch.TimeoutHandler.repeatUntilTimeout) STOPPED(org.jboss.hal.core.runtime.server.ServerConfigStatus.STOPPED) StatementContext(org.jboss.hal.meta.StatementContext) LoggerFactory(org.slf4j.LoggerFactory) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) ManagementModel(org.jboss.hal.meta.ManagementModel) Icons(org.jboss.hal.resources.Icons) ModelNodeHelper.asEnumValue(org.jboss.hal.dmr.ModelNodeHelper.asEnumValue) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) OnError(org.jboss.hal.dmr.dispatch.Dispatcher.OnError) Elements.p(org.jboss.gwt.elemento.core.Elements.p) STARTED(org.jboss.hal.core.runtime.server.ServerConfigStatus.STARTED) HTMLElement(elemental2.dom.HTMLElement) Map(java.util.Map) SuspendState(org.jboss.hal.core.runtime.SuspendState) Message(org.jboss.hal.spi.Message) Timeouts(org.jboss.hal.core.runtime.Timeouts) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) EnumSet(java.util.EnumSet) CSS.marginLeft5(org.jboss.hal.resources.CSS.marginLeft5) Predicate(java.util.function.Predicate) SingleSelectBoxItem(org.jboss.hal.ballroom.form.SingleSelectBoxItem) FORM(org.jboss.hal.resources.Ids.FORM) ReadSocketBinding(org.jboss.hal.core.runtime.server.ServerUrlTasks.ReadSocketBinding) List(java.util.List) MetadataProcessor(org.jboss.hal.meta.processing.MetadataProcessor) Callback(org.jboss.hal.spi.Callback) Action(org.jboss.hal.core.runtime.Action) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Core(org.jboss.hal.core.Core) Flow.series(org.jboss.hal.flow.Flow.series) Footer(org.jboss.hal.spi.Footer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Subscription(rx.Subscription) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) DomGlobal.setTimeout(elemental2.dom.DomGlobal.setTimeout) ModelNode(org.jboss.hal.dmr.ModelNode) Alert(org.jboss.hal.ballroom.Alert) MessageEvent(org.jboss.hal.spi.MessageEvent) SHORT_TIMEOUT(org.jboss.hal.resources.UIConstants.SHORT_TIMEOUT) SuccessfulMetadataCallback(org.jboss.hal.meta.processing.SuccessfulMetadataCallback) ModelNodeHelper.getOrDefault(org.jboss.hal.dmr.ModelNodeHelper.getOrDefault) HashMap(java.util.HashMap) RUNNING(org.jboss.hal.core.runtime.RunningState.RUNNING) Result(org.jboss.hal.core.runtime.Result) FlowContext(org.jboss.hal.flow.FlowContext) Outcome(org.jboss.hal.flow.Outcome) ArrayList(java.util.ArrayList) OnFail(org.jboss.hal.dmr.dispatch.Dispatcher.OnFail) Inject(javax.inject.Inject) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Property(org.jboss.hal.dmr.Property) Strings(com.google.common.base.Strings) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) TimeoutHandler.repeatOperationUntil(org.jboss.hal.dmr.dispatch.TimeoutHandler.repeatOperationUntil) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) ReadSocketBindingGroup(org.jboss.hal.core.runtime.server.ServerUrlTasks.ReadSocketBindingGroup) BlockingDialog(org.jboss.hal.ballroom.dialog.BlockingDialog) Logger(org.slf4j.Logger) CompositeResult(org.jboss.hal.dmr.CompositeResult) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) EventBus(com.google.web.bindery.event.shared.EventBus) CSS.pfIcon(org.jboss.hal.resources.CSS.pfIcon) DialogFactory(org.jboss.hal.ballroom.dialog.DialogFactory) CompletableSubscriber(rx.CompletableSubscriber) Consumer(java.util.function.Consumer) Composite(org.jboss.hal.dmr.Composite) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Resources(org.jboss.hal.resources.Resources) SUSPENDED(org.jboss.hal.core.runtime.SuspendState.SUSPENDED) RunningState(org.jboss.hal.core.runtime.RunningState) Elements.span(org.jboss.gwt.elemento.core.Elements.span) Elements(org.jboss.gwt.elemento.core.Elements) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) Form(org.jboss.hal.ballroom.form.Form) URL_KEY(org.jboss.hal.core.runtime.server.ServerUrlTasks.URL_KEY) HTMLElement(elemental2.dom.HTMLElement) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) Dialog(org.jboss.hal.ballroom.dialog.Dialog) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) BlockingDialog(org.jboss.hal.ballroom.dialog.BlockingDialog) Alert(org.jboss.hal.ballroom.Alert) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 9 with FORM

use of org.jboss.hal.resources.Ids.FORM in project console by hal.

the class LoggingView method init.

@PostConstruct
void init() {
    noRootLogger = new EmptyState.Builder("logging-root-logger-empty", mbuiContext.resources().constants().noRootLogger()).description(mbuiContext.resources().constants().noRootLoggerDescription()).icon("fa fa-sitemap").primaryAction(mbuiContext.resources().constants().add(), this::addRootLogger).build();
    noRootLogger.element().classList.add(marginTopLarge);
    // hack which relies on the element hierarchy given in the template. will break if you change that hierarchy.
    rootLoggerForm.element().parentNode.appendChild(noRootLogger.element());
    rootLoggerVisibility(true);
    // --------------------------- json formatter
    LabelBuilder labelBuilder = new LabelBuilder();
    Metadata jsonMetadata = mbuiContext.metadataRegistry().lookup(JSON_FORMATTER_TEMPLATE);
    Metadata jsonKeyOverridesMetadata = jsonMetadata.forComplexAttribute(KEY_OVERRIDES);
    String jsonLabel = labelBuilder.label(JSON_FORMATTER_TEMPLATE.lastName());
    jsonFormatterTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(LOGGING, JSON, FORMATTER, TABLE), jsonMetadata).button(mbuiContext.tableButtonFactory().add(Ids.build(LOGGING, JSON, FORMATTER, Ids.ADD), jsonLabel, JSON_FORMATTER_TEMPLATE, (name, address) -> presenter.reload())).button(mbuiContext.tableButtonFactory().remove(jsonLabel, JSON_FORMATTER_TEMPLATE, table -> table.selectedRow().getName(), () -> presenter.reload())).column(NAME, (cell, type, row, meta) -> row.getName()).build();
    jsonFormatterForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(LOGGING, JSON, FORMATTER, FORM), jsonMetadata).onSave((form, changedValues) -> mbuiContext.crud().save(jsonLabel, form.getModel().getName(), JSON_FORMATTER_TEMPLATE, changedValues, () -> presenter.reload())).prepareReset(form -> mbuiContext.crud().reset(jsonLabel, jsonFormatterTable.selectedRow().getName(), JSON_FORMATTER_TEMPLATE, form, jsonMetadata, () -> presenter.reload())).build();
    jsonKeyOverridesForm = new ModelNodeForm.Builder<>(Ids.build(LOGGING, FORMATTER, JSON, KEY_OVERRIDES, FORM), jsonKeyOverridesMetadata).singleton(() -> {
        StatementContext jsonStatementContext = new SelectionAwareStatementContext(presenter.getStatementContext(), () -> jsonFormatterTable.selectedRow().getName());
        return new Operation.Builder(JSON_FORMATTER_TEMPLATE.resolve(jsonStatementContext), READ_ATTRIBUTE_OPERATION).param(NAME, KEY_OVERRIDES).build();
    }, () -> presenter.addComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, JSON_FORMATTER_TEMPLATE)).onSave((form, changedValues) -> presenter.saveComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, JSON_FORMATTER_TEMPLATE, changedValues)).prepareReset(form -> presenter.resetComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, JSON_FORMATTER_TEMPLATE, jsonKeyOverridesMetadata, form)).prepareRemove(form -> presenter.removeComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, JSON_FORMATTER_TEMPLATE)).build();
    Tabs jsonTabs = new Tabs(Ids.build(LOGGING, FORMATTER, JSON, TAB_CONTAINER));
    jsonTabs.add(Ids.build(LOGGING, FORMATTER, JSON, ATTRIBUTES, TAB), mbuiContext.resources().constants().attributes(), jsonFormatterForm.element());
    jsonTabs.add(Ids.build(LOGGING, FORMATTER, JSON, KEY_OVERRIDES, TAB), Names.KEY_OVERRIDES, jsonKeyOverridesForm.element());
    HTMLElement jsonSection = section().add(h(1).textContent(Names.JSON_FORMATTER)).add(p().textContent(jsonMetadata.getDescription().getDescription())).add(jsonFormatterTable).add(jsonTabs).element();
    registerAttachable(jsonFormatterTable, jsonFormatterForm, jsonKeyOverridesForm);
    navigation.insertSecondary(LOGGING_FORMATTER_ITEM, Ids.build(LOGGING, FORMATTER, JSON, Ids.ITEM), null, Names.JSON_FORMATTER, jsonSection);
    // --------------------------- xml formatter
    Metadata xmlMetadata = mbuiContext.metadataRegistry().lookup(XML_FORMATTER_TEMPLATE);
    Metadata xmlKeyOverridesMetadata = xmlMetadata.forComplexAttribute(KEY_OVERRIDES);
    String xmlLabel = labelBuilder.label(XML_FORMATTER_TEMPLATE.lastName());
    xmlFormatterTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(LOGGING, XML, FORMATTER, TABLE), xmlMetadata).button(mbuiContext.tableButtonFactory().add(Ids.build(LOGGING, XML, FORMATTER, Ids.ADD), xmlLabel, XML_FORMATTER_TEMPLATE, (name, address) -> presenter.reload())).button(mbuiContext.tableButtonFactory().remove(xmlLabel, XML_FORMATTER_TEMPLATE, table -> table.selectedRow().getName(), () -> presenter.reload())).column(NAME, (cell, type, row, meta) -> row.getName()).build();
    xmlFormatterForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(LOGGING, XML, FORMATTER, FORM), xmlMetadata).onSave((form, changedValues) -> mbuiContext.crud().save(xmlLabel, form.getModel().getName(), XML_FORMATTER_TEMPLATE, changedValues, () -> presenter.reload())).prepareReset(form -> mbuiContext.crud().reset(xmlLabel, xmlFormatterTable.selectedRow().getName(), XML_FORMATTER_TEMPLATE, form, xmlMetadata, () -> presenter.reload())).build();
    xmlKeyOverridesForm = new ModelNodeForm.Builder<>(Ids.build(LOGGING, FORMATTER, XML, KEY_OVERRIDES, FORM), xmlKeyOverridesMetadata).singleton(() -> {
        StatementContext xmlStatementContext = new SelectionAwareStatementContext(presenter.getStatementContext(), () -> xmlFormatterTable.selectedRow().getName());
        return new Operation.Builder(XML_FORMATTER_TEMPLATE.resolve(xmlStatementContext), READ_ATTRIBUTE_OPERATION).param(NAME, KEY_OVERRIDES).build();
    }, () -> presenter.addComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, XML_FORMATTER_TEMPLATE)).onSave((form, changedValues) -> presenter.saveComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, XML_FORMATTER_TEMPLATE, changedValues)).prepareReset(form -> presenter.resetComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, XML_FORMATTER_TEMPLATE, xmlKeyOverridesMetadata, form)).prepareRemove(form -> presenter.removeComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, XML_FORMATTER_TEMPLATE)).build();
    Tabs xmlTabs = new Tabs(Ids.build(LOGGING, FORMATTER, XML, TAB_CONTAINER));
    xmlTabs.add(Ids.build(LOGGING, FORMATTER, XML, ATTRIBUTES, TAB), mbuiContext.resources().constants().attributes(), xmlFormatterForm.element());
    xmlTabs.add(Ids.build(LOGGING, FORMATTER, XML, KEY_OVERRIDES, TAB), Names.KEY_OVERRIDES, xmlKeyOverridesForm.element());
    HTMLElement xmlSection = section().add(h(1).textContent(Names.XML_FORMATTER)).add(p().textContent(xmlMetadata.getDescription().getDescription())).add(xmlFormatterTable).add(xmlTabs).element();
    registerAttachable(xmlFormatterTable, xmlFormatterForm, xmlKeyOverridesForm);
    navigation.insertSecondary(LOGGING_FORMATTER_ITEM, Ids.build(LOGGING, FORMATTER, XML, Ids.ITEM), null, Names.XML_FORMATTER, xmlSection);
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) StatementContext(org.jboss.hal.meta.StatementContext) MessageEvent(org.jboss.hal.spi.MessageEvent) ModelNodeTable(org.jboss.hal.core.mbui.table.ModelNodeTable) TAB_CONTAINER(org.jboss.hal.resources.Ids.TAB_CONTAINER) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) MbuiViewImpl(org.jboss.hal.core.mbui.MbuiViewImpl) Elements.setVisible(org.jboss.gwt.elemento.core.Elements.setVisible) Tabs(org.jboss.hal.ballroom.Tabs) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) TAB(org.jboss.hal.resources.Ids.TAB) LOGGING_FORMATTER_ITEM(org.jboss.hal.resources.Ids.LOGGING_FORMATTER_ITEM) Elements.section(org.jboss.gwt.elemento.core.Elements.section) MbuiElement(org.jboss.hal.spi.MbuiElement) Elements.p(org.jboss.gwt.elemento.core.Elements.p) HTMLElement(elemental2.dom.HTMLElement) Arrays.asList(java.util.Arrays.asList) Message(org.jboss.hal.spi.Message) EmptyState(org.jboss.hal.ballroom.EmptyState) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) Elements.h(org.jboss.gwt.elemento.core.Elements.h) DomGlobal.document(elemental2.dom.DomGlobal.document) Table(org.jboss.hal.ballroom.table.Table) Operation(org.jboss.hal.dmr.Operation) SuggestHandler(org.jboss.hal.ballroom.form.SuggestHandler) Ids(org.jboss.hal.resources.Ids) ReadChildrenAutoComplete(org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete) FORM(org.jboss.hal.resources.Ids.FORM) CSS.marginTopLarge(org.jboss.hal.resources.CSS.marginTopLarge) VerticalNavigation(org.jboss.hal.ballroom.VerticalNavigation) ModelNodeHelper.failSafeGet(org.jboss.hal.dmr.ModelNodeHelper.failSafeGet) List(java.util.List) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) AddressTemplates(org.jboss.hal.client.configuration.subsystem.logging.AddressTemplates) SelectionAwareStatementContext(org.jboss.hal.meta.SelectionAwareStatementContext) MbuiContext(org.jboss.hal.core.mbui.MbuiContext) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) PostConstruct(javax.annotation.PostConstruct) MbuiView(org.jboss.hal.spi.MbuiView) NamedNode(org.jboss.hal.dmr.NamedNode) Form(org.jboss.hal.ballroom.form.Form) EmptyState(org.jboss.hal.ballroom.EmptyState) HTMLElement(elemental2.dom.HTMLElement) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Metadata(org.jboss.hal.meta.Metadata) NamedNode(org.jboss.hal.dmr.NamedNode) Operation(org.jboss.hal.dmr.Operation) SelectionAwareStatementContext(org.jboss.hal.meta.SelectionAwareStatementContext) StatementContext(org.jboss.hal.meta.StatementContext) SelectionAwareStatementContext(org.jboss.hal.meta.SelectionAwareStatementContext) ModelNodeTable(org.jboss.hal.core.mbui.table.ModelNodeTable) Tabs(org.jboss.hal.ballroom.Tabs) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) PostConstruct(javax.annotation.PostConstruct)

Aggregations

HTMLElement (elemental2.dom.HTMLElement)9 List (java.util.List)9 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)9 Metadata (org.jboss.hal.meta.Metadata)9 Ids (org.jboss.hal.resources.Ids)9 FORM (org.jboss.hal.resources.Ids.FORM)9 Names (org.jboss.hal.resources.Names)9 Form (org.jboss.hal.ballroom.form.Form)8 ModelNode (org.jboss.hal.dmr.ModelNode)8 Operation (org.jboss.hal.dmr.Operation)8 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)8 StatementContext (org.jboss.hal.meta.StatementContext)8 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)7 AddressTemplate (org.jboss.hal.meta.AddressTemplate)7 EventBus (com.google.web.bindery.event.shared.EventBus)6 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 Inject (javax.inject.Inject)6 Provider (javax.inject.Provider)6 Elements.p (org.jboss.gwt.elemento.core.Elements.p)6