(converter) Get UUID pips out of the models
Rendering concerns shouldn't be in the models, it's poor separation of concerns and very difficult to follow.
This commit is contained in:
parent
e06a8c1de2
commit
758f9b5aa5
@ -26,6 +26,21 @@ public class MustacheRenderer<T> {
|
||||
var handlebars = new Handlebars(loader);
|
||||
handlebars.registerHelpers(ConditionalHelpers.class);
|
||||
handlebars.registerHelper("md", new MarkdownHelper());
|
||||
handlebars.registerHelper("readableUUID", (context, options) -> {
|
||||
if (context == null) return "";
|
||||
String instance = context.toString();
|
||||
if (instance.length() < 31) return "";
|
||||
|
||||
String color1 = "#"+instance.substring(0, 6);
|
||||
String color2 = "#"+instance.substring(25, 31);
|
||||
String shortName = instance.substring(0, 8);
|
||||
|
||||
String ret = "<span title=\"%s\">".formatted(instance) +
|
||||
"<span style=\"background-color: %s\" class=\"uuidPip\"> </span>".formatted(color1) +
|
||||
"<span style=\"background-color: %s\" class=\"uuidPip\"> </span>".formatted(color2) +
|
||||
" " + shortName + "</span>";
|
||||
return ret;
|
||||
});
|
||||
|
||||
try {
|
||||
template = handlebars.compile(templateFile);
|
||||
|
@ -9,13 +9,4 @@ public record EventLogEntry(
|
||||
String eventType,
|
||||
String eventMessage)
|
||||
{
|
||||
public String instance() {
|
||||
return instanceFull.substring(0, 8);
|
||||
}
|
||||
public String instanceColor() {
|
||||
return '#' + instanceFull.substring(0, 6);
|
||||
}
|
||||
public String instanceColor2() {
|
||||
return '#' + instanceFull.substring(25, 31);
|
||||
}
|
||||
}
|
||||
|
@ -18,26 +18,6 @@ public record MessageQueueEntry (
|
||||
public boolean hasRelatedMessage() {
|
||||
return relatedId > 0;
|
||||
}
|
||||
public String ownerInstance() {
|
||||
if (ownerInstanceFull == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return ownerInstanceFull.substring(0, 8);
|
||||
}
|
||||
public String ownerInstanceColor() {
|
||||
if (ownerInstanceFull == null) {
|
||||
return "#000000";
|
||||
}
|
||||
return '#' + ownerInstanceFull.substring(0, 6);
|
||||
}
|
||||
public String ownerInstanceColor2() {
|
||||
if (ownerInstanceFull == null) {
|
||||
return "#000000";
|
||||
}
|
||||
|
||||
return '#' + ownerInstanceFull.substring(25, 31);
|
||||
}
|
||||
|
||||
public String stateCode() {
|
||||
if (state == null) {
|
||||
|
@ -9,15 +9,6 @@ public record ProcessHeartbeat(
|
||||
Integer progress,
|
||||
String status
|
||||
) {
|
||||
public String uuid() {
|
||||
return uuidFull.substring(0, 8);
|
||||
}
|
||||
public String uuidColor() {
|
||||
return '#' + uuidFull.substring(0, 6);
|
||||
}
|
||||
public String uuidColor2() {
|
||||
return '#' + uuidFull.substring(25, 31);
|
||||
}
|
||||
public boolean isMissing() {
|
||||
return lastSeenMillis > 10000;
|
||||
}
|
||||
|
@ -10,13 +10,4 @@ public record ServiceHeartbeat(
|
||||
public boolean isMissing() {
|
||||
return lastSeenMillis > 10000;
|
||||
}
|
||||
public String uuid() {
|
||||
return uuidFull.substring(0, 8);
|
||||
}
|
||||
public String uuidColor() {
|
||||
return '#' + uuidFull.substring(0, 6);
|
||||
}
|
||||
public String uuidColor2() {
|
||||
return '#' + uuidFull.substring(25, 31);
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,7 @@
|
||||
{{#each events}}
|
||||
<tr>
|
||||
<td>{{serviceName}}</td>
|
||||
<td title="{{instanceFull}}">
|
||||
<span style="background-color: {{instanceColor}}" class="uuidPip"> </span><span style="background-color: {{instanceColor2}}" class="uuidPip"> </span>
|
||||
{{instance}}
|
||||
</td>
|
||||
<td>{{{readableUUID instanceFull}}}</td>
|
||||
<td title="{{eventDateTime}}">{{eventTime}}</td>
|
||||
<td>{{eventType}}</td>
|
||||
<td>{{eventMessage}}</td>
|
||||
|
@ -31,10 +31,7 @@
|
||||
{{#each events}}
|
||||
<tr>
|
||||
<td>{{serviceName}}</td>
|
||||
<td title="{{instanceFull}}">
|
||||
<span style="background-color: {{instanceColor}}" class="uuidPip"> </span><span style="background-color: {{instanceColor2}}" class="uuidPip"> </span>
|
||||
{{instance}}
|
||||
</td>
|
||||
<td>{{{readableUUID instanceFull}}}</td>
|
||||
<td title="{{eventDateTime}}">{{eventTime}}</td>
|
||||
<td>{{eventType}}</td>
|
||||
<td>{{eventMessage}}</td>
|
||||
|
@ -27,9 +27,7 @@
|
||||
<td><a href="/message-queue/{{id}}">{{id}}</a></td>
|
||||
<td><a href="/message-queue?inbox={{recipientInbox}}">{{recipientInbox}}</a></td>
|
||||
<td>{{function}}</td>
|
||||
<td title="{{ownerInstanceFull}}">
|
||||
<span style="background-color: {{ownerInstanceColor}}" class="uuidPip"> </span><span style="background-color: {{ownerInstanceColor2}}" class="uuidPip"> </span> <a href="/message-queue?instance={{ownerInstanceFull}}">{{ownerInstance}}</a>
|
||||
</td>
|
||||
<td>{{{readableUUID ownerInstanceFull}}}</td>
|
||||
<td>{{createdTime}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -12,9 +12,7 @@
|
||||
{{#each processes}}
|
||||
<tr class="{{#if isMissing}}missing{{/if}}">
|
||||
<td>{{displayName}}</td>
|
||||
<td title="{{uuidFull}}">
|
||||
<span style="background-color: {{uuidColor}}" class="uuidPip"> </span><span style="background-color: {{uuidColor2}}" class="uuidPip"> </span>{{uuid}}
|
||||
</td>
|
||||
<td>{{{readableUUID uuidFull}}}</td>
|
||||
<td>{{status}}</td>
|
||||
<td style="{{progressStyle}}">{{#if progress}}{{progress}}%{{/if}}</td>
|
||||
<td>{{#unless isStopped}}{{lastSeenMillis}}{{/unless}}</td>
|
||||
|
@ -8,10 +8,7 @@
|
||||
{{#each services}}
|
||||
<tr class="{{#if isMissing}}missing{{/if}} {{#unless alive}}terminated{{/unless}}">
|
||||
<td><a href="/services/{{serviceId}}">{{serviceId}}</a></td>
|
||||
<td title="{{uuidFull}}">
|
||||
<span style="background-color: {{uuidColor}}" class="uuidPip"> </span><span style="background-color: {{uuidColor2}}" class="uuidPip"> </span>
|
||||
{{uuid}}
|
||||
</td>
|
||||
<td>{{{readableUUID uuidFull}}}</td>
|
||||
<td>{{lastSeenMillis}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
Loading…
Reference in New Issue
Block a user