use of j2html.tags.ContainerTag in project datarouter by hotpads.
the class S3BucketHandler method index.
@Handler(defaultHandler = true)
public Mav index(@Param(P_client) String client, @Param(P_bucket) String bucket, @Param(P_prefix) OptionalString prefix, @Param(P_after) OptionalString after, @Param(P_offset) OptionalInteger offset, @Param(P_limit) OptionalInteger limit, @Param(P_currentDirectory) OptionalBoolean currentDirectory, @Param(P_delimiter) OptionalString delimiter) {
var form = new HtmlForm().withMethod("get");
form.addTextField().withDisplay("Client").withName(P_client).withPlaceholder("theClientName").withValue(client);
form.addTextField().withDisplay("Bucket").withName(P_bucket).withPlaceholder("the.bucket.name").withValue(bucket);
form.addTextField().withDisplay("Prefix").withName(P_prefix).withValue(prefix.orElse(""));
form.addTextField().withDisplay("After").withName(P_after).withValue(after.orElse(""));
form.addTextField().withDisplay("Offset").withName(P_offset).withValue(offset.orElse(0) + "");
form.addTextField().withDisplay("Limit").withName(P_limit).withValue(limit.orElse(100) + "");
form.addTextField().withDisplay("Delimiter").withName(P_delimiter).withValue(delimiter.orElse(""));
form.addCheckboxField().withDisplay("currentDirectory").withName(P_currentDirectory).withChecked(currentDirectory.orElse(false));
form.addButton().withDisplay("Submit").withValue("");
var htmlForm = Bootstrap4FormHtml.render(form).withClass("card card-body bg-light");
ClientId clientId = clients.getClientId(client);
DatarouterS3Client s3Client = s3ClientManager.getClient(clientId);
List<DirectoryDto> objects = s3Client.scanSubdirectories(bucket, prefix.orElse(null), after.orElse(null), delimiter.orElse(null), limit.orElse(100), currentDirectory.orElse(false)).list();
int sizePadding = sizePadding(objects);
ContainerTag<?> table = new J2HtmlTable<DirectoryDto>().withClasses("sortable table table-sm table-striped my-4 border").withHtmlColumn("Key", object -> {
String name = object.name;
if (object.isDirectory) {
return td(makePrefixLink(client, bucket, name, "/"));
}
return td(name);
}).withHtmlColumn("Directory", object -> {
boolean isDirectory = object.isDirectory;
if (isDirectory) {
String href = new URIBuilder().setPath(request.getContextPath() + paths.datarouter.clients.awsS3.countObjects.toSlashedString()).addParameter(P_client, client).addParameter(P_bucket, bucket).addParameter(P_prefix, object.name).toString();
return td(a("true, view count").withHref(href));
}
return td(String.valueOf(isDirectory));
}).withHtmlColumn("Size", object -> {
String commas = NumberFormatter.addCommas(object.size);
String padded = StringTool.pad(commas, ' ', sizePadding);
String escaped = padded.replaceAll(" ", " ");
return td(rawHtml(escaped));
}).withColumn("Last Modified", object -> object.lastModified).withColumn("Storage Class", object -> object.storageClass).build(objects);
ContainerTag<?> tableWrapper = table.withStyle("font-family:monospace; font-size:.9em;");
var content = div(htmlForm, h4(bucket), tableWrapper).withClass("container-fluid my-4");
return pageFactory.startBuilder(request).withTitle("S3 Bucket").withRequires(DatarouterWebRequireJsV2.SORTTABLE).withContent(content).buildMav();
}
use of j2html.tags.ContainerTag 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.tags.ContainerTag in project datarouter by hotpads.
the class JobletExceptionHandler method makeContent.
private ContainerTag<?> makeContent(List<JobletRequest> rows) {
var title = h4(TITLE).withClass("mt-2");
var table = new J2HtmlTable<JobletRequest>().withClasses("sortable table table-sm table-striped border").withHtmlColumn("Exception ID", row -> {
String id = row.getExceptionRecordId();
return externalLinkBuilder.get().exception(request.getContextPath(), id).map(href -> td(a(id).withHref(href))).orElse(td(id));
}).withColumn("Type", row -> row.getKey().getType()).withColumn("Execution order", row -> row.getKey().getExecutionOrder()).withColumn("Batch sequence", row -> row.getKey().getBatchSequence()).withColumn("Data ID", JobletRequest::getJobletDataId).withColumn("Reserved by", JobletRequest::getReservedBy).withColumn("Created ago", JobletRequest::getCreatedAgo).withColumn("Restartable", JobletRequest::getRestartable).withColumn("Num items", JobletRequest::getNumItems).withColumn("Queue ID", JobletRequest::getQueueId).build(rows);
return div(title, table).withClass("container-fluid");
}
use of j2html.tags.ContainerTag in project datarouter by hotpads.
the class JobletHandler method makeContent.
private ContainerTag<?> makeContent(Collection<JobletSummary> rows) {
String contextPath = request.getContextPath();
var title = h4(TITLE).withClass("mt-2");
var table = new J2HtmlTable<JobletSummary>().withClasses("sortable table table-sm table-striped table-bordered table-hover").withHtmlColumn("Type", row -> {
String metricNamePrefix = DatarouterJobletCounters.makeQueueLengthJobletsCreatedPrefix(row.getType());
String text = row.getType();
return externalLinkBuilder.get().counters(metricNamePrefix).map(href -> td(a(text).withHref(href))).orElse(td(text));
}).withColumn("Execution order", JobletSummary::getExecutionOrder).withColumn("Status", row -> row.getStatus().getPersistentString()).withHtmlColumn("Num Joblets", row -> tdAlignRight(NumberFormatter.addCommas(row.getNumType()))).withHtmlColumn("Sum items", row -> tdAlignRight(NumberFormatter.addCommas(row.getSumItems()))).withHtmlColumn("Avg items", row -> tdAlignRight(NumberFormatter.format(row.getAvgItems(), 1))).withHtmlColumn("Queues", row -> {
String href = localLinkBuilder.queues(contextPath, row.getType(), row.getExecutionOrder(), row.getNumQueueIds());
return tdAlignRight(a(row.getNumQueueIds() + "").withHref(href));
}).withHtmlColumn("Failures", row -> {
String href = localLinkBuilder.exceptions(contextPath, row.getType());
return tdAlignRight(a(row.getNumFailures() + "").withHref(href));
}).withHtmlColumn("First reserved", row -> tdAlignRight(row.getFirstReservedAgo()).attr("sorttable_customkey", row.getFirstReservedMsAgo())).withHtmlColumn("First created", row -> tdAlignRight(row.getFirstCreatedAgo()).attr("sorttable_customkey", row.getFirstCreatedMsAgo())).withHtmlColumn("", row -> {
var chartIcon = i().withClass("fas fa-chart-line");
var href = metricLinkBuilder.availableMetricsLink("Joblet .* " + row.getType() + "$");
return td(a(chartIcon).withHref(href));
}).withHtmlColumn("X", row -> {
var trashIcon = i().withClass("fas fa-trash");
String href = localLinkBuilder.delete(contextPath, row.getType(), row.getExecutionOrder(), row.getStatus());
return td(a(trashIcon).withHref(href));
}).build(rows);
return div(title, table).withClass("container-fluid");
}
use of j2html.tags.ContainerTag in project datarouter by hotpads.
the class WebappInstanceAlertJob method makeContent.
private ContainerTag<?> makeContent(WebappInstance webappInstance, DatarouterDuration buildAge) {
ZoneId zoneId = defaultDistributionListZoneId.get();
var rows = List.of(new Twin<>("webapp", webappInstance.getKey().getWebappName()), new Twin<>("build date", ZonedDateFormatterTool.formatInstantWithZone(webappInstance.getBuildInstant(), zoneId)), new Twin<>("build age", buildAge.toString()), new Twin<>("startup date", ZonedDateFormatterTool.formatInstantWithZone(webappInstance.getStartupInstant(), zoneId)), new Twin<>("commitId", webappInstance.getCommitId()));
return new J2HtmlEmailTable<Twin<String>>().withColumn(new J2HtmlEmailTableColumn<>(null, row -> makeDivBoldRight(row.getLeft()))).withColumn(new J2HtmlEmailTableColumn<>(null, row -> text(row.getRight()))).build(rows);
}
Aggregations