mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-24 05:18:58 +00:00
(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);
|
var handlebars = new Handlebars(loader);
|
||||||
handlebars.registerHelpers(ConditionalHelpers.class);
|
handlebars.registerHelpers(ConditionalHelpers.class);
|
||||||
handlebars.registerHelper("md", new MarkdownHelper());
|
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 {
|
try {
|
||||||
template = handlebars.compile(templateFile);
|
template = handlebars.compile(templateFile);
|
||||||
|
@ -9,13 +9,4 @@ public record EventLogEntry(
|
|||||||
String eventType,
|
String eventType,
|
||||||
String eventMessage)
|
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() {
|
public boolean hasRelatedMessage() {
|
||||||
return relatedId > 0;
|
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() {
|
public String stateCode() {
|
||||||
if (state == null) {
|
if (state == null) {
|
||||||
|
@ -9,15 +9,6 @@ public record ProcessHeartbeat(
|
|||||||
Integer progress,
|
Integer progress,
|
||||||
String status
|
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() {
|
public boolean isMissing() {
|
||||||
return lastSeenMillis > 10000;
|
return lastSeenMillis > 10000;
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,4 @@ public record ServiceHeartbeat(
|
|||||||
public boolean isMissing() {
|
public boolean isMissing() {
|
||||||
return lastSeenMillis > 10000;
|
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}}
|
{{#each events}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{serviceName}}</td>
|
<td>{{serviceName}}</td>
|
||||||
<td title="{{instanceFull}}">
|
<td>{{{readableUUID instanceFull}}}</td>
|
||||||
<span style="background-color: {{instanceColor}}" class="uuidPip"> </span><span style="background-color: {{instanceColor2}}" class="uuidPip"> </span>
|
|
||||||
{{instance}}
|
|
||||||
</td>
|
|
||||||
<td title="{{eventDateTime}}">{{eventTime}}</td>
|
<td title="{{eventDateTime}}">{{eventTime}}</td>
|
||||||
<td>{{eventType}}</td>
|
<td>{{eventType}}</td>
|
||||||
<td>{{eventMessage}}</td>
|
<td>{{eventMessage}}</td>
|
||||||
|
@ -31,10 +31,7 @@
|
|||||||
{{#each events}}
|
{{#each events}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{serviceName}}</td>
|
<td>{{serviceName}}</td>
|
||||||
<td title="{{instanceFull}}">
|
<td>{{{readableUUID instanceFull}}}</td>
|
||||||
<span style="background-color: {{instanceColor}}" class="uuidPip"> </span><span style="background-color: {{instanceColor2}}" class="uuidPip"> </span>
|
|
||||||
{{instance}}
|
|
||||||
</td>
|
|
||||||
<td title="{{eventDateTime}}">{{eventTime}}</td>
|
<td title="{{eventDateTime}}">{{eventTime}}</td>
|
||||||
<td>{{eventType}}</td>
|
<td>{{eventType}}</td>
|
||||||
<td>{{eventMessage}}</td>
|
<td>{{eventMessage}}</td>
|
||||||
|
@ -27,9 +27,7 @@
|
|||||||
<td><a href="/message-queue/{{id}}">{{id}}</a></td>
|
<td><a href="/message-queue/{{id}}">{{id}}</a></td>
|
||||||
<td><a href="/message-queue?inbox={{recipientInbox}}">{{recipientInbox}}</a></td>
|
<td><a href="/message-queue?inbox={{recipientInbox}}">{{recipientInbox}}</a></td>
|
||||||
<td>{{function}}</td>
|
<td>{{function}}</td>
|
||||||
<td title="{{ownerInstanceFull}}">
|
<td>{{{readableUUID ownerInstanceFull}}}</td>
|
||||||
<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>{{createdTime}}</td>
|
<td>{{createdTime}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -12,9 +12,7 @@
|
|||||||
{{#each processes}}
|
{{#each processes}}
|
||||||
<tr class="{{#if isMissing}}missing{{/if}}">
|
<tr class="{{#if isMissing}}missing{{/if}}">
|
||||||
<td>{{displayName}}</td>
|
<td>{{displayName}}</td>
|
||||||
<td title="{{uuidFull}}">
|
<td>{{{readableUUID uuidFull}}}</td>
|
||||||
<span style="background-color: {{uuidColor}}" class="uuidPip"> </span><span style="background-color: {{uuidColor2}}" class="uuidPip"> </span>{{uuid}}
|
|
||||||
</td>
|
|
||||||
<td>{{status}}</td>
|
<td>{{status}}</td>
|
||||||
<td style="{{progressStyle}}">{{#if progress}}{{progress}}%{{/if}}</td>
|
<td style="{{progressStyle}}">{{#if progress}}{{progress}}%{{/if}}</td>
|
||||||
<td>{{#unless isStopped}}{{lastSeenMillis}}{{/unless}}</td>
|
<td>{{#unless isStopped}}{{lastSeenMillis}}{{/unless}}</td>
|
||||||
|
@ -8,10 +8,7 @@
|
|||||||
{{#each services}}
|
{{#each services}}
|
||||||
<tr class="{{#if isMissing}}missing{{/if}} {{#unless alive}}terminated{{/unless}}">
|
<tr class="{{#if isMissing}}missing{{/if}} {{#unless alive}}terminated{{/unless}}">
|
||||||
<td><a href="/services/{{serviceId}}">{{serviceId}}</a></td>
|
<td><a href="/services/{{serviceId}}">{{serviceId}}</a></td>
|
||||||
<td title="{{uuidFull}}">
|
<td>{{{readableUUID uuidFull}}}</td>
|
||||||
<span style="background-color: {{uuidColor}}" class="uuidPip"> </span><span style="background-color: {{uuidColor2}}" class="uuidPip"> </span>
|
|
||||||
{{uuid}}
|
|
||||||
</td>
|
|
||||||
<td>{{lastSeenMillis}}</td>
|
<td>{{lastSeenMillis}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
Loading…
Reference in New Issue
Block a user