diff --git a/avian/api/birdnet-api.php b/avian/api/birdnet-api.php index f2a20b4..b33c379 100644 --- a/avian/api/birdnet-api.php +++ b/avian/api/birdnet-api.php @@ -184,6 +184,64 @@ switch ($action) { break; } + + case 'frame_config': { + $cfg_path = __DIR__ . '/frame-config.json'; + $defaults = [ + 'mode' => 'today', + 'hours' => 24, + 'start_time' => '06:00', + 'hold_overnight' => true, + 'species_source' => '', + 'zip' => '', + 'bw_days' => 7, + 'bw_country' => 'us', + 'image_url' => '', + 'shoot' => true, + 'shoot_title' => 'avian visitors', + 'shoot_subtitle' => 'Heard Today', + 'shoot_headline_px' => 42, + 'shoot_eyebrow_px' => 18, + 'shoot_lowercase' => false, + 'shoot_mat' => 0.04, + 'shoot_small_floor' => 0.04, + 'shoot_count_exp' => 0.65, + 'mat' => 0.0, + 'mat_opening_w' => 0, + 'mat_opening_h' => 0, + 'rotate' => 90, + 'saturation' => 0.6, + 'panel' => '', + 'quiet_start' => 22, + 'quiet_end' => 6, + 'heal_hours' => 24, + 'timeout' => 45, + 'basic_user' => '', + 'basic_pass' => '', + ]; + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $input = json_decode(file_get_contents('php://input'), true); + if (!is_array($input)) { + http_response_code(400); + echo json_encode(['error' => 'invalid JSON']); + break; + } + $current = file_exists($cfg_path) ? json_decode(file_get_contents($cfg_path), true) : $defaults; + if (!is_array($current)) $current = $defaults; + $allowed = array_keys($defaults); + foreach ($input as $k => $v) { + if (in_array($k, $allowed, true)) $current[$k] = $v; + } + file_put_contents($cfg_path, json_encode($current, JSON_PRETTY_PRINT) . "\n"); + echo json_encode($current); + } else { + $current = file_exists($cfg_path) ? json_decode(file_get_contents($cfg_path), true) : $defaults; + if (!is_array($current)) $current = $defaults; + echo json_encode(array_merge($defaults, $current)); + } + break; + } + default: http_response_code(404); echo json_encode(['error' => 'unknown action']); diff --git a/avian/api/menu.php b/avian/api/menu.php index d1138af..b7c6122 100644 --- a/avian/api/menu.php +++ b/avian/api/menu.php @@ -31,6 +31,7 @@ if (getenv('AV_REQUIRE_AUTH') === '1' && empty($_SERVER['HTTP_AUTHORIZATION'])) echo json_encode([ 'items' => [ ['label' => 'settings', 'href' => '/#admin=settings', 'native' => true], + ['label' => 'frame', 'href' => '/#admin=frame', 'native' => true], ['label' => 'system', 'href' => '/#admin=system', 'native' => true], ['label' => 'logs', 'href' => '/#admin=logs', 'native' => true], ['label' => 'tools', 'href' => '/#admin=tools', 'native' => true], diff --git a/avian/frontend/apt.js b/avian/frontend/apt.js index 05504b0..5b18827 100644 --- a/avian/frontend/apt.js +++ b/avian/frontend/apt.js @@ -2367,6 +2367,7 @@ var adminSect = null; var ADMIN_TITLES = { settings: 'Settings', + frame: 'Frame', system: 'System', logs: 'Logs', tools: 'Tools', @@ -2402,6 +2403,7 @@ if (adminPollT) { clearInterval(adminPollT); adminPollT = null; } adminSect = section; if (section === 'settings') renderAdminSettings(); + else if (section === 'frame') renderAdminFrame(); else if (section === 'system') renderAdminSystem(); else if (section === 'logs') renderAdminLogs(); else if (section === 'tools') renderAdminTools(); @@ -2424,6 +2426,175 @@ return '
loading frame config...
'; + fetch('./avian/api/birdnet-api.php?action=frame_config', { credentials: 'same-origin', cache: 'no-store' }) + .then(function (r) { return r.ok ? r.json() : Promise.reject(r.status); }) + .then(function (fc) { + adminBody.innerHTML = + 'loading settings...
'; fetch('./avian/api/config.php', { credentials: 'same-origin', cache: 'no-store' }) diff --git a/avian/frontend/styles.css b/avian/frontend/styles.css index c2bb1c8..ceed7bd 100644 --- a/avian/frontend/styles.css +++ b/avian/frontend/styles.css @@ -1622,3 +1622,15 @@ * See avian/forwarding/. */ body.av-local #dd-locked { display: none; } body.av-local #dd-items { display: block; } + + .frame-section-label { + font: 600 11px/1 var(--sans, ui-sans-serif, system-ui, sans-serif); + text-transform: uppercase; + letter-spacing: 0.05em; + color: var(--ink-soft, #8a8078); + padding: 18px 0 6px; + border-bottom: 1px solid rgba(26,22,18,0.08); + margin-bottom: 2px; + } + .frame-section-label:first-child { padding-top: 4px; } +