Private/Show-StatusDashboard.ps1

<#
.SYNOPSIS
    Displays the status dashboard
.DESCRIPTION
    Shows an overview of the current status of all components
.PARAMETER WorkspacePath
    Path to the workspace folder
#>

function Show-StatusDashboard {
    [CmdletBinding()]
    param(
        [string]$WorkspacePath
    )

    Clear-Host
    Write-Host "`n" -NoNewline
    Write-Host "=" * 80 -ForegroundColor Cyan
    Write-Host " STATUS DASHBOARD" -ForegroundColor Cyan
    Write-Host "=" * 80 -ForegroundColor Cyan
    Write-Host "`n"

    try {
        # Get workspace path
        if (-not $WorkspacePath) {
            $WorkspacePath = Get-WorkspacePath
        }

        # Workspace Folder Status
        Write-Host "Workspace Folder Status:" -ForegroundColor Yellow
        if ($WorkspacePath) {
            if (Test-Path -Path $WorkspacePath) {
                Write-Host " Path: $WorkspacePath" -ForegroundColor Green
                Write-Host " Status: Configured" -ForegroundColor Green
                
                # Check folder size
                $folderSize = (Get-ChildItem -Path $WorkspacePath -Recurse -ErrorAction SilentlyContinue | 
                    Measure-Object -Property Length -Sum).Sum / 1MB
                Write-Host " Size: $([math]::Round($folderSize, 2)) MB" -ForegroundColor White
            }
            else {
                Write-Host " Status: Path not accessible" -ForegroundColor Red
            }
        }
        else {
            Write-Host " Status: Not configured" -ForegroundColor Red
        }

        Write-Host "`n"

        # Configuration Status
        Write-Host "Configuration Status:" -ForegroundColor Yellow
        if ($WorkspacePath) {
            $config = Get-Config -WorkspacePath $WorkspacePath
            if ($config) {
                $appRegConfigured = -not [string]::IsNullOrEmpty($config.AppRegistration.ClientId)
                $openAIConfigured = -not [string]::IsNullOrEmpty($config.OpenAI.Endpoint)
                
                Write-Host " App Registration: $(if ($appRegConfigured) { 'Configured' } else { 'Not configured' })" -ForegroundColor $(if ($appRegConfigured) { 'Green' } else { 'Red' })
                Write-Host " OpenAI: $(if ($openAIConfigured) { 'Configured' } else { 'Not configured' })" -ForegroundColor $(if ($openAIConfigured) { 'Green' } else { 'Red' })
                Write-Host " Overall Status: $(if ($appRegConfigured -and $openAIConfigured) { 'Complete' } else { 'Incomplete' })" -ForegroundColor $(if ($appRegConfigured -and $openAIConfigured) { 'Green' } else { 'Yellow' })
            }
            else {
                Write-Host " Status: Configuration file not found" -ForegroundColor Red
            }
        }
        else {
            Write-Host " Status: Workspace not configured" -ForegroundColor Red
        }

        Write-Host "`n"

        # Baseline Status
        Write-Host "Baseline Status:" -ForegroundColor Yellow
        if ($WorkspacePath) {
            $baselinePath = Join-Path -Path $WorkspacePath -ChildPath "Baseline"
            if (Test-Path -Path $baselinePath) {
                $baselineFiles = Get-ChildItem -Path $baselinePath -Filter "*.json"
                Write-Host " Total Components: $($baselineFiles.Count)" -ForegroundColor White
                
                # Check last update from config
                try {
                    $configPath = Join-Path -Path $WorkspacePath -ChildPath "config.json"
                    if (Test-Path -Path $configPath) {
                        $config = Get-Content -Path $configPath -Raw | ConvertFrom-Json
                        if ($config.Workspace.LastUpdated) {
                            Write-Host " Last Updated: $($config.Workspace.LastUpdated)" -ForegroundColor White
                        }
                        else {
                            Write-Host " Last Updated: Never" -ForegroundColor Gray
                        }
                    }
                }
                catch {
                    Write-Host " Last Updated: Unknown" -ForegroundColor Gray
                }
            }
            else {
                Write-Host " Status: Baseline folder not found" -ForegroundColor Red
            }
        }
        else {
            Write-Host " Status: Workspace not configured" -ForegroundColor Red
        }

        Write-Host "`n"

        # Resource Folders Status
        Write-Host "Resource Folders Status:" -ForegroundColor Yellow
        if ($WorkspacePath) {
            $requiredFolders = @(
                @{ Name = "Baseline"; Required = $true },
                @{ Name = "ExploitProtections"; Required = $true },
                @{ Name = "EventViewerCustomViews"; Required = $true },
                @{ Name = "CountryIPsData"; Required = $true },
                @{ Name = "Mitigations"; Required = $true },
                @{ Name = "IntuneFiles"; Required = $true },
                @{ Name = "WingetAutoUpdate"; Required = $true },
                @{ Name = "Deployment"; Required = $true }
            )
            
            $missingFolders = @()
            $presentFolders = @()
            
            foreach ($folder in $requiredFolders) {
                $folderPath = Join-Path -Path $WorkspacePath -ChildPath $folder.Name
                if (Test-Path -Path $folderPath) {
                    $fileCount = (Get-ChildItem -Path $folderPath -Recurse -File -ErrorAction SilentlyContinue | Measure-Object).Count
                    Write-Host " $($folder.Name): Present ($fileCount files)" -ForegroundColor Green
                    $presentFolders += $folder.Name
                }
                else {
                    Write-Host " $($folder.Name): Missing" -ForegroundColor Red
                    $missingFolders += $folder.Name
                }
            }
            
            if ($missingFolders.Count -gt 0) {
                Write-Host "`n ACTION REQUIRED:" -ForegroundColor Yellow
                Write-Host " Run: Sync-NLBaselineWorkspace -Force" -ForegroundColor Cyan
                Write-Host " Or use menu: 5. Update & Sync → 3. Sync Workspace Resources" -ForegroundColor Cyan
            }
        }

        Write-Host "`n"
        
        # Action Instructions
        if ($WorkspacePath) {
            $config = Get-Config -WorkspacePath $WorkspacePath -ErrorAction SilentlyContinue
            $appRegConfigured = $config -and -not [string]::IsNullOrEmpty($config.AppRegistration.ClientId)
            
            $baselinePath = Join-Path -Path $WorkspacePath -ChildPath "Baseline"
            $baselineExists = Test-Path -Path $baselinePath
            $baselineFiles = if ($baselineExists) { (Get-ChildItem -Path $baselinePath -Filter "*.json" -ErrorAction SilentlyContinue | Measure-Object).Count } else { 0 }
            
            if (-not $appRegConfigured -or $baselineFiles -lt 16) {
                Write-Host ("=" * 80) -ForegroundColor Yellow
                Write-Host " ACTIE VEREIST / ACTION REQUIRED" -ForegroundColor Yellow
                Write-Host ("=" * 80) -ForegroundColor Yellow
                Write-Host ""
                
                if ($baselineFiles -lt 16) {
                    Write-Host "1. SYNCHRONISEER WORKSPACE BESTANDEN:" -ForegroundColor Cyan
                    Write-Host " Menu: 5. Update & Sync → 3. Sync Workspace Resources" -ForegroundColor White
                    Write-Host " Of: Sync-NLBaselineWorkspace -Force" -ForegroundColor White
                    Write-Host " Dit kopieert alle baseline bestanden naar: $WorkspacePath" -ForegroundColor Gray
                    Write-Host ""
                }
                
                if (-not $appRegConfigured) {
                    Write-Host "2. CONFIGUREER APP REGISTRATION:" -ForegroundColor Cyan
                    Write-Host " Menu: 1. Setup → 3. View Configuration" -ForegroundColor White
                    Write-Host " Of: Bewerk config.json handmatig:" -ForegroundColor White
                    Write-Host " Locatie: $WorkspacePath\config.json" -ForegroundColor Gray
                    Write-Host " Vereist: ClientId, ClientSecret, TenantId" -ForegroundColor Gray
                    Write-Host ""
                }
                
                Write-Host "Zie WORKSPACE-SETUP-GUIDE.md voor volledige instructies" -ForegroundColor Yellow
                Write-Host ""
            }
        }
        
        Write-Host "Press any key to continue..." -ForegroundColor Gray
        $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
    }
    catch {
        Write-Host "Error displaying status dashboard: $_" -ForegroundColor Red
        Write-Host "Press any key to continue..." -ForegroundColor Gray
        $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
    }
}