Search in sources :

Example 16 with LabelBuilder

use of org.jboss.hal.ballroom.LabelBuilder in project console by hal.

the class PasswordWizard method show.

public void show() {
    Constants constants = resources.constants();
    Wizard.Builder<PasswordContext, PasswordState> wb = new Wizard.Builder<>(constants.setIdentityPasswordTitle(), new PasswordContext());
    wb.addStep(PasswordState.CHOOSE_PASSWORD_TYPE, new ChoosePasswordTypeStep(resources)).addStep(PasswordState.CONFIGURATION, new ConfigurePasswordStep(resources, metadata)).addStep(PasswordState.REVIEW, new ReviewPasswordStep(resources, metadata)).onBack((context, currentState) -> {
        PasswordState previous = null;
        switch(currentState) {
            case CHOOSE_PASSWORD_TYPE:
                break;
            case CONFIGURATION:
                previous = PasswordState.CHOOSE_PASSWORD_TYPE;
                break;
            case REVIEW:
                previous = PasswordState.CONFIGURATION;
                break;
            default:
                break;
        }
        return previous;
    }).onNext((context, currentState) -> {
        PasswordState next = null;
        switch(currentState) {
            case CHOOSE_PASSWORD_TYPE:
                next = PasswordState.CONFIGURATION;
                break;
            case CONFIGURATION:
                next = PasswordState.REVIEW;
                break;
            case REVIEW:
                break;
            default:
                break;
        }
        return next;
    }).onFinish((wizard, context) -> {
        ResourceAddress address = metadata.getTemplate().resolve(statementContext, selectedRealm);
        Operation operation = new Operation.Builder(address, SET_PASSWORD).param(IDENTITY, selectedIdentity).param(context.type.name, context.model).build();
        LabelBuilder labelBuilder = new LabelBuilder();
        String type = labelBuilder.label(metadata.getTemplate().lastName());
        String resourceName = type + "" + selectedRealm;
        dispatcher.execute(operation, result -> MessageEvent.fire(eventBus, Message.success(resources.messages().setIdentityPasswordSuccess(selectedIdentity, resourceName))), (operation1, failure) -> MessageEvent.fire(eventBus, Message.error(resources.messages().setIdentityPasswordError(selectedIdentity, resourceName, failure))), (operation1, exception) -> MessageEvent.fire(eventBus, Message.error(resources.messages().setIdentityPasswordError(selectedIdentity, resourceName, exception.getMessage()))));
    });
    Wizard<PasswordContext, PasswordState> wizard = wb.build();
    wizard.show();
}
Also used : IDENTITY(org.jboss.hal.dmr.ModelDescriptionConstants.IDENTITY) Operation(org.jboss.hal.dmr.Operation) StatementContext(org.jboss.hal.meta.StatementContext) MessageEvent(org.jboss.hal.spi.MessageEvent) Wizard(org.jboss.hal.ballroom.wizard.Wizard) EventBus(com.google.web.bindery.event.shared.EventBus) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Resources(org.jboss.hal.resources.Resources) Constants(org.jboss.hal.resources.Constants) SET_PASSWORD(org.jboss.hal.dmr.ModelDescriptionConstants.SET_PASSWORD) Message(org.jboss.hal.spi.Message) Metadata(org.jboss.hal.meta.Metadata) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Constants(org.jboss.hal.resources.Constants) Operation(org.jboss.hal.dmr.Operation) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Wizard(org.jboss.hal.ballroom.wizard.Wizard)

Example 17 with LabelBuilder

use of org.jboss.hal.ballroom.LabelBuilder in project console by hal.

the class RealmsPresenter method removeIdentity.

public void removeIdentity(Metadata metadata, String realm, String identity, Consumer<Boolean> consumer) {
    LabelBuilder labelBuilder = new LabelBuilder();
    String resourceName = labelBuilder.label(metadata.getTemplate().lastName()) + SPACE + realm;
    SafeHtml question = resources.messages().removeIdentityQuestion(identity, resourceName);
    DialogFactory.showConfirmation(resources.constants().removeIdentity(), question, () -> {
        ResourceAddress address = metadata.getTemplate().resolve(statementContext, realm);
        Operation operation = new Operation.Builder(address, REMOVE_IDENTITY).param(IDENTITY, identity).build();
        dispatcher.execute(operation, result -> {
            MessageEvent.fire(getEventBus(), Message.success(resources.messages().removeIdentitySuccess(identity, resourceName)));
            consumer.accept(true);
        }, (operation1, failure) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().removeIdentityError(identity, resourceName, failure))), (operation1, exception) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().removeIdentityError(identity, resourceName, exception.getMessage()))));
    });
}
Also used : ResourceAddress(org.jboss.hal.dmr.ResourceAddress) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Operation(org.jboss.hal.dmr.Operation)

Example 18 with LabelBuilder

use of org.jboss.hal.ballroom.LabelBuilder in project console by hal.

the class RealmsPresenter method addIdentity.

void addIdentity(AddressTemplate template, Metadata metadata, String name) {
    Metadata opMetadata = metadata.forOperation(ADD_IDENTITY);
    SafeHtml identityAttributeHelp = resources.messages().identityAttributeHelp();
    IdentityAttributeItem identityAttribute = new IdentityAttributeItem(Ids.asId(IDENTITY_ATTRIBUTE_MAPPING), IDENTITY_ATTRIBUTE_MAPPING);
    Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(template.lastName(), ADD_IDENTITY), opMetadata).unboundFormItem(identityAttribute, 1, identityAttributeHelp).build();
    form.attach();
    AddResourceDialog dialog = new AddResourceDialog(resources.constants().addIdentity(), form, (name1, model) -> {
        LabelBuilder labelBuilder = new LabelBuilder();
        String resourceName = labelBuilder.label(template.lastName()) + SPACE + name;
        String identity = model.get(IDENTITY).asString();
        ResourceAddress address = template.resolve(statementContext, name);
        List<Task<FlowContext>> tasks = new ArrayList<>();
        Task<FlowContext> addTask = flowContext -> {
            Operation addOp = new Operation.Builder(address, ADD_IDENTITY).param(IDENTITY, identity).build();
            return dispatcher.execute(addOp).doOnError(ex -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().addError(resources.constants().identity(), identity, resourceName, ex.getMessage())))).toCompletable();
        };
        tasks.add(addTask);
        if (identityAttribute.getValue() != null) {
            identityAttribute.getValue().forEach((key, values) -> {
                Task<FlowContext> addAttribute = flowContext -> {
                    ModelNode modelValues = new ModelNode();
                    values.forEach(modelValues::add);
                    Operation addIdentAttributeOp = new Operation.Builder(address, ADD_IDENTITY_ATTRIBUTE).param(IDENTITY, identity).param(NAME, key).param(VALUE, modelValues).build();
                    return dispatcher.execute(addIdentAttributeOp).doOnError(ex -> MessageEvent.fire(getEventBus(), Message.error(resources.messages().addError(resources.constants().identity(), identity, resourceName, ex.getMessage())))).toCompletable();
                };
                tasks.add(addAttribute);
            });
        }
        series(new FlowContext(progress.get()), tasks).subscribe(new SuccessfulOutcome<FlowContext>(getEventBus(), resources) {

            @Override
            public void onSuccess(FlowContext flowContext) {
                MessageEvent.fire(getEventBus(), Message.success(resources.messages().addSuccess(resources.constants().identity(), identity, resourceName)));
            }

            @Override
            public void onError(FlowContext context, Throwable throwable) {
                MessageEvent.fire(getEventBus(), Message.error(resources.messages().addError(resources.constants().identity(), identity, resourceName, throwable.getMessage())));
            }
        });
    });
    dialog.show();
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) Dialog(org.jboss.hal.ballroom.dialog.Dialog) Provider(javax.inject.Provider) StatementContext(org.jboss.hal.meta.StatementContext) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) IDENTITY_ATTRIBUTE_MAPPING(org.jboss.hal.resources.Names.IDENTITY_ATTRIBUTE_MAPPING) Map(java.util.Map) Message(org.jboss.hal.spi.Message) 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) NameToken(com.gwtplatform.mvp.client.annotations.NameToken) FinderPath(org.jboss.hal.core.finder.FinderPath) List(java.util.List) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) AddressTemplates(org.jboss.hal.client.runtime.subsystem.elytron.AddressTemplates) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) HalView(org.jboss.hal.core.mvp.HalView) Flow.series(org.jboss.hal.flow.Flow.series) 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) PasswordWizard(org.jboss.hal.client.runtime.subsystem.elytron.wizardpassword.PasswordWizard) MessageEvent(org.jboss.hal.spi.MessageEvent) ProxyPlace(com.gwtplatform.mvp.client.proxy.ProxyPlace) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) FlowContext(org.jboss.hal.flow.FlowContext) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Task(org.jboss.hal.flow.Task) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) ApplicationFinderPresenter(org.jboss.hal.core.mvp.ApplicationFinderPresenter) Requires(org.jboss.hal.spi.Requires) CompositeResult(org.jboss.hal.dmr.CompositeResult) ProxyCodeSplit(com.gwtplatform.mvp.client.annotations.ProxyCodeSplit) 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) DialogFactory(org.jboss.hal.ballroom.dialog.DialogFactory) Consumer(java.util.function.Consumer) Composite(org.jboss.hal.dmr.Composite) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) NameTokens(org.jboss.hal.meta.token.NameTokens) Resources(org.jboss.hal.resources.Resources) NamedNode(org.jboss.hal.dmr.NamedNode) Form(org.jboss.hal.ballroom.form.Form) Task(org.jboss.hal.flow.Task) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Metadata(org.jboss.hal.meta.Metadata) ArrayList(java.util.ArrayList) Operation(org.jboss.hal.dmr.Operation) FlowContext(org.jboss.hal.flow.FlowContext) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 19 with LabelBuilder

use of org.jboss.hal.ballroom.LabelBuilder in project console by hal.

the class ConstantHeadersElement method removeConstantHeaderPath.

private void removeConstantHeaderPath(ModelNode row) {
    int pathIndex = row.get(HAL_INDEX).asInt();
    String path = row.get(PATH).asString();
    LabelBuilder labelBuilder = new LabelBuilder();
    String type = labelBuilder.label(PATH);
    String title = resources.messages().removeConfirmationTitle(type);
    SafeHtml question = resources.messages().removeConfirmationQuestion(path);
    SafeHtml success = resources.messages().removeResourceSuccess(type, path);
    DialogFactory.showConfirmation(title, question, () -> presenter.removeConstantHeaderPath(pathIndex, path, success));
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Constraint(org.jboss.hal.meta.security.Constraint)

Example 20 with LabelBuilder

use of org.jboss.hal.ballroom.LabelBuilder in project console by hal.

the class ConstantHeadersElement method addConstantHeaderPath.

private void addConstantHeaderPath(Metadata metadata) {
    LabelBuilder labelBuilder = new LabelBuilder();
    String type = labelBuilder.label(PATH);
    TextBoxItem headerName = new TextBoxItem(HEADER_NAME);
    headerName.setRequired(true);
    TextBoxItem headerValue = new TextBoxItem(HEADER_VALUE);
    headerValue.setRequired(true);
    Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(Ids.CONSTANT_HEADERS, Ids.ADD), metadata).addOnly().include(PATH).exclude(HEADERS).dontVerifyExcludes().unboundFormItem(headerName).unboundFormItem(headerValue).build();
    AddResourceDialog dialog = new AddResourceDialog(resources.messages().addResourceTitle(type), form, (name, model) -> {
        if (model != null) {
            ModelNode header = new ModelNode();
            header.get(NAME).set(String.valueOf(form.getFormItem(HEADER_NAME).getValue()));
            header.get(VALUE).set(String.valueOf(form.getFormItem(HEADER_VALUE).getValue()));
            model.get(HEADERS).add(header);
            String finiWasHere = model.get(PATH).asString();
            SafeHtml message = resources.messages().addSuccess(type, finiWasHere, labelBuilder.label(CONSTANT_HEADERS));
            presenter.addConstantHeaderPath(model, message);
        }
    });
    dialog.show();
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) ModelNode(org.jboss.hal.dmr.ModelNode) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm)

Aggregations

LabelBuilder (org.jboss.hal.ballroom.LabelBuilder)48 ModelNode (org.jboss.hal.dmr.ModelNode)33 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)32 Metadata (org.jboss.hal.meta.Metadata)28 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)26 Operation (org.jboss.hal.dmr.Operation)25 AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)23 Form (org.jboss.hal.ballroom.form.Form)20 Ids (org.jboss.hal.resources.Ids)17 List (java.util.List)15 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)15 AddressTemplate (org.jboss.hal.meta.AddressTemplate)15 Resources (org.jboss.hal.resources.Resources)15 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)14 EventBus (com.google.web.bindery.event.shared.EventBus)14 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)14 StatementContext (org.jboss.hal.meta.StatementContext)14 Names (org.jboss.hal.resources.Names)14 Inject (javax.inject.Inject)13 NamedNode (org.jboss.hal.dmr.NamedNode)12