Merge pull request 'Add report logos and configurable folder scan depth' (#2) from feat/report-logos-and-scan-depth into main
Reviewed-on: #2
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
</button>
|
||||
@if (_running) { <button class="btn btn-secondary" @onclick="Cancel">Cancel</button> }
|
||||
</div>
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="_status" Current="_current" Total="_total" />
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="@_status" Current="_current" Total="_total" />
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_error)) { <div class="alert alert-error">@_error</div> }
|
||||
@@ -94,7 +94,8 @@
|
||||
_error = string.Empty; _summary = null; _running = true;
|
||||
_cts = new CancellationTokenSource();
|
||||
var validRows = _rows.Where(r => r.IsValid && r.Record != null).Select(r => r.Record!).ToList();
|
||||
var siteUrl = string.IsNullOrWhiteSpace(_siteUrl) ? Session.CurrentProfile!.TenantUrl : _siteUrl.Trim();
|
||||
if (string.IsNullOrWhiteSpace(_siteUrl)) { _error = "Please enter a site URL."; _running = false; return; }
|
||||
var siteUrl = _siteUrl.Trim();
|
||||
var progress = new Progress<OperationProgress>(p => { _status = p.Message; _current = p.Current; _total = p.Total; InvokeAsync(StateHasChanged); });
|
||||
try
|
||||
{
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
</button>
|
||||
@if (_running) { <button class="btn btn-secondary" @onclick="Cancel">Cancel</button> }
|
||||
</div>
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="_status" Current="_current" Total="_total" />
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="@_status" Current="_current" Total="_total" />
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_error)) { <div class="alert alert-error">@_error</div> }
|
||||
|
||||
@@ -14,11 +14,8 @@
|
||||
@if (!Session.HasProfile) { <NoProfilePrompt /> return; }
|
||||
|
||||
<div class="card">
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Site URL</label>
|
||||
<input class="form-input" @bind="_siteUrl" placeholder="@Session.CurrentProfile!.TenantUrl" />
|
||||
</div>
|
||||
<SitePicker Profile="Session.CurrentProfile!" @bind-SelectedSites="_sites" />
|
||||
<div class="form-row mt-8">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Mode</label>
|
||||
<select class="form-select" @bind="_mode" style="width:120px">
|
||||
@@ -47,7 +44,7 @@
|
||||
</button>
|
||||
@if (_running) { <button class="btn btn-secondary" @onclick="Cancel">Cancel</button> }
|
||||
</div>
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="_status" Current="_current" Total="_total" />
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="@_status" Current="_current" Total="_total" />
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_error)) { <div class="alert alert-error">@_error</div> }
|
||||
@@ -58,6 +55,7 @@
|
||||
<div class="flex-row">
|
||||
<div class="card-title">Duplicate Groups <span class="count-badge">@_results.Count</span></div>
|
||||
<div class="spacer"></div>
|
||||
<MergeModeSelect Value="_mergeMode" ValueChanged="v => _mergeMode = v" Visible="_bySite.Count > 1" />
|
||||
<button class="btn btn-secondary btn-sm" @onclick="ExportCsv">Export CSV</button>
|
||||
<button class="btn btn-secondary btn-sm" @onclick="ExportHtml">Export HTML</button>
|
||||
</div>
|
||||
@@ -81,28 +79,43 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
private string _siteUrl = string.Empty, _library = string.Empty, _mode = "Files";
|
||||
private List<SiteInfo> _sites = new();
|
||||
private string _library = string.Empty, _mode = "Files";
|
||||
private bool _matchSize = true, _matchCreated, _matchModified, _matchFolderCount, _matchFileCount;
|
||||
private bool _running; private string _status = string.Empty, _error = string.Empty;
|
||||
private int _current, _total;
|
||||
private List<DuplicateGroup> _results = new();
|
||||
private List<(string Label, IReadOnlyList<DuplicateGroup> Results)> _bySite = new();
|
||||
private ReportMergeMode _mergeMode = ReportMergeMode.SingleMerged;
|
||||
private CancellationTokenSource? _cts;
|
||||
|
||||
private async Task RunScan()
|
||||
{
|
||||
_error = string.Empty; _results.Clear(); _running = true;
|
||||
_error = string.Empty; _results = new(); _bySite = new(); _running = true;
|
||||
_cts = new CancellationTokenSource();
|
||||
var siteUrl = string.IsNullOrWhiteSpace(_siteUrl) ? Session.CurrentProfile!.TenantUrl : _siteUrl.Trim();
|
||||
if (_sites.Count == 0) { _error = "Please select at least one site."; _running = false; return; }
|
||||
var progress = new Progress<OperationProgress>(p => { _status = p.Message; _current = p.Current; _total = p.Total; InvokeAsync(StateHasChanged); });
|
||||
try
|
||||
{
|
||||
var opts = new DuplicateScanOptions(_mode, _matchSize, _matchCreated, _matchModified, _matchFolderCount, _matchFileCount, Library: _library.TrimOrNull());
|
||||
_results = (await Elevation.RunAsync(async c =>
|
||||
var bySite = new List<(string, IReadOnlyList<DuplicateGroup>)>();
|
||||
var flat = new List<DuplicateGroup>();
|
||||
int i = 0;
|
||||
foreach (var site in _sites)
|
||||
{
|
||||
var ctx = await SessionMgr.GetOrCreateContextAsync(siteUrl, Session.CurrentProfile!, c);
|
||||
return await DupSvc.ScanDuplicatesAsync(ctx, opts, progress, c);
|
||||
}, _cts.Token)).ToList();
|
||||
_status = $"Found {_results.Count} duplicate groups.";
|
||||
_cts.Token.ThrowIfCancellationRequested();
|
||||
_status = $"Scanning {site.Title} ({++i}/{_sites.Count})…";
|
||||
await InvokeAsync(StateHasChanged);
|
||||
var groups = await Elevation.RunAsync(async c =>
|
||||
{
|
||||
var ctx = await SessionMgr.GetOrCreateContextAsync(site.Url, Session.CurrentProfile!, c);
|
||||
return await DupSvc.ScanDuplicatesAsync(ctx, opts, progress, c);
|
||||
}, _cts.Token);
|
||||
bySite.Add((site.Title, groups));
|
||||
flat.AddRange(groups);
|
||||
}
|
||||
_bySite = bySite; _results = flat;
|
||||
_status = $"Found {_results.Count} duplicate groups across {_sites.Count} site(s).";
|
||||
}
|
||||
catch (OperationCanceledException) { _status = "Cancelled."; }
|
||||
catch (Exception ex) { _error = ex.Message; }
|
||||
@@ -110,6 +123,16 @@
|
||||
}
|
||||
|
||||
private void Cancel() => _cts?.Cancel();
|
||||
private async Task ExportCsv() { await WebExport.DownloadCsvAsync(CsvExport.BuildCsv(_results), $"duplicates_{DateTime.Now:yyyyMMdd_HHmmss}.csv"); }
|
||||
private async Task ExportHtml() { await WebExport.DownloadHtmlAsync(HtmlExport.BuildHtml(_results), $"duplicates_{DateTime.Now:yyyyMMdd_HHmmss}.html"); }
|
||||
private async Task ExportCsv()
|
||||
{
|
||||
var ts = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||
var output = ReportMergeHelper.Build(_bySite, _mergeMode, "duplicates", ts, ReportFormat.Csv, rs => CsvExport.BuildCsv(rs));
|
||||
await WebExport.DownloadBytesAsync(output.Bytes, output.FileName, output.Mime);
|
||||
}
|
||||
private async Task ExportHtml()
|
||||
{
|
||||
var ts = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||
var output = ReportMergeHelper.Build(_bySite, _mergeMode, "duplicates", ts, ReportFormat.Html, rs => HtmlExport.BuildHtml(rs, Session.CurrentBranding));
|
||||
await WebExport.DownloadBytesAsync(output.Bytes, output.FileName, output.Mime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
</button>
|
||||
@if (_running) { <button class="btn btn-secondary" @onclick="Cancel">Cancel</button> }
|
||||
</div>
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="_status" Current="_current" Total="_total" />
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="@_status" Current="_current" Total="_total" />
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_error)) { <div class="alert alert-error">@_error</div> }
|
||||
@@ -118,8 +118,10 @@
|
||||
var progress = new Progress<OperationProgress>(p => { _status = p.Message; _current = p.Current; _total = p.Total; InvokeAsync(StateHasChanged); });
|
||||
try
|
||||
{
|
||||
var srcUrl = string.IsNullOrWhiteSpace(_srcSiteUrl) ? Session.CurrentProfile!.TenantUrl : _srcSiteUrl.Trim();
|
||||
var dstUrl = string.IsNullOrWhiteSpace(_dstSiteUrl) ? Session.CurrentProfile!.TenantUrl : _dstSiteUrl.Trim();
|
||||
if (string.IsNullOrWhiteSpace(_srcSiteUrl)) { _error = "Please enter a source site URL."; return; }
|
||||
if (string.IsNullOrWhiteSpace(_dstSiteUrl)) { _error = "Please enter a destination site URL."; return; }
|
||||
var srcUrl = _srcSiteUrl.Trim();
|
||||
var dstUrl = _dstSiteUrl.Trim();
|
||||
var job = new TransferJob
|
||||
{
|
||||
SourceSiteUrl = srcUrl, SourceLibrary = _srcLibrary, SourceFolderPath = _srcFolder,
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
</button>
|
||||
@if (_running) { <button class="btn btn-secondary" @onclick="Cancel">Cancel</button> }
|
||||
</div>
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="_status" Current="_current" Total="_total" />
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="@_status" Current="_current" Total="_total" />
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_error)) { <div class="alert alert-error">@_error</div> }
|
||||
@@ -75,7 +75,8 @@
|
||||
_error = string.Empty; _summary = null; _running = true;
|
||||
_cts = new CancellationTokenSource();
|
||||
var validRows = _rows.Where(r => r.IsValid && r.Record != null).Select(r => r.Record!).ToList();
|
||||
var siteUrl = string.IsNullOrWhiteSpace(_siteUrl) ? Session.CurrentProfile!.TenantUrl : _siteUrl.Trim();
|
||||
if (string.IsNullOrWhiteSpace(_siteUrl)) { _error = "Please enter a site URL."; _running = false; return; }
|
||||
var siteUrl = _siteUrl.Trim();
|
||||
var progress = new Progress<OperationProgress>(p => { _status = p.Message; _current = p.Current; _total = p.Total; InvokeAsync(StateHasChanged); });
|
||||
try
|
||||
{
|
||||
|
||||
@@ -15,13 +15,8 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-title">Scan Options</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Site URL</label>
|
||||
<input class="form-input" @bind="_siteUrl" placeholder="@Session.CurrentProfile!.TenantUrl" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<SitePicker Profile="Session.CurrentProfile!" @bind-SelectedSites="_sites" />
|
||||
<div class="form-row mt-8">
|
||||
<div class="form-group" style="flex:0 0 auto">
|
||||
<label class="form-label">Folder Depth</label>
|
||||
<input class="form-input" type="number" @bind="_folderDepth" min="0" max="999" style="width:80px" />
|
||||
@@ -34,14 +29,14 @@
|
||||
</div>
|
||||
<div class="flex-row mt-8">
|
||||
<button class="btn btn-primary" @onclick="RunScan" disabled="@_running">
|
||||
@(_running ? "Scanning…" : "Scan Site")
|
||||
@(_running ? "Scanning…" : "Scan Sites")
|
||||
</button>
|
||||
@if (_running)
|
||||
{
|
||||
<button class="btn btn-secondary" @onclick="Cancel">Cancel</button>
|
||||
}
|
||||
</div>
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="_status" Current="_current" Total="_total" />
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="@_status" Current="_current" Total="_total" />
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_error))
|
||||
@@ -55,6 +50,7 @@
|
||||
<div class="flex-row">
|
||||
<div class="card-title">Results <span class="count-badge">@_results.Count</span></div>
|
||||
<div class="spacer"></div>
|
||||
<MergeModeSelect Value="_mergeMode" ValueChanged="v => _mergeMode = v" Visible="_bySite.Count > 1" />
|
||||
<button class="btn btn-secondary btn-sm" @onclick="ExportCsv">Export CSV</button>
|
||||
<button class="btn btn-secondary btn-sm" @onclick="ExportHtml">Export HTML</button>
|
||||
</div>
|
||||
@@ -91,7 +87,7 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
private string _siteUrl = string.Empty;
|
||||
private List<SiteInfo> _sites = new();
|
||||
private bool _includeInherited, _includeSubsites;
|
||||
private bool _scanFolders = true;
|
||||
private int _folderDepth = 1;
|
||||
@@ -100,23 +96,37 @@
|
||||
private string _error = string.Empty;
|
||||
private int _current, _total;
|
||||
private List<PermissionEntry> _results = new();
|
||||
private List<(string Label, IReadOnlyList<PermissionEntry> Results)> _bySite = new();
|
||||
private ReportMergeMode _mergeMode = ReportMergeMode.SingleMerged;
|
||||
private CancellationTokenSource? _cts;
|
||||
|
||||
private async Task RunScan()
|
||||
{
|
||||
_error = string.Empty; _results.Clear(); _running = true;
|
||||
_error = string.Empty; _results = new(); _bySite = new(); _running = true;
|
||||
_cts = new CancellationTokenSource();
|
||||
var siteUrl = string.IsNullOrWhiteSpace(_siteUrl) ? Session.CurrentProfile!.TenantUrl : _siteUrl.Trim();
|
||||
if (_sites.Count == 0) { _error = "Please select at least one site."; _running = false; return; }
|
||||
var progress = new Progress<OperationProgress>(p => { _status = p.Message; _current = p.Current; _total = p.Total; InvokeAsync(StateHasChanged); });
|
||||
try
|
||||
{
|
||||
var opts = new ScanOptions(_includeInherited, _scanFolders, _folderDepth, _includeSubsites);
|
||||
_results = (await Elevation.RunAsync(async c =>
|
||||
var bySite = new List<(string, IReadOnlyList<PermissionEntry>)>();
|
||||
var flat = new List<PermissionEntry>();
|
||||
int i = 0;
|
||||
foreach (var site in _sites)
|
||||
{
|
||||
var ctx = await SessionMgr.GetOrCreateContextAsync(siteUrl, Session.CurrentProfile!, c);
|
||||
return await PermSvc.ScanSiteAsync(ctx, opts, progress, c);
|
||||
}, _cts.Token)).ToList();
|
||||
_status = $"Scan complete: {_results.Count} entries found.";
|
||||
_cts.Token.ThrowIfCancellationRequested();
|
||||
_status = $"Scanning {site.Title} ({++i}/{_sites.Count})…";
|
||||
await InvokeAsync(StateHasChanged);
|
||||
var entries = await Elevation.RunAsync(async c =>
|
||||
{
|
||||
var ctx = await SessionMgr.GetOrCreateContextAsync(site.Url, Session.CurrentProfile!, c);
|
||||
return await PermSvc.ScanSiteAsync(ctx, opts, progress, c);
|
||||
}, _cts.Token);
|
||||
bySite.Add((site.Title, entries));
|
||||
flat.AddRange(entries);
|
||||
}
|
||||
_bySite = bySite; _results = flat;
|
||||
_status = $"Scan complete: {_results.Count} entries across {_sites.Count} site(s).";
|
||||
}
|
||||
catch (OperationCanceledException) { _status = "Cancelled."; }
|
||||
catch (Exception ex) { _error = ex.Message; }
|
||||
@@ -127,13 +137,17 @@
|
||||
|
||||
private async Task ExportCsv()
|
||||
{
|
||||
var csv = CsvExport.BuildCsv(_results);
|
||||
await WebExport.DownloadCsvAsync(csv, $"permissions_{DateTime.Now:yyyyMMdd_HHmmss}.csv");
|
||||
var ts = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||
var output = ReportMergeHelper.Build(_bySite, _mergeMode, "permissions", ts, ReportFormat.Csv,
|
||||
rs => CsvExport.BuildCsv(rs));
|
||||
await WebExport.DownloadBytesAsync(output.Bytes, output.FileName, output.Mime);
|
||||
}
|
||||
|
||||
private async Task ExportHtml()
|
||||
{
|
||||
var html = HtmlExport.BuildHtml(_results);
|
||||
await WebExport.DownloadHtmlAsync(html, $"permissions_{DateTime.Now:yyyyMMdd_HHmmss}.html");
|
||||
var ts = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||
var output = ReportMergeHelper.Build(_bySite, _mergeMode, "permissions", ts, ReportFormat.Html,
|
||||
rs => HtmlExport.BuildHtml(rs, Session.CurrentBranding));
|
||||
await WebExport.DownloadBytesAsync(output.Bytes, output.FileName, output.Mime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,6 +146,12 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label">Client logo (optional)</label>
|
||||
<small class="text-muted d-block" style="margin-bottom:6px">Shown top-right on exported reports for this client.</small>
|
||||
<LogoUpload Value="_form.ClientLogo" ValueChanged="(LogoData? l) => _form.ClientLogo = l" />
|
||||
</div>
|
||||
|
||||
<div class="flex-row mt-8">
|
||||
<button class="btn btn-primary" @onclick="SaveProfile">Save</button>
|
||||
<button class="btn btn-secondary" @onclick="CancelForm">Cancel</button>
|
||||
@@ -214,7 +220,7 @@
|
||||
private void EditProfile(TenantProfile p)
|
||||
{
|
||||
_editing = p;
|
||||
_form = new TenantProfile { Id = p.Id, Name = p.Name, TenantUrl = p.TenantUrl, TenantId = p.TenantId, ClientId = p.ClientId };
|
||||
_form = new TenantProfile { Id = p.Id, Name = p.Name, TenantUrl = p.TenantUrl, TenantId = p.TenantId, ClientId = p.ClientId, ClientLogo = p.ClientLogo };
|
||||
_showForm = true;
|
||||
_formError = _pageError = string.Empty;
|
||||
}
|
||||
|
||||
@@ -15,11 +15,8 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-title">Search Options</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Site URL</label>
|
||||
<input class="form-input" @bind="_siteUrl" placeholder="@Session.CurrentProfile!.TenantUrl" />
|
||||
</div>
|
||||
<SitePicker Profile="Session.CurrentProfile!" @bind-SelectedSites="_sites" />
|
||||
<div class="form-row mt-8">
|
||||
<div class="form-group">
|
||||
<label class="form-label">File Extensions (comma-separated)</label>
|
||||
<input class="form-input" @bind="_extensions" placeholder="docx, xlsx, pdf" />
|
||||
@@ -55,7 +52,7 @@
|
||||
</button>
|
||||
@if (_running) { <button class="btn btn-secondary" @onclick="Cancel">Cancel</button> }
|
||||
</div>
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="_status" Current="_current" Total="_total" />
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="@_status" Current="_current" Total="_total" />
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_error)) { <div class="alert alert-error">@_error</div> }
|
||||
@@ -66,6 +63,7 @@
|
||||
<div class="flex-row">
|
||||
<div class="card-title">Results <span class="count-badge">@_results.Count</span></div>
|
||||
<div class="spacer"></div>
|
||||
<MergeModeSelect Value="_mergeMode" ValueChanged="v => _mergeMode = v" Visible="_bySite.Count > 1" />
|
||||
<button class="btn btn-secondary btn-sm" @onclick="ExportCsv">Export CSV</button>
|
||||
<button class="btn btn-secondary btn-sm" @onclick="ExportHtml">Export HTML</button>
|
||||
</div>
|
||||
@@ -92,30 +90,45 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
private string _siteUrl = string.Empty, _extensions = string.Empty, _regex = string.Empty;
|
||||
private List<SiteInfo> _sites = new();
|
||||
private string _extensions = string.Empty, _regex = string.Empty;
|
||||
private string _createdBy = string.Empty, _modifiedBy = string.Empty, _library = string.Empty;
|
||||
private int _maxResults = 5000;
|
||||
private bool _running; private string _status = string.Empty, _error = string.Empty;
|
||||
private int _current, _total;
|
||||
private List<SearchResult> _results = new();
|
||||
private List<(string Label, IReadOnlyList<SearchResult> Results)> _bySite = new();
|
||||
private ReportMergeMode _mergeMode = ReportMergeMode.SingleMerged;
|
||||
private CancellationTokenSource? _cts;
|
||||
|
||||
private async Task RunSearch()
|
||||
{
|
||||
_error = string.Empty; _results.Clear(); _running = true;
|
||||
_error = string.Empty; _results = new(); _bySite = new(); _running = true;
|
||||
_cts = new CancellationTokenSource();
|
||||
var siteUrl = string.IsNullOrWhiteSpace(_siteUrl) ? Session.CurrentProfile!.TenantUrl : _siteUrl.Trim();
|
||||
if (_sites.Count == 0) { _error = "Please select at least one site."; _running = false; return; }
|
||||
var progress = new Progress<OperationProgress>(p => { _status = p.Message; _current = p.Current; _total = p.Total; InvokeAsync(StateHasChanged); });
|
||||
try
|
||||
{
|
||||
var exts = _extensions.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
var opts = new SearchOptions(exts, _regex, null, null, null, null, _createdBy.TrimOrNull(), _modifiedBy.TrimOrNull(), _library.TrimOrNull(), _maxResults, siteUrl);
|
||||
_results = (await Elevation.RunAsync(async c =>
|
||||
var bySite = new List<(string, IReadOnlyList<SearchResult>)>();
|
||||
var flat = new List<SearchResult>();
|
||||
int i = 0;
|
||||
foreach (var site in _sites)
|
||||
{
|
||||
var ctx = await SessionMgr.GetOrCreateContextAsync(siteUrl, Session.CurrentProfile!, c);
|
||||
return await SearchSvc.SearchFilesAsync(ctx, opts, progress, c);
|
||||
}, _cts.Token)).ToList();
|
||||
_status = $"Found {_results.Count} files.";
|
||||
_cts.Token.ThrowIfCancellationRequested();
|
||||
_status = $"Searching {site.Title} ({++i}/{_sites.Count})…";
|
||||
await InvokeAsync(StateHasChanged);
|
||||
var opts = new SearchOptions(exts, _regex, null, null, null, null, _createdBy.TrimOrNull(), _modifiedBy.TrimOrNull(), _library.TrimOrNull(), _maxResults, site.Url);
|
||||
var found = await Elevation.RunAsync(async c =>
|
||||
{
|
||||
var ctx = await SessionMgr.GetOrCreateContextAsync(site.Url, Session.CurrentProfile!, c);
|
||||
return await SearchSvc.SearchFilesAsync(ctx, opts, progress, c);
|
||||
}, _cts.Token);
|
||||
bySite.Add((site.Title, found));
|
||||
flat.AddRange(found);
|
||||
}
|
||||
_bySite = bySite; _results = flat;
|
||||
_status = $"Found {_results.Count} files across {_sites.Count} site(s).";
|
||||
}
|
||||
catch (OperationCanceledException) { _status = "Cancelled."; }
|
||||
catch (Exception ex) { _error = ex.Message; }
|
||||
@@ -123,6 +136,16 @@
|
||||
}
|
||||
|
||||
private void Cancel() => _cts?.Cancel();
|
||||
private async Task ExportCsv() { await WebExport.DownloadCsvAsync(CsvExport.BuildCsv(_results), $"search_{DateTime.Now:yyyyMMdd_HHmmss}.csv"); }
|
||||
private async Task ExportHtml() { await WebExport.DownloadHtmlAsync(HtmlExport.BuildHtml(_results), $"search_{DateTime.Now:yyyyMMdd_HHmmss}.html"); }
|
||||
private async Task ExportCsv()
|
||||
{
|
||||
var ts = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||
var output = ReportMergeHelper.Build(_bySite, _mergeMode, "search", ts, ReportFormat.Csv, rs => CsvExport.BuildCsv(rs));
|
||||
await WebExport.DownloadBytesAsync(output.Bytes, output.FileName, output.Mime);
|
||||
}
|
||||
private async Task ExportHtml()
|
||||
{
|
||||
var ts = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||
var output = ReportMergeHelper.Build(_bySite, _mergeMode, "search", ts, ReportFormat.Html, rs => HtmlExport.BuildHtml(rs, Session.CurrentBranding));
|
||||
await WebExport.DownloadBytesAsync(output.Bytes, output.FileName, output.Mime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,21 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-title">Report Branding</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">MSP logo</label>
|
||||
<p class="text-muted" style="margin-top:0">Shown top-left on exported HTML reports. The client's logo (top-right) is set per profile.</p>
|
||||
<LogoUpload Value="_mspLogo" ValueChanged="OnMspLogoChanged" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (_saved) { <div class="alert alert-success">Settings saved.</div> }
|
||||
|
||||
@code {
|
||||
private string _lang = "en", _theme = "System";
|
||||
private bool _autoTakeOwnership, _saved;
|
||||
private LogoData? _mspLogo;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
@@ -47,11 +57,18 @@
|
||||
_lang = s.Lang;
|
||||
_theme = s.Theme is "System" or "Light" ? s.Theme : "System";
|
||||
_autoTakeOwnership = s.AutoTakeOwnership;
|
||||
_mspLogo = s.MspLogo;
|
||||
}
|
||||
|
||||
private async Task OnMspLogoChanged(LogoData? logo)
|
||||
{
|
||||
_mspLogo = logo;
|
||||
await Save();
|
||||
}
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
Session.UpdateSettings(new AppSettings { Lang = _lang, Theme = _theme, AutoTakeOwnership = _autoTakeOwnership });
|
||||
Session.UpdateSettings(new AppSettings { Lang = _lang, Theme = _theme, AutoTakeOwnership = _autoTakeOwnership, MspLogo = _mspLogo });
|
||||
SharepointToolbox.Web.Localization.TranslationSource.Instance.SetCulture(_lang);
|
||||
await JS.InvokeVoidAsync("sptb.setTheme", _theme);
|
||||
_saved = true;
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-title">Scan Options</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Site URL</label>
|
||||
<input class="form-input" @bind="_siteUrl" placeholder="@Session.CurrentProfile!.TenantUrl" />
|
||||
<SitePicker Profile="Session.CurrentProfile!" @bind-SelectedSites="_sites" />
|
||||
<div class="form-row mt-8">
|
||||
<div class="form-group" style="max-width:220px">
|
||||
<label class="form-label">Folder scan depth</label>
|
||||
<input class="form-input" type="number" min="0" max="20" @bind="_folderDepth" />
|
||||
<small class="text-muted">0 = libraries only. 1+ = drill into subfolders that many levels deep.</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
@@ -32,9 +34,10 @@
|
||||
<button class="btn btn-primary" @onclick="RunScan" disabled="@_running">
|
||||
@(_running ? "Scanning…" : "Scan Storage")
|
||||
</button>
|
||||
@if (_sites.Count > 0) { <span class="text-muted" style="align-self:center">@_sites.Count site(s) selected</span> }
|
||||
@if (_running) { <button class="btn btn-secondary" @onclick="Cancel">Cancel</button> }
|
||||
</div>
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="_status" Current="_current" Total="_total" />
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="@_status" Current="_current" Total="_total" />
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_error)) { <div class="alert alert-error">@_error</div> }
|
||||
@@ -45,6 +48,7 @@
|
||||
<div class="flex-row">
|
||||
<div class="card-title">Storage Report <span class="count-badge">@_results.Count libraries</span></div>
|
||||
<div class="spacer"></div>
|
||||
<MergeModeSelect Value="_mergeMode" ValueChanged="v => _mergeMode = v" Visible="_bySite.Count > 1" />
|
||||
<button class="btn btn-secondary btn-sm" @onclick="ExportCsv">Export CSV</button>
|
||||
<button class="btn btn-secondary btn-sm" @onclick="ExportHtml">Export HTML</button>
|
||||
</div>
|
||||
@@ -79,28 +83,43 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
private string _siteUrl = string.Empty;
|
||||
private List<SiteInfo> _sites = new();
|
||||
private bool _includeSubsites, _includeHidden = true, _includeRecycleBin = true;
|
||||
private int _folderDepth;
|
||||
private bool _running; private string _status = string.Empty, _error = string.Empty;
|
||||
private int _current, _total;
|
||||
private List<StorageNode> _results = new();
|
||||
private List<(string Label, IReadOnlyList<StorageNode> Results)> _bySite = new();
|
||||
private ReportMergeMode _mergeMode = ReportMergeMode.SingleMerged;
|
||||
private CancellationTokenSource? _cts;
|
||||
|
||||
private async Task RunScan()
|
||||
{
|
||||
_error = string.Empty; _results.Clear(); _running = true;
|
||||
_error = string.Empty; _results = new(); _bySite = new(); _running = true;
|
||||
_cts = new CancellationTokenSource();
|
||||
var siteUrl = string.IsNullOrWhiteSpace(_siteUrl) ? Session.CurrentProfile!.TenantUrl : _siteUrl.Trim();
|
||||
if (_sites.Count == 0) { _error = "Please select at least one site."; _running = false; return; }
|
||||
var progress = new Progress<OperationProgress>(p => { _status = p.Message; _current = p.Current; _total = p.Total; InvokeAsync(StateHasChanged); });
|
||||
try
|
||||
{
|
||||
var opts = new StorageScanOptions(IncludeSubsites: _includeSubsites, IncludeHiddenLibraries: _includeHidden, IncludeRecycleBin: _includeRecycleBin);
|
||||
_results = (await Elevation.RunAsync(async c =>
|
||||
var opts = new StorageScanOptions(IncludeSubsites: _includeSubsites, FolderDepth: Math.Clamp(_folderDepth, 0, 20), IncludeHiddenLibraries: _includeHidden, IncludeRecycleBin: _includeRecycleBin);
|
||||
var bySite = new List<(string, IReadOnlyList<StorageNode>)>();
|
||||
var flat = new List<StorageNode>();
|
||||
int i = 0;
|
||||
foreach (var site in _sites)
|
||||
{
|
||||
var ctx = await SessionMgr.GetOrCreateContextAsync(siteUrl, Session.CurrentProfile!, c);
|
||||
return await StorageSvc.CollectStorageAsync(ctx, opts, progress, c);
|
||||
}, _cts.Token)).ToList();
|
||||
_status = $"Complete: {_results.Count} nodes.";
|
||||
_cts.Token.ThrowIfCancellationRequested();
|
||||
_status = $"Scanning {site.Title} ({++i}/{_sites.Count})…";
|
||||
await InvokeAsync(StateHasChanged);
|
||||
var nodes = await Elevation.RunAsync(async c =>
|
||||
{
|
||||
var ctx = await SessionMgr.GetOrCreateContextAsync(site.Url, Session.CurrentProfile!, c);
|
||||
return await StorageSvc.CollectStorageAsync(ctx, opts, progress, c);
|
||||
}, _cts.Token);
|
||||
bySite.Add((site.Title, nodes));
|
||||
flat.AddRange(nodes);
|
||||
}
|
||||
_bySite = bySite; _results = flat;
|
||||
_status = $"Complete: {_results.Count} nodes across {_sites.Count} site(s).";
|
||||
}
|
||||
catch (OperationCanceledException) { _status = "Cancelled."; }
|
||||
catch (Exception ex) { _error = ex.Message; }
|
||||
@@ -111,12 +130,16 @@
|
||||
|
||||
private async Task ExportCsv()
|
||||
{
|
||||
var csv = CsvExport.BuildCsv(_results);
|
||||
await WebExport.DownloadCsvAsync(csv, $"storage_{DateTime.Now:yyyyMMdd_HHmmss}.csv");
|
||||
var ts = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||
var output = ReportMergeHelper.Build(_bySite, _mergeMode, "storage", ts, ReportFormat.Csv,
|
||||
rs => CsvExport.BuildCsv(rs));
|
||||
await WebExport.DownloadBytesAsync(output.Bytes, output.FileName, output.Mime);
|
||||
}
|
||||
private async Task ExportHtml()
|
||||
{
|
||||
var html = HtmlExport.BuildHtml(_results);
|
||||
await WebExport.DownloadHtmlAsync(html, $"storage_{DateTime.Now:yyyyMMdd_HHmmss}.html");
|
||||
var ts = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||
var output = ReportMergeHelper.Build(_bySite, _mergeMode, "storage", ts, ReportFormat.Html,
|
||||
rs => HtmlExport.BuildHtml(rs, Session.CurrentBranding));
|
||||
await WebExport.DownloadBytesAsync(output.Bytes, output.FileName, output.Mime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<button class="btn btn-primary mt-8" @onclick="CaptureTemplate" disabled="@_running">
|
||||
@(_running ? "Capturing…" : "Capture")
|
||||
</button>
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="_status" />
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="@_status" />
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
</button>
|
||||
@if (_running) { <button class="btn btn-secondary" @onclick="Cancel">Cancel</button> }
|
||||
</div>
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="_status" Current="_current" Total="_total" />
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="@_status" Current="_current" Total="_total" />
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_error)) { <div class="alert alert-error">@_error</div> }
|
||||
@@ -103,5 +103,5 @@
|
||||
|
||||
private void Cancel() => _cts?.Cancel();
|
||||
private async Task ExportCsv() { await WebExport.DownloadCsvAsync(CsvExport.BuildCsv(_results.FirstOrDefault()?.UserDisplayName ?? "Users", _results.FirstOrDefault()?.UserLogin ?? "", _results), $"user_audit_{DateTime.Now:yyyyMMdd_HHmmss}.csv"); }
|
||||
private async Task ExportHtml() { await WebExport.DownloadHtmlAsync(HtmlExport.BuildHtml(_results), $"user_audit_{DateTime.Now:yyyyMMdd_HHmmss}.html"); }
|
||||
private async Task ExportHtml() { await WebExport.DownloadHtmlAsync(HtmlExport.BuildHtml(_results, branding: Session.CurrentBranding), $"user_audit_{DateTime.Now:yyyyMMdd_HHmmss}.html"); }
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
@(_running ? $"Loading… ({_loadCount} users)" : "Load Users")
|
||||
</button>
|
||||
</div>
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="_status" />
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="@_status" />
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_error)) { <div class="alert alert-error">@_error</div> }
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
</button>
|
||||
@if (_running) { <button class="btn btn-secondary" @onclick="Cancel">Cancel</button> }
|
||||
</div>
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="_status" Current="_current" Total="_total" />
|
||||
<ProgressPanel IsRunning="_running" StatusMessage="@_status" Current="_current" Total="_total" />
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_error)) { <div class="alert alert-error">@_error</div> }
|
||||
@@ -109,7 +109,8 @@
|
||||
_loading = true; _error = string.Empty;
|
||||
try
|
||||
{
|
||||
var siteUrl = string.IsNullOrWhiteSpace(_siteUrl) ? Session.CurrentProfile!.TenantUrl : _siteUrl.Trim();
|
||||
if (string.IsNullOrWhiteSpace(_siteUrl)) { _error = "Please enter a site URL."; return; }
|
||||
var siteUrl = _siteUrl.Trim();
|
||||
_libraries = (await Elevation.RunAsync(async c =>
|
||||
{
|
||||
var ctx = await SessionMgr.GetOrCreateContextAsync(siteUrl, Session.CurrentProfile!, c);
|
||||
@@ -126,7 +127,8 @@
|
||||
{
|
||||
_error = string.Empty; _results.Clear(); _running = true;
|
||||
_cts = new CancellationTokenSource();
|
||||
var siteUrl = string.IsNullOrWhiteSpace(_siteUrl) ? Session.CurrentProfile!.TenantUrl : _siteUrl.Trim();
|
||||
if (string.IsNullOrWhiteSpace(_siteUrl)) { _error = "Please enter a site URL."; _running = false; return; }
|
||||
var siteUrl = _siteUrl.Trim();
|
||||
var progress = new Progress<OperationProgress>(p => { _status = p.Message; _current = p.Current; _total = p.Total; InvokeAsync(StateHasChanged); });
|
||||
try
|
||||
{
|
||||
@@ -144,5 +146,5 @@
|
||||
}
|
||||
|
||||
private void Cancel() => _cts?.Cancel();
|
||||
private async Task ExportHtml() { await WebExport.DownloadHtmlAsync(HtmlExport.BuildHtml(_results), $"versions_{DateTime.Now:yyyyMMdd_HHmmss}.html"); }
|
||||
private async Task ExportHtml() { await WebExport.DownloadHtmlAsync(HtmlExport.BuildHtml(_results, Session.CurrentBranding), $"versions_{DateTime.Now:yyyyMMdd_HHmmss}.html"); }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
@using SharepointToolbox.Web.Core.Models
|
||||
|
||||
@* Reusable logo picker. Reads an image into a base64 LogoData (no disk/blob storage). *@
|
||||
<div class="logo-upload">
|
||||
@if (Value is not null)
|
||||
{
|
||||
<div class="flex-row" style="gap:12px;align-items:center">
|
||||
<img src="data:@Value.MimeType;base64,@Value.Base64" alt=""
|
||||
style="max-height:60px;max-width:200px;object-fit:contain;border:1px solid var(--border);border-radius:4px;padding:4px;background:#fff" />
|
||||
<button type="button" class="btn btn-secondary btn-sm" @onclick="Remove">Remove</button>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<InputFile OnChange="OnChange" accept="image/png,image/jpeg,image/svg+xml,image/gif" />
|
||||
<small class="text-muted d-block">PNG, JPEG, SVG or GIF — max @(MaxBytes / 1024) KB.</small>
|
||||
}
|
||||
@if (!string.IsNullOrEmpty(_error)) { <div class="alert alert-error mt-8">@_error</div> }
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public LogoData? Value { get; set; }
|
||||
[Parameter] public EventCallback<LogoData?> ValueChanged { get; set; }
|
||||
|
||||
/// <summary>Upload size cap. Logos are stored inline as base64 in JSON, so keep small.</summary>
|
||||
[Parameter] public long MaxBytes { get; set; } = 512 * 1024;
|
||||
|
||||
private string _error = string.Empty;
|
||||
|
||||
private async Task OnChange(InputFileChangeEventArgs e)
|
||||
{
|
||||
_error = string.Empty;
|
||||
var file = e.File;
|
||||
if (file is null) return;
|
||||
|
||||
if (file.Size > MaxBytes)
|
||||
{
|
||||
_error = $"File too large ({file.Size / 1024} KB). Max {MaxBytes / 1024} KB.";
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
await file.OpenReadStream(MaxBytes).CopyToAsync(ms);
|
||||
var mime = string.IsNullOrWhiteSpace(file.ContentType) ? "image/png" : file.ContentType;
|
||||
var logo = new LogoData { Base64 = Convert.ToBase64String(ms.ToArray()), MimeType = mime };
|
||||
Value = logo;
|
||||
await ValueChanged.InvokeAsync(logo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_error = $"Could not read image: {ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Remove()
|
||||
{
|
||||
Value = null;
|
||||
_error = string.Empty;
|
||||
await ValueChanged.InvokeAsync(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
@* Dropdown for choosing how multi-site reports are bundled on export. *@
|
||||
@if (Visible)
|
||||
{
|
||||
<select class="form-select" style="width:auto;font-size:13px" value="@Value" @onchange="OnChange"
|
||||
title="How to bundle reports when multiple sites are scanned">
|
||||
<option value="@ReportMergeMode.SingleMerged">One document, no tabs</option>
|
||||
<option value="@ReportMergeMode.SingleTabbed">One document, tabs (HTML)</option>
|
||||
<option value="@ReportMergeMode.MultipleFiles">Multiple documents (ZIP)</option>
|
||||
</select>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public ReportMergeMode Value { get; set; }
|
||||
[Parameter] public EventCallback<ReportMergeMode> ValueChanged { get; set; }
|
||||
[Parameter] public bool Visible { get; set; } = true;
|
||||
|
||||
private async Task OnChange(ChangeEventArgs e)
|
||||
{
|
||||
if (Enum.TryParse<ReportMergeMode>(e.Value?.ToString(), out var mode))
|
||||
await ValueChanged.InvokeAsync(mode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
@inject ISiteDiscoveryService SiteDiscovery
|
||||
|
||||
<div class="site-picker">
|
||||
<div class="flex-row" style="gap:8px;align-items:flex-end">
|
||||
<div class="form-group" style="flex:1">
|
||||
<label class="form-label">Sites</label>
|
||||
<input class="form-input" @bind="_filter" @bind:event="oninput" placeholder="Filter loaded sites by name or URL…" />
|
||||
</div>
|
||||
<button class="btn btn-secondary" @onclick="LoadSites" disabled="@_loading">
|
||||
@(_loading ? "Loading…" : (_all.Count > 0 ? "Reload sites" : "Load sites"))
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_error))
|
||||
{
|
||||
<div class="alert alert-error mt-8">@_error</div>
|
||||
}
|
||||
|
||||
@if (_all.Count > 0)
|
||||
{
|
||||
<div class="flex-row mt-8" style="gap:12px;align-items:center">
|
||||
<button class="btn btn-link btn-sm" @onclick="SelectAllFiltered">Select all (@Filtered.Count())</button>
|
||||
<button class="btn btn-link btn-sm" @onclick="ClearSelection">Clear</button>
|
||||
<span class="spacer"></span>
|
||||
<span class="count-badge">@SelectedSites.Count selected</span>
|
||||
</div>
|
||||
<div class="site-picker-list" style="max-height:240px;overflow:auto;border:1px solid var(--border);border-radius:4px;padding:4px;margin-top:6px">
|
||||
@foreach (var s in Filtered)
|
||||
{
|
||||
<label style="display:flex;align-items:center;gap:8px;padding:3px 6px;cursor:pointer">
|
||||
<input type="checkbox" checked="@IsSelected(s)" @onchange="e => Toggle(s, (bool)(e.Value ?? false))" />
|
||||
<span>@s.Title</span>
|
||||
<span class="text-muted" style="font-size:11px">@s.Url</span>
|
||||
</label>
|
||||
}
|
||||
@if (!Filtered.Any())
|
||||
{
|
||||
<div class="text-muted" style="padding:6px">No sites match the filter.</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
else if (!_loading)
|
||||
{
|
||||
<div class="text-muted mt-8" style="font-size:12px">Click “Load sites” to list the tenant’s SharePoint sites, then tick the ones to scan.</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public TenantProfile Profile { get; set; } = default!;
|
||||
[Parameter] public List<SiteInfo> SelectedSites { get; set; } = new();
|
||||
[Parameter] public EventCallback<List<SiteInfo>> SelectedSitesChanged { get; set; }
|
||||
[Parameter] public bool Disabled { get; set; }
|
||||
|
||||
private List<SiteInfo> _all = new();
|
||||
private string _filter = string.Empty;
|
||||
private bool _loading;
|
||||
private string _error = string.Empty;
|
||||
|
||||
private IEnumerable<SiteInfo> Filtered =>
|
||||
string.IsNullOrWhiteSpace(_filter)
|
||||
? _all
|
||||
: _all.Where(s =>
|
||||
s.Title.Contains(_filter, StringComparison.OrdinalIgnoreCase) ||
|
||||
s.Url.Contains(_filter, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
private bool IsSelected(SiteInfo s) =>
|
||||
SelectedSites.Any(x => string.Equals(x.Url, s.Url, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
private async Task LoadSites()
|
||||
{
|
||||
_loading = true; _error = string.Empty;
|
||||
try
|
||||
{
|
||||
_all = (await SiteDiscovery.SearchSitesAsync(Profile)).ToList();
|
||||
if (_all.Count == 0) _error = "No sites returned. The account may lack Sites.Read.All.";
|
||||
}
|
||||
catch (Exception ex) { _error = ex.Message; }
|
||||
finally { _loading = false; }
|
||||
}
|
||||
|
||||
private async Task Toggle(SiteInfo s, bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
if (!IsSelected(s)) SelectedSites.Add(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedSites.RemoveAll(x => string.Equals(x.Url, s.Url, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
await SelectedSitesChanged.InvokeAsync(SelectedSites);
|
||||
}
|
||||
|
||||
private async Task SelectAllFiltered()
|
||||
{
|
||||
foreach (var s in Filtered)
|
||||
if (!IsSelected(s)) SelectedSites.Add(s);
|
||||
await SelectedSitesChanged.InvokeAsync(SelectedSites);
|
||||
}
|
||||
|
||||
private async Task ClearSelection()
|
||||
{
|
||||
SelectedSites.Clear();
|
||||
await SelectedSitesChanged.InvokeAsync(SelectedSites);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user