Initial commit

This commit is contained in:
2026-06-02 10:51:14 +02:00
committed by kawa
commit d19092c84e
182 changed files with 13757 additions and 0 deletions
+74
View File
@@ -0,0 +1,74 @@
@page "/user-directory"
@attribute [Authorize]
@inject IUserSessionService Session
@inject IGraphUserDirectoryService GraphSvc
@rendermode InteractiveServer
<h1 class="page-title">User Directory</h1>
<p class="page-subtitle">Browse all tenant users via Microsoft Graph.</p>
@if (!Session.HasProfile) { <NoProfilePrompt /> return; }
<div class="card">
<div class="flex-row">
<label><input type="checkbox" @bind="_includeGuests" /> Include guests</label>
<button class="btn btn-primary" @onclick="LoadUsers" disabled="@_running">
@(_running ? $"Loading… ({_loadCount} users)" : "Load Users")
</button>
</div>
<ProgressPanel IsRunning="_running" StatusMessage="_status" />
</div>
@if (!string.IsNullOrEmpty(_error)) { <div class="alert alert-error">@_error</div> }
@if (_users.Count > 0)
{
<div class="card">
<div class="flex-row">
<div class="card-title">Users <span class="count-badge">@_users.Count</span></div>
<input class="form-input" style="width:260px" @bind="_filter" @bind:event="oninput" placeholder="Filter by name or email…" />
</div>
<div class="data-table-wrap">
<table class="data-table">
<thead><tr><th>Name</th><th>UPN</th><th>Department</th><th>Job Title</th><th>Type</th></tr></thead>
<tbody>
@foreach (var u in FilteredUsers.Take(500))
{
<tr>
<td>@u.DisplayName</td>
<td>@u.UserPrincipalName</td>
<td>@u.Department</td>
<td>@u.JobTitle</td>
<td><span class="chip @(u.UserType == "Guest" ? "chip-yellow" : "chip-blue")">@(u.UserType ?? "Member")</span></td>
</tr>
}
</tbody>
</table>
</div>
@if (FilteredUsers.Count() > 500) { <div class="text-muted mt-8">Showing first 500 of @FilteredUsers.Count() filtered.</div> }
</div>
}
@code {
private bool _includeGuests, _running;
private string _status = string.Empty, _error = string.Empty, _filter = string.Empty;
private int _loadCount;
private List<GraphDirectoryUser> _users = new();
private IEnumerable<GraphDirectoryUser> FilteredUsers => string.IsNullOrWhiteSpace(_filter)
? _users
: _users.Where(u => u.DisplayName.Contains(_filter, StringComparison.OrdinalIgnoreCase) || u.UserPrincipalName.Contains(_filter, StringComparison.OrdinalIgnoreCase));
private async Task LoadUsers()
{
_error = string.Empty; _users.Clear(); _running = true; _loadCount = 0;
var progress = new Progress<int>(count => { _loadCount = count; InvokeAsync(StateHasChanged); });
try
{
_users = (await GraphSvc.GetUsersAsync(Session.CurrentProfile!, _includeGuests, progress)).ToList();
_status = $"Loaded {_users.Count} users.";
}
catch (Exception ex) { _error = ex.Message; }
finally { _running = false; await InvokeAsync(StateHasChanged); }
}
}