Agent Catalog and Maui Test
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
@page "/counter"
|
||||
|
||||
<h1>Counter</h1>
|
||||
|
||||
<p role="status">Current count: @currentCount</p>
|
||||
|
||||
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
|
||||
|
||||
@code {
|
||||
private int currentCount = 0;
|
||||
|
||||
private void IncrementCount()
|
||||
{
|
||||
currentCount++;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
@page "/database"
|
||||
@using Model.Entity
|
||||
@using Model.Entity.Data
|
||||
@using Model.Entity.Parts
|
||||
|
||||
<PageTitle>Database</PageTitle>
|
||||
|
||||
<div class="container-fluid py-3">
|
||||
<h1 class="mb-3">Database</h1>
|
||||
|
||||
<div class="card mb-4 shadow-sm filters-card">
|
||||
<div class="card-body">
|
||||
<div class="row g-3 align-items-end">
|
||||
<div class="col-12 col-md-6 col-lg-4">
|
||||
<label for="factionSelect" class="form-label fw-semibold">Faction</label>
|
||||
<select id="factionSelect" class="form-select" @bind="selectedFaction" @bind:after="OnFactionChanged">
|
||||
<option value="@DataType.Any">Any</option>
|
||||
<option value="@DataType.FACTION_QRath">Q'Rath</option>
|
||||
<option value="@DataType.FACTION_Aru">Aru</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12 col-md-6 col-lg-4">
|
||||
<label for="immortalSelect" class="form-label fw-semibold">Immortal</label>
|
||||
<select id="immortalSelect" class="form-select" @bind="selectedImmortal" @bind:after="OnImmortalChanged">
|
||||
<option value="@DataType.Any">Any</option>
|
||||
@foreach (var choice in immortalChoices)
|
||||
{
|
||||
<option value="@choice.Key">@choice.Name</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2 text-muted small">
|
||||
Showing @filteredEntities.Count @(filteredEntities.Count == 1 ? "entity" : "entities")
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row g-3">
|
||||
@foreach (var entity in filteredEntities)
|
||||
{
|
||||
<div class="col-12 col-sm-6 col-lg-4 col-xl-3">
|
||||
<div class="card h-100 shadow-sm entity-card">
|
||||
<div class="card-body d-flex flex-column">
|
||||
<div class="d-flex justify-content-between align-items-start mb-2 gap-2">
|
||||
<h5 class="card-title mb-0 text-break">@entity.Info().Name</h5>
|
||||
@{
|
||||
var vanguard = entity.VanguardAdded();
|
||||
if (vanguard != null)
|
||||
{
|
||||
<span class="immortal-badge">@(EntityData.Get().TryGetValue(vanguard!.ImmortalId, out var imm) ? imm.Info().Name : "")</span>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<h6 class="card-subtitle mb-2">
|
||||
<span class="badge bg-secondary me-1">@entity.EntityType.Replace("_", " ")</span>
|
||||
@if (entity.Faction() != null)
|
||||
{
|
||||
<span class="badge bg-dark-subtle text-dark-emphasis">@(EntityData.Get().TryGetValue(entity.Faction().Faction, out var fac) ? fac.Info().Name : "")</span>
|
||||
}
|
||||
</h6>
|
||||
@if (!string.IsNullOrEmpty(entity.Info().Description))
|
||||
{
|
||||
<p class="card-text flex-grow-1 small">
|
||||
@(entity.Info().Description.Length > 120
|
||||
? entity.Info().Description[..117] + "..."
|
||||
: entity.Info().Description)
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (filteredEntities.Count == 0)
|
||||
{
|
||||
<div class="alert alert-info mt-3" role="alert">No entities match the selected filters.</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.filters-card {
|
||||
border: 1px solid rgba(0, 0, 0, 0.125);
|
||||
}
|
||||
|
||||
.entity-card {
|
||||
border: 1px solid rgba(0, 0, 0, 0.125);
|
||||
transition: box-shadow 0.15s ease-in-out;
|
||||
}
|
||||
|
||||
.entity-card:hover {
|
||||
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
|
||||
}
|
||||
|
||||
.immortal-badge {
|
||||
display: inline-block;
|
||||
padding: 0.25em 0.65em;
|
||||
font-size: 0.75em;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
color: #000;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
vertical-align: baseline;
|
||||
border-radius: 0.375rem;
|
||||
background-color: #cff4fc;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
private string selectedFaction = DataType.Any;
|
||||
private string selectedImmortal = DataType.Any;
|
||||
private List<ImmortalChoice> immortalChoices = new();
|
||||
|
||||
private List<EntityModel> allEntities = new();
|
||||
private List<EntityModel> filteredEntities = new();
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
allEntities = EntityModel.GetList()
|
||||
.Where(e => !e.IsSpeculative)
|
||||
.ToList();
|
||||
RefreshImmortalChoices();
|
||||
ApplyFilters();
|
||||
}
|
||||
|
||||
private void OnFactionChanged()
|
||||
{
|
||||
if (selectedFaction != DataType.FACTION_QRath && selectedFaction != DataType.FACTION_Aru)
|
||||
{
|
||||
selectedFaction = DataType.Any;
|
||||
}
|
||||
selectedImmortal = DataType.Any;
|
||||
RefreshImmortalChoices();
|
||||
ApplyFilters();
|
||||
}
|
||||
|
||||
private void OnImmortalChanged()
|
||||
{
|
||||
ApplyFilters();
|
||||
}
|
||||
|
||||
private void RefreshImmortalChoices()
|
||||
{
|
||||
immortalChoices.Clear();
|
||||
|
||||
if (selectedFaction == DataType.FACTION_QRath || selectedFaction == DataType.Any)
|
||||
{
|
||||
AddImmortalChoice(DataType.IMMORTAL_Orzum);
|
||||
AddImmortalChoice(DataType.IMMORTAL_Ajari);
|
||||
}
|
||||
|
||||
if (selectedFaction == DataType.FACTION_Aru || selectedFaction == DataType.Any)
|
||||
{
|
||||
AddImmortalChoice(DataType.IMMORTAL_Atzlan);
|
||||
AddImmortalChoice(DataType.IMMORTAL_Mala);
|
||||
AddImmortalChoice(DataType.IMMORTAL_Xol);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddImmortalChoice(string id)
|
||||
{
|
||||
var name = EntityData.Get().TryGetValue(id, out var model)
|
||||
? model.Info().Name
|
||||
: id.Replace("IMMORTAL_", "");
|
||||
immortalChoices.Add(new ImmortalChoice(id, name));
|
||||
}
|
||||
|
||||
private void ApplyFilters()
|
||||
{
|
||||
var query = allEntities.AsEnumerable();
|
||||
|
||||
if (selectedFaction != DataType.Any)
|
||||
{
|
||||
query = query.Where(e =>
|
||||
e.Faction() != null && e.Faction().Faction == selectedFaction);
|
||||
}
|
||||
|
||||
if (selectedImmortal != DataType.Any)
|
||||
{
|
||||
query = query.Where(e =>
|
||||
e.VanguardAdded() != null && e.VanguardAdded().ImmortalId == selectedImmortal);
|
||||
}
|
||||
|
||||
filteredEntities = query.OrderBy(e => e.Info().Name).ToList();
|
||||
}
|
||||
|
||||
private record ImmortalChoice(string Key, string Name);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
@page "/"
|
||||
|
||||
<h1>Hello, world!</h1>
|
||||
|
||||
Welcome to your new app.
|
||||
|
||||
<ButtonComponent>Test</ButtonComponent>
|
||||
@@ -0,0 +1,5 @@
|
||||
@page "/not-found"
|
||||
@layout MainLayout
|
||||
|
||||
<h3>Not Found</h3>
|
||||
<p>Sorry, the content you are looking for does not exist.</p>
|
||||
@@ -0,0 +1,64 @@
|
||||
@page "/weather"
|
||||
|
||||
<h1>Weather</h1>
|
||||
|
||||
<p>This component demonstrates showing data.</p>
|
||||
|
||||
@if (forecasts == null)
|
||||
{
|
||||
<p>
|
||||
<em>Loading...</em>
|
||||
</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th aria-label="Temperature in Celsius">Temp. (C)</th>
|
||||
<th aria-label="Temperature in Fahrenheit">Temp. (F)</th>
|
||||
<th>Summary</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var forecast in forecasts)
|
||||
{
|
||||
<tr>
|
||||
<td>@forecast.Date.ToShortDateString()</td>
|
||||
<td>@forecast.TemperatureC</td>
|
||||
<td>@forecast.TemperatureF</td>
|
||||
<td>@forecast.Summary</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
@code {
|
||||
private WeatherForecast[]? forecasts;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
// Simulate asynchronous loading to demonstrate a loading indicator
|
||||
await Task.Delay(500);
|
||||
|
||||
var startDate = DateOnly.FromDateTime(DateTime.Now);
|
||||
var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" };
|
||||
forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = startDate.AddDays(index),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = summaries[Random.Shared.Next(summaries.Length)]
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
private class WeatherForecast
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
public int TemperatureC { get; set; }
|
||||
public string? Summary { get; set; }
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user