ui.recordsStructure.structureElements.ftl Maven / Gradle / Ivy
<#-- @ftlvariable name="json" type="com.fasterxml.jackson.databind.ObjectMapper" -->
<#import "../common/infoIcon.ftl" as info>
<#assign collapseIdGen = 1>
<#function nextCollapseId>
<#assign collapseId = collapseIdGen>
<#assign collapseIdGen = collapseIdGen + 1>
<#return "collapse-${collapseId}">
#function>
<#macro showFieldValue fieldValue>
<#-- @ftlvariable name="fieldValue" type="com.infobip.kafkistry.model.RecordFieldValue" -->
Values:
<#if fieldValue.highCardinality>
HIGH CARDINALITY
<#elseif fieldValue.tooBig>
TOO BIG
<#elseif fieldValue.valueSet??>
[
<#list fieldValue.valueSet as val>
<#assign valAsString>
<#attempt>
<#if val?is_boolean>${val?then('true', 'false')}
<#elseif val?is_number>${val?c}
<#elseif val?is_string>${val}
<#else>${val?api.toString()}#if>
<#recover>
???
#attempt>
#assign>
${valAsString}<#if !val?is_last>,#if>
#list>
]
#if>
#macro>
<#macro showFieldInfo field parentType="" fullName=false>
<#-- @ftlvariable name="field" type="com.infobip.kafkistry.model.RecordField" -->
${field.type}
<#if fullName>
<#if (field.fullName)??>
${field.fullName}
<#else>
ROOT
#if>
<#if field.nullable>
NULLABLE
#if>
<#else>
<#if field.nullable>
NULLABLE
#if>
<#if (field.name)??>
${field.name}
<#else>
<#assign name>
<#switch parentType>
<#case "OBJECT">*<#break>
<#case "ARRAY">[*]<#break>
<#default>
#switch>
#assign>
<#if name?has_content>
${name}
(variable)
#if>
#if>
#if>
<#if field.value??>
<@showFieldValue fieldValue=field.value/>
#if>
#macro>
<#macro showRecordField field parentType>
<#-- @ftlvariable name="field" type="com.infobip.kafkistry.model.RecordField" -->
<#-- @ftlvariable name="parentType" type="com.infobip.kafkistry.model.RecordFieldType" -->
<#assign hasChildren = (field.children)?? && field.children?size gt 0>
<@showFieldInfo field=field parentType=parentType/>
<#if hasChildren>
<#assign collapseTarget = nextCollapseId()>
<#list field.children as childField>
<@showRecordField field=childField parentType=field.type/>
#list>
#if>
#macro>
<#function fieldsFlat jsonFields>
<#-- @ftlvariable name="jsonFields" type="java.util.List" -->
<#assign fields = []>
<#list jsonFields as f>
<#assign fields += [f] + ((f.children)??)?then(fieldsFlat(f.children), [])>
#list>
<#return fields>
#function>
<#macro showSizeStat stat>
<#-- @ftlvariable name="stat" type="com.infobip.kafkistry.model.SizeStatistic" -->
<#assign tooltip>
# samples ${stat.count}
Avg ${stat.avg} bytes
Min ${stat.min} bytes
Max ${stat.max} bytes
#assign>
${stat.avg} <@info.icon tooltip=tooltip/>
#macro>
<#macro showRecordSize size>
<#-- @ftlvariable name="size" type="com.infobip.kafkistry.model.RecordSize" -->
15 Min
1 Hour
6 Hours
Day
Week
Month
Msg Total
<#if (size.msg.last15Min)??><@showSizeStat stat=size.msg.last15Min/><#else>---#if>
<#if (size.msg.lastHour)??><@showSizeStat stat=size.msg.lastHour/><#else>---#if>
<#if (size.msg.last6Hours)??><@showSizeStat stat=size.msg.last6Hours/><#else>---#if>
<#if (size.msg.lastDay)??><@showSizeStat stat=size.msg.lastDay/><#else>---#if>
<#if (size.msg.lastWeek)??><@showSizeStat stat=size.msg.lastWeek/><#else>---#if>
<#if (size.msg.lastMonth)??><@showSizeStat stat=size.msg.lastMonth/><#else>---#if>
Key
<#if (size.key.last15Min)??><@showSizeStat stat=size.key.last15Min/><#else>---#if>
<#if (size.key.lastHour)??><@showSizeStat stat=size.key.lastHour/><#else>---#if>
<#if (size.key.last6Hours)??><@showSizeStat stat=size.key.last6Hours/><#else>---#if>
<#if (size.key.lastDay)??><@showSizeStat stat=size.key.lastDay/><#else>---#if>
<#if (size.key.lastWeek)??><@showSizeStat stat=size.key.lastWeek/><#else>---#if>
<#if (size.key.lastMonth)??><@showSizeStat stat=size.key.lastMonth/><#else>---#if>
Value
<#if (size.value.last15Min)??><@showSizeStat stat=size.value.last15Min/><#else>---#if>
<#if (size.value.lastHour)??><@showSizeStat stat=size.value.lastHour/><#else>---#if>
<#if (size.value.last6Hours)??><@showSizeStat stat=size.value.last6Hours/><#else>---#if>
<#if (size.value.lastDay)??><@showSizeStat stat=size.value.lastDay/><#else>---#if>
<#if (size.value.lastWeek)??><@showSizeStat stat=size.value.lastWeek/><#else>---#if>
<#if (size.value.lastMonth)??><@showSizeStat stat=size.value.lastMonth/><#else>---#if>
Headers
<#if (size.headers.last15Min)??><@showSizeStat stat=size.headers.last15Min/><#else>---#if>
<#if (size.headers.lastHour)??><@showSizeStat stat=size.headers.lastHour/><#else>---#if>
<#if (size.headers.last6Hours)??><@showSizeStat stat=size.headers.last6Hours/><#else>---#if>
<#if (size.headers.lastDay)??><@showSizeStat stat=size.headers.lastDay/><#else>---#if>
<#if (size.headers.lastWeek)??><@showSizeStat stat=size.headers.lastWeek/><#else>---#if>
<#if (size.headers.lastMonth)??><@showSizeStat stat=size.headers.lastMonth/><#else>---#if>
#macro>
<#macro showPayloadStructure structure>
<#-- @ftlvariable name="structure" type="com.infobip.kafkistry.model.RecordsStructure" -->
Record root structure type: ${structure.payloadType}
<#if structure.nullable>
NULLABLE
#if>
<#if (structure.jsonFields)??>
#if>
#macro>
<#macro showStructure structure>
<#-- @ftlvariable name="structure" type="com.infobip.kafkistry.model.RecordsStructure" -->
Sizes
<@showRecordSize size=structure.size/>
Headers
<#if structure.headerFields?? && structure.headerFields?size gt 0 && structure.headerFields?first.children?size gt 0>
<#list structure.headerFields?first.children as headerField>
<@showRecordField field=headerField parentType=""/>
#list>
<#else>
(no headers)
#if>
Inferred structure
<@showPayloadStructure structure=structure/>
#macro>