Add 'use main stack settings' toggle for third-party integration credentials
Each of Newbook, Resos, SambaPOS, SMTP, and Nextcloud now has a checkbox at the top of its credentials block. When enabled, the app reads auth credentials from the central stack settings service (SETTINGS_URL + STACK_INTERNAL_SECRET) and the local auth fields are grayed out. App-specific fields (base path, GL codes, keywords, sync intervals, etc.) remain editable regardless. Backend: new use_global_* columns on kitchen_settings, migration, global_settings_service with apply_global_overrides() for in-memory credential injection, GET /api/settings/global-status endpoint, and apply_global_overrides() called in test-connection endpoints and FileArchivalService. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
62417d59de
commit
d7898ba897
10 changed files with 356 additions and 34 deletions
|
|
@ -41,6 +41,7 @@ interface SettingsData {
|
|||
llm_confidence_threshold: number | null
|
||||
llm_monthly_token_limit: number
|
||||
llm_features_enabled: Record<string, boolean> | null
|
||||
use_global_smtp: boolean
|
||||
}
|
||||
|
||||
interface NewbookSettingsData {
|
||||
|
|
@ -58,6 +59,7 @@ interface NewbookSettingsData {
|
|||
newbook_dinner_gl_codes: string | null
|
||||
newbook_breakfast_vat_rate: string | null
|
||||
newbook_dinner_vat_rate: string | null
|
||||
use_global_newbook: boolean
|
||||
}
|
||||
|
||||
interface ResosSettingsData {
|
||||
|
|
@ -78,6 +80,7 @@ interface ResosSettingsData {
|
|||
resos_manual_breakfast_periods: Array<{day: number; start: string; end: string}> | null
|
||||
sambapos_food_gl_codes: string | null // Phase 8.1
|
||||
sambapos_beverage_gl_codes: string | null // Phase 8.1
|
||||
use_global_resos: boolean
|
||||
}
|
||||
|
||||
interface GLAccount {
|
||||
|
|
@ -121,6 +124,7 @@ interface SambaPOSSettingsData {
|
|||
sambapos_db_password_set: boolean
|
||||
sambapos_tracked_categories: string[]
|
||||
sambapos_excluded_items: string[]
|
||||
use_global_sambapos: boolean
|
||||
}
|
||||
|
||||
interface SambaPOSCategory {
|
||||
|
|
@ -171,6 +175,7 @@ interface NextcloudSettingsData {
|
|||
nextcloud_base_path: string | null
|
||||
nextcloud_enabled: boolean
|
||||
nextcloud_delete_local: boolean
|
||||
use_global_nextcloud: boolean
|
||||
}
|
||||
|
||||
interface NextcloudStatsData {
|
||||
|
|
@ -426,6 +431,13 @@ export default function Settings() {
|
|||
const [budgetSaveMessage, setBudgetSaveMessage] = useState<string | null>(null)
|
||||
|
||||
// Nextcloud state
|
||||
// Global settings flags — use central stack credentials
|
||||
const [useGlobalSmtp, setUseGlobalSmtp] = useState(false)
|
||||
const [useGlobalNextcloud, setUseGlobalNextcloud] = useState(false)
|
||||
const [useGlobalNewbook, setUseGlobalNewbook] = useState(false)
|
||||
const [useGlobalResos, setUseGlobalResos] = useState(false)
|
||||
const [useGlobalSambapos, setUseGlobalSambapos] = useState(false)
|
||||
|
||||
const [nextcloudHost, setNextcloudHost] = useState('')
|
||||
const [nextcloudUsername, setNextcloudUsername] = useState('')
|
||||
const [nextcloudPassword, setNextcloudPassword] = useState('')
|
||||
|
|
@ -774,6 +786,20 @@ export default function Settings() {
|
|||
enabled: !!token,
|
||||
})
|
||||
|
||||
// Fetch which integrations are configured in the central stack settings service
|
||||
const { data: globalStatus } = useQuery<Record<string, boolean>>({
|
||||
queryKey: ['global-integration-status'],
|
||||
queryFn: async () => {
|
||||
const res = await fetch('/kitchen/api/settings/global-status', {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
if (!res.ok) return {}
|
||||
return res.json()
|
||||
},
|
||||
enabled: !!token,
|
||||
staleTime: 60000,
|
||||
})
|
||||
|
||||
// Fetch Nextcloud archive stats
|
||||
const { data: nextcloudStats } = useQuery<NextcloudStatsData>({
|
||||
queryKey: ['nextcloud-stats'],
|
||||
|
|
@ -906,6 +932,8 @@ export default function Settings() {
|
|||
setOcrUseWeightAsQuantity(settings.ocr_use_weight_as_quantity || false)
|
||||
// Cost distribution
|
||||
setCostDistMaxDays(settings.cost_distribution_max_days ?? 90)
|
||||
// Global flags
|
||||
setUseGlobalSmtp(settings.use_global_smtp ?? false)
|
||||
// LLM settings — LLM FEATURE
|
||||
setLlmEnabled(settings.llm_enabled ?? false)
|
||||
setLlmModel(settings.llm_model || 'claude-haiku-4-5-20251001')
|
||||
|
|
@ -923,6 +951,7 @@ export default function Settings() {
|
|||
setNextcloudBasePath(nextcloudSettings.nextcloud_base_path || '/Kitchen Invoices')
|
||||
setNextcloudEnabled(nextcloudSettings.nextcloud_enabled)
|
||||
setNextcloudDeleteLocal(nextcloudSettings.nextcloud_delete_local)
|
||||
setUseGlobalNextcloud(nextcloudSettings.use_global_nextcloud ?? false)
|
||||
}
|
||||
}, [nextcloudSettings])
|
||||
|
||||
|
|
@ -974,6 +1003,7 @@ export default function Settings() {
|
|||
// Convert decimal rate to percentage for display (e.g., 0.10 -> 10)
|
||||
setNewbookBreakfastVatRate(newbookSettings.newbook_breakfast_vat_rate ? String(parseFloat(newbookSettings.newbook_breakfast_vat_rate) * 100) : '10')
|
||||
setNewbookDinnerVatRate(newbookSettings.newbook_dinner_vat_rate ? String(parseFloat(newbookSettings.newbook_dinner_vat_rate) * 100) : '10')
|
||||
setUseGlobalNewbook(newbookSettings.use_global_newbook ?? false)
|
||||
}
|
||||
}, [newbookSettings])
|
||||
|
||||
|
|
@ -987,6 +1017,7 @@ export default function Settings() {
|
|||
// Use array to preserve order
|
||||
setSambaSelectedCourses(sambaSettings.sambapos_tracked_categories || [])
|
||||
setSambaExcludedItems(new Set(sambaSettings.sambapos_excluded_items || []))
|
||||
setUseGlobalSambapos(sambaSettings.use_global_sambapos ?? false)
|
||||
}
|
||||
}, [sambaSettings])
|
||||
|
||||
|
|
@ -1048,6 +1079,7 @@ export default function Settings() {
|
|||
// Note: sync settings (auto_sync_enabled, upcoming_sync_enabled, upcoming_sync_interval)
|
||||
// are now read directly from resosSettings, not local state
|
||||
setResosLargeGroupThreshold(resosSettings.resos_large_group_threshold || 8)
|
||||
setUseGlobalResos(resosSettings.use_global_resos ?? false)
|
||||
setResosNoteKeywords(resosSettings.resos_note_keywords || '')
|
||||
setResosAllergyKeywords(resosSettings.resos_allergy_keywords || '')
|
||||
setCustomFieldMapping(resosSettings.resos_custom_field_mapping || {})
|
||||
|
|
@ -2510,6 +2542,7 @@ export default function Settings() {
|
|||
ocr_filter_subtotal_rows: ocrFilterSubtotalRows,
|
||||
ocr_use_weight_as_quantity: ocrUseWeightAsQuantity,
|
||||
cost_distribution_max_days: costDistMaxDays,
|
||||
use_global_smtp: useGlobalSmtp,
|
||||
}
|
||||
if (azureKey) {
|
||||
data.azure_key = azureKey
|
||||
|
|
@ -2522,6 +2555,7 @@ export default function Settings() {
|
|||
newbook_api_username: newbookUsername,
|
||||
newbook_api_region: newbookRegion,
|
||||
newbook_instance_id: newbookInstanceId,
|
||||
use_global_newbook: useGlobalNewbook,
|
||||
}
|
||||
if (newbookPassword) data.newbook_api_password = newbookPassword
|
||||
if (newbookApiKey) data.newbook_api_key = newbookApiKey
|
||||
|
|
@ -2535,6 +2569,7 @@ export default function Settings() {
|
|||
sambapos_db_port: parseInt(sambaDbPort) || 1433,
|
||||
sambapos_db_name: sambaDbName,
|
||||
sambapos_db_username: sambaDbUsername,
|
||||
use_global_sambapos: useGlobalSambapos,
|
||||
}
|
||||
if (sambaDbPassword) {
|
||||
data.sambapos_db_password = sambaDbPassword
|
||||
|
|
@ -3250,6 +3285,9 @@ export default function Settings() {
|
|||
{settings?.azure_key_set && !azureKey && <span style={styles.keyStatus}>Key is configured</span>}
|
||||
</label>
|
||||
</div>
|
||||
<p style={{ ...styles.hint, marginTop: '0.75rem' }}>
|
||||
Azure Document Intelligence uses app-specific credentials (not shared with the main stack).
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* OCR Post-Processing Block */}
|
||||
|
|
@ -3314,6 +3352,22 @@ export default function Settings() {
|
|||
{/* SMTP Settings Block */}
|
||||
<div style={styles.settingsBlock}>
|
||||
<h3 style={styles.blockTitle}>SMTP Settings</h3>
|
||||
|
||||
{/* Global settings toggle */}
|
||||
<label style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', marginBottom: '1rem', cursor: 'pointer' }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={useGlobalSmtp}
|
||||
onChange={(e) => setUseGlobalSmtp(e.target.checked)}
|
||||
/>
|
||||
<span style={{ fontWeight: 500 }}>Use credentials from main stack settings</span>
|
||||
{useGlobalSmtp && (
|
||||
<span style={{ fontSize: '0.8rem', padding: '0.15rem 0.5rem', borderRadius: '10px', background: globalStatus?.smtp ? '#d4edda' : '#fff3cd', color: globalStatus?.smtp ? '#155724' : '#856404' }}>
|
||||
{globalStatus?.smtp ? 'Configured' : 'Not configured in stack settings'}
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
|
||||
<div style={styles.form}>
|
||||
<label style={styles.label}>
|
||||
SMTP Server
|
||||
|
|
@ -3321,8 +3375,9 @@ export default function Settings() {
|
|||
type="text"
|
||||
value={smtpHost}
|
||||
onChange={(e) => setSmtpHost(e.target.value)}
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalSmtp ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
placeholder="smtp.gmail.com"
|
||||
disabled={useGlobalSmtp}
|
||||
/>
|
||||
</label>
|
||||
<label style={styles.label}>
|
||||
|
|
@ -3331,8 +3386,9 @@ export default function Settings() {
|
|||
type="number"
|
||||
value={smtpPort}
|
||||
onChange={(e) => setSmtpPort(e.target.value)}
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalSmtp ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
placeholder="587"
|
||||
disabled={useGlobalSmtp}
|
||||
/>
|
||||
</label>
|
||||
<label style={styles.label}>
|
||||
|
|
@ -3341,8 +3397,9 @@ export default function Settings() {
|
|||
type="text"
|
||||
value={smtpUsername}
|
||||
onChange={(e) => setSmtpUsername(e.target.value)}
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalSmtp ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
placeholder="your-email@example.com"
|
||||
disabled={useGlobalSmtp}
|
||||
/>
|
||||
</label>
|
||||
<label style={styles.label}>
|
||||
|
|
@ -3351,16 +3408,18 @@ export default function Settings() {
|
|||
type="password"
|
||||
value={smtpPassword}
|
||||
onChange={(e) => setSmtpPassword(e.target.value)}
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalSmtp ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
placeholder={settings?.smtp_password_set ? '••••••••••••••••' : 'Enter password'}
|
||||
disabled={useGlobalSmtp}
|
||||
/>
|
||||
{settings?.smtp_password_set && !smtpPassword && <span style={styles.keyStatus}>Password is configured</span>}
|
||||
{settings?.smtp_password_set && !smtpPassword && !useGlobalSmtp && <span style={styles.keyStatus}>Password is configured</span>}
|
||||
</label>
|
||||
<label style={styles.label}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={smtpUseTls}
|
||||
onChange={(e) => setSmtpUseTls(e.target.checked)}
|
||||
disabled={useGlobalSmtp}
|
||||
/>
|
||||
Use TLS/STARTTLS
|
||||
</label>
|
||||
|
|
@ -4002,6 +4061,22 @@ export default function Settings() {
|
|||
{/* API Credentials Block */}
|
||||
<div style={styles.settingsBlock}>
|
||||
<h3 style={styles.blockTitle}>API Credentials</h3>
|
||||
|
||||
{/* Global settings toggle */}
|
||||
<label style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', marginBottom: '1rem', cursor: 'pointer' }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={useGlobalNewbook}
|
||||
onChange={(e) => setUseGlobalNewbook(e.target.checked)}
|
||||
/>
|
||||
<span style={{ fontWeight: 500 }}>Use credentials from main stack settings</span>
|
||||
{useGlobalNewbook && (
|
||||
<span style={{ fontSize: '0.8rem', padding: '0.15rem 0.5rem', borderRadius: '10px', background: globalStatus?.newbook ? '#d4edda' : '#fff3cd', color: globalStatus?.newbook ? '#155724' : '#856404' }}>
|
||||
{globalStatus?.newbook ? 'Configured' : 'Not configured in stack settings'}
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
|
||||
<div style={styles.form}>
|
||||
<label style={styles.label}>
|
||||
Username
|
||||
|
|
@ -4009,7 +4084,8 @@ export default function Settings() {
|
|||
type="text"
|
||||
value={newbookUsername}
|
||||
onChange={(e) => setNewbookUsername(e.target.value)}
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalNewbook ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
disabled={useGlobalNewbook}
|
||||
/>
|
||||
</label>
|
||||
<label style={styles.label}>
|
||||
|
|
@ -4018,8 +4094,9 @@ export default function Settings() {
|
|||
type="password"
|
||||
value={newbookPassword}
|
||||
onChange={(e) => setNewbookPassword(e.target.value)}
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalNewbook ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
placeholder={newbookSettings?.newbook_api_password_set ? '••••••••' : 'Enter password'}
|
||||
disabled={useGlobalNewbook}
|
||||
/>
|
||||
</label>
|
||||
<label style={styles.label}>
|
||||
|
|
@ -4028,13 +4105,14 @@ export default function Settings() {
|
|||
type="password"
|
||||
value={newbookApiKey}
|
||||
onChange={(e) => setNewbookApiKey(e.target.value)}
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalNewbook ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
placeholder={newbookSettings?.newbook_api_key_set ? '••••••••' : 'Enter API key'}
|
||||
disabled={useGlobalNewbook}
|
||||
/>
|
||||
</label>
|
||||
<label style={styles.label}>
|
||||
Region
|
||||
<select value={newbookRegion} onChange={(e) => setNewbookRegion(e.target.value)} style={styles.input}>
|
||||
<select value={newbookRegion} onChange={(e) => setNewbookRegion(e.target.value)} style={{ ...styles.input, ...(useGlobalNewbook ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }} disabled={useGlobalNewbook}>
|
||||
<option value="au">Australia (au)</option>
|
||||
<option value="ap">Asia Pacific (ap)</option>
|
||||
<option value="eu">Europe (eu)</option>
|
||||
|
|
@ -4313,6 +4391,21 @@ export default function Settings() {
|
|||
<div style={styles.settingsBlock}>
|
||||
<h3 style={styles.blockTitle}>API Configuration</h3>
|
||||
|
||||
{/* Global settings toggle */}
|
||||
<label style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', marginBottom: '1rem', cursor: 'pointer' }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={useGlobalResos}
|
||||
onChange={(e) => setUseGlobalResos(e.target.checked)}
|
||||
/>
|
||||
<span style={{ fontWeight: 500 }}>Use credentials from main stack settings</span>
|
||||
{useGlobalResos && (
|
||||
<span style={{ fontSize: '0.8rem', padding: '0.15rem 0.5rem', borderRadius: '10px', background: globalStatus?.resos ? '#d4edda' : '#fff3cd', color: globalStatus?.resos ? '#155724' : '#856404' }}>
|
||||
{globalStatus?.resos ? 'Configured' : 'Not configured in stack settings'}
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
|
||||
<div style={styles.formGroup}>
|
||||
<label style={styles.label}>Resos API Key *</label>
|
||||
<input
|
||||
|
|
@ -4320,9 +4413,10 @@ export default function Settings() {
|
|||
value={resosApiKey}
|
||||
onChange={(e) => setResosApiKey(e.target.value)}
|
||||
placeholder={resosSettings?.resos_api_key_set ? '••••••••••••' : 'Enter API key'}
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalResos ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
disabled={useGlobalResos}
|
||||
/>
|
||||
{resosSettings?.resos_api_key_set && <small style={styles.hint}>API key is configured (enter new value to update)</small>}
|
||||
{resosSettings?.resos_api_key_set && !useGlobalResos && <small style={styles.hint}>API key is configured (enter new value to update)</small>}
|
||||
</div>
|
||||
|
||||
<button
|
||||
|
|
@ -4872,7 +4966,8 @@ export default function Settings() {
|
|||
resos_opening_hours_mapping: openingHoursMapping,
|
||||
resos_arrival_widget_service_filter: resosArrivalWidgetServiceFilter || null,
|
||||
resos_enable_manual_breakfast: resosEnableManualBreakfast,
|
||||
resos_manual_breakfast_periods: resosManualBreakfastPeriods
|
||||
resos_manual_breakfast_periods: resosManualBreakfastPeriods,
|
||||
use_global_resos: useGlobalResos,
|
||||
})
|
||||
})
|
||||
if (res.ok) {
|
||||
|
|
@ -4980,6 +5075,22 @@ export default function Settings() {
|
|||
{/* Database Connection Block */}
|
||||
<div style={styles.settingsBlock}>
|
||||
<h3 style={styles.blockTitle}>Database Connection</h3>
|
||||
|
||||
{/* Global settings toggle */}
|
||||
<label style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', marginBottom: '1rem', cursor: 'pointer' }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={useGlobalSambapos}
|
||||
onChange={(e) => setUseGlobalSambapos(e.target.checked)}
|
||||
/>
|
||||
<span style={{ fontWeight: 500 }}>Use credentials from main stack settings</span>
|
||||
{useGlobalSambapos && (
|
||||
<span style={{ fontSize: '0.8rem', padding: '0.15rem 0.5rem', borderRadius: '10px', background: globalStatus?.sambapos ? '#d4edda' : '#fff3cd', color: globalStatus?.sambapos ? '#155724' : '#856404' }}>
|
||||
{globalStatus?.sambapos ? 'Configured' : 'Not configured in stack settings'}
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
|
||||
<div style={styles.form}>
|
||||
<label style={styles.label}>
|
||||
Server Host
|
||||
|
|
@ -4987,8 +5098,9 @@ export default function Settings() {
|
|||
type="text"
|
||||
value={sambaDbHost}
|
||||
onChange={(e) => setSambaDbHost(e.target.value)}
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalSambapos ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
placeholder="localhost\SQLEXPRESS17"
|
||||
disabled={useGlobalSambapos}
|
||||
/>
|
||||
<span style={{ fontSize: '0.8rem', color: '#888' }}>For named instances, use format: hostname\instancename</span>
|
||||
</label>
|
||||
|
|
@ -4998,8 +5110,9 @@ export default function Settings() {
|
|||
type="number"
|
||||
value={sambaDbPort}
|
||||
onChange={(e) => setSambaDbPort(e.target.value)}
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalSambapos ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
placeholder="1433"
|
||||
disabled={useGlobalSambapos}
|
||||
/>
|
||||
<span style={{ fontSize: '0.8rem', color: '#888' }}>Default SQL Server port is 1433 (ignored for named instances)</span>
|
||||
</label>
|
||||
|
|
@ -5009,8 +5122,9 @@ export default function Settings() {
|
|||
type="text"
|
||||
value={sambaDbName}
|
||||
onChange={(e) => setSambaDbName(e.target.value)}
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalSambapos ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
placeholder="SambaPOS5"
|
||||
disabled={useGlobalSambapos}
|
||||
/>
|
||||
</label>
|
||||
<label style={styles.label}>
|
||||
|
|
@ -5019,8 +5133,9 @@ export default function Settings() {
|
|||
type="text"
|
||||
value={sambaDbUsername}
|
||||
onChange={(e) => setSambaDbUsername(e.target.value)}
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalSambapos ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
placeholder="sa"
|
||||
disabled={useGlobalSambapos}
|
||||
/>
|
||||
</label>
|
||||
<label style={styles.label}>
|
||||
|
|
@ -5029,10 +5144,11 @@ export default function Settings() {
|
|||
type="password"
|
||||
value={sambaDbPassword}
|
||||
onChange={(e) => setSambaDbPassword(e.target.value)}
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalSambapos ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
placeholder={sambaSettings?.sambapos_db_password_set ? '********' : 'Enter password'}
|
||||
disabled={useGlobalSambapos}
|
||||
/>
|
||||
{sambaSettings?.sambapos_db_password_set && !sambaDbPassword && (
|
||||
{sambaSettings?.sambapos_db_password_set && !sambaDbPassword && !useGlobalSambapos && (
|
||||
<span style={styles.keyStatus}>Password is configured</span>
|
||||
)}
|
||||
</label>
|
||||
|
|
@ -5861,6 +5977,21 @@ export default function Settings() {
|
|||
Frees up Docker storage after files are safely archived to Nextcloud
|
||||
</p>
|
||||
|
||||
{/* Global settings toggle */}
|
||||
<label style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', marginBottom: '1rem', marginTop: '0.5rem', cursor: 'pointer' }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={useGlobalNextcloud}
|
||||
onChange={(e) => setUseGlobalNextcloud(e.target.checked)}
|
||||
/>
|
||||
<span style={{ fontWeight: 500 }}>Use credentials from main stack settings</span>
|
||||
{useGlobalNextcloud && (
|
||||
<span style={{ fontSize: '0.8rem', padding: '0.15rem 0.5rem', borderRadius: '10px', background: globalStatus?.nextcloud ? '#d4edda' : '#fff3cd', color: globalStatus?.nextcloud ? '#155724' : '#856404' }}>
|
||||
{globalStatus?.nextcloud ? 'Configured' : 'Not configured in stack settings'}
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
|
||||
<label style={styles.label}>
|
||||
Nextcloud Host URL
|
||||
<input
|
||||
|
|
@ -5868,7 +5999,8 @@ export default function Settings() {
|
|||
value={nextcloudHost}
|
||||
onChange={(e) => setNextcloudHost(e.target.value)}
|
||||
placeholder="https://cloud.example.com"
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalNextcloud ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
disabled={useGlobalNextcloud}
|
||||
/>
|
||||
</label>
|
||||
|
||||
|
|
@ -5878,7 +6010,8 @@ export default function Settings() {
|
|||
type="text"
|
||||
value={nextcloudUsername}
|
||||
onChange={(e) => setNextcloudUsername(e.target.value)}
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalNextcloud ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
disabled={useGlobalNextcloud}
|
||||
/>
|
||||
</label>
|
||||
|
||||
|
|
@ -5889,9 +6022,10 @@ export default function Settings() {
|
|||
value={nextcloudPassword}
|
||||
onChange={(e) => setNextcloudPassword(e.target.value)}
|
||||
placeholder={nextcloudSettings?.nextcloud_password_set ? '••••••••' : 'Enter password'}
|
||||
style={styles.input}
|
||||
style={{ ...styles.input, ...(useGlobalNextcloud ? { opacity: 0.4, pointerEvents: 'none' as const } : {}) }}
|
||||
disabled={useGlobalNextcloud}
|
||||
/>
|
||||
{nextcloudSettings?.nextcloud_password_set && (
|
||||
{nextcloudSettings?.nextcloud_password_set && !useGlobalNextcloud && (
|
||||
<span style={styles.keyStatus}>Password is set</span>
|
||||
)}
|
||||
</label>
|
||||
|
|
@ -5920,6 +6054,7 @@ export default function Settings() {
|
|||
nextcloud_base_path: nextcloudBasePath,
|
||||
nextcloud_enabled: nextcloudEnabled,
|
||||
nextcloud_delete_local: nextcloudDeleteLocal,
|
||||
use_global_nextcloud: useGlobalNextcloud,
|
||||
}
|
||||
if (nextcloudPassword) {
|
||||
data.nextcloud_password = nextcloudPassword
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue