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