Skip to content

Commit fe8f214

Browse files
committed
ui: status: hide trivial systemd services in good state
The list of systemd services is getting huge and growing. Roll the trivial ones with just one task and good state into a summary line. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent de8e5bd commit fe8f214

2 files changed

Lines changed: 51 additions & 3 deletions

File tree

ui/status.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ <h3>Build processing</h3>
4444
</tr>
4545
</table>
4646
<br />
47+
<div style="display: flex; justify-content: flex-end; align-items: baseline;">
48+
<label>
49+
<input type="checkbox" id="systemd-summary" checked />
50+
Hide okay services
51+
</label>
52+
</div>
4753
<table id="systemd">
4854
<tr>
4955
<th>Service</th>

ui/status.js

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,58 @@ function systemd_add_one(table, system, sname, v)
212212
mem.setAttribute("style", "text-align: right");
213213
}
214214

215-
function systemd(data_raw, data_local, data_remote)
215+
function systemd_is_okay(v)
216+
{
217+
if (v.TriggeredBy == 0) {
218+
let state = v.ActiveState + " / " + v.SubState;
219+
return state == "active / running" && v.TasksCurrent <= 1;
220+
} else {
221+
return v.Result == "success";
222+
}
223+
}
224+
225+
let systemd_entries = [];
226+
227+
function reload_systemd()
216228
{
217229
var table = document.getElementById("systemd");
230+
const summarize = document.getElementById("systemd-summary").checked;
231+
var hidden = 0;
232+
233+
$("#systemd tr").slice(1).remove();
234+
235+
$.each(systemd_entries, function(i, e) {
236+
if (summarize && systemd_is_okay(e.v)) {
237+
hidden++;
238+
return 1;
239+
}
240+
systemd_add_one(table, e.system, e.name, e.v);
241+
});
242+
243+
if (summarize && hidden) {
244+
var row = table.insertRow();
245+
var cell = row.insertCell(0);
246+
cell.innerHTML = '<span style="font-style: italic;"><b>' + hidden + ' / ' + systemd_entries.length + '</b> trivial services in good state hidden</span>';
247+
cell.setAttribute("colspan", "5");
248+
cell.setAttribute("style", "text-align: right");
249+
}
250+
}
251+
252+
function systemd(data_raw, data_local, data_remote)
253+
{
254+
systemd_entries = [];
218255

219256
$.each(data_local, function(i, v) {
220-
systemd_add_one(table, data_raw, i, v);
257+
systemd_entries.push({system: data_raw, name: i, v: v});
221258
});
222259

223260
$.each(data_remote, function(name, remote) {
224261
$.each(remote["services"], function(service, v) {
225-
systemd_add_one(table, remote, name + "/" + service, v);
262+
systemd_entries.push({system: remote, name: name + "/" + service, v: v});
226263
});
227264
});
265+
266+
reload_systemd();
228267
}
229268

230269
function load_runners(data_raw)
@@ -365,6 +404,9 @@ function status_system(data_raw)
365404
load_runners(data_raw["runners"]);
366405
load_runtime(data_raw["log-files"]);
367406
load_db_size(data_raw["db"]["data"]);
407+
408+
let summary_checkbox = document.getElementById("systemd-summary");
409+
summary_checkbox.addEventListener("change", reload_systemd);
368410
}
369411

370412
function msec_to_str(msec) {

0 commit comments

Comments
 (0)