Replaces the Photos/Calendar/Whiteboard tabs with a single Layout page
(now the frame's landing route) where each widget gets a gear icon
opening a dialog scoped to that specific widget's own settings. This
was the missing piece for genuinely independent same-type widgets --
"the Calendar tab" never made sense once a frame could hold more than
one calendar widget with different settings.
Data layer: FrameCalendar re-keyed from frame_id to widget_id, so each
calendar widget has its own independent included-calendars set. The
rekey runs as an unconditional post-startup step (like the existing
widget backfill), not a numbered migration -- it depends on calendar
widgets already existing, which themselves come from that same
backfill step, not from schema migration. Registering it as a numbered
migration would have run it first during a real upgrade, silently
dropping every row; caught by a new test that exercises the raw-SQL
upgrade path instead of the fresh-install create_all() shortcut every
other migration test takes.
API layer: every endpoint that used to assume "the frame's widget of
this type" (photo queue/thumbnail/preview, calendar select/color/
tasks/weather, whiteboard source/browse/preview) moved into
api_widgets.py under /api/frames/{id}/widgets/{widget_id}/..., with a
new require_widget_view/control dependency pair mirroring the existing
frame-level ones. Device status (battery/last-seen/firmware) got its
own frame-level /status endpoint, split out of the old photo-specific
/queue it used to piggyback on -- fixes the status bar going silently
blank on any frame without a photo widget.
UI layer: each widget type's existing settings markup/JS was ported
into a dialog partial + an explicit init/close function pair (the
content is now fetched and injected on demand, not loaded at page load
time). window.FRAME_API is repointed to the open dialog's widget-scoped
API base for its duration and restored on close; a separate
window.FRAME_BASE_API stays stable for the always-present header/
status-bar scripts.
Caught during manual browser testing: the consolidated config-save
endpoint initially expected a JSON body while the copied-over dialog JS
posts form-urlencoded data (the old convention) -- fixed to match, with
new HTTP-level test coverage that would have caught it immediately.
46 lines
1.9 KiB
JavaScript
46 lines
1.9 KiB
JavaScript
// Settings page: "Discover calendars" against the CalDAV account already
|
|
// saved on this form (same idiom as widget_dialog_photos.js's Load
|
|
// Albums using the frame's already-saved Immich creds) -- so this only
|
|
// works after the CalDAV URL/username/password have been saved once.
|
|
|
|
// Hides the dedicated WebDAV username/password fields while "reuse my
|
|
// CalDAV creds" is checked -- they'd be ignored server-side anyway (see
|
|
// routers/common.py's webdav_creds_for), no reason to leave them visibly
|
|
// editable and implying they still do something.
|
|
const reuseCaldavCreds = document.getElementById('webdav_reuse_caldav_creds');
|
|
if (reuseCaldavCreds) {
|
|
const updateWebdavFieldVisibility = () => {
|
|
document.getElementById('webdav-creds-fields').style.display = reuseCaldavCreds.checked ? 'none' : '';
|
|
};
|
|
reuseCaldavCreds.addEventListener('change', updateWebdavFieldVisibility);
|
|
updateWebdavFieldVisibility();
|
|
}
|
|
|
|
const discoverBtn = document.getElementById('caldav-discover');
|
|
if (discoverBtn) {
|
|
discoverBtn.addEventListener('click', async () => {
|
|
const list = document.getElementById('caldav-calendar-list');
|
|
discoverBtn.disabled = true;
|
|
try {
|
|
const resp = await fetch('/api/settings/caldav-discover', { method: 'POST' });
|
|
if (!resp.ok) throw new Error(await apiError(resp));
|
|
const calendars = await resp.json();
|
|
list.innerHTML = '';
|
|
if (calendars.length === 0) {
|
|
list.innerHTML = '<li>No calendars found in this account.</li>';
|
|
} else {
|
|
for (const c of calendars) {
|
|
const li = document.createElement('li');
|
|
li.textContent = c.display_name;
|
|
list.appendChild(li);
|
|
}
|
|
}
|
|
showStatus(true, `Found ${calendars.length} calendar${calendars.length === 1 ? '' : 's'}.`);
|
|
} catch (e) {
|
|
showStatus(false, e.message);
|
|
} finally {
|
|
discoverBtn.disabled = false;
|
|
}
|
|
});
|
|
}
|