feat(dac-wizard): add node name validation and DAC type detection
- Validate node.name format (alsa_output.* or alsa_input.*) - Detect DAC type: USB, PCI, Bluetooth, Virtual - Show visual feedback with color-coded status: - USB DAC: green (bit-perfect supported) - PCI: yellow (depends on hardware) - Bluetooth/Virtual: red (not possible) - Add translations for validation messages (EN/ES/FR/DE)
This commit is contained in:
1 parent
8e74689226
commit
5ce5a57d5b
5 files changed
+156
-5
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { X, CheckCircle } from 'lucide-svelte';
|
import { X, CheckCircle, Check, AlertTriangle, XCircle } from 'lucide-svelte';
|
||||||
import { t } from '$lib/i18n';
|
import { t } from '$lib/i18n';
|
||||||
import WizardStepper, { type Step } from './wizard/WizardStepper.svelte';
|
import WizardStepper, { type Step } from './wizard/WizardStepper.svelte';
|
||||||
import CommandBlock from './wizard/CommandBlock.svelte';
|
import CommandBlock from './wizard/CommandBlock.svelte';
|
||||||
@@ -7,6 +7,28 @@
|
|||||||
import DistroSelector from './wizard/DistroSelector.svelte';
|
import DistroSelector from './wizard/DistroSelector.svelte';
|
||||||
import BitPerfectAppSelector from './wizard/BitPerfectAppSelector.svelte';
|
import BitPerfectAppSelector from './wizard/BitPerfectAppSelector.svelte';
|
||||||
|
|
||||||
|
// DAC node name validation
|
||||||
|
type DacType = 'usb' | 'pci' | 'bluetooth' | 'virtual' | 'unknown';
|
||||||
|
type ValidationStatus = 'empty' | 'valid' | 'invalid';
|
||||||
|
|
||||||
|
function validateNodeName(name: string): ValidationStatus {
|
||||||
|
if (!name.trim()) return 'empty';
|
||||||
|
// Valid patterns: alsa_output.* or alsa_input.*
|
||||||
|
if (/^alsa_(output|input)\.[a-zA-Z0-9_.-]+$/.test(name)) return 'valid';
|
||||||
|
// Might be valid but unusual format
|
||||||
|
if (name.includes('alsa_output') || name.includes('alsa_input')) return 'valid';
|
||||||
|
return 'invalid';
|
||||||
|
}
|
||||||
|
|
||||||
|
function detectDacType(name: string): DacType {
|
||||||
|
const lower = name.toLowerCase();
|
||||||
|
if (lower.includes('usb-') || lower.includes('.usb')) return 'usb';
|
||||||
|
if (lower.includes('pci-') || lower.includes('.pci')) return 'pci';
|
||||||
|
if (lower.includes('bluez') || lower.includes('bluetooth')) return 'bluetooth';
|
||||||
|
if (lower.includes('virtual') || lower.includes('null') || lower.includes('dummy')) return 'virtual';
|
||||||
|
return 'unknown';
|
||||||
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
@@ -64,6 +86,8 @@
|
|||||||
|
|
||||||
// Derived values
|
// Derived values
|
||||||
const currentIndex = $derived(STEPS.indexOf(currentStep));
|
const currentIndex = $derived(STEPS.indexOf(currentStep));
|
||||||
|
const dacValidation = $derived(validateNodeName(dacNodeName));
|
||||||
|
const dacType = $derived(detectDacType(dacNodeName));
|
||||||
|
|
||||||
const steps = $derived<Step[]>(STEPS.map((step, index) => ({
|
const steps = $derived<Step[]>(STEPS.map((step, index) => ({
|
||||||
id: step,
|
id: step,
|
||||||
@@ -259,9 +283,49 @@
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
class="text-input mono"
|
class="text-input mono"
|
||||||
|
class:valid={dacValidation === 'valid'}
|
||||||
|
class:invalid={dacValidation === 'invalid'}
|
||||||
bind:value={dacNodeName}
|
bind:value={dacNodeName}
|
||||||
placeholder={$t('dacWizard.detectDac.inputPlaceholder')}
|
placeholder={$t('dacWizard.detectDac.inputPlaceholder')}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{#if dacValidation === 'valid'}
|
||||||
|
<div class="validation-feedback">
|
||||||
|
<span class="validation-status valid">
|
||||||
|
<Check size={14} />
|
||||||
|
{$t('dacWizard.detectDac.validation.validFormat')}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{#if dacType === 'usb'}
|
||||||
|
<span class="dac-type usb">
|
||||||
|
<CheckCircle size={14} />
|
||||||
|
{$t('dacWizard.detectDac.validation.usbDac')}
|
||||||
|
</span>
|
||||||
|
{:else if dacType === 'pci'}
|
||||||
|
<span class="dac-type pci">
|
||||||
|
<AlertTriangle size={14} />
|
||||||
|
{$t('dacWizard.detectDac.validation.pciDac')}
|
||||||
|
</span>
|
||||||
|
{:else if dacType === 'bluetooth'}
|
||||||
|
<span class="dac-type bluetooth">
|
||||||
|
<XCircle size={14} />
|
||||||
|
{$t('dacWizard.detectDac.validation.bluetoothDac')}
|
||||||
|
</span>
|
||||||
|
{:else if dacType === 'virtual'}
|
||||||
|
<span class="dac-type virtual">
|
||||||
|
<XCircle size={14} />
|
||||||
|
{$t('dacWizard.detectDac.validation.virtualDac')}
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{:else if dacValidation === 'invalid'}
|
||||||
|
<div class="validation-feedback">
|
||||||
|
<span class="validation-status invalid">
|
||||||
|
<XCircle size={14} />
|
||||||
|
{$t('dacWizard.detectDac.validation.invalidFormat')}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -613,6 +677,61 @@
|
|||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text-input.valid {
|
||||||
|
border-color: var(--color-success, #22c55e);
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-input.invalid {
|
||||||
|
border-color: var(--color-error, #ef4444);
|
||||||
|
}
|
||||||
|
|
||||||
|
.validation-feedback {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.validation-status {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.validation-status.valid {
|
||||||
|
color: var(--color-success, #22c55e);
|
||||||
|
}
|
||||||
|
|
||||||
|
.validation-status.invalid {
|
||||||
|
color: var(--color-error, #ef4444);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dac-type {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
font-size: 13px;
|
||||||
|
padding: 6px 10px;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dac-type.usb {
|
||||||
|
color: var(--color-success, #22c55e);
|
||||||
|
background: rgba(34, 197, 94, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dac-type.pci {
|
||||||
|
color: var(--warning, #fbbf24);
|
||||||
|
background: rgba(251, 191, 36, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dac-type.bluetooth,
|
||||||
|
.dac-type.virtual {
|
||||||
|
color: var(--color-error, #ef4444);
|
||||||
|
background: rgba(239, 68, 68, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
.targeting-info {
|
.targeting-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -991,7 +991,15 @@
|
|||||||
"step1": "Finden Sie Ihren DAC unter 'Audio > Sinks'. Notieren Sie die Nummer (z.B. 46).",
|
"step1": "Finden Sie Ihren DAC unter 'Audio > Sinks'. Notieren Sie die Nummer (z.B. 46).",
|
||||||
"step2": "Dann mit dieser Nummer ausführen:",
|
"step2": "Dann mit dieser Nummer ausführen:",
|
||||||
"inputLabel": "node.name eingeben",
|
"inputLabel": "node.name eingeben",
|
||||||
"inputPlaceholder": "alsa_output.usb-..."
|
"inputPlaceholder": "alsa_output.usb-...",
|
||||||
|
"validation": {
|
||||||
|
"validFormat": "Gültiges Format",
|
||||||
|
"invalidFormat": "Ungültiges Format - muss mit alsa_output. oder alsa_input. beginnen",
|
||||||
|
"usbDac": "USB-DAC - Bit-Perfect unterstützt",
|
||||||
|
"pciDac": "Internes Audio - Bit-Perfect abhängig von Hardware",
|
||||||
|
"bluetoothDac": "Bluetooth-Gerät - Bit-Perfect nicht möglich",
|
||||||
|
"virtualDac": "Virtuelles Gerät - Bit-Perfect nicht anwendbar"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"backup": {
|
"backup": {
|
||||||
"title": "Sicherung erstellen",
|
"title": "Sicherung erstellen",
|
||||||
|
|||||||
@@ -1050,7 +1050,15 @@
|
|||||||
"step1": "Find your DAC under 'Audio > Sinks'. Note the number (e.g., 46).",
|
"step1": "Find your DAC under 'Audio > Sinks'. Note the number (e.g., 46).",
|
||||||
"step2": "Then run with that number:",
|
"step2": "Then run with that number:",
|
||||||
"inputLabel": "Enter node.name",
|
"inputLabel": "Enter node.name",
|
||||||
"inputPlaceholder": "alsa_output.usb-..."
|
"inputPlaceholder": "alsa_output.usb-...",
|
||||||
|
"validation": {
|
||||||
|
"validFormat": "Valid format",
|
||||||
|
"invalidFormat": "Invalid format - should start with alsa_output. or alsa_input.",
|
||||||
|
"usbDac": "USB DAC - bit-perfect supported",
|
||||||
|
"pciDac": "Internal audio - bit-perfect depends on hardware",
|
||||||
|
"bluetoothDac": "Bluetooth device - bit-perfect not possible",
|
||||||
|
"virtualDac": "Virtual device - bit-perfect not applicable"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"backup": {
|
"backup": {
|
||||||
"title": "Create Backup",
|
"title": "Create Backup",
|
||||||
|
|||||||
@@ -1050,7 +1050,15 @@
|
|||||||
"step1": "Busca tu DAC en 'Audio > Sinks'. Anota el número (ej. 46).",
|
"step1": "Busca tu DAC en 'Audio > Sinks'. Anota el número (ej. 46).",
|
||||||
"step2": "Luego ejecuta con ese número:",
|
"step2": "Luego ejecuta con ese número:",
|
||||||
"inputLabel": "Ingresa node.name",
|
"inputLabel": "Ingresa node.name",
|
||||||
"inputPlaceholder": "alsa_output.usb-..."
|
"inputPlaceholder": "alsa_output.usb-...",
|
||||||
|
"validation": {
|
||||||
|
"validFormat": "Formato válido",
|
||||||
|
"invalidFormat": "Formato inválido - debe empezar con alsa_output. o alsa_input.",
|
||||||
|
"usbDac": "DAC USB - bit-perfect soportado",
|
||||||
|
"pciDac": "Audio interno - bit-perfect depende del hardware",
|
||||||
|
"bluetoothDac": "Dispositivo Bluetooth - bit-perfect no es posible",
|
||||||
|
"virtualDac": "Dispositivo virtual - bit-perfect no aplica"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"backup": {
|
"backup": {
|
||||||
"title": "Crear Backup",
|
"title": "Crear Backup",
|
||||||
|
|||||||
@@ -991,7 +991,15 @@
|
|||||||
"step1": "Trouvez votre DAC sous 'Audio > Sinks'. Notez le numéro (ex. 46).",
|
"step1": "Trouvez votre DAC sous 'Audio > Sinks'. Notez le numéro (ex. 46).",
|
||||||
"step2": "Puis exécutez avec ce numéro :",
|
"step2": "Puis exécutez avec ce numéro :",
|
||||||
"inputLabel": "Entrez node.name",
|
"inputLabel": "Entrez node.name",
|
||||||
"inputPlaceholder": "alsa_output.usb-..."
|
"inputPlaceholder": "alsa_output.usb-...",
|
||||||
|
"validation": {
|
||||||
|
"validFormat": "Format valide",
|
||||||
|
"invalidFormat": "Format invalide - doit commencer par alsa_output. ou alsa_input.",
|
||||||
|
"usbDac": "DAC USB - bit-perfect supporté",
|
||||||
|
"pciDac": "Audio interne - bit-perfect dépend du matériel",
|
||||||
|
"bluetoothDac": "Appareil Bluetooth - bit-perfect impossible",
|
||||||
|
"virtualDac": "Appareil virtuel - bit-perfect non applicable"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"backup": {
|
"backup": {
|
||||||
"title": "Créer une sauvegarde",
|
"title": "Créer une sauvegarde",
|
||||||
|
|||||||
Reference in new issue
Block a user