Extends weather's experimental Chromium+Jinja2 render style to battery, text, tasks, static image, whiteboard, and calendar (all four view modes -- agenda/today_tomorrow/week/month), and gives the photos widget its own genuinely independent palette + dithering strength. Photos: Frame.photo_palette_rgb/photo_dither_strength (mirroring the existing palette_rgb/dither_strength), with a second "Photos configuration" card in Advanced Configuration. widgets/photos.py's render() quantizes itself against these before returning -- no render_panel changes needed, since photos is the only widget that genuinely needs a different reference palette and can carry that itself, the same way modern-style widgets already self-dither via ordered_dither. Battery/text/tasks/static image/whiteboard: same render_style pattern weather established (render_style column, html_render.py build function, Jinja2 template, dialog toggle). Static image/whiteboard get their first-ever visual chrome (a rounded-corner shadowed card, shared framed_image.html.jinja) since classic draws them with zero frame at all. Fixed the same "preview endpoint bypasses render_style" bug weather originally shipped with, for tasks/static/whiteboard/ calendar's preview endpoints. Calendar: own module (app/calendar_html_render.py, mirroring calendar_render.py's separation from the simpler widgets) covering all four view modes, not just agenda -- reuses calendar_render's own private helpers so event colors/times/weather/month-grid math match classic exactly. Found and fixed two real cross-day layout bugs along the way: a per-day header height that varied based on whether that specific day had a weather entry (misaligning where every other day's event rows started across the week/month grid), and regular-weight small text being fragile under Bayer ordered dithering (out-of-month day numbers degraded into unrecognizable speckle) -- fixed by using bold everywhere and de-emphasizing via size instead of weight/gray, since gray text has the same dithering fragility this project's PIL renderers already avoid for exactly this reason. Migrations 32-38 (Frame's two new columns, then one render_style column per widget config table). 452 tests passing, including new dispatch/ migration coverage per widget type and a dedicated photos test proving photo_palette_rgb produces genuinely independent quantization from the frame's main palette_rgb.
99 lines
4.0 KiB
JavaScript
99 lines
4.0 KiB
JavaScript
// Tasks widget dialog: per-user included-task-list checkboxes + color
|
|
// pins (same shape as the calendar widget's "Included calendars"), the
|
|
// name/recently-completed settings form, and the rendered preview. Not
|
|
// a page-load script -- frame_layout.js fetches this widget's dialog
|
|
// HTML fragment, injects it into the shared <dialog>, points
|
|
// window.FRAME_API at this specific widget
|
|
// (/api/frames/{id}/widgets/{widget_id}), then calls initTasksDialog().
|
|
|
|
function loadTasksPreview() {
|
|
document.getElementById('tasks-preview').src = `${window.FRAME_API}/preview/tasks?_=${Date.now()}`;
|
|
}
|
|
|
|
function initTasksDialog() {
|
|
// Each task list's own include/mute toggle -- auto-saves on change,
|
|
// not batched into the form below, since it's a data-sharing choice
|
|
// (see api_widget_task_list_select), not a widget-wide setting. Works
|
|
// the same element for your own lists (full add/remove) and other
|
|
// people's (mute only) -- the server enforces which direction is
|
|
// allowed and this just reverts the checkbox with an error message if
|
|
// rejected.
|
|
document.querySelectorAll('.task-list-toggle').forEach((el) => {
|
|
el.addEventListener('change', async () => {
|
|
try {
|
|
const resp = await fetch(`${window.FRAME_API}/task-list-select`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
user_id: Number(el.dataset.userId),
|
|
calendar_key: el.dataset.key,
|
|
calendar_label: el.dataset.label,
|
|
included: el.checked,
|
|
}),
|
|
});
|
|
if (!resp.ok) throw new Error(await apiError(resp));
|
|
showStatus(true, el.checked ? 'Task list included on this widget.' : 'Task list removed from this widget.');
|
|
loadTasksPreview();
|
|
} catch (e) {
|
|
el.checked = !el.checked;
|
|
showStatus(false, e.message);
|
|
}
|
|
});
|
|
});
|
|
|
|
// Per-task-list color pin -- owner-only (the server enforces it;
|
|
// these buttons only ever render for the viewer's own lists anyway).
|
|
document.querySelectorAll('.task-list-color-picker').forEach((picker) => {
|
|
const key = picker.dataset.key;
|
|
picker.querySelectorAll('.color-swatch').forEach((btn) => {
|
|
btn.addEventListener('click', async () => {
|
|
const colorIndex = btn.dataset.index === '' ? null : Number(btn.dataset.index);
|
|
try {
|
|
const resp = await fetch(`${window.FRAME_API}/task-list-color`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ calendar_key: key, color_index: colorIndex }),
|
|
});
|
|
if (!resp.ok) throw new Error(await apiError(resp));
|
|
picker.querySelectorAll('.color-swatch').forEach((el) => el.classList.remove('selected'));
|
|
btn.classList.add('selected');
|
|
showStatus(true, 'Color saved.');
|
|
loadTasksPreview();
|
|
} catch (e) {
|
|
showStatus(false, e.message);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
document.getElementById('tasks-config-form').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
const body = new URLSearchParams({
|
|
tasks_name: document.getElementById('tasks_name').value,
|
|
tasks_show_completed: String(document.getElementById('tasks_show_completed').checked),
|
|
tasks_render_style: document.getElementById('tasks_render_style').value,
|
|
});
|
|
try {
|
|
const resp = await fetch(`${window.FRAME_API}/config`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
body,
|
|
});
|
|
if (!resp.ok) throw new Error(await apiError(resp));
|
|
showStatus(true, 'Saved.');
|
|
loadTasksPreview();
|
|
} catch (e) {
|
|
showStatus(false, e.message);
|
|
}
|
|
});
|
|
|
|
document.getElementById('tasks-preview-refresh').addEventListener('click', loadTasksPreview);
|
|
loadTasksPreview();
|
|
initBorderFields();
|
|
initButtonActionFields();
|
|
}
|
|
|
|
function closeTasksDialog() {
|
|
// Nothing to tear down -- no poll interval, unlike the photos dialog.
|
|
}
|