Merge branch 'main' of https://git.azuze.fr/kawa/SharepointToolbox-Web
This commit is contained in:
@@ -8,47 +8,48 @@
|
||||
@inject SearchHtmlExportService HtmlExport
|
||||
@inject WebExportService WebExport
|
||||
@inject IAuditService Audit
|
||||
@inject TranslationSource T
|
||||
@rendermode InteractiveServer
|
||||
|
||||
<h1 class="page-title">File Search</h1>
|
||||
<h1 class="page-title">@T["tab.search"]</h1>
|
||||
|
||||
@if (!Session.HasProfile) { <NoProfilePrompt /> return; }
|
||||
|
||||
<div class="card">
|
||||
<div class="card-title">Search Options</div>
|
||||
<div class="card-title">@T["srch.options"]</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" />
|
||||
<label class="form-label">@T["srch.lbl.extensions"]</label>
|
||||
<input class="form-input" @bind="_extensions" placeholder="@T["ph.extensions"]" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Regex filter (filename)</label>
|
||||
<input class="form-input" @bind="_regex" placeholder="Optional regex pattern" />
|
||||
<label class="form-label">@T["lbl.regex"]</label>
|
||||
<input class="form-input" @bind="_regex" placeholder="@T["ph.regex"]" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Max results</label>
|
||||
<label class="form-label">@T["lbl.max.results"]</label>
|
||||
<input class="form-input" type="number" @bind="_maxResults" min="1" max="50000" style="width:120px" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Created by</label>
|
||||
<label class="form-label">@T["lbl.created.by"]</label>
|
||||
<input class="form-input" @bind="_createdBy" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Modified by</label>
|
||||
<label class="form-label">@T["lbl.modified.by"]</label>
|
||||
<input class="form-input" @bind="_modifiedBy" />
|
||||
</div>
|
||||
<LibraryPicker Profile="Session.CurrentProfile!" SiteUrl="@(_sites.FirstOrDefault()?.Url)" @bind-Library="_library" Label="Library (optional)" Placeholder="" />
|
||||
<LibraryPicker Profile="Session.CurrentProfile!" SiteUrl="@(_sites.FirstOrDefault()?.Url)" @bind-Library="_library" Label="@T["srch.lbl.library"]" Placeholder="" />
|
||||
</div>
|
||||
<div class="flex-row mt-8">
|
||||
<button class="btn btn-primary" @onclick="RunSearch" disabled="@_running">
|
||||
@(_running ? "Searching…" : "Search")
|
||||
@(_running ? T["audit.searching"] : T["audit.mode.search"])
|
||||
</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>
|
||||
@@ -59,15 +60,15 @@
|
||||
{
|
||||
<div class="card">
|
||||
<div class="flex-row">
|
||||
<div class="card-title">Results <span class="count-badge">@_results.Count</span></div>
|
||||
<div class="card-title">@T["srch.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>
|
||||
<button class="btn btn-secondary btn-sm" @onclick="ExportCsv">@T["audit.btn.exportCsv"]</button>
|
||||
<button class="btn btn-secondary btn-sm" @onclick="ExportHtml">@T["audit.btn.exportHtml"]</button>
|
||||
</div>
|
||||
<div class="data-table-wrap">
|
||||
<table class="data-table">
|
||||
<thead><tr><th>Name</th><th>Ext</th><th>Path</th><th>Created</th><th>Modified</th><th class="num">Size (KB)</th></tr></thead>
|
||||
<thead><tr><th>@T["srch.col.name"]</th><th>@T["srch.col.ext"]</th><th>@T["srch.col.path"]</th><th>@T["srch.col.created"]</th><th>@T["srch.col.modified"]</th><th class="num">@T["srch.col.size.kb"]</th></tr></thead>
|
||||
<tbody>
|
||||
@foreach (var r in _results.Take(500))
|
||||
{
|
||||
@@ -83,7 +84,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@if (_results.Count > 500) { <div class="text-muted mt-8">Showing first 500 of @_results.Count. Export for full results.</div> }
|
||||
@if (_results.Count > 500) { <div class="text-muted mt-8">@(string.Format(T["srch.truncated"], _results.Count))</div> }
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -103,7 +104,7 @@
|
||||
{
|
||||
_error = string.Empty; _results = new(); _bySite = new(); _running = true;
|
||||
_cts = new CancellationTokenSource();
|
||||
if (_sites.Count == 0) { _error = "Please select at least one site."; _running = false; return; }
|
||||
if (_sites.Count == 0) { _error = T["srch.err.noSites"]; _running = false; return; }
|
||||
var progress = new Progress<OperationProgress>(p => { _status = p.Message; _current = p.Current; _total = p.Total; InvokeAsync(StateHasChanged); });
|
||||
try
|
||||
{
|
||||
@@ -114,7 +115,7 @@
|
||||
foreach (var site in _sites)
|
||||
{
|
||||
_cts.Token.ThrowIfCancellationRequested();
|
||||
_status = $"Searching {site.Title} ({++i}/{_sites.Count})…";
|
||||
_status = string.Format(T["srch.status.searchingSite"], 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 =>
|
||||
@@ -126,11 +127,11 @@
|
||||
flat.AddRange(found);
|
||||
}
|
||||
_bySite = bySite; _results = flat;
|
||||
_status = $"Found {_results.Count} files across {_sites.Count} site(s).";
|
||||
_status = string.Format(T["srch.status.found"], _results.Count, _sites.Count);
|
||||
await Audit.LogAsync("FileSearch", Session.CurrentProfile?.Name ?? "", _sites.Select(s => s.Url),
|
||||
$"{_results.Count} files; ext=[{_extensions}] regex=[{_regex}] lib=[{_library}]");
|
||||
}
|
||||
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