Merge branch 'main' of https://git.azuze.fr/kawa/SharepointToolbox-Web
This commit is contained in:
@@ -8,10 +8,11 @@
|
||||
@inject ICsvValidationService CsvValidation
|
||||
@inject BulkResultCsvExportService ExportSvc
|
||||
@inject WebExportService WebExport
|
||||
@inject TranslationSource T
|
||||
@rendermode InteractiveServer
|
||||
|
||||
<h1 class="page-title">Bulk Members</h1>
|
||||
<p class="page-subtitle">Add users to SharePoint groups from a CSV file.</p>
|
||||
<h1 class="page-title">@T["tab.bulkMembers"]</h1>
|
||||
<p class="page-subtitle">@T["bulkmembers.subtitle"]</p>
|
||||
|
||||
@if (!Session.HasProfile) { <NoProfilePrompt /> return; }
|
||||
@if (UserContext.Role < UserRole.TechN1) { <WriteGuard /> return; }
|
||||
@@ -19,18 +20,18 @@
|
||||
<div class="card">
|
||||
<SitePicker Profile="Session.CurrentProfile!" @bind-SelectedSites="_sites" Single="true" />
|
||||
<div class="form-group">
|
||||
<label class="form-label">CSV File (GroupName, GroupUrl, Email, Role)</label>
|
||||
<label class="form-label">@T["bulkmembers.csvlabel"]</label>
|
||||
<InputFile OnChange="LoadFile" accept=".csv" class="form-input" />
|
||||
</div>
|
||||
|
||||
@if (_rows.Count > 0)
|
||||
{
|
||||
<div class="alert alert-info mt-8">
|
||||
@_rows.Count(r => r.IsValid) valid rows, @_rows.Count(r => !r.IsValid) errors.
|
||||
@string.Format(T["bulkmembers.validsummary"], _rows.Count(r => r.IsValid), _rows.Count(r => !r.IsValid))
|
||||
</div>
|
||||
<div class="data-table-wrap" style="max-height:200px;overflow-y:auto">
|
||||
<table class="data-table">
|
||||
<thead><tr><th>Group</th><th>Email</th><th>Role</th><th>Status</th></tr></thead>
|
||||
<thead><tr><th>@T["report.col.group"]</th><th>@T["bulkmembers.email"]</th><th>@T["bulkmembers.role"]</th><th>@T["bulkmembers.status"]</th></tr></thead>
|
||||
<tbody>
|
||||
@foreach (var row in _rows.Take(50))
|
||||
{
|
||||
@@ -48,9 +49,9 @@
|
||||
|
||||
<div class="flex-row mt-8">
|
||||
<button class="btn btn-primary" @onclick="RunBulk" disabled="@(_running || _rows.Count == 0 || _rows.All(r => !r.IsValid))">
|
||||
@(_running ? "Processing…" : "Add Members")
|
||||
@(_running ? T["bulkmembers.processing"] : T["bulkmembers.execute"])
|
||||
</button>
|
||||
@if (_running) { <button class="btn btn-secondary" @onclick="Cancel">Cancel</button> }
|
||||
@if (_running) { <button class="btn btn-secondary" @onclick="Cancel">@T["btn.cancel"]</button> }
|
||||
</div>
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="@_status" Current="_current" Total="_total" />
|
||||
</div>
|
||||
@@ -61,11 +62,11 @@
|
||||
{
|
||||
<div class="card">
|
||||
<div class="alert @(_summary.HasFailures ? "alert-warn" : "alert-success")">
|
||||
Processed: @_summary.SuccessCount / @_summary.TotalCount. Failures: @_summary.FailedCount
|
||||
@string.Format(T["bulkmembers.processed"], _summary.SuccessCount, _summary.TotalCount, _summary.FailedCount)
|
||||
</div>
|
||||
@if (_summary.HasFailures)
|
||||
{
|
||||
<button class="btn btn-secondary btn-sm mt-8" @onclick="ExportErrors">Export Errors CSV</button>
|
||||
<button class="btn btn-secondary btn-sm mt-8" @onclick="ExportErrors">@T["bulkmembers.exporterrors"]</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@@ -92,7 +93,7 @@
|
||||
_cts = new CancellationTokenSource();
|
||||
var validRows = _rows.Where(r => r.IsValid && r.Record != null).Select(r => r.Record!).ToList();
|
||||
var siteUrl = _sites.FirstOrDefault()?.Url;
|
||||
if (string.IsNullOrWhiteSpace(siteUrl)) { _error = "Please select a site."; _running = false; return; }
|
||||
if (string.IsNullOrWhiteSpace(siteUrl)) { _error = T["bulkmembers.err.nosite"]; _running = false; return; }
|
||||
var progress = new Progress<OperationProgress>(p => { _status = p.Message; _current = p.Current; _total = p.Total; InvokeAsync(StateHasChanged); });
|
||||
try
|
||||
{
|
||||
@@ -101,9 +102,9 @@
|
||||
var ctx = await SessionMgr.GetOrCreateContextAsync(siteUrl, Session.CurrentProfile!, c);
|
||||
return await BulkSvc.AddMembersAsync(ctx, Session.CurrentProfile!, validRows, progress, c);
|
||||
}, _cts.Token);
|
||||
_status = $"Complete: {_summary.SuccessCount} added, {_summary.FailedCount} failed.";
|
||||
_status = string.Format(T["bulkmembers.complete"], _summary.SuccessCount, _summary.FailedCount);
|
||||
}
|
||||
catch (OperationCanceledException) { _status = "Cancelled."; }
|
||||
catch (OperationCanceledException) { _status = T["status.cancelled"]; }
|
||||
catch (Exception ex) { _error = ex.Message; }
|
||||
finally { _running = false; await InvokeAsync(StateHasChanged); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user