diff --git a/CHANGELOG.md b/CHANGELOG.md index 0836f62..0498c79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,20 @@ Versionierung folgt [Semantic Versioning](https://semver.org/lang/de/) — solan --- +## [0.1.40] - 2026-12-02 + +Include-Gruppen für mehrere Apps (Bulk). + +### Neu + +- **Gruppe für mehrere Apps zuweisen (Bulk)**: Die Mehrfachauswahl-Leiste im Apps-Tab hat jetzt neben *Ausschlussgruppe…* die Aktion **„Gruppe zuweisen…"** für reguläre Include-Zuweisungen. Im Dialog wählt man Aktion (zuweisen/entfernen), Intent (**Required** und/oder **Available**) und die Gruppe — analog zur Ausschlussgruppe. Neuer Endpoint `POST /api/apps/assignments/bulk-assign`; der bestehende `/bulk-exclude` bleibt erhalten. + +### Geändert + +- Die Zuweisungs-Logik im Backend (`Add-GraphAppTargetAssignment`) verarbeitet Include- und Exclude-Ziele über denselben Lade-Merge-Ersetze-Pfad; bestehende Zuweisungen bleiben erhalten, Duplikate werden übersprungen. + +--- + ## [0.1.39] - 2026-11-18 Bulk-Ausschlussgruppen für Apps, App-Typ-Filter. diff --git a/Start.ps1 b/Start.ps1 index fa93e0c..6c411c8 100644 --- a/Start.ps1 +++ b/Start.ps1 @@ -190,7 +190,7 @@ $script:State = [pscustomobject]@{ Session = @() # geplante Zuweisungen } -$script:ToolVersion = "0.1.39" +$script:ToolVersion = "0.1.40" $script:BuildStamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" Write-Host "" diff --git a/installer/build-local.ps1 b/installer/build-local.ps1 index e934e12..ced654b 100644 --- a/installer/build-local.ps1 +++ b/installer/build-local.ps1 @@ -12,7 +12,7 @@ if (Test-Path "$x64Dotnet\dotnet.exe") { $env:DOTNET_ROOT = "C:\Program Files\dotnet" } -$version = "0.1.39" +$version = "0.1.40" $src = "\\Mac\Home\ClaudePRJ\Intune Manager" $stage = "$env:TEMP\IntuneManagerStage" $installerDir = "$src\installer" diff --git a/src/Api.ps1 b/src/Api.ps1 index 0f5a722..b0a8c81 100644 --- a/src/Api.ps1 +++ b/src/Api.ps1 @@ -48,7 +48,8 @@ function Invoke-ApiHandler { "POST /api/membership/bulk" { return Get-MembershipBulkEndpoint -Body $Body } "POST /api/assignments/apply" { return Invoke-ApplyEndpoint -Body $Body } - "POST /api/apps/assignments/bulk-exclude" { return Invoke-AppBulkExcludeEndpoint -Body $Body } + "POST /api/apps/assignments/bulk-exclude" { return Invoke-AppBulkAssignEndpoint -Body $Body } + "POST /api/apps/assignments/bulk-assign" { return Invoke-AppBulkAssignEndpoint -Body $Body } "GET /api/tenants" { return Get-TenantsEndpoint } "POST /api/tenants/switch" { return Switch-TenantEndpoint -Body $Body } @@ -3278,13 +3279,14 @@ function Add-AppAssignmentEndpoint { return @{ ok = $true; appId = $AppId; intent = $intent; targets = @($targets); count = $targets.Count } } -function Invoke-AppBulkExcludeEndpoint { - # Weist MEHREREN Apps in einem Rutsch EINE Ausschlussgruppe zu — oder entfernt - # sie wieder. Body: +function Invoke-AppBulkAssignEndpoint { + # Weist MEHREREN Apps in einem Rutsch EINE Gruppe zu — als Include ODER als + # Ausschluss — oder entfernt sie wieder. Body: # { appIds: [ "", ... ], # groupId: "", # groupName: "", # intents: [ "required", "available" ], # mind. einer + # kind: "include" | "exclude", # Default "exclude" (Rueckwaerts-Kompat.) # action: "add" | "remove" } # Default "add" param($Body) $err = Test-Connected @@ -3309,6 +3311,11 @@ function Invoke-AppBulkExcludeEndpoint { $action = if ($Body.action) { ([string]$Body.action).ToLower() } else { "add" } if ($action -notin @('add','remove')) { return @{ __status = 400; error = "action muss 'add' oder 'remove' sein" } } + # Default 'exclude' haelt die alte /bulk-exclude-Route (und den Detail-Panel- + # Remove) rueckwaerts-kompatibel, auch wenn kein kind mitgeschickt wird. + $kind = if ($Body.kind) { ([string]$Body.kind).ToLower() } else { "exclude" } + if ($kind -notin @('include','exclude')) { return @{ __status = 400; error = "kind muss 'include' oder 'exclude' sein" } } + # Gruppennamen aufloesen (fuer Logging/Cache). Falls nicht mitgeliefert: Graph fragen. $groupName = if ($Body.groupName) { [string]$Body.groupName } else { "" } if ([string]::IsNullOrWhiteSpace($groupName)) { @@ -3325,7 +3332,8 @@ function Invoke-AppBulkExcludeEndpoint { } if ([string]::IsNullOrWhiteSpace($groupName)) { $groupName = $groupId } - Write-Host "[BULK EXCLUDE] action=$action group='$groupName' intents=$($intents -join '+') apps=$($appIds.Count)" -ForegroundColor Cyan + $logTag = if ($kind -eq 'include') { 'BULK INCLUDE' } else { 'BULK EXCLUDE' } + Write-Host "[$logTag] action=$action group='$groupName' intents=$($intents -join '+') apps=$($appIds.Count)" -ForegroundColor Cyan $results = @() $okCount = 0 @@ -3336,11 +3344,11 @@ function Invoke-AppBulkExcludeEndpoint { try { $changed = 0 if ($action -eq 'add') { - $r = Add-GraphAppExclusion -AppId $appId -GroupId $groupId -Intents $intents + $r = Add-GraphAppTargetAssignment -AppId $appId -GroupId $groupId -Intents $intents -Kind $kind $changed = [int]$r.added } else { foreach ($intent in $intents) { - $removed = Remove-GraphAppAssignmentByGroup -AppId $appId -GroupId $groupId -Intent $intent -TargetKind 'exclude' + $removed = Remove-GraphAppAssignmentByGroup -AppId $appId -GroupId $groupId -Intent $intent -TargetKind $kind $changed += @($removed).Count } } @@ -3364,16 +3372,17 @@ function Invoke-AppBulkExcludeEndpoint { try { $j = $rawBody | ConvertFrom-Json; if ($j.error.message) { $graphMsg = [string]$j.error.message } } catch {} } $friendly = if ($graphMsg) { $graphMsg } else { $details.Friendly } - Write-Host "[BULK EXCLUDE] FAIL $appName [$($details.Code)] $friendly" -ForegroundColor Red - if ($rawBody) { Write-Host "[BULK EXCLUDE] GRAPH-BODY: $rawBody" -ForegroundColor DarkYellow } + Write-Host "[$logTag] FAIL $appName [$($details.Code)] $friendly" -ForegroundColor Red + if ($rawBody) { Write-Host "[$logTag] GRAPH-BODY: $rawBody" -ForegroundColor DarkYellow } $results += @{ appId = $appId; appName = $appName; ok = $false; error = $friendly; code = $details.Code } } } - Write-Host "[BULK EXCLUDE] OK=$okCount FAIL=$failCount" -ForegroundColor Green + Write-Host "[$logTag] OK=$okCount FAIL=$failCount" -ForegroundColor Green return @{ ok = ($failCount -eq 0) action = $action + kind = $kind groupId = $groupId groupName = $groupName intents = @($intents) diff --git a/src/Graph.ps1 b/src/Graph.ps1 index f380f37..d86098c 100644 --- a/src/Graph.ps1 +++ b/src/Graph.ps1 @@ -446,20 +446,24 @@ function Add-GraphAppAssignment { Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/beta/deviceAppManagement/mobileApps/$AppId/assign" -Method POST -Body $body } -function Add-GraphAppExclusion { - # Fuegt EINER App eine Ausschlussgruppe (exclusionGroupAssignmentTarget) fuer - # einen oder mehrere Intents hinzu. Wie bei /assign ueblich: bestehende - # Zuweisungen laden, die Ausschluesse mergen (Duplikate ueberspringen) und den - # VOLLEN Satz in EINEM Request schicken (sonst wuerde /assign alles ersetzen). +function Add-GraphAppTargetAssignment { + # Fuegt EINER App eine Gruppen-Zuweisung fuer einen oder mehrere Intents hinzu — + # entweder als Include (groupAssignmentTarget) ODER als Ausschluss + # (exclusionGroupAssignmentTarget). Wie bei /assign ueblich: bestehende + # Zuweisungen laden, die neuen mergen (Duplikate ueberspringen) und den VOLLEN + # Satz in EINEM Request schicken (sonst wuerde /assign alles ersetzen). param( [Parameter(Mandatory=$true)][string]$AppId, - [Parameter(Mandatory=$true)][string]$GroupId, # GUID der Ausschlussgruppe - [string[]]$Intents = @('required') # "required" und/oder "available" + [Parameter(Mandatory=$true)][string]$GroupId, # GUID der Gruppe + [string[]]$Intents = @('required'), # "required" und/oder "available" + [ValidateSet('include','exclude')][string]$Kind = 'exclude' ) $wanted = @(@($Intents) | ForEach-Object { ([string]$_).ToLower() } | Where-Object { $_ -in @('required','available') } | Select-Object -Unique) if ($wanted.Count -eq 0) { throw "Kein gueltiger Intent (required/available) uebergeben." } + $odataType = if ($Kind -eq 'include') { '#microsoft.graph.groupAssignmentTarget' } else { '#microsoft.graph.exclusionGroupAssignmentTarget' } + $existing = Get-GraphMobileAppAssignments -AppId $AppId $assignments = @() $seen = @{} @@ -477,18 +481,18 @@ function Add-GraphAppExclusion { } $added = 0 foreach ($intent in $wanted) { - $key = $intent + '|#microsoft.graph.exclusionGroupAssignmentTarget|' + $GroupId - if ($seen.ContainsKey($key)) { continue } + $key = $intent + '|' + $odataType + '|' + $GroupId + if ($seen.ContainsKey($key)) { continue } # schon mit diesem Intent/Typ zugewiesen $seen[$key] = $true $assignments += @{ '@odata.type' = '#microsoft.graph.mobileAppAssignment' intent = $intent - target = @{ '@odata.type' = '#microsoft.graph.exclusionGroupAssignmentTarget'; groupId = [string]$GroupId } + target = @{ '@odata.type' = $odataType; groupId = [string]$GroupId } settings = $null } $added++ } - if ($added -eq 0) { return @{ added = 0 } } # schon fuer alle Intents ausgeschlossen + if ($added -eq 0) { return @{ added = 0 } } # schon fuer alle Intents vorhanden $body = @{ mobileAppAssignments = @($assignments) } # WICHTIG: Body selbst serialisieren (Depth hoch genug). Die implizite # Serialisierung von Invoke-MgGraphRequest macht aus verschachtelten Werten diff --git a/www/app.js b/www/app.js index 0ac2b51..910ad8c 100644 --- a/www/app.js +++ b/www/app.js @@ -29,8 +29,9 @@ const State = { selectedAppIds: new Set(), }; -// Kontext des Bulk-Ausschluss-Dialogs (gewählte Gruppe) +// Kontext des Bulk-Dialogs (gewählte Gruppe + Art: include|exclude) let bulkExcludeGroup = null; // { id, name } | null +let bulkKind = 'exclude'; // 'include' | 'exclude' let bxGroupTimer = null; let bxGroupAbort = null; @@ -3402,8 +3403,10 @@ function updateBulkBar() { const n = State.selectedAppIds.size; const cnt = document.getElementById('appBulkCount'); if (cnt) cnt.textContent = String(n); + const btnI = document.getElementById('btnBulkInclude'); const btnX = document.getElementById('btnBulkExclude'); const btnC = document.getElementById('btnBulkClear'); + if (btnI) btnI.disabled = n === 0; if (btnX) btnX.disabled = n === 0; if (btnC) btnC.disabled = n === 0; // "Alle sichtbaren"-Checkbox zum Zustand der Liste synchronisieren @@ -3461,17 +3464,49 @@ function bxAction() { return el ? el.value : 'add'; } +// Texte je nach Art (Include-Zuweisung vs. Ausschluss) +function bxTexts() { + return bulkKind === 'include' + ? { + title: 'Gruppe für mehrere Apps', + addTitle: 'Gruppe zuweisen', addDesc: 'Gruppe als Zuweisung zu den gewählten Apps hinzufügen.', + removeTitle: 'Zuweisung entfernen', removeDesc: 'Diese Gruppen-Zuweisung von den gewählten Apps wieder entfernen.', + intentHint: 'Als welche Zuweisung? Available (Firmenportal) und/oder Required (Zwangsinstallation). Mind. einer.', + groupLabel: 'Gruppe suchen', + applyAdd: 'Gruppe zuweisen', applyRemove: 'Zuweisung entfernen', + } + : { + title: 'Ausschlussgruppe für mehrere Apps', + addTitle: 'Ausschluss zuweisen', addDesc: 'Gruppe als Ausschluss zu den gewählten Apps hinzufügen.', + removeTitle: 'Ausschluss entfernen', removeDesc: 'Diese Ausschlussgruppe von den gewählten Apps wieder entfernen.', + intentHint: 'In Intune hängt ein Ausschluss immer an einem Intent. Mind. einer muss gewählt sein.', + groupLabel: 'Ausschlussgruppe suchen', + applyAdd: 'Ausschluss zuweisen', applyRemove: 'Ausschluss entfernen', + }; +} + function updateBxApplyBtn() { const btn = document.getElementById('bxApply'); if (!btn) return; + const t = bxTexts(); const ok = !!bulkExcludeGroup && bxSelectedIntents().length > 0 && State.selectedAppIds.size > 0; btn.disabled = !ok; - btn.textContent = bxAction() === 'remove' ? 'Ausschluss entfernen' : 'Ausschluss zuweisen'; + btn.textContent = bxAction() === 'remove' ? t.applyRemove : t.applyAdd; } -function openBulkExcludeModal() { +function openBulkModal(kind) { if (State.selectedAppIds.size === 0) { toast('Keine Apps ausgewählt', 'warn'); return; } + bulkKind = (kind === 'include') ? 'include' : 'exclude'; resetBxGroup(); + + // Texte im Dialog an die Art anpassen + const t = bxTexts(); + const set = (id, txt) => { const el = document.getElementById(id); if (el) el.textContent = txt; }; + set('bxTitle', t.title); + set('bxAddTitle', t.addTitle); set('bxAddDesc', t.addDesc); + set('bxRemoveTitle', t.removeTitle); set('bxRemoveDesc', t.removeDesc); + set('bxIntentHint', t.intentHint); set('bxGroupLabel', t.groupLabel); + const summary = document.getElementById('bxAppSummary'); if (summary) { const ids = [...State.selectedAppIds]; @@ -3516,25 +3551,31 @@ async function submitBulkExclude() { const group = bulkExcludeGroup; const intents = bxSelectedIntents(); const action = bxAction(); + const kind = bulkKind; const appIds = [...State.selectedAppIds]; if (!group || intents.length === 0 || appIds.length === 0) return; + const noun = kind === 'include' ? 'Zuweisung' : 'Ausschluss'; const verb = action === 'remove' ? 'Entferne' : 'Setze'; - setLoading(`${verb} Ausschluss "${group.name}" für ${appIds.length} App(s)...`); + setLoading(`${verb} ${noun} "${group.name}" für ${appIds.length} App(s)...`); try { - const res = await api('/api/apps/assignments/bulk-exclude', { + const res = await api('/api/apps/assignments/bulk-assign', { method: 'POST', - body: { appIds, groupId: group.id, groupName: group.name, intents, action }, + body: { appIds, groupId: group.id, groupName: group.name, intents, action, kind }, timeoutMs: 600000, }); closeModal('modalBulkExclude'); const ok = res.success || 0, fail = res.errors || 0; - // Client-State nachziehen — nur für erfolgreich geänderte Apps + // Client-State nachziehen — nur für erfolgreich geänderte Apps. + // Include -> Available/RequiredGroups, Exclude -> Available/RequiredExclusions. const okIds = new Set((res.results || []).filter(r => r.ok).map(r => r.appId)); for (const app of State.apps) { if (!okIds.has(app.AppId)) continue; for (const intent of intents) { - const key = intent === 'available' ? 'AvailableExclusions' : 'RequiredExclusions'; + const avail = intent === 'available'; + const key = kind === 'include' + ? (avail ? 'AvailableGroups' : 'RequiredGroups') + : (avail ? 'AvailableExclusions' : 'RequiredExclusions'); if (!Array.isArray(app[key])) app[key] = []; if (action === 'add') { if (!app[key].some(g => g.GroupId === group.id)) { @@ -3544,9 +3585,13 @@ async function submitBulkExclude() { app[key] = app[key].filter(g => g.GroupId !== group.id); } } + if (kind === 'include') { + app.AvailableCount = (app.AvailableGroups || []).length; + app.RequiredCount = (app.RequiredGroups || []).length; + } } if (fail === 0) { - toast(`Ausschluss für ${ok} App(s) ${action === 'remove' ? 'entfernt' : 'gesetzt'}`, 'ok'); + toast(`${noun} für ${ok} App(s) ${action === 'remove' ? 'entfernt' : 'gesetzt'}`, 'ok'); } else { const failNames = (res.results || []).filter(r => !r.ok).map(r => r.appName); toast(`${ok} ok, ${fail} fehlgeschlagen: ${failNames.slice(0, 5).join(', ')}`, 'warn', 'Teilweise fehlgeschlagen'); @@ -3554,7 +3599,7 @@ async function submitBulkExclude() { // Bulk-Auswahl nach dem Lauf leeren und neu rendern clearAppSelection(); } catch (e) { - toast(e.message, 'err', 'Bulk-Ausschluss fehlgeschlagen'); + toast(e.message, 'err', 'Bulk-Zuweisung fehlgeschlagen'); } finally { clearLoading(); } @@ -3563,7 +3608,8 @@ async function submitBulkExclude() { // --- Bulk-Verkabelung --- document.getElementById('btnAppBulk')?.addEventListener('click', () => toggleAppBulkMode()); document.getElementById('btnBulkClear')?.addEventListener('click', () => clearAppSelection()); -document.getElementById('btnBulkExclude')?.addEventListener('click', () => openBulkExcludeModal()); +document.getElementById('btnBulkInclude')?.addEventListener('click', () => openBulkModal('include')); +document.getElementById('btnBulkExclude')?.addEventListener('click', () => openBulkModal('exclude')); document.getElementById('appBulkSelectAll')?.addEventListener('change', e => bulkSelectAllVisible(e.target.checked)); document.getElementById('bxApply')?.addEventListener('click', () => submitBulkExclude()); document.querySelectorAll('input[name="bxAction"]').forEach(el => el.addEventListener('change', updateBxApplyBtn)); diff --git a/www/index.html b/www/index.html index 5fb9107..72114ae 100644 --- a/www/index.html +++ b/www/index.html @@ -242,7 +242,8 @@ 0 ausgewählt
- + + @@ -859,12 +860,12 @@ - +
- +