use of org.jboss.hal.core.runtime.host.Host in project console by hal.
the class TopologyPreview method hostElement.
private HTMLElement hostElement(Host host) {
HTMLElement dropdown;
HTMLTableCellElement th = th().css(asList(rowHeader, statusCss(host)).toArray(new String[] {})).on(click, event -> hostDetails(host)).data("host", // NON-NLS
host.getName()).add(div().css(hostContainer).add(dropdown = div().css(CSS.dropdown).element())).element();
HTMLElement hostNameElement;
if (host.isAlive() && !hostActions.isPending(host) && isAllowed(host)) {
String hostDropDownId = Ids.host(host.getAddressName());
dropdown.appendChild(hostNameElement = a().id(hostDropDownId).css(clickable, dropdownToggle, name).data(UIConstants.TOGGLE, UIConstants.DROPDOWN).aria(UIConstants.HAS_POPUP, UIConstants.TRUE).title(host.getName()).element());
dropdown.appendChild(ul().css(dropdownMenu).attr(UIConstants.ROLE, UIConstants.MENU).aria(UIConstants.LABELLED_BY, hostDropDownId).addAll(hostActions(host)).element());
} else {
dropdown.appendChild(hostNameElement = span().css(name).title(host.getName()).element());
}
hostNameElement.appendChild(hostNameElement.ownerDocument.createTextNode(host.getName()));
if (!host.isConnected()) {
hostNameElement.classList.add(disconnected);
hostNameElement.title = hostNameElement.title + " (" + resources.constants().disconnected() + ")";
}
if (host.isDomainController()) {
hostNameElement.appendChild(span().css(fontAwesome("star"), marginLeft5).title(Names.DOMAIN_CONTROLLER).element());
}
return th;
}
use of org.jboss.hal.core.runtime.host.Host in project console by hal.
the class HostColumn method onHostResult.
@Override
public void onHostResult(HostResultEvent event) {
if (isVisible()) {
Host host = event.getHost();
ItemMonitor.stopProgress(Ids.host(host.getAddressName()));
event.getServers().forEach(server -> ItemMonitor.stopProgress(server.getId()));
refresh(RESTORE_SELECTION);
}
}
use of org.jboss.hal.core.runtime.host.Host in project console by hal.
the class HostPresenter method disableSslForManagementInterface.
@Override
@SuppressWarnings("DuplicatedCode")
public void disableSslForManagementInterface() {
Constants constants = resources.constants();
String serverName = environment.isStandalone() ? Names.STANDALONE_SERVER : Names.DOMAIN_CONTROLLER;
String label = constants.reload() + " " + serverName;
SwitchItem reload = new SwitchItem(RELOAD, label);
reload.setExpressionAllowed(false);
Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(RELOAD, FORM), Metadata.empty()).unboundFormItem(reload).build();
form.attach();
HTMLElement formElement = form.element();
ModelNode model = new ModelNode();
model.setEmptyObject();
form.edit(model);
ResourceAddress httpAddress = HTTP_INTERFACE_TEMPLATE.resolve(statementContext);
DialogFactory.buildConfirmation(constants.disableSSL(), resources.messages().disableSSLManagementQuestion(serverName), formElement, Dialog.Size.MEDIUM, () -> {
List<Task<FlowContext>> tasks = new ArrayList<>();
// load the http-interface resource to get the port
Task<FlowContext> loadHttpInterface = flowContext -> {
Operation readHttpInterface = new Operation.Builder(httpAddress, READ_RESOURCE_OPERATION).build();
return dispatcher.execute(readHttpInterface).doOnSuccess(value -> {
if (value.hasDefined(PORT)) {
// only domain mode contains "port" attribute
String port = value.get(PORT).asString();
if (port.contains("$")) {
// if it contains an expression value, resolve it at host level
ResourceAddress address = AddressTemplate.of("/host=" + environment.getDomainController()).resolve(statementContext);
Operation readPort = new Operation.Builder(address, RESOLVE_EXPRESSION).param(EXPRESSION, port).build();
dispatcher.execute(readPort, portResult -> flowContext.set(PORT, portResult.asString()));
} else {
flowContext.set(PORT, port);
}
}
}).toCompletable();
};
tasks.add(loadHttpInterface);
// in domain-mode read the /host=<dc> domain controller
// it is important for later use if user wants to reload dc if in admin-mode
Task<FlowContext> loadDc = flowContext -> {
ResourceAddress dcAddress = AddressTemplate.of("/host=" + environment.getDomainController()).resolve(statementContext);
Operation readDcOp = new Operation.Builder(dcAddress, READ_RESOURCE_OPERATION).param(ATTRIBUTES_ONLY, true).build();
return dispatcher.execute(readDcOp).doOnSuccess(value -> flowContext.set(HOST, new Host(value))).toCompletable();
};
tasks.add(loadDc);
// as part of the disable ssl task, undefine the secure-port, it only exists in domain mode
Task<FlowContext> undefineSecurePortTask = flowContext -> {
Operation op = new Operation.Builder(httpAddress, UNDEFINE_ATTRIBUTE_OPERATION).param(NAME, SECURE_PORT).build();
return dispatcher.execute(op).toCompletable();
};
tasks.add(undefineSecurePortTask);
// as part of the disable ssl task, undefine the ssl-context
Task<FlowContext> undefineSslContextTask = flowContext -> {
Operation op = new Operation.Builder(httpAddress, UNDEFINE_ATTRIBUTE_OPERATION).param(NAME, SSL_CONTEXT).build();
return dispatcher.execute(op).toCompletable();
};
tasks.add(undefineSslContextTask);
series(new FlowContext(progress.get()), tasks).subscribe(new SuccessfulOutcome<FlowContext>(getEventBus(), resources) {
@Override
public void onSuccess(FlowContext flowContext) {
if (reload.getValue() != null && reload.getValue()) {
String port = flowContext.get(PORT).toString();
// extracts the url search path, so the reload shows the same view the use is on
String urlSuffix = window.location.getHref();
urlSuffix = urlSuffix.substring(urlSuffix.indexOf("//") + 2);
urlSuffix = urlSuffix.substring(urlSuffix.indexOf("/"));
// the location to redirect the browser to the unsecure URL
// TODO Replace hardcoded scheme
String location = "http://" + window.location.getHostname() + ":" + port + urlSuffix;
Host host = flowContext.get(HOST);
reloadServer(host, location);
} else {
reloadView();
MessageEvent.fire(getEventBus(), Message.success(resources.messages().disableSSLManagementSuccess()));
}
}
@Override
public void onError(FlowContext context, Throwable throwable) {
MessageEvent.fire(getEventBus(), Message.error(resources.messages().disableSSLManagementError(throwable.getMessage())));
}
});
}).show();
}
Aggregations