Skip to content

Commit 0526865

Browse files
committed
cleanup
1 parent 8bc8bb4 commit 0526865

6 files changed

Lines changed: 25 additions & 11 deletions

File tree

src/main/java/com/samourai/javaserver/web/controllers/AbstractSystemWebController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package com.samourai.javaserver.web.controllers;
22

33
import com.samourai.javaserver.web.models.SystemTemplateModel;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.context.ApplicationContext;
46
import org.springframework.ui.Model;
57

68
public class AbstractSystemWebController {
9+
@Autowired protected ApplicationContext applicationContext;
710

811
public String system(Model model, SystemTemplateModel templateModel) {
12+
templateModel.setStartupTime(applicationContext.getStartupDate());
913
templateModel.apply(model);
1014
return "decorators/system.html";
1115
}

src/main/java/com/samourai/javaserver/web/models/ConfigTemplateModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public ConfigTemplateModel(String pageTitle, String logoTitle, Map<String, Strin
1313

1414
public void apply(Model model) {
1515
super.apply(model);
16-
model.addAttribute("configInfo", configInfo);
16+
model.addAttribute("configModel", this);
1717
}
1818
}

src/main/java/com/samourai/javaserver/web/models/SystemTemplateModel.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
public class SystemTemplateModel extends DashboardTemplateModel {
99
public Collection<Thread> threads;
10-
private long memUsed;
11-
private long memTotal;
10+
public long memUsed;
11+
public long memTotal;
12+
public long startupTime;
1213

1314
public SystemTemplateModel(String pageTitle, String logoTitle) {
1415
super(pageTitle, logoTitle);
@@ -21,7 +22,7 @@ public SystemTemplateModel(String pageTitle, String logoTitle) {
2122
.filter(t -> t.getThreadGroup() == tg)
2223
.sorted(Comparator.comparing(o -> o.getName().toLowerCase()))
2324
.collect(Collectors.toList());
24-
if (false) {
25+
if (false) { // template usage
2526
Thread t = threads.iterator().next();
2627
t.getName();
2728
t.getState();
@@ -35,11 +36,13 @@ public SystemTemplateModel(String pageTitle, String logoTitle) {
3536
memTotal = bytesToMB(total);
3637
}
3738

39+
public void setStartupTime(long startupTime) {
40+
this.startupTime = startupTime;
41+
}
42+
3843
public void apply(Model model) {
3944
super.apply(model);
40-
model.addAttribute("threads", threads);
41-
model.addAttribute("memUsed", memUsed);
42-
model.addAttribute("memTotal", memTotal);
45+
model.addAttribute("systemModel", this);
4346
}
4447

4548
private static long bytesToMB(long bytes) {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
td.threadIndex {
2+
color:#ccc;
3+
width:3em;
4+
}

src/main/resources/templates/decorators/config.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ <h1 class="h2">Configuration</h1>
2121
</tr>
2222
</thead>
2323
<tbody>
24-
<tr th:each="entry : *{configInfo}">
24+
<tr th:each="entry : *{configModel.configInfo}">
2525
<td class="configInfoKey"><span th:text="${entry.key}"/></td>
2626
<td class="configInfoValue"><small th:text="${entry.value}"/></td>
2727
</tr>

src/main/resources/templates/decorators/system.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,26 @@
66
th:with="currentPage = 'system'">
77
<head>
88
<title>System</title>
9-
<link rel="stylesheet" href="/css/config.css" />
9+
<link rel="stylesheet" href="/css/system.css" />
1010
</head>
1111
<body>
1212
<div layout:fragment="main">
1313
<h1 class="h2">System</h1>
1414

15-
<div>Mem use: <strong th:text="${memUsed}"/>M/<span th:text="${memTotal}"/>M, <strong th:text="${threads.size()}"/> threads running.</div>
15+
<div>Startup: <strong><span th:text="${#dates.format(systemModel.startupTime, 'dd-MMM-yyyy HH:mm:ss')}"/></strong></div>
16+
<div>Mem use: <strong><span th:text="${systemModel.memUsed}"/>M</strong>/<span th:text="${systemModel.memTotal}"/>M, <strong th:text="${systemModel.threads.size()}"/> threads running.</div>
1617
<div class="table-responsive">
1718
<table class="table table-sm system">
1819
<thead>
1920
<tr>
21+
<th scope="col"></th>
2022
<th scope="col">Thread</th>
2123
<th scope="col">Status</th>
2224
</tr>
2325
</thead>
2426
<tbody>
25-
<tr th:each="thread : ${threads}">
27+
<tr th:each="thread,iter : ${systemModel.threads}">
28+
<td class="threadIndex"><span th:text="${iter.index+1}"/></td>
2629
<td class="threadName"><span th:text="${thread.getName()}"/></td>
2730
<td class="threadState"><span th:text="${thread.getState()}"/></td>
2831
</tr>

0 commit comments

Comments
 (0)