diff --git a/www/app.js b/www/app.js index 84664de..206e1e9 100644 --- a/www/app.js +++ b/www/app.js @@ -5660,19 +5660,19 @@ async function polExportSelected() { if (res.exports) allExports = allExports.concat(res.exports); } if (!allExports.length) { toast('Nichts exportiert.', 'warn'); return; } - if (allExports.length === 1) { - polDownloadJson(allExports[0].data, allExports[0].fileName || 'policy.json'); - } else { - const stamp = new Date().toISOString().slice(0, 19).replace(/[:T]/g, '').replace(/-/g, ''); - const bundle = { - type: 'IntuneManagerPolicyBundle', - exportDate: new Date().toISOString(), - count: allExports.length, - policies: allExports.map(e => e.data), - }; - polDownloadJson(bundle, `intune-policies_${stamp}.json`); + // Jede ausgewählte Policy als eigene JSON-Datei herunterladen. + const usedNames = new Set(); + for (let i = 0; i < allExports.length; i++) { + const e = allExports[i]; + let fn = e.fileName || `policy_${i + 1}.json`; + // Dateinamens-Kollisionen (z.B. gleicher Anzeigename) eindeutig machen. + if (usedNames.has(fn)) fn = fn.replace(/\.json$/i, '') + `_${i + 1}.json`; + usedNames.add(fn); + polDownloadJson(e.data, fn); + // Kurze Pause, damit der Browser mehrere aufeinanderfolgende Downloads nicht verwirft. + if (i < allExports.length - 1) await new Promise(r => setTimeout(r, 150)); } - toast(`${allExports.length} Policy(s) exportiert (auch im Server-Archiv abgelegt).`, 'ok'); + toast(`${allExports.length} Policy(s) als Einzeldatei(en) exportiert (auch im Server-Archiv abgelegt).`, 'ok'); } catch (e) { toast('Export fehlgeschlagen: ' + e.message, 'err'); } finally {