0 sélectionné(s)
@@ -156,6 +166,13 @@
const selCount = document.getElementById('selection-count');
const btnPre = document.getElementById('btn-prepatch');
const btnPatch = document.getElementById('btn-patch');
+ const fAsset = document.getElementById('filter-asset');
+ const fInter = document.getElementById('filter-intervenant');
+ const fEnv = document.getElementById('filter-env');
+ const fReset = document.getElementById('filter-reset');
+ const fCount = document.getElementById('filter-count');
+
+ let currentRows = [];
function escapeHTML(s){
if (s === null || s === undefined) return '';
@@ -163,18 +180,44 @@
}
function refreshSelection(){
+ const visible = tbody.querySelectorAll('tr:not(.row-hidden)');
+ const visibleCb = tbody.querySelectorAll('tr:not(.row-hidden) input.row-cb');
const checked = tbody.querySelectorAll('input.row-cb:checked').length;
- const total = tbody.querySelectorAll('input.row-cb').length;
- selCount.textContent = checked + ' / ' + total + ' sélectionné(s)';
- selAll.checked = (checked > 0 && checked === total);
- selAllHead.checked = selAll.checked;
- // Pré-patching et patch désactivés tant que les étapes 2/3 ne sont pas faites
- // mais on prépare la condition pour la suite :
+ selCount.textContent = checked + ' sélectionné(s) · ' + visible.length + ' visible(s)';
+ const allVisibleChecked = visibleCb.length > 0 && Array.from(visibleCb).every(cb => cb.checked);
+ selAll.checked = allVisibleChecked;
+ selAllHead.checked = allVisibleChecked;
const hasSel = checked > 0;
btnPre.disabled = !hasSel;
btnPatch.disabled = !hasSel;
}
+ function applyFilters(){
+ const fa = (fAsset.value || '').toLowerCase().trim();
+ const fi = (fInter.value || '').toLowerCase().trim();
+ const fe = (fEnv.value || '').trim();
+ let visibleCount = 0;
+ tbody.querySelectorAll('tr').forEach(tr => {
+ const a = (tr.dataset.asset || '').toLowerCase();
+ const i = (tr.dataset.intervenant || '').toLowerCase();
+ const e = tr.dataset.env || '';
+ const ok = (!fa || a.includes(fa))
+ && (!fi || i.includes(fi))
+ && (!fe || e === fe);
+ if (ok) { tr.classList.remove('row-hidden'); tr.style.display=''; visibleCount++; }
+ else { tr.classList.add('row-hidden'); tr.style.display='none'; }
+ });
+ fCount.textContent = visibleCount + ' / ' + currentRows.length + ' affichées';
+ refreshSelection();
+ }
+
+ function rebuildEnvOptions(rows){
+ const envs = Array.from(new Set(rows.map(r => r.environnement).filter(x => x))).sort();
+ const cur = fEnv.value;
+ fEnv.innerHTML = '
'
+ + envs.map(e => '
').join('');
+ }
+
async function loadSheet(name){
if (!name) { wrap.style.display='none'; empty.style.display='none'; return; }
summary.textContent = 'Chargement…';
@@ -187,12 +230,17 @@
}
empty.style.display='none'; wrap.style.display='';
summary.textContent = j.count + ' lignes';
+ currentRows = j.rows;
+ rebuildEnvOptions(currentRows);
tbody.innerHTML = j.rows.map(r => {
const linkSrv = r.server_id
? '
' + escapeHTML(r.resolved_hostname || r.asset_name) + ''
: '
' + escapeHTML(r.asset_name || '') + ' ⚠';
const pb = r.pb_espace_disque === true ? '
⚠ Oui' : (r.pb_espace_disque === false ? 'Non' : '');
- return '
'
+ return '
'
+ ' | '
+ '' + escapeHTML(r.asset_name||'') + ' | '
+ '' + escapeHTML(r.environnement||'') + ' | '
@@ -209,17 +257,24 @@
+ '
';
}).join('');
tbody.querySelectorAll('input.row-cb').forEach(cb => cb.addEventListener('change', refreshSelection));
- refreshSelection();
+ applyFilters();
}
sel.addEventListener('change', () => loadSheet(sel.value));
function toggleAll(state){
- tbody.querySelectorAll('input.row-cb').forEach(cb => cb.checked = state);
+ tbody.querySelectorAll('tr:not(.row-hidden) input.row-cb').forEach(cb => cb.checked = state);
refreshSelection();
}
selAll.addEventListener('change', () => toggleAll(selAll.checked));
selAllHead.addEventListener('change', () => toggleAll(selAllHead.checked));
+ [fAsset, fInter, fEnv].forEach(el => el.addEventListener('input', applyFilters));
+ fEnv.addEventListener('change', applyFilters);
+ fReset.addEventListener('click', () => {
+ fAsset.value = ''; fInter.value = ''; fEnv.value = '';
+ applyFilters();
+ });
+
btnPre.addEventListener('click', () => {
const ids = Array.from(tbody.querySelectorAll('input.row-cb:checked')).map(cb => cb.dataset.serverId).filter(x => x);
alert('Pré-patching à brancher (étape 2) — ' + ids.length + ' serveur(s) résolu(s) en base.');