Add throttling status tracking
This commit is contained in:
+38
-9
@@ -24,6 +24,9 @@
|
||||
statusLowVoltage: $('#statusLowVoltage'),
|
||||
statusLowVoltageLast: $('#statusLowVoltageLast'),
|
||||
statusLowVoltageDuration: $('#statusLowVoltageDuration'),
|
||||
statusThrottling: $('#statusThrottling'),
|
||||
statusThrottlingLast: $('#statusThrottlingLast'),
|
||||
statusThrottlingDuration: $('#statusThrottlingDuration'),
|
||||
statusBatteryVoltage: $('#statusBatteryVoltage'),
|
||||
statusBatterySoc: $('#statusBatterySoc'),
|
||||
statusBatteryRemaining: $('#statusBatteryRemaining'),
|
||||
@@ -99,6 +102,13 @@
|
||||
lowVoltageNormal: 'Normal',
|
||||
lowVoltageSeen: 'seen since boot',
|
||||
lowVoltageNotSeen: 'not seen since boot',
|
||||
throttling: 'Throttling',
|
||||
throttlingLast: 'Last Throttling',
|
||||
throttlingDuration: 'Throttle Duration',
|
||||
throttlingActive: 'Throttling',
|
||||
throttlingNormal: 'Normal',
|
||||
throttlingSeen: 'seen since boot',
|
||||
throttlingNotSeen: 'not seen since boot',
|
||||
currentEpisode: 'current',
|
||||
lastEpisode: 'last',
|
||||
batteryV: 'Battery V',
|
||||
@@ -241,6 +251,13 @@
|
||||
lowVoltageNormal: '정상',
|
||||
lowVoltageSeen: '부팅 후 이력 있음',
|
||||
lowVoltageNotSeen: '부팅 후 이력 없음',
|
||||
throttling: '스로틀링',
|
||||
throttlingLast: '최근 스로틀링',
|
||||
throttlingDuration: '스로틀링 지속',
|
||||
throttlingActive: '감지 중',
|
||||
throttlingNormal: '정상',
|
||||
throttlingSeen: '부팅 후 이력 있음',
|
||||
throttlingNotSeen: '부팅 후 이력 없음',
|
||||
currentEpisode: '현재',
|
||||
lastEpisode: '최근',
|
||||
batteryV: '배터리 전압',
|
||||
@@ -787,27 +804,35 @@
|
||||
return formatDhms(parseWifiDurationSeconds(value)) || value;
|
||||
}
|
||||
|
||||
function lowVoltageStateText(lowVoltage) {
|
||||
if (!lowVoltage || lowVoltage.available === false) {
|
||||
function eventStateText(eventState, activeKey, normalKey, seenKey, notSeenKey) {
|
||||
if (!eventState || eventState.available === false) {
|
||||
return t('na');
|
||||
}
|
||||
|
||||
const stateText = lowVoltage.active ? t('lowVoltageActive') : t('lowVoltageNormal');
|
||||
const seenText = lowVoltage.seen_since_boot ? t('lowVoltageSeen') : t('lowVoltageNotSeen');
|
||||
const stateText = eventState.active ? t(activeKey) : t(normalKey);
|
||||
const seenText = eventState.seen_since_boot ? t(seenKey) : t(notSeenKey);
|
||||
return `${stateText} (${seenText})`;
|
||||
}
|
||||
|
||||
function lowVoltageDurationText(lowVoltage) {
|
||||
if (!lowVoltage || lowVoltage.available === false) {
|
||||
function eventDurationText(eventState) {
|
||||
if (!eventState || eventState.available === false) {
|
||||
return t('na');
|
||||
}
|
||||
|
||||
const seconds = Number(lowVoltage.duration_seconds ?? 0);
|
||||
const label = lowVoltage.active ? t('currentEpisode') : t('lastEpisode');
|
||||
const seconds = Number(eventState.duration_seconds ?? 0);
|
||||
const label = eventState.active ? t('currentEpisode') : t('lastEpisode');
|
||||
const formatted = formatDhms(seconds) || '-';
|
||||
return `${label}: ${formatted}`;
|
||||
}
|
||||
|
||||
function lowVoltageStateText(lowVoltage) {
|
||||
return eventStateText(lowVoltage, 'lowVoltageActive', 'lowVoltageNormal', 'lowVoltageSeen', 'lowVoltageNotSeen');
|
||||
}
|
||||
|
||||
function throttlingStateText(throttling) {
|
||||
return eventStateText(throttling, 'throttlingActive', 'throttlingNormal', 'throttlingSeen', 'throttlingNotSeen');
|
||||
}
|
||||
|
||||
function timeAgo(seconds) {
|
||||
const formatted = formatDhms(seconds);
|
||||
return formatted ? `${formatted} ${t('ago')}` : '-';
|
||||
@@ -839,6 +864,7 @@
|
||||
const memory = system.memory || {};
|
||||
const battery = data.battery || {};
|
||||
const lowVoltage = system.low_voltage || {};
|
||||
const throttling = system.throttling || {};
|
||||
const load = Array.isArray(system.load) ? system.load : [];
|
||||
const activeUsers = system.active_users || {};
|
||||
|
||||
@@ -850,7 +876,10 @@
|
||||
setText(els.statusUptime, system.uptime || '-');
|
||||
setText(els.statusLowVoltage, lowVoltageStateText(lowVoltage));
|
||||
setText(els.statusLowVoltageLast, lowVoltage.last_detected_at || '-');
|
||||
setText(els.statusLowVoltageDuration, lowVoltageDurationText(lowVoltage));
|
||||
setText(els.statusLowVoltageDuration, eventDurationText(lowVoltage));
|
||||
setText(els.statusThrottling, throttlingStateText(throttling));
|
||||
setText(els.statusThrottlingLast, throttling.last_detected_at || '-');
|
||||
setText(els.statusThrottlingDuration, eventDurationText(throttling));
|
||||
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