Show custom systemd services

This commit is contained in:
seo
2026-06-21 23:10:13 +09:00
parent 772010562a
commit cc5943df87
4 changed files with 215 additions and 2 deletions
+50
View File
@@ -34,6 +34,7 @@
statusBatteryRemaining: $('#statusBatteryRemaining'),
spikeLogList: $('#spikeLogList'),
haNotifyList: $('#haNotifyList'),
customServiceList: $('#customServiceList'),
noticeBaseline: $('#noticeBaseline'),
rebootBtn: $('#rebootBtn'),
translateBtn: $('#translateBtn'),
@@ -140,6 +141,12 @@
noNoticeHistory: 'No system notice history.',
haNotifyHistory: 'HA Notify History',
noHaNotifyHistory: 'No HA notify history.',
customServices: 'Custom Services',
noCustomServices: 'No custom services.',
serviceLogs: 'Logs',
serviceEnabled: 'enabled',
servicePid: 'pid',
serviceRestarts: 'restarts',
notifySuccess: 'success',
notifyFailed: 'failed',
show: 'Show',
@@ -262,6 +269,12 @@
noNoticeHistory: '시스템 알림 이력이 없습니다.',
haNotifyHistory: 'HA 알림 이력',
noHaNotifyHistory: 'HA 알림 이력이 없습니다.',
customServices: '사용자 서비스',
noCustomServices: '사용자 생성 서비스가 없습니다.',
serviceLogs: '로그',
serviceEnabled: '활성화',
servicePid: 'PID',
serviceRestarts: '재시작',
notifySuccess: '성공',
notifyFailed: '실패',
show: '보기',
@@ -1032,6 +1045,42 @@
: `<div class="spike-log-empty">${escapeHtml(t('noHaNotifyHistory'))}</div>`;
}
function renderCustomServices(rows = []) {
if (!els.customServiceList) return;
els.customServiceList.innerHTML = rows.length
? rows.map(row => {
const active = String(row.active || 'unknown');
const sub = String(row.sub || '').trim();
const stateClass = active === 'active' ? 'active' : (active === 'failed' ? 'failed' : '');
const stateLabel = sub ? `${active} / ${sub}` : active;
const meta = [
row.enabled ? `${t('serviceEnabled')}: ${row.enabled}` : '',
Number(row.pid || 0) > 0 ? `${t('servicePid')}: ${Number(row.pid).toLocaleString()}` : '',
Number(row.restarts || 0) > 0 ? `${t('serviceRestarts')}: ${Number(row.restarts).toLocaleString()}` : '',
row.active_enter ? row.active_enter : '',
].filter(Boolean).join(' · ');
const logLines = Array.isArray(row.logs) && row.logs.length
? row.logs.join('\n')
: (row.logs_ok === false ? row.logs_error : `${t('serviceLogs')}: -`);
return `
<div class="service-item">
<div class="service-head">
<div class="service-title">
<div class="service-name">${escapeHtml(row.name || '-')}</div>
<div class="service-desc">${escapeHtml(row.description || row.fragment || '-')}</div>
</div>
<div class="service-state ${stateClass}">${escapeHtml(stateLabel)}</div>
</div>
<div class="service-meta">${escapeHtml(meta || row.fragment || '-')}</div>
<pre class="service-log">${escapeHtml(logLines)}</pre>
</div>
`;
}).join('')
: `<div class="spike-log-empty">${escapeHtml(t('noCustomServices'))}</div>`;
}
function renderFanCause(data) {
const processes = data.processes || {};
const baseline = data.fan_spike || {};
@@ -1043,6 +1092,7 @@
: stateText;
renderSpikeHistory(data.fan_spike_history || []);
renderHaNotifyHistory(data.ha_notify_history || []);
renderCustomServices(data.custom_services || []);
setText(els.noticeBaseline, baselineText);
renderProcessRows(els.processCpuTable, processes.cpu || [], 'cpu');