Search in sources :

Example 11 with ContainerTag

use of j2html.tags.ContainerTag in project datarouter by hotpads.

the class Bootstrap4PageBuilder method build.

public DatarouterPage build() {
    require.add(DatarouterWebRequireJsV2.BOOTSTRAP);
    boolean isAdmin = mavProperties.getIsAdmin();
    var head = new Bootstrap4PageHead(mavProperties, mavProperties.getContextPath(), webappRequireJsConfigJsonString, require.toArray(String[]::new), isAdmin, title, httpEquivs);
    NavBar navbar = mavProperties.getIsDatarouterPage() ? mavProperties.getDatarouterNavBar() : mavProperties.getNavBar();
    List<ContainerTag<?>> allNavbars = new ArrayList<>();
    if (includeNav) {
        if (isAdmin) {
            allNavbars.add(new DatarouterNavbarV2Html(mavProperties).build());
        }
        allNavbars.add(new WebappNavbarV2Html(mavProperties, navbar).build());
        allNavbars.addAll(navbars);
    }
    var body = new DatarouterPageBody(allNavbars.toArray(ContainerTag[]::new), content);
    return new DatarouterPage(head, body);
}
Also used : NavBar(io.datarouter.web.navigation.NavBar) DatarouterNavbarV2Html(io.datarouter.web.navigation.DatarouterNavbarV2Html) ArrayList(java.util.ArrayList) DatarouterPageBody(io.datarouter.web.html.j2html.DatarouterPageBody) WebappNavbarV2Html(io.datarouter.web.navigation.WebappNavbarV2Html) DatarouterPage(io.datarouter.web.html.j2html.DatarouterPage) ContainerTag(j2html.tags.ContainerTag)

Example 12 with ContainerTag

use of j2html.tags.ContainerTag in project datarouter by hotpads.

the class WebappInstanceServersHandler method makeContent.

private ContainerTag<?> makeContent(Page<WebappInstanceLogDto> page, List<String> activeServerNames) {
    var form = Bootstrap4PagerHtml.renderForm(page).withClass("mt-4");
    var linkBar = Bootstrap4PagerHtml.renderLinkBar(page).withClass("mt-2");
    ZoneId zoneId = getUserZoneId();
    var table = new J2HtmlTable<WebappInstanceLogDto>().withClasses("sortable table table-sm table-striped my-4 border").withHtmlColumn("", row -> {
        if (activeServerNames.contains(row.key.serverName)) {
            if (row.shutdown.isEmpty()) {
                return td();
            }
            if (row.shutdown.get().toEpochMilli() < System.currentTimeMillis()) {
                return td();
            }
            return td(span("Active").withClass("badge badge-success"));
        }
        return td();
    }).withColumn("Server Name", row -> row.key.serverName).withColumn("Private IP", row -> row.key.serverPrivateIp).withColumn("Build Date", row -> ZonedDateFormatterTool.formatInstantWithZone(row.key.buildDate, zoneId)).withColumn("Startup Range", row -> row.startup.map(date -> ZonedDateFormatterTool.formatInstantWithZone(date, zoneId)).orElse("unknown") + " - " + row.shutdown.map(date -> ZonedDateFormatterTool.formatInstantWithZone(date, zoneId)).orElse("unknown")).withColumn("Up Time", row -> {
        if (row.startup.isEmpty() || row.shutdown.isEmpty()) {
            return "unknown";
        }
        var duration = Duration.ofMillis(row.shutdown.get().toEpochMilli() - row.startup.get().toEpochMilli());
        return new DatarouterDuration(duration).toString(TimeUnit.MINUTES);
    }).build(page.rows);
    return div(form, linkBar, table).withClass("container-fluid");
}
Also used : J2HtmlTable(io.datarouter.web.html.j2html.J2HtmlTable) Scanner(io.datarouter.scanner.Scanner) DatarouterWebappInstanceLogDao(io.datarouter.webappinstance.storage.webappinstancelog.DatarouterWebappInstanceLogDao) Bootstrap4PagerHtml(io.datarouter.web.html.pager.Bootstrap4PagerHtml) HashMap(java.util.HashMap) DatarouterWebappInstancePaths(io.datarouter.webappinstance.config.DatarouterWebappInstancePaths) Inject(javax.inject.Inject) Duration(java.time.Duration) WebappInstanceKey(io.datarouter.webappinstance.storage.webappinstance.WebappInstanceKey) J2HtmlTable(io.datarouter.web.html.j2html.J2HtmlTable) Page(io.datarouter.web.html.pager.MemoryPager.Page) WebappInstanceLog(io.datarouter.webappinstance.storage.webappinstancelog.WebappInstanceLog) TagCreator.span(j2html.TagCreator.span) Mav(io.datarouter.web.handler.mav.Mav) WebappInstanceLogKey(io.datarouter.webappinstance.storage.webappinstancelog.WebappInstanceLogKey) Instant(java.time.Instant) DatarouterDuration(io.datarouter.util.duration.DatarouterDuration) ZoneId(java.time.ZoneId) ContainerTag(j2html.tags.ContainerTag) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) ZonedDateFormatterTool(io.datarouter.util.time.ZonedDateFormatterTool) List(java.util.List) MemoryPager(io.datarouter.web.html.pager.MemoryPager) TagCreator.td(j2html.TagCreator.td) BaseHandler(io.datarouter.web.handler.BaseHandler) Optional(java.util.Optional) Bootstrap4PageFactory(io.datarouter.web.html.j2html.bootstrap4.Bootstrap4PageFactory) Comparator(java.util.Comparator) TagCreator.div(j2html.TagCreator.div) Collections(java.util.Collections) DatarouterWebappInstanceDao(io.datarouter.webappinstance.storage.webappinstance.DatarouterWebappInstanceDao) MemorySorter(io.datarouter.web.html.pager.MemorySorter) ZoneId(java.time.ZoneId) DatarouterDuration(io.datarouter.util.duration.DatarouterDuration)

Example 13 with ContainerTag

use of j2html.tags.ContainerTag 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)

Example 14 with ContainerTag

use of j2html.tags.ContainerTag in project nivio by dedica-team.

the class SVGRelationTest method marker.

@Test
@DisplayName("The dataflow marker is not null")
void marker() {
    ContainerTag containerTag = SVGRelation.dataflowMarker();
    assertThat(containerTag).isNotNull();
    assertThat(containerTag.getTagName()).isEqualTo("marker");
}
Also used : ContainerTag(j2html.tags.ContainerTag) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 15 with ContainerTag

use of j2html.tags.ContainerTag in project nivio by dedica-team.

the class SVGBackgroundFactoryTest method generatesHexTemplate.

@Test
void generatesHexTemplate() {
    ContainerTag hex = SVGBackgroundFactory.getHex();
    assertThat(hex).isNotNull();
    assertThat(hex.getTagName()).isEqualTo("polygon");
}
Also used : ContainerTag(j2html.tags.ContainerTag) Test(org.junit.jupiter.api.Test)

Aggregations

ContainerTag (j2html.tags.ContainerTag)150 Tag (j2html.tags.Tag)30 TagCreator.div (j2html.TagCreator.div)20 HtmlBundle (views.HtmlBundle)20 Inject (javax.inject.Inject)17 List (java.util.List)13 TagCreator (j2html.TagCreator)12 DomContent (j2html.tags.DomContent)12 Mav (io.datarouter.web.handler.mav.Mav)11 LinkElement (views.components.LinkElement)11 J2HtmlTable (io.datarouter.web.html.j2html.J2HtmlTable)10 DatarouterWebRequireJsV2 (io.datarouter.web.requirejs.DatarouterWebRequireJsV2)10 TagCreator.a (j2html.TagCreator.a)10 BaseHandler (io.datarouter.web.handler.BaseHandler)9 Bootstrap4PageFactory (io.datarouter.web.html.j2html.bootstrap4.Bootstrap4PageFactory)8 TagCreator.td (j2html.TagCreator.td)8 ArrayList (java.util.ArrayList)8 Optional (java.util.Optional)8 TagCreator.each (j2html.TagCreator.each)7 ZoneId (java.time.ZoneId)7