Search in sources :

Example 1 with Dialog

use of org.jboss.hal.ballroom.dialog.Dialog in project console by hal.

the class HeaderPresenter method logout.

void logout() {
    if (environment.isSingleSignOn()) {
        keycloakHolder.getKeycloak().logout(null);
    } else {
        Dialog dialog = new Dialog.Builder(resources.constants().logout()).add(p().innerHtml(resources.messages().closeToLogout()).element()).primary(resources.constants().ok(), () -> true).build();
        dialog.show();
    }
}
Also used : Dialog(org.jboss.hal.ballroom.dialog.Dialog)

Example 2 with Dialog

use of org.jboss.hal.ballroom.dialog.Dialog in project console by hal.

the class ServerActions method copyServer.

// ------------------------------------------------------ server operations
public void copyServer(Server server, Callback callback) {
    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 = AddressTemplate.of("/host=" + hosts.get(0) + "/server-config=*");
        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).fromRequestProperties().unboundFormItem(nameItem, 0).unboundFormItem(hostFormItem, 1, resources.messages().addServerHostHelp()).exclude(AUTO_START, SOCKET_BINDING_DEFAULT_INTERFACE, SOCKET_BINDING_GROUP, UPDATE_AUTO_START_WITH_SERVER_STATUS).build();
                AddResourceDialog dialog = new AddResourceDialog(resources.messages().copyServerTitle(), form, (resource, payload) -> {
                    // read server-config recursively to retrieve nested resources
                    ModelNode serverConfigModel = new ModelNode();
                    serverConfigModel.get(HOST).set(server.getHost());
                    serverConfigModel.get(SERVER_CONFIG).set(server.getName());
                    ResourceAddress serverAddress = new ResourceAddress(serverConfigModel);
                    Operation opReadServer = new Operation.Builder(serverAddress, READ_RESOURCE_OPERATION).param(RECURSIVE, true).build();
                    dispatcher.execute(opReadServer, new Consumer<ModelNode>() {

                        @Override
                        public void accept(ModelNode newServerModel) {
                            String newServerName = nameItem.getValue();
                            // set the chosen group in the model
                            newServerModel.get(GROUP).set(payload.get(GROUP).asString());
                            if (payload.hasDefined(SOCKET_BINDING_PORT_OFFSET)) {
                                newServerModel.get(SOCKET_BINDING_PORT_OFFSET).set(payload.get(SOCKET_BINDING_PORT_OFFSET).asLong());
                            }
                            newServerModel.get(NAME).set(newServerName);
                            ModelNode newServerModelAddress = new ModelNode();
                            newServerModelAddress.get(HOST).set(hostFormItem.getValue());
                            newServerModelAddress.get(SERVER_CONFIG).set(newServerName);
                            Operation opAddServer = new Operation.Builder(new ResourceAddress(newServerModelAddress), ADD).payload(newServerModel).build();
                            Composite comp = new Composite();
                            comp.add(opAddServer);
                            // create operation for each nested resource of the source server
                            createOperation(comp, JVM, newServerModel, newServerModelAddress);
                            createOperation(comp, INTERFACE, newServerModel, newServerModelAddress);
                            createOperation(comp, PATH, newServerModel, newServerModelAddress);
                            createOperation(comp, SYSTEM_PROPERTY, newServerModel, newServerModelAddress);
                            createOperation(comp, SSL, newServerModel, newServerModelAddress);
                            dispatcher.execute(comp, (CompositeResult result) -> {
                                MessageEvent.fire(eventBus, Message.success(resources.messages().addResourceSuccess(Names.SERVER, newServerName)));
                                callback.execute();
                            }, (operation1, failure) -> {
                                MessageEvent.fire(eventBus, Message.error(resources.messages().addResourceError(newServerName, failure)));
                                callback.execute();
                            }, (operation1, exception) -> {
                                MessageEvent.fire(eventBus, Message.error(resources.messages().addResourceError(newServerName, exception.getMessage())));
                                callback.execute();
                            });
                        }

                        private void createOperation(Composite composite, String resource, ModelNode model, ModelNode baseAddress) {
                            if (model.hasDefined(resource)) {
                                List<Property> props = model.get(resource).asPropertyList();
                                props.forEach(p -> {
                                    String propname = p.getName();
                                    ModelNode _address = baseAddress.clone();
                                    _address.get(resource).set(propname);
                                    Operation operation = new Operation.Builder(new ResourceAddress(_address), ADD).payload(p.getValue()).build();
                                    composite.add(operation);
                                });
                            }
                        }
                    });
                });
                dialog.show();
            }
        });
    });
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) 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) SingleSelectBoxItem(org.jboss.hal.ballroom.form.SingleSelectBoxItem) Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) 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) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) Consumer(java.util.function.Consumer) ModelNode(org.jboss.hal.dmr.ModelNode) Property(org.jboss.hal.dmr.Property)

Example 3 with Dialog

use of org.jboss.hal.ballroom.dialog.Dialog in project console by hal.

the class StandaloneDeploymentColumn method replace.

private void replace(Deployment deployment) {
    UploadElement uploadElement = new UploadElement(resources.messages().noDeployment());
    Dialog dialog = new Dialog.Builder(resources.constants().replaceDeployment()).add(uploadElement.element()).cancel().primary(resources.constants().replace(), () -> {
        boolean valid = uploadElement.validate();
        if (valid) {
            ReplaceDeploymentPanel replaceDeploymentPanel = new ReplaceDeploymentPanel();
            replaceDeploymentPanel.on();
            series(new FlowContext(progress.get()), new CheckDeployment(dispatcher, deployment.getName()), // To replace an existing deployment, the original name and runtime-name must be preserved.
            new UploadOrReplace(environment, dispatcher, deployment.getName(), deployment.getRuntimeName(), uploadElement.getFiles().item(0), false)).subscribe(new Outcome<FlowContext>() {

                @Override
                public void onError(FlowContext context, Throwable error) {
                    replaceDeploymentPanel.off();
                    MessageEvent.fire(eventBus, Message.error(resources.messages().contentReplaceError(deployment.getName()), error.getMessage()));
                }

                @Override
                public void onSuccess(FlowContext context) {
                    refresh(Ids.content(deployment.getName()));
                    replaceDeploymentPanel.off();
                    MessageEvent.fire(eventBus, Message.success(resources.messages().contentReplaceSuccess(deployment.getName())));
                }
            });
        }
        return valid;
    }).build();
    dialog.show();
}
Also used : UploadOrReplace(org.jboss.hal.client.deployment.DeploymentTasks.UploadOrReplace) CheckDeployment(org.jboss.hal.client.deployment.DeploymentTasks.CheckDeployment) Dialog(org.jboss.hal.ballroom.dialog.Dialog) CreateEmptyDialog(org.jboss.hal.client.deployment.dialog.CreateEmptyDialog) AddUnmanagedDialog(org.jboss.hal.client.deployment.dialog.AddUnmanagedDialog) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) Outcome(org.jboss.hal.flow.Outcome) UploadElement(org.jboss.hal.client.shared.uploadwizard.UploadElement) FlowContext(org.jboss.hal.flow.FlowContext)

Example 4 with Dialog

use of org.jboss.hal.ballroom.dialog.Dialog in project console by hal.

the class ResetServerDialog method reset.

void reset(String messagingServer) {
    LabelBuilder labelBuilder = new LabelBuilder();
    String l1 = labelBuilder.label(RESET_ALL_MESSAGE_COUNTERS);
    Property p1 = metadata.getDescription().findOperation(RESET_ALL_MESSAGE_COUNTERS);
    if (p1 != null && p1.getValue().hasDefined(DESCRIPTION)) {
        l1 = p1.getValue().get(DESCRIPTION).asString();
        l1 = Strings.sanitize(l1);
    }
    String l2 = labelBuilder.label(RESET_ALL_MESSAGE_COUNTER_HISTORIES);
    Property p2 = metadata.getDescription().findOperation(RESET_ALL_MESSAGE_COUNTER_HISTORIES);
    if (p2 != null && p2.getValue().hasDefined(DESCRIPTION)) {
        l2 = p2.getValue().get(DESCRIPTION).asString();
        l2 = Strings.sanitize(l2);
    }
    Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.RESET_MESSAGE_COUNTERS, Metadata.empty()).unboundFormItem(new SwitchItem(RESET_ALL_MESSAGE_COUNTERS, l1)).unboundFormItem(new SwitchItem(RESET_ALL_MESSAGE_COUNTER_HISTORIES, l2)).onSave((f, changedValues) -> column.resetServer(messagingServer, !f.getFormItem(RESET_ALL_MESSAGE_COUNTERS).isEmpty(), !f.getFormItem(RESET_ALL_MESSAGE_COUNTER_HISTORIES).isEmpty())).build();
    form.addFormValidation(new RequireAtLeastOneAttributeValidation<>(asList(RESET_ALL_MESSAGE_COUNTERS, RESET_ALL_MESSAGE_COUNTER_HISTORIES), resources));
    // Make the long labels more readable
    stream(form.element().querySelectorAll("." + halFormLabel + ", ." + halFormInput)).filter(htmlElements()).map(asHtmlElement()).forEach(element -> element.style.width = WidthUnionType.of("50%"));
    Dialog dialog = new Dialog.Builder(resources.constants().reset()).add(form.element()).primary(resources.constants().reset(), form::save).size(Size.MEDIUM).closeIcon(true).closeOnEsc(true).cancel().build();
    dialog.registerAttachable(form);
    form.edit(new ModelNode());
    dialog.show();
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) Dialog(org.jboss.hal.ballroom.dialog.Dialog) RESET_ALL_MESSAGE_COUNTERS(org.jboss.hal.dmr.ModelDescriptionConstants.RESET_ALL_MESSAGE_COUNTERS) Size(org.jboss.hal.ballroom.dialog.Dialog.Size) Ids(org.jboss.hal.resources.Ids) Elements.stream(org.jboss.gwt.elemento.core.Elements.stream) Elements.asHtmlElement(org.jboss.gwt.elemento.core.Elements.asHtmlElement) CSS.halFormLabel(org.jboss.hal.resources.CSS.halFormLabel) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Elements.htmlElements(org.jboss.gwt.elemento.core.Elements.htmlElements) Property(org.jboss.hal.dmr.Property) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) SwitchItem(org.jboss.hal.ballroom.form.SwitchItem) RESET_ALL_MESSAGE_COUNTER_HISTORIES(org.jboss.hal.dmr.ModelDescriptionConstants.RESET_ALL_MESSAGE_COUNTER_HISTORIES) Resources(org.jboss.hal.resources.Resources) DESCRIPTION(org.jboss.hal.dmr.ModelDescriptionConstants.DESCRIPTION) Arrays.asList(java.util.Arrays.asList) RequireAtLeastOneAttributeValidation(org.jboss.hal.core.mbui.form.RequireAtLeastOneAttributeValidation) Strings(org.jboss.hal.resources.Strings) WidthUnionType(elemental2.dom.CSSProperties.WidthUnionType) Metadata(org.jboss.hal.meta.Metadata) CSS.halFormInput(org.jboss.hal.resources.CSS.halFormInput) Form(org.jboss.hal.ballroom.form.Form) Dialog(org.jboss.hal.ballroom.dialog.Dialog) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) ModelNode(org.jboss.hal.dmr.ModelNode) Property(org.jboss.hal.dmr.Property) SwitchItem(org.jboss.hal.ballroom.form.SwitchItem)

Example 5 with Dialog

use of org.jboss.hal.ballroom.dialog.Dialog in project console by hal.

the class CloseConnectionsDialog method show.

void show() {
    Form<ModelNode> cfaForm = new OperationFormBuilder<>(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_FOR_ADDRESS_FORM, metadata, CLOSE_CONNECTIONS_FOR_ADDRESS).build();
    Form<ModelNode> ccForm = new OperationFormBuilder<>(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_CONSUMER_FORM, metadata, CLOSE_CONSUMER_CONNECTIONS_FOR_ADDRESS).build();
    Form<ModelNode> cfuForm = new OperationFormBuilder<>(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_FOR_USER_FORM, metadata, CLOSE_CONNECTIONS_FOR_USER).build();
    operationToForm = new HashMap<>();
    operationToForm.put(CLOSE_CONNECTIONS_FOR_ADDRESS, cfaForm);
    operationToForm.put(CLOSE_CONSUMER_CONNECTIONS_FOR_ADDRESS, ccForm);
    operationToForm.put(CLOSE_CONNECTIONS_FOR_USER, cfuForm);
    tabs = new Tabs(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_TABS);
    tabs.add(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_FOR_ADDRESS_TAB, resources.constants().forAddress(), cfaForm.element());
    tabs.add(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_CONSUMER_TAB, resources.constants().consumersForAddress(), ccForm.element());
    tabs.add(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_FOR_USER_TAB, resources.constants().forUser(), cfuForm.element());
    tabToOperation = new HashMap<>();
    tabToOperation.put(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_FOR_ADDRESS_TAB, CLOSE_CONNECTIONS_FOR_ADDRESS);
    tabToOperation.put(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_CONSUMER_TAB, CLOSE_CONSUMER_CONNECTIONS_FOR_ADDRESS);
    tabToOperation.put(Ids.MESSAGING_SERVER_CONNECTION_CLOSE_FOR_USER_TAB, CLOSE_CONNECTIONS_FOR_USER);
    Dialog dialog = new Dialog.Builder(resources.constants().close()).add(p().textContent(resources.constants().chooseConnectionsToClose()).element()).add(tabs.element()).primary(resources.constants().close(), this::onClose).size(Size.MEDIUM).closeIcon(true).closeOnEsc(true).cancel().build();
    dialog.registerAttachable(cfaForm, ccForm, cfuForm);
    cfaForm.edit(new ModelNode());
    ccForm.edit(new ModelNode());
    cfuForm.edit(new ModelNode());
    dialog.show();
}
Also used : Dialog(org.jboss.hal.ballroom.dialog.Dialog) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder) Tabs(org.jboss.hal.ballroom.Tabs) ModelNode(org.jboss.hal.dmr.ModelNode)

Aggregations

Dialog (org.jboss.hal.ballroom.dialog.Dialog)30 ModelNode (org.jboss.hal.dmr.ModelNode)26 Operation (org.jboss.hal.dmr.Operation)23 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)22 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)21 LabelBuilder (org.jboss.hal.ballroom.LabelBuilder)18 Metadata (org.jboss.hal.meta.Metadata)17 AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)15 AddressTemplate (org.jboss.hal.meta.AddressTemplate)12 FlowContext (org.jboss.hal.flow.FlowContext)11 Form (org.jboss.hal.ballroom.form.Form)9 Ids (org.jboss.hal.resources.Ids)9 Resources (org.jboss.hal.resources.Resources)9 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)8 EventBus (com.google.web.bindery.event.shared.EventBus)8 Inject (javax.inject.Inject)8 Provider (javax.inject.Provider)8 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)8 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)8 Progress (org.jboss.hal.flow.Progress)8