diff --git a/electron/main.js b/electron/main.js index 4fade6c..b4ca903 100644 --- a/electron/main.js +++ b/electron/main.js @@ -454,7 +454,13 @@ app.whenReady().then(async () => { if (users.find(u => u.name === name)) { return { success: false, error: `Un utilisateur "${name}" existe déjà` }; } - const user = { name, group, input_channel: parseInt(input_channel), output_channel: output_channel !== null && output_channel !== '' ? parseInt(output_channel) : null }; + const parsedInput = input_channel !== null && input_channel !== undefined ? parseInt(input_channel) : null; + const user = { + name, + group, + input_channel: parsedInput, + output_channel: output_channel !== null && output_channel !== '' ? parseInt(output_channel) : null + }; config.server_audio_users = [...users, user]; writeConfig(config); return { success: true, user }; @@ -469,7 +475,13 @@ app.whenReady().then(async () => { const users = config.server_audio_users || []; const idx = users.findIndex(u => u.name === name); if (idx === -1) return { success: false, error: `Utilisateur "${name}" introuvable` }; - config.server_audio_users[idx] = { name, group, input_channel: parseInt(input_channel), output_channel: output_channel !== null && output_channel !== '' ? parseInt(output_channel) : null }; + const parsedInput = input_channel !== null && input_channel !== undefined ? parseInt(input_channel) : null; + config.server_audio_users[idx] = { + name, + group, + input_channel: parsedInput, + output_channel: output_channel !== null && output_channel !== '' ? parseInt(output_channel) : null + }; writeConfig(config); return { success: true }; } catch (error) { diff --git a/electron/ui/app.js b/electron/ui/app.js index 49c96a5..98c5262 100644 --- a/electron/ui/app.js +++ b/electron/ui/app.js @@ -803,7 +803,7 @@ document.addEventListener('DOMContentLoaded', () => { const action = btn.dataset.sauAction; const name = btn.dataset.sauName; if (action === 'edit') { - await editServerAudioUser(name, btn.dataset.sauGroup, parseInt(btn.dataset.sauInput), parseInt(btn.dataset.sauOutput)); + await editServerAudioUser(name, btn.dataset.sauGroup, btn.dataset.sauInput, btn.dataset.sauOutput); } else if (action === 'delete') { await deleteServerAudioUser(name); } @@ -874,9 +874,7 @@ function buildChannelOptions(dir) { label: names[i] ? `Ch ${i}: ${names[i]}` : `Ch ${i}` })); - if (dir === 'output') { - opts.unshift({ value: '', label: 'Aucune sortie' }); - } + opts.unshift({ value: '', label: dir === 'input' ? 'Aucune entrée' : 'Aucune sortie' }); return opts; } @@ -890,8 +888,8 @@ async function addServerAudioUser() { const outOpts = buildChannelOptions('output'); const inputField = inOpts - ? { name: 'input_channel', label: 'Canal d\'entrée', type: 'select', options: inOpts, default: '0' } - : { name: 'input_channel', label: 'Canal entrée (index)', type: 'number', default: 0, min: 0, max: 63 }; + ? { name: 'input_channel', label: 'Canal d\'entrée', type: 'select', options: inOpts, default: '' } + : { name: 'input_channel', label: 'Canal entrée (index, vide = aucune)', type: 'number', default: '', min: 0, max: 63 }; const outputField = outOpts ? { name: 'output_channel', label: 'Canal de sortie', type: 'select', options: outOpts, default: '' } : { name: 'output_channel', label: 'Canal sortie (index, vide = aucune)', type: 'number', default: '', min: 0, max: 63 }; @@ -912,7 +910,7 @@ async function addServerAudioUser() { const res = await window.electronAPI.serverAudioUsers.create({ name: result.name.trim(), group: result.group, - input_channel: parseInt(result.input_channel), + input_channel: result.input_channel !== '' ? parseInt(result.input_channel) : null, output_channel: result.output_channel !== '' ? parseInt(result.output_channel) : null }); @@ -931,10 +929,11 @@ async function editServerAudioUser(name, group, input_channel, output_channel) { const inOpts = buildChannelOptions('input'); const outOpts = buildChannelOptions('output'); + const inputDefault = input_channel !== null && input_channel !== undefined && input_channel !== 'null' ? String(input_channel) : ''; const inputField = inOpts - ? { name: 'input_channel', label: 'Canal d\'entrée', type: 'select', options: inOpts, default: String(input_channel) } - : { name: 'input_channel', label: 'Canal entrée (index)', type: 'number', default: input_channel, min: 0, max: 63 }; - const outputDefault = output_channel !== null && output_channel !== undefined ? String(output_channel) : ''; + ? { name: 'input_channel', label: 'Canal d\'entrée', type: 'select', options: inOpts, default: inputDefault } + : { name: 'input_channel', label: 'Canal entrée (index, vide = aucune)', type: 'number', default: inputDefault, min: 0, max: 63 }; + const outputDefault = output_channel !== null && output_channel !== undefined && output_channel !== 'null' ? String(output_channel) : ''; const outputField = outOpts ? { name: 'output_channel', label: 'Canal de sortie', type: 'select', options: outOpts, default: outputDefault } : { name: 'output_channel', label: 'Canal sortie (index, vide = aucune)', type: 'number', default: outputDefault, min: 0, max: 63 }; @@ -954,7 +953,7 @@ async function editServerAudioUser(name, group, input_channel, output_channel) { const res = await window.electronAPI.serverAudioUsers.update({ name, group: result.group, - input_channel: parseInt(result.input_channel), + input_channel: result.input_channel !== '' ? parseInt(result.input_channel) : null, output_channel: result.output_channel !== '' ? parseInt(result.output_channel) : null }); @@ -1118,6 +1117,15 @@ function showModal({ title, fields = [], confirmLabel = 'Confirmer', confirmClas `; } + if (field.type === 'checkbox') { + return ` +