Skip to content

Commit

Permalink
Fix wrapping of query and plan in vertical/default display
Browse files Browse the repository at this point in the history
  • Loading branch information
billoley committed May 20, 2024
1 parent 5dfc27a commit 7bc5e52
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -53,16 +54,17 @@ public String getProxyServersStr() {
return getProxyServers() == null ? "" : StringUtils.join(getProxyServers(), "<BR/>");
}

public String getQueryStyle() {
return isJexlQuery(parameters) ? "white-space: pre; word-wrap: break-word;" : "word-wrap: break-word;";
}

public String getParametersStr() {
return parameters == null ? "" : toFormattedParametersString(parameters);
}

public String getQueryAuthorizationsStr() {
return getQueryAuthorizations() == null ? "" : getQueryAuthorizations().replaceAll(",", " ");
String queryAuthorizations = getQueryAuthorizations();
if (queryAuthorizations == null) {
return "";
} else {
return Arrays.stream(queryAuthorizations.split(",")).sorted().collect(Collectors.joining(" "));
}
}

public String getPredictionsStr() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public interface QueryMetricModelFormat {

String getProxyServersStr();

String getQueryStyle();

String getParametersStr();

String getQueryAuthorizationsStr();
Expand Down
6 changes: 3 additions & 3 deletions api/src/main/resources/templates/querymetric-horizontal.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ <h1>Query Metrics</h1>
<td th:text="${metric.queryType}"></td>
<td th:text="${metric.queryLogic}"></td>
<!--/* Note the HTML for the Query and Query Plan are set later... See scripts at end of this tr element */-->
<td th:id="query + ${metricIter.index + 1}" th:style="${metric.queryStyle}"></td>
<td th:id="query + ${metricIter.index + 1}" style="white-space: pre; word-wrap: break-word;"></td>
<td th:id="query-plan + ${metricIter.index + 1}" style="white-space: pre; word-wrap: break-word;"></td>
<td th:text="${metric.queryName}"></td>
<td style="min-width:125px !important;" th:text="${metric.beginDateStr}"></td>
Expand All @@ -105,8 +105,8 @@ <h1>Query Metrics</h1>
<td th:text="${metric.totalBytesSentStr}"></td>
<td th:text="${metric.lifecycle}"></td>
<td th:text="${metric.elapsedTimeStr}"></td>
<td style="word-wrap: break-word;" th:text="${metric.errorCode}"></td>
<td style="word-wrap: break-word;" th:text="${metric.errorMessage}"></td>
<td style="overflow-wrap: anywhere;" th:text="${metric.errorCode}"></td>
<td style="overflow-wrap: anywhere;" th:text="${metric.errorMessage}"></td>

<!--/*
Makes the metric's query and the metric's query plan interactive (highlight matching parens on mouse over, clicking a paren brings
Expand Down
37 changes: 27 additions & 10 deletions api/src/main/resources/templates/querymetric.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,44 @@ <h1>Query Metrics</h1>
<div th:each="metric,metricIter : ${metricList}">
<table class="metric">
<tr class="highlight"><td>Visibility</td><td th:text="${metric.columnVisibility}"></td></tr>
<tr><td>Query Date</td><td style="min-width:125px !important;" th:text="${metric.createDateStr}"></td></tr>
<tr><td>Query Date</td><td th:text="${metric.createDateStr}"></td></tr>
<tr class="highlight"><td>User</td><td th:text="${metric.user}"></td></tr>
<tr><td>UserDN</td><td style="min-width:500px !important;" th:text="${metric.userDN}"></td></tr>
<tr><td>UserDN</td><td th:text="${metric.userDN}"></td></tr>
<tr class="highlight"><td>Proxy Server(s)</td><td th:utext="${metric.proxyServersStr}"></td></tr>
<tr><td>Query Id</td><td><a th:href="${metric.queryIdUrl}" th:text="${metric.queryId}"></a></td></tr>
<tr class="highlight"><td>Query Logic</td><td th:text="${metric.queryLogic}"></td></tr>
<tr><td>Query Name</td><td th:text="${metric.queryName}"></td></tr>
<tr class="highlight"><td>Query Type</td><td th:text="${metric.queryType}"></td>
<tr><td>Begin Date</td><td style="min-width:125px !important;" th:text="${metric.beginDateStr}"></td></tr>
<tr class="highlight"><td>End Date</td><td style="min-width:125px !important;" th:text="${metric.endDateStr}"></td></tr>
<tr><td>Begin Date</td><td th:text="${metric.beginDateStr}"></td></tr>
<tr class="highlight"><td>End Date</td><td th:text="${metric.endDateStr}"></td></tr>
<tr><td>Versions</td><td th:utext="${metric.versionStr}"></td></tr>
<tr class="highlight"><td>Query Auths</td><td style="word-wrap: break-word; min-width:300px !important;" th:text="${metric.queryAuthorizationsStr}"></td></tr>
<tr><td>Parameters</td><td style="white-space: pre; word-wrap: break-word;" th:utext="${metric.parametersStr}"></td></tr>

<tr class="highlight" th:id="'queryauths' + ${metricIter.index + 1} + '-placeholder'">
<td>Query Auths (<a th:onClick="|toggleDisplay('queryauths${metricIter.index + 1}')|">show</a>)</td>
<td>click link to show/hide</td>
</tr>
<tr class="highlight" th:id="'queryauths' + ${metricIter.index + 1} + '-value'" hidden="true">
<td>Query Auths (<a th:onClick="|toggleDisplay('queryauths${metricIter.index + 1}')|">hide</a>)</td>
<td style="overflow-wrap: anywhere" th:text="${metric.queryAuthorizationsStr}"></td>
</tr>

<tr th:id="'parameters' + ${metricIter.index + 1} + '-placeholder'">
<td>Parameters (<a th:onClick="|toggleDisplay('parameters${metricIter.index + 1}')|">show</a>)</td>
<td>click link to show/hide</td>
</tr>
<tr th:id="'parameters' + ${metricIter.index + 1} + '-value'" hidden="true">
<td>Parameters (<a th:onClick="|toggleDisplay('parameters${metricIter.index + 1}')|">hide</a>)</td>
<td style="overflow-wrap: anywhere;" th:utext="${metric.parametersStr}"></td>
</tr>

<!--/* Note the HTML for the Query and Query Plan are set later... See scripts at end of these tr elements */-->
<tr class="highlight" th:id="'query' + ${metricIter.index + 1} + '-placeholder'">
<td>Query (<a th:onClick="|toggleDisplay('query${metricIter.index + 1}')|">show</a>)</td>
<td>click link to show/hide</td>
</tr>
<tr class="highlight" th:id="'query' + ${metricIter.index + 1} + '-value'" hidden="true">
<td id="query-header">Query (<a th:onClick="|toggleDisplay('query${metricIter.index + 1}')|">hide</a>)</td>
<td th:id="'query' + ${metricIter.index + 1}" th:style="${metric.queryStyle}"/>
<td th:id="'query' + ${metricIter.index + 1}" style="overflow-wrap: anywhere;"/>
</tr>

<tr th:id="'query-plan' + ${metricIter.index + 1} + '-placeholder'">
Expand All @@ -59,16 +76,16 @@ <h1>Query Metrics</h1>
</tr>
<tr th:id="'query-plan' + ${metricIter.index + 1} + '-value'" hidden="true">
<td>Query Plan (<a th:onClick="|toggleDisplay('query-plan${metricIter.index + 1}')|">hide</a>)</td>
<td th:id="'query-plan' + ${metricIter.index + 1}" style="white-space: pre; word-wrap: break-word;"/>
<td th:id="'query-plan' + ${metricIter.index + 1}" style="overflow-wrap: anywhere;"/>
</tr>
<tr class="highlight"><td>Predictions</td><td th:text="${metric.predictionsStr}"></td></tr>
<tr><td>Server</td><td th:text="${metric.host}"></td></tr>
<tr class="highlight"><td>Elapsed Time</td><td th:text="${metric.elapsedTimeStr}"></td></tr>
<tr><td>Lifecycle</td><td th:text="${metric.lifecycle}"></td></tr>
<tr class="highlight"><td>Number Pages</td><td th:text="${metric.numPagesStr}"></td></tr>
<tr><td>Number Results</td><td th:text="${metric.numResultsStr}"></td></tr>
<tr class="highlight"><td>Error Code</td><td style="word-wrap: break-word;" th:text="${metric.errorCode}"></td></tr>
<tr><td>Error Message</td><td style="word-wrap: break-word;" th:text="${metric.errorMessage}"></td></tr>
<tr class="highlight"><td>Error Code</td><td style="overflow-wrap: anywhere;" th:text="${metric.errorCode}"></td></tr>
<tr><td>Error Message</td><td style="overflow-wrap: anywhere;" th:text="${metric.errorMessage}"></td></tr>
<tr class="highlight"><td>Login Time (ms)</td><td th:text="${metric.loginTimeStr}"></td></tr>
<tr><td>Query Setup Time (ms)</td><td th:text="${metric.setupTimeStr}"></td></tr>
<tr class="highlight"><td>Query Setup Call Time (ms)</td><td th:text="${metric.createCallTimeStr}"></td></tr>
Expand Down

0 comments on commit 7bc5e52

Please sign in to comment.