Policy-Export: mehrere Policies als Einzeldateien statt Bundle
Bei mehreren ausgewaehlten Policies wird jede als eigene JSON-Datei heruntergeladen (statt einer gebuendelten Datei). 150ms Pause zwischen den Downloads gegen verschluckte Browser-Downloads; Dateinamen bei gleichem Anzeigenamen automatisch eindeutig. Import liest alte Bundles weiterhin. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+12
-12
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user