그리드 표현 일부 완료. 데이터 검측 필수 예정
This commit is contained in:
80
SchemaEditor/Components/Pages/DataExplorer.razor
Normal file
80
SchemaEditor/Components/Pages/DataExplorer.razor
Normal file
@@ -0,0 +1,80 @@
|
||||
@page "/data"
|
||||
@using Microsoft.AspNetCore.Components.QuickGrid
|
||||
@using SchemaEditor.Services
|
||||
@inject GarnetClientService GarnetClient
|
||||
@rendermode InteractiveServer
|
||||
|
||||
<div class="container-fluid">
|
||||
<h1 class="mb-4">Data Explorer (Garnet)</h1>
|
||||
|
||||
<div class="card mb-4">
|
||||
<div class="card-header bg-light">
|
||||
<h5 class="mb-0">Query Store</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">Key Pattern</span>
|
||||
<input class="form-control" @bind="searchPattern" placeholder="e.g. *, SheetName:*" />
|
||||
<button class="btn btn-primary" @onclick="SearchKeys">Search</button>
|
||||
</div>
|
||||
<div class="form-text">Using SCAN/KEYS command. Use specific patterns for performance.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (errorMsg != null)
|
||||
{
|
||||
<div class="alert alert-danger">@errorMsg</div>
|
||||
}
|
||||
|
||||
@if (searchResults != null)
|
||||
{
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between">
|
||||
<h5 class="mb-0">Results</h5>
|
||||
<span class="badge bg-secondary">@searchResults.Count keys found</span>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="grid-container" style="height: 600px; overflow-y: auto;">
|
||||
<QuickGrid Items="@searchResults.AsQueryable()" Pagination="@pagination" Class="table table-striped table-hover mb-0">
|
||||
<PropertyColumn Property="@(p => p.Key)" Sortable="true" Title="Key" />
|
||||
<PropertyColumn Property="@(p => p.Value)" Sortable="true" Title="Value" />
|
||||
</QuickGrid>
|
||||
</div>
|
||||
<div class="p-2 border-top">
|
||||
<Paginator State="@pagination" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private string searchPattern = "*";
|
||||
private List<KeyValuePair<string, string>>? searchResults;
|
||||
private string? errorMsg;
|
||||
private PaginationState pagination = new PaginationState { ItemsPerPage = 20 };
|
||||
|
||||
private async Task SearchKeys()
|
||||
{
|
||||
errorMsg = null;
|
||||
searchResults = null;
|
||||
try
|
||||
{
|
||||
var keys = await GarnetClient.SearchKeysAsync(searchPattern);
|
||||
var list = new List<KeyValuePair<string, string>>();
|
||||
|
||||
// Fetch values (Bulk get would be better but keeping simple for now)
|
||||
// Limit to 1000 for safety in PoC UI
|
||||
foreach (var k in keys.Take(1000))
|
||||
{
|
||||
var val = await GarnetClient.GetValueAsync(k);
|
||||
list.Add(new KeyValuePair<string, string>(k, val));
|
||||
}
|
||||
searchResults = list;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errorMsg = $"Query failed: {ex.Message}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user