You've already forked linux-packaging-mono
Imported Upstream version 6.6.0.89
Former-commit-id: b39a328747c2f3414dc52e009fb6f0aa80ca2492
This commit is contained in:
parent
cf815e07e0
commit
95fdb59ea6
83
external/illinker-test-assets/wasm/BlazingPizza.Client/Pages/OrderDetails.razor
vendored
Normal file
83
external/illinker-test-assets/wasm/BlazingPizza.Client/Pages/OrderDetails.razor
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
@page "/myorders/{orderId:int}"
|
||||
@using System.Threading
|
||||
@inject HttpClient HttpClient
|
||||
@implements IDisposable
|
||||
@attribute [Authorize]
|
||||
|
||||
<div class="main">
|
||||
@if (invalidOrder)
|
||||
{
|
||||
<h2>Nope</h2>
|
||||
<p>Sorry, this order could not be loaded.</p>
|
||||
}
|
||||
else if (orderWithStatus == null)
|
||||
{
|
||||
<text>Loading...</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="track-order">
|
||||
<div class="track-order-title">
|
||||
<h2>
|
||||
Order placed @orderWithStatus.Order.CreatedTime.ToLongDateString()
|
||||
</h2>
|
||||
<p class="ml-auto mb-0">
|
||||
Status: <strong>@orderWithStatus.StatusText</strong>
|
||||
</p>
|
||||
</div>
|
||||
<div class="track-order-body">
|
||||
<div class="track-order-details">
|
||||
<OrderReview Order="@orderWithStatus.Order" />
|
||||
</div>
|
||||
<div class="track-order-map">
|
||||
<Map Zoom="13" Markers="@orderWithStatus.MapMarkers" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@functions {
|
||||
[Parameter] int OrderId { get; set; }
|
||||
|
||||
OrderWithStatus orderWithStatus;
|
||||
bool invalidOrder;
|
||||
CancellationTokenSource pollingCancellationToken;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
// If we were already polling for a different order, stop doing so
|
||||
pollingCancellationToken?.Cancel();
|
||||
|
||||
// Start a new poll loop
|
||||
PollForUpdates();
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
pollingCancellationToken?.Cancel();
|
||||
}
|
||||
|
||||
private async void PollForUpdates()
|
||||
{
|
||||
pollingCancellationToken = new CancellationTokenSource();
|
||||
while (!pollingCancellationToken.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
invalidOrder = false;
|
||||
orderWithStatus = await HttpClient.GetJsonAsync<OrderWithStatus>($"orders/{OrderId}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
invalidOrder = true;
|
||||
pollingCancellationToken.Cancel();
|
||||
Console.Error.WriteLine(ex);
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
|
||||
await Task.Delay(4000);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user