feat(search/rag): implement NexusSearchBox, dynamic Qdrant collection auto-provisioning, batch vector ingestion, mobile Serilog logging, and resolve 401 auth handler error (#51)

Resolves #52

This Pull Request introduces the **NexusSearchBox** search feature with premium unified styling, implements a robust **dynamic Qdrant collection auto-provisioning and batch-vector ingestion pipeline**, integrates a unified **Serilog logging infrastructure** for the Blazor Hybrid environment (MAUI), and resolves the **401 Unauthorized API header propagation error** inside mobile builds.

### 🚀 Key Implementations

#### 1. Premium `NexusSearchBox` & Semantic Search UI
* **NexusSearchBox Component:** Created an elegant search-as-you-type search box with smooth key navigation, quick-clearing, and seamless dynamic styling.
* **Unified Aesthetics:** Refactored the search box isolated styling to align perfectly with the dashboard's design system using glassmorphism, `--nexus-neon` token gradients, and smooth pulse/fade animations.
* **Semantic Search Integration:** Integrated semantic search query dispatching (`SearchLibrarySemanticallyQuery`) and wired up navigation seamlessly through the updated `ReaderNavigationService`.
* **Tests Hardening:** Added/adapted query assertions in `QueryTests.cs` to guarantee safe parameterization and error boundary mapping.

#### 2. Qdrant Collection Provisioning & Vector Ingestion
* **Dynamic Auto-Provisioning:** Implemented dynamic checking and lazy-creation of the `knowledge_units` collection using 768 dimensions and Cosine distance.
* **High-Performance Ingestion:** Optimized `ProcessKnowledgeUnitsAsync` with high-performance batch embedding generation using `_embeddingGenerator` and deterministic MD5 GUIDs for stable, duplicate-free upsertion.
* **Database Cache Clear Sync:** Integrated Qdrant collection deletion in `ClearCacheAsync` to ensure absolute consistency between the PostgreSQL database cache and vector database indices.

#### 3. Cross-Platform MAUI Logging (Serilog Infrastructure)
* **Serilog Integration:** Configured cross-platform Serilog routing in `SerilogConfiguration.cs`, streaming diagnostic logs safely across native platforms and the Blazor Webview container.
* **Interop Bridge:** Built `BlazorLoggingBridge.cs` to capture web console messages and pipe them directly to the native host logger.
* **Demo Interface:** Added an interactive `SerilogDemo.razor` sandbox under Pages.

#### 4. Resolving 401 Load Errors (Authentication Handler Flow)
* **Authentication Header Handler:** Implemented the `MobileAuthenticationHeaderHandler` to correctly extract, validate, and inject bearer JWT tokens into outbound API requests.
* **Configuration-based API Host:** Structured standard API URI routing to use clean configuration bindings in `appsettings.json`.

---

### 🧪 Verification & Build Status
* Run `dotnet build` from the solution root: Successfully compiled the full multi-targeted solution (`Liczba błędów: 0`).
* All unit and integration tests successfully executed and verified (`dotnet test`).

---------

Co-authored-by: Marek Jasiński <jasins.marek@gmail.com>
Co-authored-by: Marek Jaisński <jasins.marek@gmail.com>
Reviewed-on: #51
Co-authored-by: Antigravity <antigravity@google.com>
Co-committed-by: Antigravity <antigravity@google.com>
This commit was merged in pull request #51.
This commit is contained in:
2026-05-26 12:15:28 +00:00
committed by Marek Jaisński
parent 758b152a0c
commit a0bf6c15f4
61 changed files with 5111 additions and 570 deletions
+131 -22
View File
@@ -5,7 +5,10 @@
@using NexusReader.UI.Shared.Services
@inject IIdentityService IdentityService
@inject NavigationManager NavigationManager
@inject ISyncService SyncService
@attribute [Authorize]
@implements IDisposable
<PageTitle>Dashboard | Nexus Reader</PageTitle>
@@ -18,20 +21,20 @@
<img src="https://api.dicebear.com/7.x/bottts/svg?seed=Nexus" alt="Profile" class="profile-img" />
<div class="avatar-glow"></div>
</div>
<h1 class="username">[User_Explorer1988]</h1>
<h1 class="username">@(string.IsNullOrEmpty(_profile?.DisplayName) ? (_profile?.Email.Split('@')[0] ?? "Użytkownik") : _profile.DisplayName)</h1>
<div class="status-pills">
<div class="status-pill">
<span class="pill-label">Books Read:</span>
<span class="pill-value">12</span>
<span class="pill-label">Książki:</span>
<span class="pill-value">@(_profile?.BooksReadCount ?? 0)</span>
</div>
<div class="status-pill">
<span class="pill-label">Concepts Mapped:</span>
<span class="pill-value">450</span>
<span class="pill-label">Pojęcia:</span>
<span class="pill-value">@(_profile?.ConceptsMappedCount ?? 0)</span>
</div>
<div class="status-pill">
<span class="pill-label">Quiz Mastery:</span>
<span class="pill-value">88%</span>
<span class="pill-label">Średni Wynik:</span>
<span class="pill-value">@(_profile?.AverageQuizScore ?? 0)%</span>
</div>
</div>
</div>
@@ -39,7 +42,7 @@
<!-- Main Content Area -->
<main class="dashboard-content">
<h2 class="section-title">Witaj, @(_profile?.Email.Split('@')[0] ?? "Użytkowniku")</h2>
<h2 class="section-title">Witaj, @(string.IsNullOrEmpty(_profile?.DisplayName) ? (_profile?.Email.Split('@')[0] ?? "Użytkowniku") : _profile.DisplayName)</h2>
<div class="main-grid">
<!-- Current Reading Card -->
@@ -49,34 +52,88 @@
<!-- Knowledge Integration -->
<section class="integration-card glass-panel">
<div class="panel-header">
<h4>Knowledge Integration Progress</h4>
<h4>Integracja Wiedzy</h4>
<NexusIcon Name="arrow-right" Size="16" />
</div>
<div class="graph-placeholder">
<div class="graph-node central"></div>
<div class="graph-node satellite" style="--angle: 0deg; --dist: 60px;"></div>
<div class="graph-node satellite" style="--angle: 120deg; --dist: 50px;"></div>
<div class="graph-node satellite" style="--angle: 240deg; --dist: 70px;"></div>
<div class="active-node-label">TU JESTEŚ</div>
<div class="graph-node central" title="Ośrodek Wiedzy Nexus Reader"></div>
@if (_profile?.MappedConcepts != null && _profile.MappedConcepts.Any())
{
@for (int i = 0; i < _profile.MappedConcepts.Count; i++)
{
var concept = _profile.MappedConcepts[i];
var angle = i * (360.0 / _profile.MappedConcepts.Count);
var dist = 65;
<div class="graph-node satellite"
style="--angle: @(angle)deg; --dist: @(dist)px;"
title="[@concept.Type] @concept.Content"
@onmouseover="() => SetHoveredConcept(concept)"
@onmouseout="ClearHoveredConcept">
</div>
}
}
else
{
<div class="graph-node satellite" style="--angle: 0deg; --dist: 60px;"></div>
<div class="graph-node satellite" style="--angle: 120deg; --dist: 50px;"></div>
<div class="graph-node satellite" style="--angle: 240deg; --dist: 70px;"></div>
}
<div class="active-node-label">
@(string.IsNullOrEmpty(_hoveredConceptLabel) ? "TU JESTEŚ" : _hoveredConceptLabel)
</div>
</div>
@if (_hoveredConcept != null)
{
<div class="concept-detail-toast">
<span class="concept-type">@_hoveredConcept.Type</span>
<p class="concept-content">@_hoveredConcept.Content</p>
</div>
}
else
{
<div class="concept-detail-toast placeholder">
<span class="concept-type">Mapowanie AI</span>
<p class="concept-content">Najedź na węzeł, aby zbadać pojęcie wydobyte przez Nexus AI.</p>
</div>
}
</section>
<!-- Quiz Summary -->
<section class="quiz-card glass-panel">
<div class="panel-header">
<h4>Quiz Summary: Key Thinkers</h4>
<h4>Rozwiązane Quizy</h4>
<NexusIcon Name="arrow-right" Size="16" />
</div>
<div class="quiz-preview">
<p class="question">Który artysta namalował 'Ostatnią Wieczerzę'?</p>
<div class="quiz-options">
<div class="quiz-option active">
<span class="option-letter">A)</span> Michal Anioł
@if (_profile?.RecentQuizzes != null && _profile.RecentQuizzes.Any())
{
<div class="quiz-history-list">
@foreach (var quiz in _profile.RecentQuizzes)
{
<div class="quiz-history-item">
<div class="quiz-item-header">
<span class="quiz-topic">@quiz.Topic</span>
<span class="quiz-score badge @(quiz.Percentage >= 80 ? "badge-success" : quiz.Percentage >= 50 ? "badge-warning" : "badge-danger")">
@quiz.Score / @quiz.TotalQuestions (@((int)quiz.Percentage)%)
</span>
</div>
<div class="quiz-item-meta">
<span class="quiz-date">@quiz.CompletedDate.ToString("g")</span>
</div>
</div>
}
</div>
<div class="quiz-option">
<span class="option-letter">B)</span> Leonardo da Vinci
}
else
{
<div class="empty-quiz-state">
<p class="question">Brak rozwiązanych quizów</p>
<p class="sub-text">Rozwiązuj quizy w trakcie czytania książek, aby śledzić swoje postępy.</p>
</div>
</div>
}
</div>
</section>
</div>
@@ -86,13 +143,65 @@
@code {
private UserProfileDto? _profile;
private MappedConceptDto? _hoveredConcept;
private string _hoveredConceptLabel = string.Empty;
protected override async Task OnInitializedAsync()
{
IdentityService.OnStateInvalidated += HandleStateInvalidatedAsync;
await LoadProfileAsync();
await SyncService.InitializeAsync();
SyncService.OnProgressReceived += HandleProgressReceivedAsync;
}
private void SetHoveredConcept(MappedConceptDto concept)
{
_hoveredConcept = concept;
_hoveredConceptLabel = concept.DisplayLabel;
}
private void ClearHoveredConcept()
{
_hoveredConcept = null;
_hoveredConceptLabel = string.Empty;
}
private async Task LoadProfileAsync()
{
var result = await IdentityService.GetProfileAsync();
if (result.IsSuccess)
{
_profile = result.Value;
}
else
{
_profile = null;
}
StateHasChanged();
}
private async Task HandleStateInvalidatedAsync()
{
await InvokeAsync(async () =>
{
await LoadProfileAsync();
});
}
private async Task HandleProgressReceivedAsync(string pageId, DateTime timestamp)
{
await InvokeAsync(async () =>
{
IdentityService.ClearCache();
await LoadProfileAsync();
});
}
public void Dispose()
{
IdentityService.OnStateInvalidated -= HandleStateInvalidatedAsync;
SyncService.OnProgressReceived -= HandleProgressReceivedAsync;
}
}
@@ -294,9 +294,19 @@
}
.graph-node.satellite {
width: 20px;
height: 20px;
width: 16px;
height: 16px;
transform: rotate(var(--angle)) translateY(var(--dist));
background: rgba(0, 255, 153, 0.4);
border: 1px solid var(--nexus-neon);
cursor: pointer;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.graph-node.satellite:hover {
background: var(--nexus-neon);
box-shadow: 0 0 15px var(--nexus-neon);
transform: rotate(var(--angle)) translateY(var(--dist)) scale(1.3);
}
.active-node-label {
@@ -404,3 +414,117 @@
grid-template-columns: 1fr;
}
}
/* --- Quiz History Styling --- */
.quiz-history-list {
display: flex;
flex-direction: column;
gap: 1rem;
}
.quiz-history-item {
background: rgba(255, 255, 255, 0.02);
border: 1px solid rgba(255, 255, 255, 0.05);
border-radius: 12px;
padding: 1rem;
transition: all 0.2s ease;
}
.quiz-history-item:hover {
background: rgba(255, 255, 255, 0.04);
border-color: rgba(255, 255, 255, 0.1);
}
.quiz-item-header {
display: flex;
justify-content: space-between;
align-items: center;
gap: 1rem;
margin-bottom: 0.5rem;
}
.quiz-topic {
font-size: 0.95rem;
font-weight: 500;
color: #ffffff;
}
.quiz-item-meta {
display: flex;
font-size: 0.75rem;
color: #666666;
}
.badge {
padding: 0.25rem 0.5rem;
border-radius: 6px;
font-size: 0.75rem;
font-weight: 600;
}
.badge-success {
background: rgba(0, 255, 153, 0.1);
color: var(--nexus-neon);
border: 1px solid rgba(0, 255, 153, 0.3);
}
.badge-warning {
background: rgba(255, 170, 0, 0.1);
color: #ffa800;
border: 1px solid rgba(255, 170, 0, 0.3);
}
.badge-danger {
background: rgba(255, 50, 50, 0.1);
color: #ff3232;
border: 1px solid rgba(255, 50, 50, 0.3);
}
.empty-quiz-state {
text-align: center;
padding: 2rem 1rem;
}
.empty-quiz-state .sub-text {
font-size: 0.8rem;
color: #666666;
margin-top: 0.5rem;
}
/* --- Concept Detail Toast for Dashboard --- */
.concept-detail-toast {
margin-top: 1rem;
padding: 0.75rem 1rem;
background: rgba(255, 255, 255, 0.02);
border: 1px solid rgba(255, 255, 255, 0.05);
border-radius: 12px;
min-height: 80px;
display: flex;
flex-direction: column;
gap: 0.25rem;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.concept-detail-toast.placeholder {
opacity: 0.5;
}
.concept-type {
font-size: 0.75rem;
font-weight: 700;
color: var(--nexus-neon);
text-transform: uppercase;
letter-spacing: 1px;
}
.concept-content {
font-size: 0.85rem;
line-height: 1.4;
color: #E0E0E0;
margin: 0;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
+561 -282
View File
@@ -3,179 +3,430 @@
@using NexusReader.Application.DTOs.AI
@using NexusReader.Application.Abstractions.Services
@using NexusReader.Application.DTOs.User
@using NexusReader.UI.Shared.Components.Atoms
@using System.Net.Http.Json
@inject HttpClient Http
@inject IKnowledgeService KnowledgeService
@inject AuthenticationStateProvider AuthStateProvider
<div class="intelligence-page">
<header class="intelligence-header">
<div class="header-title-section">
<h1>Global AI Q&A</h1>
<p class="subtitle">Search, interrogate, and extract grounded facts from your library using Polyglot KM-RAG</p>
<h1 class="neon-glow-text">Global Intelligence</h1>
<p class="subtitle">Interrogate, explore, and synthesize grounded knowledge from your library using Polyglot KM-RAG</p>
</div>
</header>
<div class="intelligence-layout glass-panel">
<div class="search-scope-bar">
<div class="input-group search-input-group">
<input class="nexus-input"
placeholder="Ask a question about your books..."
@bind="_question"
@bind:event="oninput"
@onkeyup="HandleKeyUp" />
<button class="btn-nexus primary search-btn"
disabled="@(string.IsNullOrWhiteSpace(_question) || _isLoading)"
@onclick="AskQuestionAsync">
@if (_isLoading)
{
<div class="spinner-glow small btn-spinner"></div>
}
else
{
<span>Ask AI</span>
}
</button>
</div>
<div class="scope-selector">
<label for="book-select">Scope:</label>
<select id="book-select" class="nexus-select" @bind="_selectedBookId">
<option value="">All Books (Global Search)</option>
@if (_books != null)
{
@foreach (var book in _books)
{
<option value="@book.Id">@book.Title</option>
}
}
</select>
</div>
</div>
<div class="results-area">
@if (_isLoading)
<div class="chat-thread-container">
@if (_chatMessages.Count == 0)
{
<div class="loading-state">
<div class="nexus-spinner"></div>
<span>Analyzing conceptual graph and synthesizing response...</span>
<div class="welcome-state">
<div class="welcome-icon">
<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
</svg>
</div>
<h3>Start Interrogating Your Library</h3>
<p>Ask complex questions across your entire ebook collection. The KM-RAG engine dynamically builds semantic maps, resolves dependencies, and formulates high-fidelity, grounded answers with interactive popover citations.</p>
</div>
}
else if (_response != null)
else
{
<div class="response-container">
<div class="response-section">
<h4><i class="bi bi-robot"></i> Answer</h4>
<div class="answer-text">
@_response.Answer
</div>
</div>
@if (_response.Citations != null && _response.Citations.Any())
<div class="chat-bubbles-scroll">
@foreach (var message in _chatMessages)
{
<div class="citations-section">
<h4><i class="bi bi-journal-check"></i> Grounded Citations</h4>
<div class="citations-grid">
@foreach (var citation in _response.Citations)
<div class="message-row @(message.Sender == "User" ? "user-row" : "ai-row")" key="@message.Id">
<div class="message-avatar">
@if (message.Sender == "User")
{
<div class="citation-card">
<div class="citation-header">
<span class="source-badge">@citation.SourceBook</span>
@if (!string.IsNullOrEmpty(citation.CitationId) && citation.CitationId.Length > 8)
{
<span class="id-badge">ID: @citation.CitationId.Substring(0, Math.Min(8, citation.CitationId.Length))</span>
}
</div>
<div class="citation-body">
"@citation.Snippet"
</div>
</div>
<i class="bi bi-person-fill"></i>
}
else
{
<i class="bi bi-robot"></i>
}
</div>
<div class="message-bubble @(message.Sender == "User" ? "user-bubble" : "ai-bubble")">
<div class="message-header">
<span class="sender-name">@message.Sender</span>
<span class="message-time">@message.Timestamp.ToString("HH:mm")</span>
</div>
<div class="message-content">
@foreach (var segment in message.Segments)
{
@if (segment.IsCitation)
{
<NexusCitationMarker SourceId="@segment.CitationId" Citations="@message.Citations" />
}
else
{
@RenderMarkdown(segment.Text)
}
}
</div>
</div>
</div>
}
@if (_isLoading)
{
<div class="message-row ai-row">
<div class="message-avatar">
<i class="bi bi-robot"></i>
</div>
<div class="message-bubble ai-bubble pending-bubble">
<div class="message-header">
<span class="sender-name">AI</span>
<span class="message-time">Thinking...</span>
</div>
<div class="message-content">
<div class="typing-indicator">
<span></span>
<span></span>
<span></span>
</div>
<span class="loading-label">Analyzing conceptual graphs and synthesizing response...</span>
</div>
</div>
</div>
}
</div>
}
else if (_hasSearched)
{
<div class="empty-state">
<i class="bi bi-info-circle"></i>
<p>No answers generated. Try adjusting your question.</p>
</div>
}
else
{
<div class="welcome-state">
<div class="welcome-icon">
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
</svg>
</div>
<div class="chat-input-controls">
<div class="input-panel-wrapper">
<div class="scope-bar">
<div class="scope-selector">
<label for="book-select"><i class="bi bi-compass"></i> Scope:</label>
<select id="book-select" class="nexus-select" @bind="_selectedBookId">
<option value="">All Books (Global Search)</option>
@if (_books != null)
{
@foreach (var book in _books)
{
<option value="@book.Id">@book.Title</option>
}
}
</select>
</div>
<h3>Start Interrogating Your Library</h3>
<p>Ask complex questions across all your books. The system will search vectors, pull concept graph relations, and formulate a grounded answer with precise citations.</p>
</div>
}
<div class="input-field-group">
<input class="nexus-input"
placeholder="Ask a question about your books..."
@bind="_question"
@bind:event="oninput"
@onkeyup="HandleKeyUp"
disabled="@_isLoading" />
<button class="btn-nexus primary search-btn"
disabled="@(string.IsNullOrWhiteSpace(_question) || _isLoading)"
@onclick="AskQuestionAsync">
@if (_isLoading)
{
<div class="btn-spinner"></div>
}
else
{
<span><i class="bi bi-send-fill"></i></span>
}
</button>
</div>
</div>
</div>
</div>
</div>
<style>
.intelligence-page {
padding: 3rem 2rem;
padding: 2rem;
max-width: 1100px;
margin: 0 auto;
height: calc(100vh - 100px);
display: flex;
flex-direction: column;
animation: fadeIn 0.5s ease-out;
}
.intelligence-header {
margin-bottom: 2rem;
margin-bottom: 1.5rem;
flex-shrink: 0;
}
.header-title-section h1 {
font-family: var(--nexus-font-serif, 'Outfit', 'Georgia', serif);
font-size: 2.8rem;
font-weight: 700;
margin: 0 0 0.5rem 0;
background: linear-gradient(135deg, var(--nexus-text, #ffffff) 0%, rgba(255, 255, 255, 0.7) 100%);
.neon-glow-text {
font-family: var(--nexus-font-sans, 'Outfit', sans-serif);
font-size: 2.5rem;
font-weight: 800;
margin: 0 0 0.25rem 0;
background: linear-gradient(135deg, #00ff99 0%, #06b6d4 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
filter: drop-shadow(0 0 8px rgba(6, 182, 212, 0.2));
}
.subtitle {
font-size: 1rem;
font-size: 0.95rem;
color: rgba(255, 255, 255, 0.6);
margin: 0;
}
.intelligence-layout {
padding: 2.5rem;
border-radius: var(--nexus-radius-lg, 16px);
background: rgba(15, 23, 42, 0.4);
border: 1px solid rgba(255, 255, 255, 0.08);
backdrop-filter: blur(20px);
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.search-scope-bar {
display: flex;
gap: 1.5rem;
align-items: center;
margin-bottom: 2.5rem;
flex-wrap: wrap;
}
.search-input-group {
flex-grow: 1;
display: flex;
background: rgba(15, 23, 42, 0.5);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 30px;
padding: 0.25rem 0.25rem 0.25rem 1.25rem;
transition: all 0.3s ease;
flex-direction: column;
border-radius: 20px;
background: rgba(10, 16, 26, 0.45);
border: 1px solid rgba(6, 182, 212, 0.15);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4), 0 0 20px rgba(6, 182, 212, 0.05);
overflow: hidden;
}
.search-input-group:focus-within {
border-color: var(--nexus-primary, #6366f1);
box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
.chat-thread-container {
flex-grow: 1;
overflow-y: auto;
padding: 2rem;
display: flex;
flex-direction: column;
}
/* Custom Scrollbars */
.chat-thread-container::-webkit-scrollbar {
width: 6px;
}
.chat-thread-container::-webkit-scrollbar-track {
background: rgba(255, 255, 255, 0.01);
}
.chat-thread-container::-webkit-scrollbar-thumb {
background: rgba(6, 182, 212, 0.2);
border-radius: 4px;
}
.chat-thread-container::-webkit-scrollbar-thumb:hover {
background: rgba(6, 182, 212, 0.4);
}
.chat-bubbles-scroll {
display: flex;
flex-direction: column;
gap: 1.5rem;
width: 100%;
}
.message-row {
display: flex;
gap: 1rem;
width: 100%;
max-width: 85%;
animation: bubble-fade-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.user-row {
align-self: flex-end;
flex-direction: row-reverse;
}
.ai-row {
align-self: flex-start;
}
.message-avatar {
width: 38px;
height: 38px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.1rem;
flex-shrink: 0;
}
.user-row .message-avatar {
background: linear-gradient(135deg, #7c3aed 0%, #4c1d95 100%);
color: #f5f3ff;
border: 1px solid rgba(139, 92, 246, 0.4);
box-shadow: 0 0 10px rgba(139, 92, 246, 0.25);
}
.ai-row .message-avatar {
background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
color: #ccfbf1;
border: 1px solid rgba(13, 148, 136, 0.4);
box-shadow: 0 0 10px rgba(13, 148, 136, 0.25);
}
.message-bubble {
padding: 1.25rem 1.5rem;
border-radius: 16px;
position: relative;
line-height: 1.6;
font-size: 0.975rem;
}
.user-bubble {
background: rgba(43, 24, 80, 0.35);
border: 1px solid rgba(139, 92, 246, 0.25);
color: #f3e8ff;
border-top-right-radius: 4px;
box-shadow: 0 4px 15px rgba(139, 92, 246, 0.05);
}
.ai-bubble {
background: rgba(10, 20, 30, 0.55);
border: 1px solid rgba(6, 182, 212, 0.2);
color: #e2e8f0;
border-top-left-radius: 4px;
box-shadow: 0 4px 15px rgba(6, 182, 212, 0.05);
flex-grow: 1;
}
.message-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.5rem;
font-size: 0.75rem;
opacity: 0.6;
}
.sender-name {
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.message-time {
font-family: monospace;
}
.message-content {
word-break: break-word;
}
/* Paragraph Spacing & Markdown */
.message-content p {
margin: 0 0 1rem 0;
}
.message-content p:last-child {
margin-bottom: 0;
}
.nexus-code-block {
background: rgba(0, 0, 0, 0.4) !important;
border: 1px solid rgba(255, 255, 255, 0.08) !important;
border-radius: 8px;
padding: 1rem;
margin: 1rem 0;
overflow-x: auto;
font-family: 'Fira Code', monospace;
font-size: 0.85rem;
color: #a7f3d0;
}
.nexus-inline-code {
background: rgba(255, 255, 255, 0.06);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 4px;
padding: 0.15rem 0.35rem;
font-family: monospace;
font-size: 0.9em;
color: #f472b6; /* Light pink for inline code */
}
/* Pending State Bubble */
.pending-bubble {
border-color: rgba(6, 182, 212, 0.4);
box-shadow: 0 0 15px rgba(6, 182, 212, 0.1);
}
.typing-indicator {
display: flex;
gap: 4px;
align-items: center;
margin-bottom: 0.5rem;
}
.typing-indicator span {
width: 8px;
height: 8px;
background: #06b6d4;
border-radius: 50%;
display: inline-block;
animation: typing-bounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.loading-label {
font-size: 0.85rem;
color: rgba(255, 255, 255, 0.5);
font-style: italic;
}
/* Input Controls */
.chat-input-controls {
padding: 1.5rem 2rem 2rem 2rem;
background: rgba(0, 0, 0, 0.2);
border-top: 1px solid rgba(255, 255, 255, 0.05);
flex-shrink: 0;
}
.input-panel-wrapper {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.scope-bar {
display: flex;
align-items: center;
}
.scope-selector {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.85rem;
color: rgba(255, 255, 255, 0.5);
}
.nexus-select {
background: rgba(255, 255, 255, 0.02);
border: 1px solid rgba(255, 255, 255, 0.08);
color: #ffffff;
padding: 0.35rem 2rem 0.35rem 0.75rem;
border-radius: 8px;
outline: none;
cursor: pointer;
font-size: 0.85rem;
transition: all 0.3s ease;
appearance: none;
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
background-repeat: no-repeat;
background-position: right 0.75rem center;
background-size: 0.85em;
}
.nexus-select:focus {
border-color: #06b6d4;
box-shadow: 0 0 8px rgba(6, 182, 212, 0.2);
}
.input-field-group {
display: flex;
background: rgba(255, 255, 255, 0.02);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 12px;
padding: 0.35rem;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.input-field-group:focus-within {
border-color: #06b6d4;
background: rgba(6, 182, 212, 0.01);
box-shadow: 0 0 15px rgba(6, 182, 212, 0.15);
}
.nexus-input {
@@ -185,205 +436,137 @@
color: #ffffff;
font-size: 1rem;
outline: none;
padding: 0.5rem 0;
padding: 0.5rem 1rem;
}
.nexus-input::placeholder {
color: rgba(255, 255, 255, 0.4);
color: rgba(255, 255, 255, 0.35);
}
.btn-nexus {
padding: 0.75rem 1.25rem;
border-radius: 10px;
font-size: 0.95rem;
font-weight: 600;
cursor: pointer;
transition: all 0.2s;
border: none;
}
.btn-nexus.primary {
background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
color: #ffffff;
box-shadow: 0 4px 10px rgba(6, 182, 212, 0.25);
}
.btn-nexus:hover:not(:disabled) {
transform: translateY(-1px);
filter: brightness(1.1);
box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
}
.btn-nexus:disabled {
background: rgba(255, 255, 255, 0.05);
color: rgba(255, 255, 255, 0.25);
box-shadow: none;
cursor: not-allowed;
}
.search-btn {
border-radius: 25px !important;
padding: 0.5rem 1.5rem !important;
font-size: 0.95rem !important;
width: 46px;
height: 46px;
padding: 0 !important;
display: flex;
align-items: center;
justify-content: center;
border-radius: 10px;
}
.scope-selector {
display: flex;
align-items: center;
gap: 0.75rem;
color: rgba(255, 255, 255, 0.7);
}
.nexus-select {
background: rgba(15, 23, 42, 0.6);
border: 1px solid rgba(255, 255, 255, 0.1);
color: #ffffff;
padding: 0.5rem 1.5rem 0.5rem 1rem;
border-radius: 20px;
outline: none;
cursor: pointer;
transition: all 0.3s ease;
}
.nexus-select:focus {
border-color: var(--nexus-primary, #6366f1);
}
.results-area {
min-height: 250px;
display: flex;
flex-direction: column;
justify-content: center;
}
.loading-state {
display: flex;
flex-direction: column;
align-items: center;
gap: 1.5rem;
color: rgba(255, 255, 255, 0.7);
}
.nexus-spinner {
width: 50px;
height: 50px;
border: 3px solid rgba(99, 102, 241, 0.1);
border-radius: 50%;
border-top-color: var(--nexus-primary, #6366f1);
animation: spin 1s linear infinite;
}
.welcome-state, .empty-state {
.welcome-state {
text-align: center;
color: rgba(255, 255, 255, 0.5);
padding: 3rem 1rem;
padding: 4rem 2rem;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
}
.welcome-icon {
color: rgba(255, 255, 255, 0.25);
color: rgba(6, 182, 212, 0.4);
margin-bottom: 1.5rem;
animation: pulse 2s infinite alternate;
filter: drop-shadow(0 0 10px rgba(6, 182, 212, 0.2));
animation: pulse 2.5s infinite alternate;
}
.welcome-state h3 {
color: #ffffff;
font-family: var(--nexus-font-sans);
margin: 0 0 0.5rem 0;
font-size: 1.5rem;
margin: 0 0 0.75rem 0;
}
.welcome-state p, .empty-state p {
max-width: 500px;
.welcome-state p {
max-width: 550px;
margin: 0;
font-size: 0.95rem;
line-height: 1.6;
}
.response-container {
display: flex;
flex-direction: column;
gap: 2.5rem;
animation: slideUp 0.4s ease-out;
}
.response-section h4, .citations-section h4 {
font-size: 1.1rem;
text-transform: uppercase;
letter-spacing: 1px;
color: rgba(255, 255, 255, 0.5);
margin: 0 0 1rem 0;
display: flex;
align-items: center;
gap: 0.5rem;
}
.answer-text {
font-size: 1.15rem;
line-height: 1.7;
color: #ffffff;
background: rgba(255, 255, 255, 0.03);
padding: 1.5rem;
border-radius: 12px;
border: 1px solid rgba(255, 255, 255, 0.05);
}
.citations-grid {
display: grid;
grid-template-columns: 1fr;
gap: 1.25rem;
}
.citation-card {
background: rgba(15, 23, 42, 0.4);
border: 1px solid rgba(255, 255, 255, 0.05);
border-radius: 12px;
padding: 1.25rem;
transition: all 0.3s ease;
}
.citation-card:hover {
border-color: rgba(99, 102, 241, 0.3);
transform: translateY(-2px);
}
.citation-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.75rem;
}
.source-badge {
font-size: 0.8rem;
font-weight: 600;
color: var(--nexus-primary, #6366f1);
background: rgba(99, 102, 241, 0.1);
padding: 0.25rem 0.75rem;
border-radius: 20px;
}
.id-badge {
font-size: 0.75rem;
color: rgba(255, 255, 255, 0.4);
font-family: monospace;
}
.citation-body {
font-size: 0.95rem;
line-height: 1.5;
color: rgba(255, 255, 255, 0.8);
font-style: italic;
}
.btn-spinner {
margin: 0;
width: 20px;
height: 20px;
border: 2px solid rgba(255, 255, 255, 0.1);
border-radius: 50%;
border-top-color: #ffffff;
animation: spin 0.8s linear infinite;
}
/* Animations */
@@keyframes fadeIn {
from { opacity: 0; transform: translateY(15px); }
to { opacity: 1; transform: translateY(0); }
/* Keyframe Animations */
@@keyframes bubble-fade-in {
0% { opacity: 0; transform: translateY(10px) scale(0.98); }
100% { opacity: 1; transform: translateY(0) scale(1); }
}
@@keyframes slideUp {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
@@keyframes typing-bounce {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-4px); }
}
@@keyframes pulse {
0% { transform: scale(0.96); opacity: 0.8; }
100% { transform: scale(1.04); opacity: 1; }
}
@@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@@keyframes pulse {
0% { transform: scale(0.95); opacity: 0.7; }
100% { transform: scale(1.05); opacity: 1; }
}
</style>
@code {
private string _question = string.Empty;
private string _selectedBookId = string.Empty;
private bool _isLoading;
private bool _hasSearched;
private GroundedResponseDto? _response;
private List<LastReadBookDto>? _books;
private List<ChatMessage> _chatMessages = new();
public class ChatMessage
{
public string Id { get; set; } = Guid.NewGuid().ToString();
public string Sender { get; set; } = string.Empty; // "User" or "AI"
public string Text { get; set; } = string.Empty;
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
public List<ResponseSegment> Segments { get; set; } = new();
public List<CitationDto> Citations { get; set; } = new();
}
public class ResponseSegment
{
public string Text { get; set; } = string.Empty;
public bool IsCitation { get; set; }
public string CitationId { get; set; } = string.Empty;
}
protected override async Task OnInitializedAsync()
{
@@ -409,9 +592,18 @@
{
if (string.IsNullOrWhiteSpace(_question) || _isLoading) return;
var userQuestion = _question;
_question = string.Empty; // Clear input field immediately
_isLoading = true;
_hasSearched = true;
_response = null;
// Add user query message
_chatMessages.Add(new ChatMessage
{
Sender = "User",
Text = userQuestion,
Segments = new List<ResponseSegment> { new ResponseSegment { Text = userQuestion, IsCitation = false } }
});
StateHasChanged();
try
@@ -422,27 +614,41 @@
ebookId = parsedId;
}
var result = await KnowledgeService.AskQuestionAsync(_question, "tenantId", ebookId);
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
var tenantId = authState.User.FindFirst("TenantId")?.Value ?? "global";
var result = await KnowledgeService.AskQuestionAsync(userQuestion, tenantId, ebookId);
if (result.IsSuccess)
{
_response = result.Value;
var response = result.Value;
_chatMessages.Add(new ChatMessage
{
Sender = "AI",
Text = response.Answer,
Segments = ParseSegments(response.Answer),
Citations = response.Citations
});
}
else
{
_response = new GroundedResponseDto
var errMsg = $"Error: {result.Errors.FirstOrDefault()?.Message ?? "An error occurred."}";
_chatMessages.Add(new ChatMessage
{
Answer = $"Error: {result.Errors.FirstOrDefault()?.Message ?? "An error occurred."}",
Citations = new List<CitationDto>()
};
Sender = "AI",
Text = errMsg,
Segments = new List<ResponseSegment> { new ResponseSegment { Text = errMsg, IsCitation = false } }
});
}
}
catch (Exception ex)
{
_response = new GroundedResponseDto
var errMsg = $"Network/API Error: {ex.Message}";
_chatMessages.Add(new ChatMessage
{
Answer = $"Network/API Error: {ex.Message}",
Citations = new List<CitationDto>()
};
Sender = "AI",
Text = errMsg,
Segments = new List<ResponseSegment> { new ResponseSegment { Text = errMsg, IsCitation = false } }
});
}
finally
{
@@ -450,4 +656,77 @@
StateHasChanged();
}
}
private List<ResponseSegment> ParseSegments(string text)
{
var segments = new List<ResponseSegment>();
if (string.IsNullOrEmpty(text)) return segments;
// Matches [Source ID: some-id] OR raw GUIDs in brackets [e225e58f-7539-cd51-e0ab-82741ec7e65c]
var regex = new System.Text.RegularExpressions.Regex(
@"\[Source ID:\s*([^\]]+)\]|\[([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})\]",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
var matches = regex.Matches(text);
int lastIndex = 0;
foreach (System.Text.RegularExpressions.Match match in matches)
{
if (match.Index > lastIndex)
{
segments.Add(new ResponseSegment
{
Text = text.Substring(lastIndex, match.Index - lastIndex),
IsCitation = false
});
}
var citationId = match.Groups[1].Success
? match.Groups[1].Value.Trim()
: match.Groups[2].Value.Trim();
segments.Add(new ResponseSegment
{
IsCitation = true,
CitationId = citationId
});
lastIndex = match.Index + match.Length;
}
if (lastIndex < text.Length)
{
segments.Add(new ResponseSegment
{
Text = text.Substring(lastIndex),
IsCitation = false
});
}
return segments;
}
private MarkupString RenderMarkdown(string text)
{
if (string.IsNullOrEmpty(text)) return new MarkupString(string.Empty);
// 1. HTML Encode to prevent XSS
var html = System.Net.WebUtility.HtmlEncode(text);
// 2. Bold: **text** -> <strong>text</strong>
html = System.Text.RegularExpressions.Regex.Replace(html, @"\*\*(.*?)\*\*", "<strong>$1</strong>");
// 3. Italic: *text* -> <em>text</em>
html = System.Text.RegularExpressions.Regex.Replace(html, @"\*(.*?)\*", "<em>$1</em>");
// 4. Code blocks: ```language ... ``` -> <pre class="nexus-code-block"><code>...</code></pre>
html = System.Text.RegularExpressions.Regex.Replace(html, @"```(?:[a-zA-Z0-9+#]+)?\s*([\s\S]*?)\s*```", "<pre class=\"nexus-code-block\"><code>$1</code></pre>");
// 5. Inline Code: `code` -> <code class="nexus-inline-code">code</code>
html = System.Text.RegularExpressions.Regex.Replace(html, @"`(.*?)`", "<code class=\"nexus-inline-code\">$1</code>");
// 6. Newlines: \n -> <br />
html = html.Replace("\n", "<br />");
return new MarkupString(html);
}
}
@@ -0,0 +1,370 @@
@page "/serilog-demo"
@inject ILogger<SerilogDemo> Logger
@inject IJSRuntime JSRuntime
<div class="serilog-demo-container">
<div class="header-card">
<div class="header-content">
<NexusIcon Name="cpu" Size="36" Class="header-icon" />
<div class="header-text">
<h1>Serilog Logging Infrastructure</h1>
<p class="subtitle">Production-grade diagnostic pipeline for unified native & web logs</p>
</div>
</div>
<div class="status-badge">
<span class="status-dot green"></span>
<span class="status-text">Pipeline Active</span>
</div>
</div>
<div class="demo-grid">
<!-- Native .NET Logging Panel -->
<div class="control-card">
<div class="card-header">
<NexusIcon Name="terminal" Size="20" Class="card-icon" />
<h2>Native .NET Logs (C#)</h2>
</div>
<p class="card-desc">Trigger structured C# logs using Dependency Injected ILogger.</p>
<div class="btn-group">
<button class="btn btn-info" @onclick="LogInfo">
<NexusIcon Name="info" Size="16" />
Log Info
</button>
<button class="btn btn-warning" @onclick="LogWarning">
<NexusIcon Name="alert-triangle" Size="16" />
Log Warning
</button>
<button class="btn btn-error" @onclick="LogError">
<NexusIcon Name="x-circle" Size="16" />
Log Error Exception
</button>
</div>
</div>
<!-- Blazor / JS Interop Bridge Panel -->
<div class="control-card">
<div class="card-header">
<NexusIcon Name="globe" Size="20" Class="card-icon js-icon" />
<h2>Blazor / JS WebView Logs</h2>
</div>
<p class="card-desc">Trigger logs from JavaScript to verify the interop error capture bridge.</p>
<div class="btn-group">
<button class="btn btn-js-info" @onclick="TriggerJsLog">
<NexusIcon Name="message-square" Size="16" />
Trigger console.log()
</button>
<button class="btn btn-js-error" @onclick="TriggerJsException">
<NexusIcon Name="zap" Size="16" />
Trigger JS Exception
</button>
</div>
</div>
</div>
<!-- Active Log Config Panel -->
<div class="config-card">
<div class="card-header">
<NexusIcon Name="settings" Size="20" Class="card-icon" />
<h2>Pipeline Diagnostics</h2>
</div>
<div class="config-grid">
<div class="config-item">
<span class="label">Rolling Daily File Sandbox Path</span>
<span class="value code-value">AppDataDirectory/logs/log-*.txt</span>
</div>
<div class="config-item">
<span class="label">Active Configuration Provider</span>
<span class="value">Serilog.Settings.Configuration (appsettings.json)</span>
</div>
<div class="config-item">
<span class="label">Native Apple Console Sink</span>
<span class="value">Serilog.Sinks.Debug (conditional compilation)</span>
</div>
<div class="config-item">
<span class="label">Native Android Logcat Sink</span>
<span class="value">AndroidLogcatSink (direct JNI bindings)</span>
</div>
</div>
</div>
</div>
<style>
.serilog-demo-container {
padding: 2rem;
max-width: 1200px;
margin: 0 auto;
color: #e2e8f0;
font-family: 'Inter', system-ui, -apple-system, sans-serif;
}
.header-card {
display: flex;
justify-content: space-between;
align-items: center;
background: linear-gradient(135deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.8) 100%);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 16px;
padding: 2rem;
margin-bottom: 2rem;
backdrop-filter: blur(12px);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}
.header-content {
display: flex;
align-items: center;
gap: 1.5rem;
}
.header-icon {
color: #6366f1;
filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.5));
}
.header-text h1 {
font-size: 1.8rem;
font-weight: 700;
margin: 0;
background: linear-gradient(to right, #ffffff, #94a3b8);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.subtitle {
margin: 0.25rem 0 0 0;
color: #94a3b8;
font-size: 0.95rem;
}
.status-badge {
display: flex;
align-items: center;
gap: 0.5rem;
background: rgba(16, 185, 129, 0.1);
border: 1px solid rgba(16, 185, 129, 0.2);
padding: 0.5rem 1rem;
border-radius: 9999px;
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
}
.status-dot.green {
background-color: #10b981;
box-shadow: 0 0 8px #10b981;
}
.status-text {
font-size: 0.85rem;
font-weight: 600;
color: #10b981;
}
.demo-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 2rem;
margin-bottom: 2rem;
}
@@media (max-width: 768px) {
.demo-grid {
grid-template-columns: 1fr;
}
}
.control-card {
background: rgba(30, 41, 59, 0.45);
border: 1px solid rgba(255, 255, 255, 0.05);
border-radius: 16px;
padding: 2rem;
backdrop-filter: blur(8px);
}
.card-header {
display: flex;
align-items: center;
gap: 0.75rem;
margin-bottom: 1rem;
}
.card-icon {
color: #6366f1;
}
.js-icon {
color: #eab308;
}
.card-header h2 {
font-size: 1.25rem;
font-weight: 600;
margin: 0;
}
.card-desc {
color: #94a3b8;
font-size: 0.9rem;
margin-bottom: 1.5rem;
line-height: 1.5;
}
.btn-group {
display: flex;
flex-wrap: wrap;
gap: 1rem;
}
.btn {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.75rem 1.25rem;
border-radius: 8px;
font-size: 0.85rem;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
border: none;
}
.btn-info {
background-color: rgba(99, 102, 241, 0.1);
color: #818cf8;
border: 1px solid rgba(99, 102, 241, 0.2);
}
.btn-info:hover {
background-color: #6366f1;
color: white;
}
.btn-warning {
background-color: rgba(245, 158, 11, 0.1);
color: #fbbf24;
border: 1px solid rgba(245, 158, 11, 0.2);
}
.btn-warning:hover {
background-color: #f59e0b;
color: white;
}
.btn-error {
background-color: rgba(239, 68, 68, 0.1);
color: #f87171;
border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-error:hover {
background-color: #ef4444;
color: white;
}
.btn-js-info {
background-color: rgba(234, 179, 8, 0.1);
color: #fef08a;
border: 1px solid rgba(234, 179, 8, 0.2);
}
.btn-js-info:hover {
background-color: #eab308;
color: #0f172a;
}
.btn-js-error {
background-color: rgba(236, 72, 153, 0.1);
color: #fbcfe8;
border: 1px solid rgba(236, 72, 153, 0.2);
}
.btn-js-error:hover {
background-color: #ec4899;
color: white;
}
.config-card {
background: rgba(15, 23, 42, 0.5);
border: 1px solid rgba(255, 255, 255, 0.05);
border-radius: 16px;
padding: 2rem;
}
.config-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1.5rem;
margin-top: 1.5rem;
}
@@media (max-width: 768px) {
.config-grid {
grid-template-columns: 1fr;
}
}
.config-item {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.config-item .label {
font-size: 0.8rem;
color: #64748b;
text-transform: uppercase;
letter-spacing: 0.05em;
font-weight: 600;
}
.config-item .value {
font-size: 0.95rem;
color: #cbd5e1;
}
.code-value {
font-family: 'Fira Code', 'Courier New', Courier, monospace;
background: rgba(0, 0, 0, 0.2);
padding: 0.25rem 0.5rem;
border-radius: 4px;
border: 1px solid rgba(255, 255, 255, 0.05);
word-break: break-all;
}
</style>
@code {
private void LogInfo()
{
Logger.LogInformation("Structured native log triggered by user from SerilogDemo. Button: LogInfo");
}
private void LogWarning()
{
Logger.LogWarning("Potential warning log triggered from Blazor razor component at {Time}", DateTime.UtcNow);
}
private void LogError()
{
try
{
throw new InvalidOperationException("Simulated native C# operation exception triggered in Diagnostic dashboard.");
}
catch (Exception ex)
{
Logger.LogError(ex, "Captured exception successfully in native Serilog pipeline!");
}
}
private async Task TriggerJsLog()
{
await JSRuntime.InvokeVoidAsync("console.log", "Intercepted JS console statement from Blazor WebView interop trigger!");
}
private async Task TriggerJsException()
{
await JSRuntime.InvokeVoidAsync("eval", "throw new Error('Simulated runtime JS Exception triggered from Blazor UI button click!');");
}
}
+50 -3
View File
@@ -2,16 +2,63 @@
@attribute [Authorize]
<div class="settings-page">
<h1>Ustawienia</h1>
<p>Konfiguracja Twojego konta i preferencji czytania.</p>
<h1>Settings</h1>
<p>Configure your account and application preferences.</p>
<div class="settings-section">
<h2>Diagnostics & System Logs</h2>
<p>Inspect native logging infrastructure, trigger custom logs, and trace WebView errors.</p>
<a class="diag-btn" href="/serilog-demo">
<NexusIcon Name="cpu" Size="16" />
Open Serilog Diagnostics Dashboard
</a>
</div>
</div>
<style>
.settings-page {
padding: 2rem;
color: #e2e8f0;
font-family: 'Inter', sans-serif;
}
h1 {
margin-bottom: 1rem;
margin-bottom: 0.5rem;
color: #fff;
}
h2 {
margin-top: 2rem;
font-size: 1.2rem;
color: #fff;
margin-bottom: 0.5rem;
}
.settings-section {
background: rgba(30, 41, 59, 0.45);
border: 1px solid rgba(255, 255, 255, 0.05);
padding: 1.5rem;
border-radius: 12px;
margin-top: 1.5rem;
}
.settings-section p {
color: #94a3b8;
font-size: 0.9rem;
margin-bottom: 1.25rem;
}
.diag-btn {
display: inline-flex;
align-items: center;
gap: 0.5rem;
background: rgba(99, 102, 241, 0.1);
color: #818cf8;
border: 1px solid rgba(99, 102, 241, 0.2);
padding: 0.75rem 1.25rem;
border-radius: 8px;
text-decoration: none;
font-size: 0.85rem;
font-weight: 600;
transition: all 0.2s ease;
}
.diag-btn:hover {
background: #6366f1;
color: white;
}
</style>