adding past hub and page skeleton to MAUI
This commit is contained in:
parent
5c44c951d5
commit
95e1c66adf
@ -28,15 +28,17 @@ public static class MauiProgram
|
|||||||
builder.Services.AddBlazorWebViewDeveloperTools();
|
builder.Services.AddBlazorWebViewDeveloperTools();
|
||||||
builder.Logging.AddDebug();
|
builder.Logging.AddDebug();
|
||||||
#endif
|
#endif
|
||||||
builder.Services.AddHttpClient();
|
builder.Services.AddHttpClient()
|
||||||
|
.AddTransient<ISelectorNetClient, SelectorNetClient>();
|
||||||
|
|
||||||
builder.Services.AddTransient<ISelectorNetClient, SelectorNetClient>();
|
|
||||||
builder.Services.AddSingleton<SessionManager>();
|
builder.Services.AddSingleton<SessionManager>();
|
||||||
|
|
||||||
builder.Services.AddSingleton<NowHubClient>();
|
builder.Services.AddSingleton<NowHubClient>()
|
||||||
builder.Services.AddSingleton<NowHubCache>();
|
.AddSingleton<NowHubCache>();
|
||||||
|
|
||||||
return builder.Build();
|
builder.Services.AddSingleton<PastHubClient>();
|
||||||
|
|
||||||
|
return builder.Build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
@using Selector.SignalR
|
@using Selector.SignalR
|
||||||
@inject NowHubClient nowClient
|
@inject NowHubClient nowClient
|
||||||
@inject NowHubCache nowCache
|
@inject NowHubCache nowCache
|
||||||
|
@inject PastHubClient pastClient
|
||||||
@inject ILogger<Index> logger
|
@inject ILogger<Index> logger
|
||||||
|
|
||||||
<h1>run that</h1>
|
<h1>run that</h1>
|
||||||
@ -16,6 +17,7 @@
|
|||||||
logger.LogInformation("Starting now hub connection");
|
logger.LogInformation("Starting now hub connection");
|
||||||
|
|
||||||
await nowClient.StartAsync();
|
await nowClient.StartAsync();
|
||||||
|
await pastClient.StartAsync();
|
||||||
nowCache.BindClient();
|
nowCache.BindClient();
|
||||||
await nowClient.OnConnected();
|
await nowClient.OnConnected();
|
||||||
}
|
}
|
||||||
|
23
Selector.MAUI/Pages/Past.razor
Normal file
23
Selector.MAUI/Pages/Past.razor
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
@page "/past"
|
||||||
|
@using Selector.SignalR;
|
||||||
|
@using System.Linq;
|
||||||
|
@implements IDisposable
|
||||||
|
|
||||||
|
<h1>Past</h1>
|
||||||
|
|
||||||
|
<div class="app">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="v-space"></div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
protected async override Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
20
Selector.MAUI/Pages/Past.razor.css
Normal file
20
Selector.MAUI/Pages/Past.razor.css
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
body {
|
||||||
|
}
|
||||||
|
|
||||||
|
.app {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
padding-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 641px) {
|
||||||
|
.app {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
width: 100%
|
||||||
|
}
|
||||||
|
}
|
@ -17,11 +17,13 @@ public class SelectorNetClient : ISelectorNetClient
|
|||||||
private readonly HttpClient _client;
|
private readonly HttpClient _client;
|
||||||
private readonly string _baseUrl;
|
private readonly string _baseUrl;
|
||||||
private readonly NowHubClient _nowClient;
|
private readonly NowHubClient _nowClient;
|
||||||
|
private readonly PastHubClient _pastClient;
|
||||||
|
|
||||||
public SelectorNetClient(HttpClient client, NowHubClient nowClient)
|
public SelectorNetClient(HttpClient client, NowHubClient nowClient, PastHubClient pastClient)
|
||||||
{
|
{
|
||||||
_client = client;
|
_client = client;
|
||||||
_nowClient = nowClient;
|
_nowClient = nowClient;
|
||||||
|
_pastClient = pastClient;
|
||||||
|
|
||||||
//var baseOverride = Environment.GetEnvironmentVariable("SELECTOR_BASE_URL");
|
//var baseOverride = Environment.GetEnvironmentVariable("SELECTOR_BASE_URL");
|
||||||
|
|
||||||
@ -83,6 +85,7 @@ public class SelectorNetClient : ISelectorNetClient
|
|||||||
ret.Status = TokenResponseStatus.OK;
|
ret.Status = TokenResponseStatus.OK;
|
||||||
ret.Token = result.Content.ReadFromJsonAsync<TokenNetworkResponse>().Result.Token;
|
ret.Token = result.Content.ReadFromJsonAsync<TokenNetworkResponse>().Result.Token;
|
||||||
_nowClient.Token = ret.Token;
|
_nowClient.Token = ret.Token;
|
||||||
|
_pastClient.Token = ret.Token;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -9,7 +9,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="nav-item px-3">
|
<div class="nav-item px-3">
|
||||||
<NavLink class="nav-link" href="now">
|
<NavLink class="nav-link" href="now">
|
||||||
<span class="oi oi-dashboard" aria-hidden="true"></span> Now
|
<span class="oi oi-media-play" aria-hidden="true"></span> Now
|
||||||
|
</NavLink>
|
||||||
|
</div>
|
||||||
|
<div class="nav-item px-3">
|
||||||
|
<NavLink class="nav-link" href="past">
|
||||||
|
<span class="oi oi-magnifying-glass" aria-hidden="true"></span> Past
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</div>
|
</div>
|
||||||
<div class="nav-item px-3">
|
<div class="nav-item px-3">
|
||||||
|
54
Selector.SignalR/PastHubClient.cs
Normal file
54
Selector.SignalR/PastHubClient.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using Microsoft.AspNetCore.SignalR.Client;
|
||||||
|
|
||||||
|
namespace Selector.SignalR;
|
||||||
|
|
||||||
|
public class PastHubClient: BaseSignalRClient, IPastHub, IDisposable
|
||||||
|
{
|
||||||
|
private List<IDisposable> SearchResultCallbacks = new();
|
||||||
|
private bool disposedValue;
|
||||||
|
|
||||||
|
public PastHubClient(string token = null): base("nowhub", token)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnRankResult(Action<IRankResult> action)
|
||||||
|
{
|
||||||
|
SearchResultCallbacks.Add(hubConnection.On(nameof(OnRankResult), action));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task OnConnected()
|
||||||
|
{
|
||||||
|
return hubConnection.InvokeAsync(nameof(OnConnected));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task OnSubmitted(IPastParams param)
|
||||||
|
{
|
||||||
|
return hubConnection.InvokeAsync(nameof(OnSubmitted), param);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (!disposedValue)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
foreach(var callback in SearchResultCallbacks)
|
||||||
|
{
|
||||||
|
callback.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
base.DisposeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
disposedValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||||
|
Dispose(disposing: true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user