UPS 제거 상태에 맞춘 배터리 기능 정리
This commit is contained in:
+23
-1
@@ -14,6 +14,7 @@ if (!is_file($controlSecretFile)) {
|
||||
$controlSecretConfig = require $controlSecretFile;
|
||||
$controlDbConfig = is_array($controlSecretConfig['db'] ?? null) ? $controlSecretConfig['db'] : [];
|
||||
$controlBatteryConfig = is_array($controlSecretConfig['battery'] ?? null) ? $controlSecretConfig['battery'] : [];
|
||||
define('CONTROL_BATTERY_ENABLED', (bool)($controlBatteryConfig['enabled'] ?? false));
|
||||
|
||||
define('APP_PASSWORD', (string)($controlSecretConfig['app_password'] ?? ''));
|
||||
define('DB_HOST', (string)($controlDbConfig['host'] ?? '127.0.0.1'));
|
||||
@@ -126,7 +127,7 @@ function clamp_float(float $value, float $min, float $max): float
|
||||
|
||||
function setting_definitions(): array
|
||||
{
|
||||
return [
|
||||
$definitions = [
|
||||
'security.remember_days' => ['group' => 'security', 'label' => '자동 로그인 유지 기간', 'type' => 'number', 'default' => 30, 'min' => 1, 'max' => 365, 'step' => 1, 'unit' => '일'],
|
||||
'security.cookie_secure_mode' => ['group' => 'security', 'label' => 'Remember 쿠키 Secure', 'type' => 'select', 'default' => 'auto', 'options' => ['auto' => 'HTTPS일 때 자동', 'always' => '항상 사용', 'never' => '사용 안함']],
|
||||
'security.cookie_samesite' => ['group' => 'security', 'label' => 'Remember 쿠키 SameSite', 'type' => 'select', 'default' => 'Lax', 'options' => ['Lax' => 'Lax', 'Strict' => 'Strict', 'None' => 'None']],
|
||||
@@ -191,6 +192,16 @@ function setting_definitions(): array
|
||||
'battery.history_chart_limit' => ['group' => 'battery', 'label' => '상태 차트 표본 수', 'type' => 'number', 'default' => 240, 'min' => 60, 'max' => 1500, 'step' => 10, 'unit' => '개'],
|
||||
'battery.history_sync_limit' => ['group' => 'battery', 'label' => '잔여시간 차트 표본 수', 'type' => 'number', 'default' => 240, 'min' => 60, 'max' => 1500, 'step' => 10, 'unit' => '개'],
|
||||
];
|
||||
|
||||
if (!CONTROL_BATTERY_ENABLED) {
|
||||
foreach (array_keys($definitions) as $key) {
|
||||
if (str_starts_with($key, 'battery.')) {
|
||||
unset($definitions[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $definitions;
|
||||
}
|
||||
|
||||
function setting_rows(bool $reload = false): array
|
||||
@@ -1123,6 +1134,15 @@ function i2cget_word_bytes(int $bus, int $address, int $register): ?array
|
||||
|
||||
function battery_status(): array
|
||||
{
|
||||
if (!CONTROL_BATTERY_ENABLED) {
|
||||
return [
|
||||
'enabled' => false,
|
||||
'removed' => true,
|
||||
'voltage' => null,
|
||||
'percent' => null,
|
||||
];
|
||||
}
|
||||
|
||||
$voltage = null;
|
||||
$percent = null;
|
||||
|
||||
@@ -1140,6 +1160,8 @@ function battery_status(): array
|
||||
}
|
||||
|
||||
return [
|
||||
'enabled' => true,
|
||||
'removed' => false,
|
||||
'voltage' => $voltage,
|
||||
'percent' => $percent,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user