use of org.jboss.hal.meta.AddressTemplate in project console by hal.
the class ChildrenPanel method update.
@SuppressWarnings("HardCodedStringLiteral")
void update(Node<Context> node, ResourceAddress address) {
this.parent = node;
SafeHtmlBuilder safeHtml = new SafeHtmlBuilder();
if (node.data.hasSingletons()) {
safeHtml.appendEscaped("Singleton ");
}
safeHtml.appendEscaped("Child Resources of ").appendHtmlConstant("<code>").appendEscaped(node.text).appendHtmlConstant("</code>");
header.innerHTML = safeHtml.toSafeHtml().asString();
Operation operation = new Operation.Builder(address.getParent(), READ_CHILDREN_NAMES_OPERATION).param(CHILD_TYPE, node.text).build();
dispatcher.execute(operation, result -> {
List<String> names = result.asList().stream().map(ModelNode::asString).collect(toList());
table.update(names);
if (node.data.hasSingletons()) {
logger.debug("Read {} / {} singletons", names.size(), node.data.getSingletons().size());
} else {
// enable / disable buttons makes only sense for none-singleton resources!
AddressTemplate template = asGenericTemplate(node, address);
metadataProcessor.lookup(template, Progress.NOOP, new MetadataProcessor.MetadataCallback() {
@Override
@SuppressWarnings("unchecked")
public void onMetadata(Metadata metadata) {
Map<Integer, String> buttonConstraints = new HashMap<>();
buttonConstraints.put(0, Constraint.executable(template, ADD).data());
buttonConstraints.put(1, Constraint.executable(template, REMOVE).data());
((DataTable) table).applySecurity(buttonConstraints, AuthorisationDecision.from(environment, constraint -> Optional.of(metadata.getSecurityContext())));
}
@Override
public void onError(Throwable error) {
logger.warn("Unable to enable / disable table buttons for {}", address);
}
});
}
});
}
use of org.jboss.hal.meta.AddressTemplate in project console by hal.
the class ModclusterView method init.
@PostConstruct
void init() {
// --------- load-provider=dynamic
Metadata dynamicMetadata = mbuiContext.metadataRegistry().lookup(LOAD_PROVIDER_DYNAMIC_TEMPLATE);
loadProviderDynamicForm = new ModelNodeForm.Builder<>("load-provider-dynamic-form", dynamicMetadata).singleton(() -> presenter.loadProviderDynamicOperation(), () -> presenter.addLoadProviderDynamic()).prepareRemove(form -> presenter.removeLoadProviderDynamic()).onSave((form, changedValues) -> {
String name = presenter.getProxyName();
AddressTemplate template = LOAD_PROVIDER_DYNAMIC_TEMPLATE.replaceWildcards(presenter.getProxyName());
saveForm(Names.LOAD_PROVIDER_DYNAMIC, name, template.resolve(mbuiContext.statementContext(), name), changedValues, dynamicMetadata);
}).prepareReset(form -> {
String name = presenter.getProxyName();
AddressTemplate template = LOAD_PROVIDER_DYNAMIC_TEMPLATE.replaceWildcards(presenter.getProxyName());
resetForm(Names.LOAD_PROVIDER_DYNAMIC, name, template.resolve(mbuiContext.statementContext(), name), form, dynamicMetadata);
}).build();
HTMLElement loadProviderDynamicElement = section().add(div().add(h(1).textContent(LOAD_PROVIDER_DYNAMIC)).add(p().textContent(dynamicMetadata.getDescription().getDescription())).element()).add(loadProviderDynamicForm).element();
navigation.insertPrimary("load-provider-dynamic-item", "custom-load-metrics-item", LOAD_PROVIDER_DYNAMIC, "fa fa-shield", loadProviderDynamicElement);
registerAttachable(loadProviderDynamicForm);
// --------- load-provider=simple
Metadata simpleMetadata = mbuiContext.metadataRegistry().lookup(LOAD_PROVIDER_SIMPLE_TEMPLATE);
loadProviderSimpleForm = new ModelNodeForm.Builder<>("load-provider-simple-form", simpleMetadata).singleton(() -> presenter.loadProviderSimpleOperation(), () -> presenter.addLoadProviderSimple()).prepareRemove(form -> presenter.removeLoadProviderSimple()).onSave((form, changedValues) -> {
String name = presenter.getProxyName();
AddressTemplate template = LOAD_PROVIDER_SIMPLE_TEMPLATE.replaceWildcards(presenter.getProxyName());
saveForm(LOAD_PROVIDER_SIMPLE, name, template.resolve(mbuiContext.statementContext(), name), changedValues, simpleMetadata);
}).prepareReset(form -> {
String name = presenter.getProxyName();
AddressTemplate template = LOAD_PROVIDER_SIMPLE_TEMPLATE.replaceWildcards(presenter.getProxyName());
resetForm(LOAD_PROVIDER_SIMPLE, name, template.resolve(mbuiContext.statementContext(), name), form, simpleMetadata);
}).build();
HTMLElement loadProviderSimpleElement = section().add(div().add(h(1).textContent(LOAD_PROVIDER_SIMPLE)).add(p().textContent(simpleMetadata.getDescription().getDescription())).element()).add(loadProviderSimpleForm).element();
navigation.insertPrimary("load-provider-simple-item", "load-provider-dynamic-item", LOAD_PROVIDER_SIMPLE, "fa fa-exchange", loadProviderSimpleElement);
registerAttachable(loadProviderSimpleForm);
}
use of org.jboss.hal.meta.AddressTemplate in project console by hal.
the class ModclusterPresenter method removeLoadProviderDynamic.
public void removeLoadProviderDynamic() {
AddressTemplate template = LOAD_PROVIDER_DYNAMIC_TEMPLATE.replaceWildcards(proxyName);
crud.removeSingleton(Names.LOAD_PROVIDER_DYNAMIC, template, this::reload);
}
use of org.jboss.hal.meta.AddressTemplate in project console by hal.
the class ModclusterPresenter method saveCustomLoadMetric.
public void saveCustomLoadMetric(Form<NamedNode> form, Map<String, Object> changedValues) {
AddressTemplate template = CUSTOM_LOAD_METRIC_TEMPLATE.replaceWildcards(proxyName);
crud.save(Names.CUSTOM_LOAD_METRIC, form.getModel().getName(), template, changedValues, this::reload);
}
use of org.jboss.hal.meta.AddressTemplate in project console by hal.
the class ModclusterPresenter method prepareResetLoadMetric.
public void prepareResetLoadMetric(Form<NamedNode> form) {
AddressTemplate template = LOAD_METRIC_TEMPLATE.replaceWildcards(proxyName);
Metadata metadata = metadataRegistry.lookup(LOAD_METRIC_TEMPLATE);
crud.reset(Names.LOAD_METRIC, form.getModel().getName(), template, form, metadata, this::reload);
}
Aggregations