use of org.jboss.hal.dmr.ModelDescriptionConstants.OPERATION in project console by hal.
the class PolicyElement method injectRemove.
private void injectRemove(Form<ModelNode> form, Callback callback) {
// hacky way to inject the remove link into the form tools, depends on FormLink internals!
String linksId = Ids.build(form.getId(), "links");
Element formLinks = form.element().querySelector(HASH + linksId);
if (formLinks != null) {
HTMLLIElement removeLink = li().add(a().css(clickable).on(click, event -> callback.execute()).add(i().css(pfIcon("remove"))).data(OPERATION, REMOVE).add(span().css(formLinkLabel).textContent(resources.constants().remove()))).element();
formLinks.insertBefore(removeLink, formLinks.lastElementChild);
}
}
use of org.jboss.hal.dmr.ModelDescriptionConstants.OPERATION in project console by hal.
the class Dispatcher method operationUrl.
private String operationUrl(Operation operation) {
StringBuilder builder = new StringBuilder();
builder.append(endpoints.dmr()).append("/");
// 1. address
ResourceAddress address = operation.getAddress();
if (!address.isEmpty()) {
String path = address.asPropertyList().stream().map(property -> encodeURIComponent(property.getName()) + "/" + encodeURIComponent(property.getValue().asString())).collect(joining("/"));
builder.append(path);
}
// 2. operation
String name = operation.getName();
if (GetOperation.isSupported(name)) {
GetOperation getOperation = GetOperation.get(name);
name = getOperation.httpGetOperation();
}
builder.append("?").append(OP).append("=").append(name);
// 3. parameter
if (operation.hasParameter()) {
operation.getParameter().asPropertyList().forEach(property -> {
builder.append("&").append(encodeURIComponent(property.getName()));
if (property.getValue().isDefined()) {
builder.append("=").append(encodeURIComponent(property.getValue().asString()));
}
});
}
// 4. bearer token
String token = getBearerToken();
if (token != null) {
builder.append("&access_token=").append(token);
}
// TODO operation headers
return builder.toString();
}
Aggregations