Search in sources :

Example 1 with J2HtmlEmailTable

use of io.datarouter.email.html.J2HtmlEmailTable 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);
}
Also used : Twin(io.datarouter.util.tuple.Twin) TagCreator.text(j2html.TagCreator.text) TagCreator.body(j2html.TagCreator.body) DatarouterHtmlEmailService(io.datarouter.web.email.DatarouterHtmlEmailService) DatarouterWebappInstanceSettingRoot(io.datarouter.webappinstance.config.DatarouterWebappInstanceSettingRoot) J2HtmlEmailTableColumn(io.datarouter.email.html.J2HtmlEmailTable.J2HtmlEmailTableColumn) DatarouterWebappInstancePaths(io.datarouter.webappinstance.config.DatarouterWebappInstancePaths) Inject(javax.inject.Inject) WebappInstanceService(io.datarouter.webappinstance.service.WebappInstanceService) ServerTypeDetector(io.datarouter.storage.servertype.ServerTypeDetector) J2HtmlEmailTable(io.datarouter.email.html.J2HtmlEmailTable) BaseJob(io.datarouter.job.BaseJob) StandardDatarouterEmailHeaderService(io.datarouter.web.email.StandardDatarouterEmailHeaderService) TaskTracker(io.datarouter.instrumentation.task.TaskTracker) WebappInstance(io.datarouter.webappinstance.storage.webappinstance.WebappInstance) Instant(java.time.Instant) DatarouterDuration(io.datarouter.util.duration.DatarouterDuration) ZoneId(java.time.ZoneId) ContainerTag(j2html.tags.ContainerTag) ZonedDateFormatterTool(io.datarouter.util.time.ZonedDateFormatterTool) DefaultEmailDistributionListZoneId(io.datarouter.web.config.properties.DefaultEmailDistributionListZoneId) WebappInstanceAlertEmailType(io.datarouter.email.type.DatarouterEmailTypes.WebappInstanceAlertEmailType) DomContent(j2html.tags.DomContent) List(java.util.List) TagCreator.div(j2html.TagCreator.div) ZoneId(java.time.ZoneId) DefaultEmailDistributionListZoneId(io.datarouter.web.config.properties.DefaultEmailDistributionListZoneId) J2HtmlEmailTableColumn(io.datarouter.email.html.J2HtmlEmailTable.J2HtmlEmailTableColumn) Twin(io.datarouter.util.tuple.Twin)

Example 2 with J2HtmlEmailTable

use of io.datarouter.email.html.J2HtmlEmailTable 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

J2HtmlEmailTable (io.datarouter.email.html.J2HtmlEmailTable)2 TagCreator.div (j2html.TagCreator.div)2 ContainerTag (j2html.tags.ContainerTag)2 ZoneId (java.time.ZoneId)2 List (java.util.List)2 Inject (javax.inject.Inject)2 SqsClientType (io.datarouter.aws.sqs.SqsClientType)1 J2HtmlEmailTableColumn (io.datarouter.email.html.J2HtmlEmailTable.J2HtmlEmailTableColumn)1 WebappInstanceAlertEmailType (io.datarouter.email.type.DatarouterEmailTypes.WebappInstanceAlertEmailType)1 TaskTracker (io.datarouter.instrumentation.task.TaskTracker)1 BaseJob (io.datarouter.job.BaseJob)1 Scanner (io.datarouter.scanner.Scanner)1 ClientId (io.datarouter.storage.client.ClientId)1 DatarouterClients (io.datarouter.storage.client.DatarouterClients)1 ServerTypeDetector (io.datarouter.storage.servertype.ServerTypeDetector)1 DatarouterDuration (io.datarouter.util.duration.DatarouterDuration)1 ZonedDateFormatterTool (io.datarouter.util.time.ZonedDateFormatterTool)1 Twin (io.datarouter.util.tuple.Twin)1 DatarouterWebPaths (io.datarouter.web.config.DatarouterWebPaths)1 DefaultEmailDistributionListZoneId (io.datarouter.web.config.properties.DefaultEmailDistributionListZoneId)1