mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
51 lines
2.0 KiB
Plaintext
51 lines
2.0 KiB
Plaintext
|
|
@page "/weather"
|
||
|
|
@attribute [StreamRendering]
|
||
|
|
|
||
|
|
<PageTitle>Weather</PageTitle>
|
||
|
|
|
||
|
|
<h1>Weather</h1>
|
||
|
|
|
||
|
|
<p>This component demonstrates showing data.</p>
|
||
|
|
|
||
|
|
<!-- This page is rendered in SSR mode, so the FluentDataGrid component does not offer any interactivity (like sorting). -->
|
||
|
|
<FluentDataGrid GridTemplateColumns="1fr 1fr 1fr 2fr" Id="weathergrid" Items="@forecasts" Loading="@(forecasts == null)" Style="height:204px;" TGridItem="WeatherForecast">
|
||
|
|
<PropertyColumn Align="Align.Start" Property="@(c => c!.Date)" Title="Date"/>
|
||
|
|
<PropertyColumn Align="Align.Center" Property="@(c => c!.TemperatureC)" Title="Temp. (C)"/>
|
||
|
|
<PropertyColumn Align="Align.Center" Property="@(c => c!.TemperatureF)" Title="Temp. (F)"/>
|
||
|
|
<PropertyColumn Align="Align.End" Property="@(c => c!.Summary)" Title="Summary"/>
|
||
|
|
</FluentDataGrid>
|
||
|
|
|
||
|
|
@code {
|
||
|
|
private IQueryable<WeatherForecast>? forecasts;
|
||
|
|
|
||
|
|
protected override async Task OnInitializedAsync()
|
||
|
|
{
|
||
|
|
// Simulate asynchronous loading to demonstrate streaming rendering
|
||
|
|
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)]
|
||
|
|
})
|
||
|
|
.AsQueryable();
|
||
|
|
}
|
||
|
|
|
||
|
|
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);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|