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();
}
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()))));
});
}
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();
}
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));
}
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();
}
Aggregations