Add low voltage status to control dashboard
This commit is contained in:
@@ -21,6 +21,9 @@
|
||||
statusDisk: $('#statusDisk'),
|
||||
statusMemory: $('#statusMemory'),
|
||||
statusUptime: $('#statusUptime'),
|
||||
statusLowVoltage: $('#statusLowVoltage'),
|
||||
statusLowVoltageLast: $('#statusLowVoltageLast'),
|
||||
statusLowVoltageDuration: $('#statusLowVoltageDuration'),
|
||||
statusBatteryVoltage: $('#statusBatteryVoltage'),
|
||||
statusBatterySoc: $('#statusBatterySoc'),
|
||||
statusBatteryRemaining: $('#statusBatteryRemaining'),
|
||||
@@ -88,6 +91,15 @@
|
||||
diskRoot: 'Disk',
|
||||
memory: 'Memory',
|
||||
uptime: 'Uptime',
|
||||
lowVoltage: 'Low Voltage',
|
||||
lowVoltageLast: 'Last Low Voltage',
|
||||
lowVoltageDuration: 'LV Duration',
|
||||
lowVoltageActive: 'Active',
|
||||
lowVoltageNormal: 'Normal',
|
||||
lowVoltageSeen: 'seen since boot',
|
||||
lowVoltageNotSeen: 'not seen since boot',
|
||||
currentEpisode: 'current',
|
||||
lastEpisode: 'last',
|
||||
batteryV: 'Battery V',
|
||||
batterySoc: 'Battery SOC',
|
||||
sensorHistory: 'Sensor History',
|
||||
@@ -221,6 +233,15 @@
|
||||
diskRoot: '디스크',
|
||||
memory: '메모리',
|
||||
uptime: '가동 시간',
|
||||
lowVoltage: '저전압',
|
||||
lowVoltageLast: '최근 저전압',
|
||||
lowVoltageDuration: '저전압 지속',
|
||||
lowVoltageActive: '감지 중',
|
||||
lowVoltageNormal: '정상',
|
||||
lowVoltageSeen: '부팅 후 이력 있음',
|
||||
lowVoltageNotSeen: '부팅 후 이력 없음',
|
||||
currentEpisode: '현재',
|
||||
lastEpisode: '최근',
|
||||
batteryV: '배터리 전압',
|
||||
batterySoc: '배터리 SOC',
|
||||
sensorHistory: '센서 이력',
|
||||
@@ -756,6 +777,27 @@
|
||||
return formatDhms(parseWifiDurationSeconds(value)) || value;
|
||||
}
|
||||
|
||||
function lowVoltageStateText(lowVoltage) {
|
||||
if (!lowVoltage || lowVoltage.available === false) {
|
||||
return t('na');
|
||||
}
|
||||
|
||||
const stateText = lowVoltage.active ? t('lowVoltageActive') : t('lowVoltageNormal');
|
||||
const seenText = lowVoltage.seen_since_boot ? t('lowVoltageSeen') : t('lowVoltageNotSeen');
|
||||
return `${stateText} (${seenText})`;
|
||||
}
|
||||
|
||||
function lowVoltageDurationText(lowVoltage) {
|
||||
if (!lowVoltage || lowVoltage.available === false) {
|
||||
return t('na');
|
||||
}
|
||||
|
||||
const seconds = Number(lowVoltage.duration_seconds ?? 0);
|
||||
const label = lowVoltage.active ? t('currentEpisode') : t('lastEpisode');
|
||||
const formatted = formatDhms(seconds) || '-';
|
||||
return `${label}: ${formatted}`;
|
||||
}
|
||||
|
||||
function timeAgo(seconds) {
|
||||
const formatted = formatDhms(seconds);
|
||||
return formatted ? `${formatted} ${t('ago')}` : '-';
|
||||
@@ -786,6 +828,7 @@
|
||||
const disk = system.disk || {};
|
||||
const memory = system.memory || {};
|
||||
const battery = data.battery || {};
|
||||
const lowVoltage = system.low_voltage || {};
|
||||
const load = Array.isArray(system.load) ? system.load : [];
|
||||
const activeUsers = system.active_users || {};
|
||||
|
||||
@@ -795,6 +838,9 @@
|
||||
setText(els.statusDisk, `${Number(disk.used_kb || 0).toLocaleString()} / ${Number(disk.total_kb || 0).toLocaleString()} KB (${disk.percent ?? '-'}%)`);
|
||||
setText(els.statusMemory, `${memory.used_mb ?? '-'} / ${memory.total_mb ?? '-'} MB (${memory.percent ?? '-'}%)`);
|
||||
setText(els.statusUptime, system.uptime || '-');
|
||||
setText(els.statusLowVoltage, lowVoltageStateText(lowVoltage));
|
||||
setText(els.statusLowVoltageLast, lowVoltage.last_detected_at || '-');
|
||||
setText(els.statusLowVoltageDuration, lowVoltageDurationText(lowVoltage));
|
||||
setText(els.statusBatteryVoltage, battery.voltage === null || battery.voltage === undefined ? '-' : `${Number(battery.voltage).toFixed(3)} V`);
|
||||
setText(els.statusBatterySoc, battery.percent === null || battery.percent === undefined ? '-' : `${Number(battery.percent).toFixed(2)}%`);
|
||||
setText(els.statusBatteryRemaining, battery.remaining?.display || '-');
|
||||
|
||||
Reference in New Issue
Block a user