Search in sources :

Example 6 with Message

use of org.jboss.hal.spi.Message in project console by hal.

the class ExtensionColumn method remove.

private void remove(InstalledExtension extension) {
    DialogFactory.showConfirmation(resources.messages().removeConfirmationTitle(Names.EXTENSION), resources.messages().removeExtensionQuestion(), () -> {
        extensionStorage.remove(extension);
        Message message = Message.success(resources.messages().removeExtensionSuccess(), resources.constants().reload(), () -> window.location.reload(), true);
        MessageEvent.fire(eventBus, message);
        refresh(RefreshMode.CLEAR_SELECTION);
    });
}
Also used : Message(org.jboss.hal.spi.Message)

Example 7 with Message

use of org.jboss.hal.spi.Message in project console by hal.

the class ServerPresenter method disableSsl.

void disableSsl(String httpsListener) {
    AddressTemplate httpsTemplate = SERVER_TEMPLATE.append(HTTPS_LISTENER + EQ_WILDCARD);
    Metadata metadata = metadataRegistry.lookup(httpsTemplate);
    SafeHtml description = resources.messages().disableSSLUndertowQuestion(httpsListener);
    String label = new LabelBuilder().label(SECURITY_REALM);
    TextBoxItem securityRealmItem = new TextBoxItem(SECURITY_REALM, label);
    securityRealmItem.setRequired(true);
    SafeHtml securityRealmDescription = SafeHtmlUtils.fromTrustedString(metadata.getDescription().get(ATTRIBUTES).get(SECURITY_REALM).get(DESCRIPTION).asString());
    Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(SECURITY_REALM, Ids.FORM), Metadata.empty()).unboundFormItem(securityRealmItem, 0, securityRealmDescription).build();
    HTMLElement content = div().add(p().innerHtml(description)).add(form.element()).element();
    Dialog dialog = new Dialog.Builder(resources.constants().disableSSL()).size(Dialog.Size.MEDIUM).primary(resources.constants().yes(), () -> {
        boolean valid = form.save();
        // if the form contains validation error, don't close the dialog
        if (valid) {
            ResourceAddress httpsAddress = httpsTemplate.resolve(statementContext, serverName, httpsListener);
            Operation undefineSslCtx = new Operation.Builder(httpsAddress, UNDEFINE_ATTRIBUTE_OPERATION).param(NAME, SSL_CONTEXT).build();
            Operation writeSecurityRealm = new Operation.Builder(httpsAddress, WRITE_ATTRIBUTE_OPERATION).param(NAME, SECURITY_REALM).param(VALUE, securityRealmItem.getValue()).build();
            Composite composite = new Composite();
            composite.add(undefineSslCtx);
            composite.add(writeSecurityRealm);
            dispatcher.execute(composite, (CompositeResult result) -> {
                MessageEvent.fire(getEventBus(), Message.success(resources.messages().disableSSLUndertowSuccess(httpsListener)));
                reload();
            }, (operation, failure) -> {
                MessageEvent.fire(getEventBus(), Message.error(resources.messages().disableSSLUndertowError(httpsListener, failure)));
            }, (operation, exception) -> {
                SafeHtml message = resources.messages().disableSSLUndertowError(httpsListener, exception.getMessage());
                MessageEvent.fire(getEventBus(), Message.error(message));
            });
        }
        return valid;
    }).secondary(resources.constants().no(), () -> true).closeIcon(true).closeOnEsc(true).add(content).build();
    dialog.registerAttachable(form);
    dialog.show();
    ModelNode model = new ModelNode().setEmptyObject();
    form.edit(model);
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate) Dialog(org.jboss.hal.ballroom.dialog.Dialog) Provider(javax.inject.Provider) FinishRemove(org.jboss.hal.ballroom.form.Form.FinishRemove) Environment(org.jboss.hal.config.Environment) StatementContext(org.jboss.hal.meta.StatementContext) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) FilteringStatementContext(org.jboss.hal.meta.FilteringStatementContext) Collections.singletonList(java.util.Collections.singletonList) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) Elements.p(org.jboss.gwt.elemento.core.Elements.p) HTMLElement(elemental2.dom.HTMLElement) Map(java.util.Map) Message(org.jboss.hal.spi.Message) AddressTemplates(org.jboss.hal.client.configuration.subsystem.undertow.AddressTemplates) FinishReset(org.jboss.hal.ballroom.form.Form.FinishReset) HasPresenter(org.jboss.hal.core.mvp.HasPresenter) 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) NameToken(com.gwtplatform.mvp.client.annotations.NameToken) FinderPath(org.jboss.hal.core.finder.FinderPath) Collectors(java.util.stream.Collectors) List(java.util.List) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) HalView(org.jboss.hal.core.mvp.HalView) Flow.series(org.jboss.hal.flow.Flow.series) ModelNodeHelper.encodeValue(org.jboss.hal.dmr.ModelNodeHelper.encodeValue) Finder(org.jboss.hal.core.finder.Finder) Footer(org.jboss.hal.spi.Footer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SupportsExpertMode(org.jboss.hal.core.mvp.SupportsExpertMode) ModelNode(org.jboss.hal.dmr.ModelNode) Elements.div(org.jboss.gwt.elemento.core.Elements.div) MessageEvent(org.jboss.hal.spi.MessageEvent) ProxyPlace(com.gwtplatform.mvp.client.proxy.ProxyPlace) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) HashMap(java.util.HashMap) FlowContext(org.jboss.hal.flow.FlowContext) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Filter(org.jboss.hal.meta.FilteringStatementContext.Filter) Task(org.jboss.hal.flow.Task) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) ApplicationFinderPresenter(org.jboss.hal.core.mvp.ApplicationFinderPresenter) SafeHtmlUtils(com.google.gwt.safehtml.shared.SafeHtmlUtils) Requires(org.jboss.hal.spi.Requires) SELECTION_KEY(org.jboss.hal.meta.SelectionAwareStatementContext.SELECTION_KEY) CompositeResult(org.jboss.hal.dmr.CompositeResult) ProxyCodeSplit(com.gwtplatform.mvp.client.annotations.ProxyCodeSplit) EnableSSLWizard(org.jboss.hal.client.shared.sslwizard.EnableSSLWizard) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) FinderPathFactory(org.jboss.hal.core.finder.FinderPathFactory) EventBus(com.google.web.bindery.event.shared.EventBus) ReadChildrenAutoComplete(org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete) PlaceRequest(com.gwtplatform.mvp.shared.proxy.PlaceRequest) Consumer(java.util.function.Consumer) Composite(org.jboss.hal.dmr.Composite) ModelNodeHelper.failSafePropertyList(org.jboss.hal.dmr.ModelNodeHelper.failSafePropertyList) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) NameTokens(org.jboss.hal.meta.token.NameTokens) Resources(org.jboss.hal.resources.Resources) EnableSSLPresenter(org.jboss.hal.client.shared.sslwizard.EnableSSLPresenter) NamedNode(org.jboss.hal.dmr.NamedNode) Form(org.jboss.hal.ballroom.form.Form) HTMLElement(elemental2.dom.HTMLElement) Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) CompositeResult(org.jboss.hal.dmr.CompositeResult) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Metadata(org.jboss.hal.meta.Metadata) Operation(org.jboss.hal.dmr.Operation) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) 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 8 with Message

use of org.jboss.hal.spi.Message in project console by hal.

the class MembershipColumn method columnActionHandler.

private ColumnActionHandler<Assignment> columnActionHandler(Principal principal, boolean include) {
    return column -> {
        Role role = findRole(getFinder().getContext().getPath());
        if (role != null) {
            series(new FlowContext(progress.get()), new CheckRoleMapping(dispatcher, role), new AddRoleMapping(dispatcher, role, status -> status == 404), new AddAssignment(dispatcher, role, principal, include)).subscribe(new org.jboss.hal.core.SuccessfulOutcome<FlowContext>(eventBus, resources) {

                @Override
                public void onSuccess(FlowContext context) {
                    String type = principal.getType() == Principal.Type.USER ? resources.constants().user() : resources.constants().group();
                    SafeHtml message = include ? resources.messages().assignmentIncludeSuccess(type, principal.getName()) : resources.messages().assignmentExcludeSuccess(type, principal.getName());
                    MessageEvent.fire(eventBus, Message.success(message));
                    accessControl.reload(() -> {
                        refresh(RefreshMode.RESTORE_SELECTION);
                        if (isCurrentUser(principal)) {
                            eventBus.fireEvent(new UserChangedEvent());
                        }
                    });
                }
            });
        }
    };
}
Also used : ColumnActionHandler(org.jboss.hal.core.finder.ColumnActionHandler) Provider(javax.inject.Provider) AsyncColumn(org.jboss.hal.spi.AsyncColumn) ItemActionFactory(org.jboss.hal.core.finder.ItemActionFactory) MessageEvent(org.jboss.hal.spi.MessageEvent) ColumnAction(org.jboss.hal.core.finder.ColumnAction) ItemAction(org.jboss.hal.core.finder.ItemAction) ItemDisplay(org.jboss.hal.core.finder.ItemDisplay) FinderSegment(org.jboss.hal.core.finder.FinderSegment) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) UserChangedEvent(org.jboss.hal.config.UserChangedEvent) FlowContext(org.jboss.hal.flow.FlowContext) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Inject(javax.inject.Inject) AddRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.AddRoleMapping) Progress(org.jboss.hal.flow.Progress) HTMLElement(elemental2.dom.HTMLElement) Message(org.jboss.hal.spi.Message) FinderColumn(org.jboss.hal.core.finder.FinderColumn) User(org.jboss.hal.config.User) Comparator.comparing(java.util.Comparator.comparing) Collectors.toSet(java.util.stream.Collectors.toSet) CheckRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.CheckRoleMapping) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) INCLUDE_TEMPLATE(org.jboss.hal.client.accesscontrol.AddressTemplates.INCLUDE_TEMPLATE) EXCLUDE_TEMPLATE(org.jboss.hal.client.accesscontrol.AddressTemplates.EXCLUDE_TEMPLATE) REMOVE(org.jboss.hal.dmr.ModelDescriptionConstants.REMOVE) Set(java.util.Set) EventBus(com.google.web.bindery.event.shared.EventBus) AddAssignment(org.jboss.hal.client.accesscontrol.AccessControlTasks.AddAssignment) FinderPath(org.jboss.hal.core.finder.FinderPath) Sets(com.google.common.collect.Sets) List(java.util.List) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Collectors.toList(java.util.stream.Collectors.toList) Resources(org.jboss.hal.resources.Resources) Flow.series(org.jboss.hal.flow.Flow.series) Role(org.jboss.hal.config.Role) Finder(org.jboss.hal.core.finder.Finder) Footer(org.jboss.hal.spi.Footer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Elements.span(org.jboss.gwt.elemento.core.Elements.span) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) Role(org.jboss.hal.config.Role) UserChangedEvent(org.jboss.hal.config.UserChangedEvent) AddRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.AddRoleMapping) AddAssignment(org.jboss.hal.client.accesscontrol.AccessControlTasks.AddAssignment) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) FlowContext(org.jboss.hal.flow.FlowContext) CheckRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.CheckRoleMapping)

Example 9 with Message

use of org.jboss.hal.spi.Message in project console by hal.

the class UploadStatistics method getMessage.

public Message getMessage() {
    SortedSet<String> added = new TreeSet<>();
    SortedSet<String> replaced = new TreeSet<>();
    SortedSet<String> failed = new TreeSet<>();
    for (Map.Entry<String, UploadStatus> entry : status.entrySet()) {
        switch(entry.getValue()) {
            case ADDED:
                added.add(entry.getKey());
                break;
            case REPLACED:
                replaced.add(entry.getKey());
                break;
            case FAILED:
                failed.add(entry.getKey());
                break;
            default:
                break;
        }
    }
    Level overallResult;
    if (status.isEmpty()) {
        overallResult = Level.INFO;
    } else if (failed.isEmpty()) {
        overallResult = Level.SUCCESS;
    } else if (added.isEmpty() && replaced.isEmpty()) {
        overallResult = Level.ERROR;
    } else {
        overallResult = Level.WARNING;
    }
    Message message;
    switch(overallResult) {
        // all deployments have been successfully added or replaced
        case SUCCESS:
            message = Message.success(sentences(added, replaced, failed));
            break;
        // no statistics
        case INFO:
            message = Message.info(MESSAGES.noDeploymentsUploaded());
            break;
        // some deployments have been successfully added or replaced, but some couldn't
        case WARNING:
            message = Message.warning(sentences(added, replaced, failed));
            break;
        // only errors
        case ERROR:
            message = Message.error(sentences(added, replaced, failed));
            break;
        default:
            message = Message.error(MESSAGES.unknownError());
    }
    return message;
}
Also used : Message(org.jboss.hal.spi.Message) TreeSet(java.util.TreeSet) Level(org.jboss.hal.spi.Message.Level) Map(java.util.Map) HashMap(java.util.HashMap)

Example 10 with Message

use of org.jboss.hal.spi.Message in project console by hal.

the class ComplexAttributeOperations method remove.

// ------------------------------------------------------ (d)elete using address
/**
 * Undefines the complex attribute at the specified index. After the attribute has been undefined a standard success message
 * is fired and the specified callback is executed.
 *
 * @param complexAttribute the name of the complex attribute
 * @param type the human readable name of the complex attribute
 * @param index the index for the list-type complex attribute
 * @param address the fq address for the operation
 * @param callback the callback executed after the complex attribute has been undefined
 */
@JsIgnore
public void remove(String complexAttribute, String type, int index, ResourceAddress address, Callback callback) {
    Operation operation = new Operation.Builder(address, LIST_REMOVE_OPERATION).param(NAME, complexAttribute).param(INDEX, index).build();
    SafeHtml question = resources.messages().removeSingletonConfirmationQuestion();
    DialogFactory.showConfirmation(resources.messages().removeConfirmationTitle(type), question, () -> dispatcher.execute(operation, result -> {
        MessageEvent.fire(eventBus, Message.success(resources.messages().removeSingletonResourceSuccess(type)));
        callback.execute();
    }));
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) Iterables(com.google.common.collect.Iterables) Provider(javax.inject.Provider) StatementContext(org.jboss.hal.meta.StatementContext) MessageEvent(org.jboss.hal.spi.MessageEvent) SuccessfulMetadataCallback(org.jboss.hal.meta.processing.SuccessfulMetadataCallback) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Inject(javax.inject.Inject) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) Map(java.util.Map) Message(org.jboss.hal.spi.Message) Metadata(org.jboss.hal.meta.Metadata) Nullable(javax.annotation.Nullable) Collectors.toSet(java.util.stream.Collectors.toSet) CompositeResult(org.jboss.hal.dmr.CompositeResult) Operation(org.jboss.hal.dmr.Operation) Collections.emptyList(java.util.Collections.emptyList) Set(java.util.Set) EventBus(com.google.web.bindery.event.shared.EventBus) DialogFactory(org.jboss.hal.ballroom.dialog.DialogFactory) Composite(org.jboss.hal.dmr.Composite) JsIgnore(jsinterop.annotations.JsIgnore) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) FormItem(org.jboss.hal.ballroom.form.FormItem) MetadataProcessor(org.jboss.hal.meta.processing.MetadataProcessor) Callback(org.jboss.hal.spi.Callback) StreamSupport.stream(java.util.stream.StreamSupport.stream) Resources(org.jboss.hal.resources.Resources) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Footer(org.jboss.hal.spi.Footer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Form(org.jboss.hal.ballroom.form.Form) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Operation(org.jboss.hal.dmr.Operation) JsIgnore(jsinterop.annotations.JsIgnore)

Aggregations

Message (org.jboss.hal.spi.Message)10 EventBus (com.google.web.bindery.event.shared.EventBus)8 Provider (javax.inject.Provider)8 Operation (org.jboss.hal.dmr.Operation)8 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)8 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)8 Progress (org.jboss.hal.flow.Progress)8 Resources (org.jboss.hal.resources.Resources)8 Footer (org.jboss.hal.spi.Footer)8 MessageEvent (org.jboss.hal.spi.MessageEvent)8 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)7 Inject (javax.inject.Inject)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Composite (org.jboss.hal.dmr.Composite)6 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)6 ModelNode (org.jboss.hal.dmr.ModelNode)6 Flow.series (org.jboss.hal.flow.Flow.series)6 FlowContext (org.jboss.hal.flow.FlowContext)6 AddressTemplate (org.jboss.hal.meta.AddressTemplate)6