Search in sources :

Example 6 with Table

use of org.jboss.hal.ballroom.table.Table in project console by hal.

the class SocketBindingGroupView method init.

@PostConstruct
@SuppressWarnings("ConstantConditions")
void init() {
    AddressTemplate inboundTemplate = ROOT_TEMPLATE.append(INBOUND.templateSuffix());
    Metadata inboundMetadata = mbuiContext.metadataRegistry().lookup(inboundTemplate);
    inboundTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(INBOUND.baseId, Ids.TABLE), inboundMetadata).button(mbuiContext.tableButtonFactory().add(inboundTemplate, table -> presenter.addSocketBinding(INBOUND))).button(mbuiContext.tableButtonFactory().remove(inboundTemplate, table -> presenter.removeSocketBinding(INBOUND, table.selectedRow().getName()))).column(NAME, (cell, type, row, meta) -> row.getName()).column(PORT, (cell, type, row, meta) -> row.get(PORT).asString()).column(new InlineAction<>(Names.CLIENT_MAPPINGS, row -> presenter.showClientMappings(row))).build();
    inboundForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(INBOUND.baseId, Ids.FORM), inboundMetadata).include(INTERFACE, PORT, FIXED_PORT, MULTICAST_ADDRESS, MULTICAST_PORT).unsorted().onSave((form, changedValues) -> presenter.saveSocketBinding(INBOUND, form, changedValues)).prepareReset(form -> presenter.resetSocketBinding(INBOUND, form)).build();
    HTMLElement inboundSection = section().add(h(1).textContent(Names.INBOUND)).add(p().textContent(inboundMetadata.getDescription().getDescription())).add(inboundTable).add(inboundForm).element();
    Metadata clientMappingsMetadata = inboundMetadata.forComplexAttribute(CLIENT_MAPPINGS);
    clientMappingTable = new ModelNodeTable.Builder<NamedNode>(Ids.SOCKET_BINDING_GROUP_INBOUND_CLIENT_MAPPING_TABLE, clientMappingsMetadata).button(mbuiContext.tableButtonFactory().add(inboundTemplate, table -> presenter.addClientMapping(clientMappingsMetadata))).button(mbuiContext.tableButtonFactory().remove(inboundTemplate, table -> presenter.removeClientMapping(table.selectedRow().get(INDEX).asInt(-1)))).column(SOURCE_NETWORK).column(Names.DESTINATION, (cell, type, row, meta) -> {
        String address = row.get(DESTINATION_ADDRESS).asString();
        if (row.hasDefined(DESTINATION_PORT)) {
            address += ":" + row.get(DESTINATION_PORT).asInt();
        }
        return address;
    }).build();
    clientMappingForm = new ModelNodeForm.Builder<NamedNode>(Ids.SOCKET_BINDING_GROUP_INBOUND_CLIENT_MAPPING_FORM, clientMappingsMetadata).include(SOURCE_NETWORK, DESTINATION_ADDRESS, DESTINATION_PORT).unsorted().onSave((form, changedValues) -> presenter.saveClientMapping(clientMappingsMetadata, form.getModel(), changedValues)).build();
    HTMLElement clientMappingSection = section().add(h(1).textContent(Names.CLIENT_MAPPINGS)).add(p().textContent(clientMappingsMetadata.getDescription().getDescription())).add(clientMappingTable).add(clientMappingForm).element();
    String id = Ids.build(INBOUND.baseId, Ids.PAGES);
    String parentId = Ids.build(INBOUND.baseId, Ids.PAGE);
    inboundPages = new Pages(id, parentId, inboundSection);
    inboundPages.addPage(parentId, Ids.SOCKET_BINDING_GROUP_INBOUND_CLIENT_MAPPING_PAGE, () -> Names.INBOUND + ": " + presenter.inbound, () -> Names.CLIENT_MAPPINGS, clientMappingSection);
    navigation.insertPrimary(Ids.build(INBOUND.baseId, Ids.ITEM), // NON-NLS
    "socket-binding-group-outbound-local-item", Names.INBOUND, fontAwesome("arrow-circle-o-left"), inboundPages);
    registerAttachable(inboundTable, inboundForm, clientMappingTable, clientMappingForm);
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate) ModelNodeTable(org.jboss.hal.core.mbui.table.ModelNodeTable) MbuiViewImpl(org.jboss.hal.core.mbui.MbuiViewImpl) INBOUND(org.jboss.hal.client.configuration.SocketBinding.INBOUND) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Elements.section(org.jboss.gwt.elemento.core.Elements.section) AddressTemplate(org.jboss.hal.meta.AddressTemplate) MbuiElement(org.jboss.hal.spi.MbuiElement) Elements.p(org.jboss.gwt.elemento.core.Elements.p) HTMLElement(elemental2.dom.HTMLElement) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) Elements.h(org.jboss.gwt.elemento.core.Elements.h) ModelNodeHelper.asNamedNodes(org.jboss.hal.dmr.ModelNodeHelper.asNamedNodes) Pages(org.jboss.hal.ballroom.Pages) Table(org.jboss.hal.ballroom.table.Table) Ids(org.jboss.hal.resources.Ids) VerticalNavigation(org.jboss.hal.ballroom.VerticalNavigation) ModelNodeHelper.failSafePropertyList(org.jboss.hal.dmr.ModelNodeHelper.failSafePropertyList) List(java.util.List) MbuiContext(org.jboss.hal.core.mbui.MbuiContext) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) ROOT_TEMPLATE(org.jboss.hal.client.configuration.SocketBindingGroupPresenter.ROOT_TEMPLATE) InlineAction(org.jboss.hal.ballroom.table.InlineAction) PostConstruct(javax.annotation.PostConstruct) MbuiView(org.jboss.hal.spi.MbuiView) NamedNode(org.jboss.hal.dmr.NamedNode) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) Form(org.jboss.hal.ballroom.form.Form) HTMLElement(elemental2.dom.HTMLElement) Metadata(org.jboss.hal.meta.Metadata) NamedNode(org.jboss.hal.dmr.NamedNode) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Pages(org.jboss.hal.ballroom.Pages) ModelNodeTable(org.jboss.hal.core.mbui.table.ModelNodeTable) PostConstruct(javax.annotation.PostConstruct)

Example 7 with Table

use of org.jboss.hal.ballroom.table.Table in project console by hal.

the class FilterView method updateHostRefs.

@SuppressWarnings("ConstantConditions")
private void updateHostRefs(final Table<NamedNode> table, final Form<NamedNode> form) {
    FormItem<String> formItem = form.getFormItem(HOSTS);
    if (formItem != null) {
        if (table.hasSelection()) {
            ResourceAddress filterRefAddress = HOST_TEMPLATE.append(FILTER_REF + "=" + table.selectedRow().getName()).resolve(mbuiContext.statementContext());
            Operation filterRefOp = new Operation.Builder(filterRefAddress, READ_RESOURCE_OPERATION).build();
            ResourceAddress locationFilterRefAddress = HOST_TEMPLATE.append(LOCATION + "=*").append(FILTER_REF + "=" + table.selectedRow().getName()).resolve(mbuiContext.statementContext());
            Operation locationFilterRefOp = new Operation.Builder(locationFilterRefAddress, READ_RESOURCE_OPERATION).build();
            mbuiContext.dispatcher().execute(new Composite(filterRefOp, locationFilterRefOp), (CompositeResult result) -> {
                SortedSet<String> hosts = new TreeSet<>();
                result.step(0).get(RESULT).asList().stream().map(node -> {
                    ResourceAddress adr = new ResourceAddress(node.get(ADDRESS));
                    ResourceAddress host = adr.getParent();
                    ResourceAddress server = host.getParent();
                    return server.lastValue() + "/" + host.lastValue();
                }).forEach(hosts::add);
                result.step(1).get(RESULT).asList().stream().map(node -> {
                    ResourceAddress adr = new ResourceAddress(node.get(ADDRESS));
                    ResourceAddress host = adr.getParent().getParent();
                    ResourceAddress server = host.getParent();
                    return server.lastValue() + "/" + host.lastValue();
                }).forEach(hosts::add);
                formItem.setValue(String.join(", ", hosts));
            }, (op1, failure) -> formItem.clearValue());
        } else {
            formItem.clearValue();
        }
    }
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) Arrays(java.util.Arrays) SortedSet(java.util.SortedSet) MbuiViewImpl(org.jboss.hal.core.mbui.MbuiViewImpl) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) TreeSet(java.util.TreeSet) StaticAutoComplete(org.jboss.hal.ballroom.autocomplete.StaticAutoComplete) MbuiElement(org.jboss.hal.spi.MbuiElement) ResponseHeader(org.jboss.hal.dmr.dispatch.ResponseHeader) ModelNodeHelper.asNamedNodes(org.jboss.hal.dmr.ModelNodeHelper.asNamedNodes) HOST_TEMPLATE(org.jboss.hal.client.configuration.subsystem.undertow.AddressTemplates.HOST_TEMPLATE) CompositeResult(org.jboss.hal.dmr.CompositeResult) Table(org.jboss.hal.ballroom.table.Table) Operation(org.jboss.hal.dmr.Operation) VerticalNavigation(org.jboss.hal.ballroom.VerticalNavigation) Composite(org.jboss.hal.dmr.Composite) ModelNodeHelper.failSafePropertyList(org.jboss.hal.dmr.ModelNodeHelper.failSafePropertyList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) FormItem(org.jboss.hal.ballroom.form.FormItem) MbuiContext(org.jboss.hal.core.mbui.MbuiContext) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) PostConstruct(javax.annotation.PostConstruct) MbuiView(org.jboss.hal.spi.MbuiView) NamedNode(org.jboss.hal.dmr.NamedNode) Form(org.jboss.hal.ballroom.form.Form) Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) TreeSet(java.util.TreeSet) Operation(org.jboss.hal.dmr.Operation)

Example 8 with Table

use of org.jboss.hal.ballroom.table.Table in project console by hal.

the class HandlerView method updateHostRefs.

@SuppressWarnings("ConstantConditions")
private void updateHostRefs(final Table<NamedNode> table, final Form<NamedNode> form) {
    FormItem<String> formItem = form.getFormItem(HOSTS);
    if (formItem != null) {
        if (table.hasSelection()) {
            ResourceAddress address = HOST_TEMPLATE.append(LOCATION + "=*").resolve(mbuiContext.statementContext());
            Operation operation = new Operation.Builder(address, READ_RESOURCE_OPERATION).build();
            mbuiContext.dispatcher().execute(operation, result -> {
                String hosts = result.asList().stream().filter(node -> table.selectedRow().getName().equals(node.get(RESULT).get(HANDLER).asString())).map(node -> {
                    ResourceAddress adr = new ResourceAddress(node.get(ADDRESS));
                    ResourceAddress host = adr.getParent();
                    ResourceAddress server = host.getParent();
                    return server.lastValue() + "/" + host.lastValue();
                }).distinct().sorted().collect(Collectors.joining(", "));
                formItem.setValue(hosts);
            }, (op1, failure) -> formItem.clearValue());
        } else {
            formItem.clearValue();
        }
    }
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) HOST_TEMPLATE(org.jboss.hal.client.configuration.subsystem.undertow.AddressTemplates.HOST_TEMPLATE) Table(org.jboss.hal.ballroom.table.Table) Operation(org.jboss.hal.dmr.Operation) MbuiViewImpl(org.jboss.hal.core.mbui.MbuiViewImpl) Collectors(java.util.stream.Collectors) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) VerticalNavigation(org.jboss.hal.ballroom.VerticalNavigation) ModelNodeHelper.failSafePropertyList(org.jboss.hal.dmr.ModelNodeHelper.failSafePropertyList) FormItem(org.jboss.hal.ballroom.form.FormItem) MbuiContext(org.jboss.hal.core.mbui.MbuiContext) MbuiElement(org.jboss.hal.spi.MbuiElement) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) PostConstruct(javax.annotation.PostConstruct) MbuiView(org.jboss.hal.spi.MbuiView) NamedNode(org.jboss.hal.dmr.NamedNode) Form(org.jboss.hal.ballroom.form.Form) ModelNodeHelper.asNamedNodes(org.jboss.hal.dmr.ModelNodeHelper.asNamedNodes) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Operation(org.jboss.hal.dmr.Operation)

Example 9 with Table

use of org.jboss.hal.ballroom.table.Table in project console by hal.

the class SecurityManagerView method createPermissionUI.

private void createPermissionUI(Permission permission) {
    Metadata metadata = metadataRegistry.lookup(DEPLOYMENT_PERMISSIONS_TEMPLATE).forComplexAttribute(permission.resource);
    Constraint constraint = Constraint.writable(DEPLOYMENT_PERMISSIONS_TEMPLATE, permission.resource);
    EmptyState emptyState = new EmptyState.Builder(Ids.DEPLOYMENT_PERMISSIONS_EMPTY, Names.DEPLOYMENT_PERMISSIONS).description(resources.messages().noDeploymentPermissions()).primaryAction(resources.constants().add(), () -> presenter.addDeploymentPermissions(), constraint).build();
    emptyState.element().classList.add(marginTopLarge);
    emptyStates.put(permission, emptyState);
    Table<ModelNode> table = new ModelNodeTable.Builder<>(Ids.build(permission.baseId, Ids.TABLE), metadata).button(resources.constants().add(), t -> presenter.addPermission(permission), constraint).button(resources.constants().remove(), t -> presenter.removePermission(permission, t.selectedRow().get(HAL_INDEX).asInt()), Scope.SELECTED, constraint).column(CLASS).build();
    tables.put(permission, table);
    registerAttachable(table);
    Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(permission.baseId, Ids.FORM), metadata).onSave((f, changedValues) -> presenter.savePermission(permission, f.getModel().get(HAL_INDEX).asInt(), changedValues)).build();
    forms.put(permission, form);
    registerAttachable(form);
    HTMLElement masterDetail;
    HTMLElement section = section().add(emptyState).add(masterDetail = div().add(h(1).textContent(permission.type)).add(p().textContent(metadata.getDescription().getDescription())).add(table).add(form).element()).element();
    masterDetails.put(permission, masterDetail);
    navigation.addPrimary(Ids.build(permission.baseId, Ids.ITEM), permission.type, permission.icon, section);
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) Elements.div(org.jboss.gwt.elemento.core.Elements.div) DEPLOYMENT_PERMISSIONS_TEMPLATE(org.jboss.hal.client.configuration.subsystem.securitymanager.AddressTemplates.DEPLOYMENT_PERMISSIONS_TEMPLATE) Constraint(org.jboss.hal.meta.security.Constraint) HAL_INDEX(org.jboss.hal.dmr.ModelDescriptionConstants.HAL_INDEX) ModelNodeTable(org.jboss.hal.core.mbui.table.ModelNodeTable) HashMap(java.util.HashMap) LayoutBuilder.column(org.jboss.hal.ballroom.LayoutBuilder.column) Inject(javax.inject.Inject) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Elements.section(org.jboss.gwt.elemento.core.Elements.section) Elements.p(org.jboss.gwt.elemento.core.Elements.p) HTMLElement(elemental2.dom.HTMLElement) Map(java.util.Map) EmptyState(org.jboss.hal.ballroom.EmptyState) HalViewImpl(org.jboss.hal.core.mvp.HalViewImpl) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) Elements.h(org.jboss.gwt.elemento.core.Elements.h) CLASS(org.jboss.hal.dmr.ModelDescriptionConstants.CLASS) Table(org.jboss.hal.ballroom.table.Table) LayoutBuilder.row(org.jboss.hal.ballroom.LayoutBuilder.row) Ids(org.jboss.hal.resources.Ids) CSS.marginTopLarge(org.jboss.hal.resources.CSS.marginTopLarge) VerticalNavigation(org.jboss.hal.ballroom.VerticalNavigation) List(java.util.List) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) Resources(org.jboss.hal.resources.Resources) Elements(org.jboss.gwt.elemento.core.Elements) Form(org.jboss.hal.ballroom.form.Form) Scope(org.jboss.hal.ballroom.table.Scope) EmptyState(org.jboss.hal.ballroom.EmptyState) HTMLElement(elemental2.dom.HTMLElement) Constraint(org.jboss.hal.meta.security.Constraint) Metadata(org.jboss.hal.meta.Metadata) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 10 with Table

use of org.jboss.hal.ballroom.table.Table in project console by hal.

the class EEView method buildServicePanel.

@SuppressWarnings("ConstantConditions")
private HTMLElement buildServicePanel(String baseId, AddressTemplate template, String type) {
    Metadata metadata = metadataRegistry.lookup(template);
    Table<NamedNode> table = new ModelNodeTable.Builder<NamedNode>(Ids.build(baseId, Ids.TABLE), metadata).column(NAME, (cell, t, row, meta) -> row.getName()).button(tableButtonFactory.add(Ids.build(baseId, Ids.ADD), type, template, (name, address) -> presenter.reload())).button(tableButtonFactory.remove(type, template, (api) -> api.selectedRow().getName(), () -> presenter.reload())).build();
    registerAttachable(table);
    tables.put(template.lastName(), table);
    ModelNodeForm<NamedNode> form = new ModelNodeForm.Builder<NamedNode>(Ids.build(baseId, Ids.FORM), metadata).onSave((f, changedValues) -> {
        AddressTemplate fullyQualified = template.replaceWildcards(table.selectedRow().getName());
        presenter.save(fullyQualified, changedValues, metadata, resources.messages().modifyResourceSuccess(Names.EE, template.lastName()));
    }).prepareReset(f -> {
        String name = table.selectedRow().getName();
        AddressTemplate fullyQualified = template.replaceWildcards(name);
        presenter.reset(type, name, fullyQualified, f, metadata, resources.messages().modifyResourceSuccess(Names.EE, template.lastName()));
    }).build();
    forms.put(template.lastName(), form);
    registerAttachable(form);
    return section().add(h(1).textContent(type)).add(p().textContent(metadata.getDescription().getDescription())).add(table).add(form).element();
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) Elements.div(org.jboss.gwt.elemento.core.Elements.div) ModelNodeTable(org.jboss.hal.core.mbui.table.ModelNodeTable) HashMap(java.util.HashMap) LayoutBuilder.column(org.jboss.hal.ballroom.LayoutBuilder.column) Inject(javax.inject.Inject) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Elements.section(org.jboss.gwt.elemento.core.Elements.section) AddressTemplate(org.jboss.hal.meta.AddressTemplate) Elements.p(org.jboss.gwt.elemento.core.Elements.p) HTMLElement(elemental2.dom.HTMLElement) Map(java.util.Map) HalViewImpl(org.jboss.hal.core.mvp.HalViewImpl) Metadata(org.jboss.hal.meta.Metadata) TableButtonFactory(org.jboss.hal.core.mbui.table.TableButtonFactory) Names(org.jboss.hal.resources.Names) Elements.h(org.jboss.gwt.elemento.core.Elements.h) ModelNodeHelper.asNamedNodes(org.jboss.hal.dmr.ModelNodeHelper.asNamedNodes) Table(org.jboss.hal.ballroom.table.Table) LayoutBuilder.row(org.jboss.hal.ballroom.LayoutBuilder.row) Ids(org.jboss.hal.resources.Ids) CSS.pfIcon(org.jboss.hal.resources.CSS.pfIcon) VerticalNavigation(org.jboss.hal.ballroom.VerticalNavigation) List(java.util.List) MetadataRegistry(org.jboss.hal.meta.MetadataRegistry) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Resources(org.jboss.hal.resources.Resources) AddressTemplates(org.jboss.hal.client.configuration.subsystem.ee.AddressTemplates) NamedNode(org.jboss.hal.dmr.NamedNode) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) Form(org.jboss.hal.ballroom.form.Form) AddressTemplate(org.jboss.hal.meta.AddressTemplate) Metadata(org.jboss.hal.meta.Metadata) NamedNode(org.jboss.hal.dmr.NamedNode) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm)

Aggregations

VerticalNavigation (org.jboss.hal.ballroom.VerticalNavigation)15 Form (org.jboss.hal.ballroom.form.Form)15 Table (org.jboss.hal.ballroom.table.Table)15 List (java.util.List)14 NamedNode (org.jboss.hal.dmr.NamedNode)13 Metadata (org.jboss.hal.meta.Metadata)12 Ids (org.jboss.hal.resources.Ids)12 Names (org.jboss.hal.resources.Names)12 HTMLElement (elemental2.dom.HTMLElement)11 PostConstruct (javax.annotation.PostConstruct)11 MbuiContext (org.jboss.hal.core.mbui.MbuiContext)11 MbuiViewImpl (org.jboss.hal.core.mbui.MbuiViewImpl)11 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)11 ModelNodeTable (org.jboss.hal.core.mbui.table.ModelNodeTable)11 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)11 MbuiElement (org.jboss.hal.spi.MbuiElement)11 MbuiView (org.jboss.hal.spi.MbuiView)11 Elements.h (org.jboss.gwt.elemento.core.Elements.h)10 Elements.p (org.jboss.gwt.elemento.core.Elements.p)10 Elements.section (org.jboss.gwt.elemento.core.Elements.section)10