79 lines
2.7 KiB
Plaintext
79 lines
2.7 KiB
Plaintext
@using NexusReader.UI.Shared.Services
|
|
@using NexusReader.Application.Abstractions.Services
|
|
@using Microsoft.Extensions.Logging
|
|
@using System.Linq
|
|
@inject IFocusModeService FocusMode
|
|
@inject IIdentityService IdentityService
|
|
@inject NavigationManager NavigationManager
|
|
@inject IThemeService ThemeService
|
|
@inject IKnowledgeService KnowledgeService
|
|
@inject ILogger<IntelligenceToolbar> Logger
|
|
@implements IDisposable
|
|
|
|
<aside class="intelligence-toolbar">
|
|
<div class="toolbar-top">
|
|
<button class="toolbar-item" @onclick='() => NavigationManager.NavigateTo("/")' title="Back to Dashboard">
|
|
<NexusIcon Name="arrow-left" Size="20" />
|
|
</button>
|
|
|
|
@if (FocusMode.IsFocusModeActive)
|
|
{
|
|
<button class="toolbar-item active" @onclick="FocusMode.ToggleAsync" title="Focus Mode Active (Click to Exit)">
|
|
<NexusIcon Name="target" Size="20" />
|
|
</button>
|
|
}
|
|
else
|
|
{
|
|
<button class="toolbar-item active" @onclick="FocusMode.ToggleAsync" title="Chat Active (Click to Focus)">
|
|
<NexusIcon Name="message-square" Size="20" />
|
|
</button>
|
|
}
|
|
</div>
|
|
|
|
<div class="toolbar-bottom">
|
|
<div class="toolbar-separator"></div>
|
|
|
|
<button class="toolbar-item" @onclick="ThemeService.ToggleTheme" title="Przełącz motyw">
|
|
<NexusIcon Name="@(ThemeService.IsLightMode ? "sun" : "moon")" Size="20" />
|
|
</button>
|
|
|
|
<div class="toolbar-separator"></div>
|
|
|
|
<button class="toolbar-item clear-cache-item" @onclick="HandleClearCache" title="Wyczyść pamięć AI">
|
|
<NexusIcon Name="trash" Size="20" />
|
|
</button>
|
|
</div>
|
|
</aside>
|
|
|
|
@code {
|
|
protected override void OnInitialized()
|
|
{
|
|
FocusMode.OnFocusModeChanged += HandleUpdate;
|
|
ThemeService.OnThemeChanged += HandleThemeChanged;
|
|
}
|
|
|
|
private async Task HandleClearCache()
|
|
{
|
|
Logger.LogInformation("[IntelligenceToolbar] Requesting cache clear...");
|
|
var result = await KnowledgeService.ClearCacheAsync();
|
|
if (result.IsSuccess)
|
|
{
|
|
Logger.LogInformation("[IntelligenceToolbar] Cache cleared successfully.");
|
|
}
|
|
else
|
|
{
|
|
Logger.LogWarning("[IntelligenceToolbar] Cache clear failed: {Errors}", string.Join("; ", result.Errors.Select(e => e.Message)));
|
|
}
|
|
}
|
|
|
|
private Task HandleUpdate() => InvokeAsync(StateHasChanged);
|
|
|
|
private void HandleThemeChanged(ThemeMode mode) => InvokeAsync(StateHasChanged);
|
|
|
|
public void Dispose()
|
|
{
|
|
FocusMode.OnFocusModeChanged -= HandleUpdate;
|
|
ThemeService.OnThemeChanged -= HandleThemeChanged;
|
|
}
|
|
}
|