Search in sources :

Example 16 with AddressTemplate

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);
                }
            });
        }
    });
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) OptionsBuilder(org.jboss.hal.ballroom.table.OptionsBuilder) Metadata(org.jboss.hal.meta.Metadata) Operation(org.jboss.hal.dmr.Operation) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) MetadataProcessor(org.jboss.hal.meta.processing.MetadataProcessor) HashMap(java.util.HashMap) Map(java.util.Map)

Example 17 with AddressTemplate

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);
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) Element(elemental2.dom.Element) Alert(org.jboss.hal.ballroom.Alert) LOAD_PROVIDER_DYNAMIC_TEMPLATE(org.jboss.hal.client.configuration.subsystem.modcluster.AddressTemplates.LOAD_PROVIDER_DYNAMIC_TEMPLATE) MbuiViewImpl(org.jboss.hal.core.mbui.MbuiViewImpl) Icons(org.jboss.hal.resources.Icons) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) AddressTemplate(org.jboss.hal.meta.AddressTemplate) MbuiElement(org.jboss.hal.spi.MbuiElement) HTMLElement(elemental2.dom.HTMLElement) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) Table(org.jboss.hal.ballroom.table.Table) LOAD_PROVIDER_SIMPLE(org.jboss.hal.resources.Names.LOAD_PROVIDER_SIMPLE) VerticalNavigation(org.jboss.hal.ballroom.VerticalNavigation) ModelNodeHelper.failSafeGet(org.jboss.hal.dmr.ModelNodeHelper.failSafeGet) List(java.util.List) MbuiContext(org.jboss.hal.core.mbui.MbuiContext) LOAD_PROVIDER_SIMPLE_TEMPLATE(org.jboss.hal.client.configuration.subsystem.modcluster.AddressTemplates.LOAD_PROVIDER_SIMPLE_TEMPLATE) PostConstruct(javax.annotation.PostConstruct) MbuiView(org.jboss.hal.spi.MbuiView) NamedNode(org.jboss.hal.dmr.NamedNode) LOAD_PROVIDER_DYNAMIC(org.jboss.hal.resources.Names.LOAD_PROVIDER_DYNAMIC) Elements(org.jboss.gwt.elemento.core.Elements) Form(org.jboss.hal.ballroom.form.Form) AddressTemplate(org.jboss.hal.meta.AddressTemplate) HTMLElement(elemental2.dom.HTMLElement) Metadata(org.jboss.hal.meta.Metadata) PostConstruct(javax.annotation.PostConstruct)

Example 18 with AddressTemplate

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);
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate)

Example 19 with AddressTemplate

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);
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate)

Example 20 with AddressTemplate

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);
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate) Metadata(org.jboss.hal.meta.Metadata)

Aggregations

AddressTemplate (org.jboss.hal.meta.AddressTemplate)90 Metadata (org.jboss.hal.meta.Metadata)43 ModelNode (org.jboss.hal.dmr.ModelNode)41 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)36 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)35 AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)29 Operation (org.jboss.hal.dmr.Operation)29 Form (org.jboss.hal.ballroom.form.Form)27 Ids (org.jboss.hal.resources.Ids)27 Names (org.jboss.hal.resources.Names)26 List (java.util.List)24 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)24 Resources (org.jboss.hal.resources.Resources)24 HTMLElement (elemental2.dom.HTMLElement)22 LabelBuilder (org.jboss.hal.ballroom.LabelBuilder)22 StatementContext (org.jboss.hal.meta.StatementContext)21 EventBus (com.google.web.bindery.event.shared.EventBus)20 Inject (javax.inject.Inject)20 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)20 NamedNode (org.jboss.hal.dmr.NamedNode)19