+ Export your .env configuration for backup or import a previously saved configuration. +
+@@ -1223,6 +1256,11 @@ // SquidWTF settings document.getElementById('config-squid-quality').textContent = data.squidWtf.quality; + // MusicBrainz settings + document.getElementById('config-musicbrainz-enabled').textContent = data.musicBrainz.enabled ? 'Yes' : 'No'; + document.getElementById('config-musicbrainz-username').textContent = data.musicBrainz.username || '(not set)'; + document.getElementById('config-musicbrainz-password').textContent = data.musicBrainz.password || '(not set)'; + // Qobuz settings document.getElementById('config-qobuz-token').textContent = data.qobuz.userAuthToken || '(not set)'; document.getElementById('config-qobuz-quality').textContent = data.qobuz.quality || 'FLAC'; @@ -1487,6 +1525,61 @@ } } + async function exportEnv() { + try { + const res = await fetch('/api/admin/export-env'); + if (!res.ok) { + throw new Error('Export failed'); + } + + const blob = await res.blob(); + const url = window.URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = `.env.backup.${new Date().toISOString().split('T')[0]}`; + document.body.appendChild(a); + a.click(); + window.URL.revokeObjectURL(url); + document.body.removeChild(a); + + showToast('.env file exported successfully', 'success'); + } catch (error) { + showToast('Failed to export .env file', 'error'); + } + } + + async function importEnv(event) { + const file = event.target.files[0]; + if (!file) return; + + if (!confirm('Import this .env file? This will replace your current configuration.\n\nA backup will be created automatically.\n\nYou will need to restart the container for changes to take effect.')) { + event.target.value = ''; + return; + } + + try { + const formData = new FormData(); + formData.append('file', file); + + const res = await fetch('/api/admin/import-env', { + method: 'POST', + body: formData + }); + + const data = await res.json(); + + if (res.ok) { + showToast(data.message, 'success'); + } else { + showToast(data.error || 'Failed to import .env file', 'error'); + } + } catch (error) { + showToast('Failed to import .env file', 'error'); + } + + event.target.value = ''; + } + async function restartContainer() { if (!confirm('Restart the container to apply configuration changes?\n\nThe dashboard will be temporarily unavailable.')) { return;