Agent code and restructuring

This commit is contained in:
2026-06-04 11:05:21 -04:00
parent 0feac0f0a0
commit 7310e4ed71
134 changed files with 3074 additions and 895 deletions
+263
View File
@@ -0,0 +1,263 @@
@implements IDisposable;
@inject ISearchService searchService
@inject IJSRuntime jsRuntime
@inject NavigationManager navigationManager
@if (searchService.IsLoaded() && searchService.IsVisible)
{
<div class="dialogOverlay" onclick="@CloseDialog">
<div class="dialogContainer searchDialog"
@onclick:preventDefault="true"
@onclick:stopPropagation="true">
<div class="dialogHeader">
<div class="dialogTitle">Search</div>
<button class="dialogCloseBtn" @onclick="CloseDialog">&times;</button>
</div>
<div class="dialogBody">
<div class="searchInputWrapper">
<FormTextComponent OnFocus="OnFocus" Id="searchInput" Placeholder="Type to search..."
OnInput="SearchChanged"></FormTextComponent>
</div>
<div class="searchResults">
@if (SearchText.Length > 0)
{
foreach (var searchSection in searchService.Searches)
{
var searchPoints = searchSection.Value.FindAll(x => x.Title.ToLower().Contains(SearchText.ToLower()));
if (searchPoints.Count > 0)
{
<div class="searchSection">
<div class="searchSectionTitle">@searchSection.Key</div>
<div class="searchSectionItems">
@foreach (var searchPoint in searchPoints)
{
<button class="searchItem @searchPoint.PointType.ToLower()"
@onclick="() => OnSearch(searchPoint)">
<span class="searchItemTitle">@searchPoint.Title</span>
@if (!string.IsNullOrWhiteSpace(searchPoint.Summary))
{
<span class="searchItemSummary"> - @searchPoint.Summary</span>
}
</button>
}
</div>
</div>
}
}
}
</div>
</div>
</div>
</div>
<style>
.dialogOverlay {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: rgba(0, 0, 0, 0.6);
display: flex;
align-items: flex-start;
justify-content: center;
z-index: 1000;
padding-top: 64px;
}
.dialogContainer {
background-color: var(--paper);
border-radius: var(--dialog-radius);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
display: flex;
flex-direction: column;
max-height: calc(100vh - 128px);
overflow: hidden;
}
.searchDialog {
width: 600px;
max-width: calc(100% - 32px);
}
.dialogHeader {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 20px;
border-bottom: 1px solid var(--paper-border);
background-color: var(--accent);
border-radius: var(--dialog-radius) var(--dialog-radius) 0 0;
min-height: 52px;
}
.dialogTitle {
font-size: 1.25rem;
font-weight: 700;
color: white;
}
.dialogCloseBtn {
background: none;
border: none;
color: rgba(255, 255, 255, 0.7);
font-size: 1.5rem;
cursor: pointer;
padding: 0;
line-height: 1;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 6px;
transition: background 0.15s, color 0.15s;
}
.dialogCloseBtn:hover {
background: rgba(255, 255, 255, 0.15);
color: white;
}
.dialogBody {
padding: 20px;
overflow-y: auto;
flex: 1;
}
.searchInputWrapper {
margin-bottom: 16px;
}
.searchResults {
display: flex;
flex-direction: column;
gap: 16px;
}
.searchSection {
display: flex;
flex-direction: column;
}
.searchSectionTitle {
font-weight: 700;
font-size: 0.85rem;
text-transform: uppercase;
letter-spacing: 0.5px;
color: var(--info-secondary-border);
margin-bottom: 8px;
padding-bottom: 4px;
border-bottom: 1px solid var(--paper-border);
}
.searchSectionItems {
display: flex;
flex-direction: column;
gap: 4px;
}
.searchItem {
display: block;
width: 100%;
text-align: left;
background: none;
border: none;
border-radius: 6px;
padding: 8px 12px;
color: var(--text-primary, #ddd);
cursor: pointer;
transition: background 0.15s;
}
.searchItem:hover {
background: var(--paper-hover);
color: white;
}
.searchItemTitle {
font-weight: 600;
}
.searchItemSummary {
color: var(--info-secondary-border);
font-size: 0.9rem;
}
</style>
}
@code {
private string SearchText { get; set; } = "";
protected override void OnInitialized()
{
searchService.Subscribe(OnSearchChanged);
timer = new Timer(200);
timer.Elapsed += FocusTimer;
timer.Enabled = false;
}
private void FocusTimer(object? sender, ElapsedEventArgs e)
{
jsRuntime.InvokeVoidAsync("SetFocusToElement", "searchInput");
StateHasChanged();
}
private Timer timer = null!;
private void OnSearchChanged()
{
if (timer.Enabled != searchService.IsVisible)
{
timer.Enabled = searchService.IsVisible;
}
StateHasChanged();
}
public void Dispose()
{
searchService.Unsubscribe(OnSearchChanged);
timer.Elapsed -= FocusTimer;
}
public void CloseDialog()
{
searchService.Hide();
}
public void NavigateTo(string url)
{
if (url.Contains("#"))
{
navigationManager.NavigateTo(url,
navigationManager.Uri.Split("#").First().Contains(url.Split("#").First()));
}
else
{
navigationManager.NavigateTo(url);
}
}
private void SearchChanged(ChangeEventArgs obj)
{
SearchText = obj.Value!.ToString()!;
}
private void OnSearch(SearchPointModel searchPoint)
{
NavigateTo(searchPoint.Href);
searchService.Hide();
}
private void OnFocus(object obj)
{
timer.Enabled = false;
}
}