mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-17 19:36:28 +02:00
fix(settings): expose UI rendering fields without requiring SETTINGS_READ (#1293)
The Clear Plate button (and 4 other features on the Printers page) read their state from /settings, which requires SETTINGS_READ. Granting that permission also adds the Settings nav item and leaks SMTP/LDAP/MQTT credentials — exactly what users were trying to avoid by giving an operator only printers:clear_plate. New /settings/ui-preferences endpoint returns a curated, opt-in subset of non-sensitive fields. Matches the existing /default-sidebar-order precedent. PrintersPage switched to the new endpoint; admin pages still use /settings for full access.
This commit is contained in:
@@ -3990,6 +3990,24 @@ export const api = {
|
||||
// Settings
|
||||
getSettings: () => request<AppSettings>('/settings/'),
|
||||
getDefaultSidebarOrder: () => request<{ default_sidebar_order: string }>('/settings/default-sidebar-order'),
|
||||
// Public subset of settings for UI rendering — no settings:read required.
|
||||
// Used by pages whose users may not have SETTINGS_READ (e.g. operators with
|
||||
// only printers:clear_plate). Keep in sync with _UI_PREFERENCE_FIELDS in
|
||||
// backend/app/api/routes/settings.py.
|
||||
getUiPreferences: () =>
|
||||
request<{
|
||||
require_plate_clear?: boolean;
|
||||
check_printer_firmware?: boolean;
|
||||
camera_view_mode?: 'window' | 'embedded';
|
||||
time_format?: 'system' | '12h' | '24h';
|
||||
date_format?: string;
|
||||
drying_presets?: string;
|
||||
ams_humidity_good?: number;
|
||||
ams_humidity_fair?: number;
|
||||
ams_temp_good?: number;
|
||||
ams_temp_fair?: number;
|
||||
bed_cooled_threshold?: number;
|
||||
}>('/settings/ui-preferences'),
|
||||
updateSettings: (data: AppSettingsUpdate) =>
|
||||
request<AppSettings>('/settings/', {
|
||||
method: 'PUT',
|
||||
|
||||
Reference in New Issue
Block a user