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;
}
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));
}
Aggregations