Search in sources :

Example 1 with TagCreator

use of j2html.TagCreator in project datarouter by hotpads.

the class AwsMemcachedWebInspector method getDetails.

@Override
protected Pair<Integer, DivTag> getDetails(ClientId clientId) {
    MemcachedClientMode mode = options.getClientMode(clientId.getName());
    Pair<Integer, DivTag> nodeCountByNodeTag = new Pair<>();
    if (mode == MemcachedClientMode.DYNAMIC) {
        List<AwsMemcachedNodeEndpointDto> nodeEndpointDtos = Scanner.of(getSpyClient(clientId).getAllNodeEndPoints()).map(nodeEndPoint -> new AwsMemcachedNodeEndpointDto(nodeEndPoint.getHostName(), nodeEndPoint.getIpAddress(), nodeEndPoint.getPort())).list();
        var table = new J2HtmlTable<AwsMemcachedNodeEndpointDto>().withClasses("sortable table table-sm table-striped my-4 border").withColumn("HostName", dto -> dto.hostName).withColumn("IpAddress", dto -> dto.ipAddress).withColumn("Port", dto -> dto.port).build(nodeEndpointDtos);
        DivTag divTable = div(table).withClass("container-fluid my-4").withStyle("padding-left: 0px");
        nodeCountByNodeTag.setLeft(nodeEndpointDtos.size());
        nodeCountByNodeTag.setRight(divTable);
    } else {
        List<LiTag> socketAddresses = Scanner.of(getSpyClient(clientId).getAvailableServers()).map(Object::toString).map(TagCreator::li).list();
        DivTag div = div(ul(socketAddresses.toArray(new ContainerTag[0])));
        nodeCountByNodeTag.setLeft(socketAddresses.size());
        nodeCountByNodeTag.setRight(div);
    }
    return nodeCountByNodeTag;
}
Also used : Scanner(io.datarouter.scanner.Scanner) MemcachedClientMode(io.datarouter.aws.memcached.client.MemcachedClientMode) DivTag(j2html.tags.specialized.DivTag) LiTag(j2html.tags.specialized.LiTag) MemcachedWebInspector(io.datarouter.client.memcached.web.MemcachedWebInspector) ContainerTag(j2html.tags.ContainerTag) Inject(javax.inject.Inject) List(java.util.List) ClientId(io.datarouter.storage.client.ClientId) Pair(io.datarouter.util.tuple.Pair) TagCreator.div(j2html.TagCreator.div) AwsMemcachedOptions(io.datarouter.aws.memcached.client.options.AwsMemcachedOptions) J2HtmlTable(io.datarouter.web.html.j2html.J2HtmlTable) TagCreator(j2html.TagCreator) TagCreator.ul(j2html.TagCreator.ul) DivTag(j2html.tags.specialized.DivTag) LiTag(j2html.tags.specialized.LiTag) MemcachedClientMode(io.datarouter.aws.memcached.client.MemcachedClientMode) Pair(io.datarouter.util.tuple.Pair)

Example 2 with TagCreator

use of j2html.TagCreator in project datarouter by hotpads.

the class SqsQueuesDailyDigest method buildContent.

private Optional<ContainerTag<?>> buildContent(ContentType contentType) {
    ClientId clientId = Scanner.of(datarouterClients.getClientIds()).include(client -> datarouterClients.getClientTypeInstance(client) instanceof SqsClientType).findFirst().orElse(null);
    if (clientId == null) {
        return Optional.empty();
    }
    List<String> unreferencedQueues = queueRegistryService.getSqsQueuesForClient(clientId).getRight();
    if (unreferencedQueues.isEmpty()) {
        return Optional.empty();
    }
    TableTag unreferencedQueuesTable = new TableTag();
    if (contentType == ContentType.PAGE) {
        unreferencedQueuesTable = new J2HtmlTable<String>().withClasses("sortable table table-sm table-striped my-4 border").withHtmlColumn(th("Queue Name"), TagCreator::td).build(unreferencedQueues);
    } else if (contentType == ContentType.EMAIL) {
        unreferencedQueuesTable = new J2HtmlEmailTable<String>().withColumn("Queue Name", row -> row).build(unreferencedQueues);
    }
    ContainerTag<?> header = digestService.makeHeader("Unreferenced Sqs Queues", paths.datarouter.client.inspectClient, "?clientName=sqs");
    return Optional.of(div(header, unreferencedQueuesTable));
}
Also used : J2HtmlTable(io.datarouter.web.html.j2html.J2HtmlTable) Scanner(io.datarouter.scanner.Scanner) J2HtmlEmailTable(io.datarouter.email.html.J2HtmlEmailTable) DatarouterWebPaths(io.datarouter.web.config.DatarouterWebPaths) DailyDigestGrouping(io.datarouter.web.digest.DailyDigestGrouping) Singleton(javax.inject.Singleton) TableTag(j2html.tags.specialized.TableTag) ZoneId(java.time.ZoneId) ContainerTag(j2html.tags.ContainerTag) Inject(javax.inject.Inject) List(java.util.List) TagCreator.th(j2html.TagCreator.th) ClientId(io.datarouter.storage.client.ClientId) Optional(java.util.Optional) DailyDigest(io.datarouter.web.digest.DailyDigest) TagCreator.div(j2html.TagCreator.div) J2HtmlTable(io.datarouter.web.html.j2html.J2HtmlTable) TagCreator(j2html.TagCreator) SqsClientType(io.datarouter.aws.sqs.SqsClientType) DatarouterClients(io.datarouter.storage.client.DatarouterClients) DailyDigestService(io.datarouter.web.digest.DailyDigestService) SqsClientType(io.datarouter.aws.sqs.SqsClientType) TagCreator(j2html.TagCreator) TableTag(j2html.tags.specialized.TableTag) ClientId(io.datarouter.storage.client.ClientId) J2HtmlEmailTable(io.datarouter.email.html.J2HtmlEmailTable)

Aggregations

Scanner (io.datarouter.scanner.Scanner)2 ClientId (io.datarouter.storage.client.ClientId)2 J2HtmlTable (io.datarouter.web.html.j2html.J2HtmlTable)2 TagCreator (j2html.TagCreator)2 TagCreator.div (j2html.TagCreator.div)2 ContainerTag (j2html.tags.ContainerTag)2 List (java.util.List)2 Inject (javax.inject.Inject)2 MemcachedClientMode (io.datarouter.aws.memcached.client.MemcachedClientMode)1 AwsMemcachedOptions (io.datarouter.aws.memcached.client.options.AwsMemcachedOptions)1 SqsClientType (io.datarouter.aws.sqs.SqsClientType)1 MemcachedWebInspector (io.datarouter.client.memcached.web.MemcachedWebInspector)1 J2HtmlEmailTable (io.datarouter.email.html.J2HtmlEmailTable)1 DatarouterClients (io.datarouter.storage.client.DatarouterClients)1 Pair (io.datarouter.util.tuple.Pair)1 DatarouterWebPaths (io.datarouter.web.config.DatarouterWebPaths)1 DailyDigest (io.datarouter.web.digest.DailyDigest)1 DailyDigestGrouping (io.datarouter.web.digest.DailyDigestGrouping)1 DailyDigestService (io.datarouter.web.digest.DailyDigestService)1 TagCreator.th (j2html.TagCreator.th)1