Skip to content

Commit 7b08bb6

Browse files
committed
ui(settings): always show env form with expected keys when .env.local missing; remove init button
1 parent f020687 commit 7b08bb6

1 file changed

Lines changed: 17 additions & 67 deletions

File tree

ui/static/js/app.js

Lines changed: 17 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,23 @@ async function loadEnv() {
2222
const container = document.getElementById('env-form');
2323
container.innerHTML = '';
2424

25-
// If API failed or returned empty, still offer to initialize .env.local
25+
// If API failed or returned empty, show form built from expected keys
2626
if (!data || (Array.isArray(data) && data.length === 0)) {
27-
const msg = document.createElement('div');
28-
msg.style.marginBottom = '8px';
29-
msg.style.color = '#b33';
30-
msg.innerText = 'Aucun paramètre trouvé — vous pouvez initialiser .env.local à partir du modèle.';
31-
container.appendChild(msg);
32-
// Show init button (reuse existing init endpoint flow)
33-
const initDiv = document.createElement('div');
34-
initDiv.style.marginTop = '10px';
35-
initDiv.innerHTML = `<button id="btn-init-env" class="secondary">Initialiser .env.local</button> <span style="color:#888; font-size:12px; margin-left:8px;">Crée .env.local à partir de .env.example</span>`;
36-
container.appendChild(initDiv);
37-
document.getElementById('btn-init-env').addEventListener('click', async () => {
38-
if (!confirm('Créer .env.local à partir de .env.example ?')) return;
39-
const btn = document.getElementById('btn-init-env');
40-
btn.disabled = true;
41-
btn.innerText = 'Initialisation...';
42-
try {
43-
const r = await fetch('/api/env/init', {method: 'POST'});
44-
const j = await r.json();
45-
if (j.error) alert('Erreur: ' + j.error);
46-
else {
47-
alert('.env.local créé');
48-
// reload form
49-
loadEnv();
50-
}
51-
} catch (e) {
52-
alert('Request failed: ' + e);
53-
} finally {
54-
btn.disabled = false;
55-
btn.innerText = 'Initialiser .env.local';
56-
}
57-
});
58-
return;
27+
data = [
28+
{key: 'SYNC_DIR', value: '', desc: ''},
29+
{key: 'PACKAGES_CONF_DIR', value: '', desc: ''},
30+
{key: 'OBSIDIAN_VAULT', value: '', desc: ''},
31+
{key: 'VSCODE_CONFIG', value: '', desc: ''},
32+
{key: 'SYNC_TYPE', value: '', desc: ''},
33+
{key: 'ENABLE_DOTFILES_SYNC', value: 'false', desc: ''},
34+
{key: 'WIFI_KDBX_DB', value: '', desc: ''},
35+
{key: 'WIFI_KDBX_GROUP', value: 'Wifi', desc: ''},
36+
{key: 'WIFI_KDBX_KEY_FILE', value: '', desc: ''},
37+
{key: 'WIFI_KDBX_DRY_RUN', value: '0', desc: ''},
38+
{key: 'WIFI_KDBX_ASK_PASS', value: '1', desc: ''},
39+
{key: 'AUTO_UPDATE_HOUR', value: '21', desc: ''},
40+
{key: 'AUTO_UPDATE_MINUTE', value: '0', desc: ''}
41+
];
5942
}
6043

6144
// data is now an array of {key, value, desc}
@@ -143,40 +126,7 @@ async function loadEnv() {
143126
});
144127
});
145128

146-
// If .env.local does not exist, show init button
147-
try {
148-
const existsRes = await fetch('/api/env/exists');
149-
const existsData = await existsRes.json();
150-
if (!existsData.exists) {
151-
const initDiv = document.createElement('div');
152-
initDiv.style.marginTop = '10px';
153-
initDiv.innerHTML = `<button id="btn-init-env" class="secondary">Initialiser .env.local</button> <span style="color:#888; font-size:12px; margin-left:8px;">Crée .env.local à partir de .env.example</span>`;
154-
container.prepend(initDiv);
155-
document.getElementById('btn-init-env').addEventListener('click', async () => {
156-
if (!confirm('Créer .env.local à partir de .env.example ?')) return;
157-
const btn = document.getElementById('btn-init-env');
158-
btn.disabled = true;
159-
btn.innerText = 'Initialisation...';
160-
try {
161-
const r = await fetch('/api/env/init', {method: 'POST'});
162-
const j = await r.json();
163-
if (j.error) alert('Erreur: ' + j.error);
164-
else {
165-
alert('.env.local créé');
166-
// reload form
167-
loadEnv();
168-
}
169-
} catch (e) {
170-
alert('Request failed: ' + e);
171-
} finally {
172-
btn.disabled = false;
173-
btn.innerText = 'Initialiser .env.local';
174-
}
175-
});
176-
}
177-
} catch (e) {
178-
// ignore existence check failures
179-
}
129+
// no init button — we always present the editable form
180130
}
181131

182132
async function saveEnv() {

0 commit comments

Comments
 (0)