173 lines
4.7 KiB
C#
173 lines
4.7 KiB
C#
// <auto-generated/>
|
|
#pragma warning disable 1591
|
|
#pragma warning disable 0414
|
|
#pragma warning disable 0649
|
|
#pragma warning disable 0169
|
|
|
|
namespace spanreed.Client.Shared
|
|
{
|
|
#line hidden
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
#nullable restore
|
|
#line 1 "/home/skins/projects/spanreed/Client/_Imports.razor"
|
|
using System.Net.Http;
|
|
|
|
#line default
|
|
#line hidden
|
|
#nullable disable
|
|
#nullable restore
|
|
#line 2 "/home/skins/projects/spanreed/Client/_Imports.razor"
|
|
using System.Net.Http.Json;
|
|
|
|
#line default
|
|
#line hidden
|
|
#nullable disable
|
|
#nullable restore
|
|
#line 3 "/home/skins/projects/spanreed/Client/_Imports.razor"
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
|
|
#line default
|
|
#line hidden
|
|
#nullable disable
|
|
#nullable restore
|
|
#line 4 "/home/skins/projects/spanreed/Client/_Imports.razor"
|
|
using Microsoft.AspNetCore.Components.Routing;
|
|
|
|
#line default
|
|
#line hidden
|
|
#nullable disable
|
|
#nullable restore
|
|
#line 5 "/home/skins/projects/spanreed/Client/_Imports.razor"
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
|
|
#line default
|
|
#line hidden
|
|
#nullable disable
|
|
#nullable restore
|
|
#line 6 "/home/skins/projects/spanreed/Client/_Imports.razor"
|
|
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
|
|
|
#line default
|
|
#line hidden
|
|
#nullable disable
|
|
#nullable restore
|
|
#line 7 "/home/skins/projects/spanreed/Client/_Imports.razor"
|
|
using Microsoft.AspNetCore.Components.WebAssembly.Http;
|
|
|
|
#line default
|
|
#line hidden
|
|
#nullable disable
|
|
#nullable restore
|
|
#line 8 "/home/skins/projects/spanreed/Client/_Imports.razor"
|
|
using Microsoft.JSInterop;
|
|
|
|
#line default
|
|
#line hidden
|
|
#nullable disable
|
|
#nullable restore
|
|
#line 9 "/home/skins/projects/spanreed/Client/_Imports.razor"
|
|
using spanreed.Client;
|
|
|
|
#line default
|
|
#line hidden
|
|
#nullable disable
|
|
#nullable restore
|
|
#line 10 "/home/skins/projects/spanreed/Client/_Imports.razor"
|
|
using spanreed.Client.Shared;
|
|
|
|
#line default
|
|
#line hidden
|
|
#nullable disable
|
|
#nullable restore
|
|
#line 1 "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor"
|
|
using Microsoft.AspNetCore.SignalR.Client;
|
|
|
|
#line default
|
|
#line hidden
|
|
#nullable disable
|
|
#nullable restore
|
|
#line 2 "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor"
|
|
using spanreed.Shared;
|
|
|
|
#line default
|
|
#line hidden
|
|
#nullable disable
|
|
public partial class NavMenu : Microsoft.AspNetCore.Components.ComponentBase, IDisposable
|
|
{
|
|
#pragma warning disable 1998
|
|
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
|
|
{
|
|
}
|
|
#pragma warning restore 1998
|
|
#nullable restore
|
|
#line 29 "/home/skins/projects/spanreed/Client/Shared/NavMenu.razor"
|
|
|
|
private string NewRoom;
|
|
private string NewRoomBox;
|
|
private bool collapseNavMenu = true;
|
|
|
|
private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
|
|
|
|
private void ToggleNavMenu()
|
|
{
|
|
collapseNavMenu = !collapseNavMenu;
|
|
}
|
|
|
|
private HubConnection hubConnection;
|
|
private List<string> rooms = new List<string>();
|
|
|
|
protected override async Task OnInitializedAsync() {
|
|
hubConnection = new HubConnectionBuilder().WithUrl(NavigationManager.ToAbsoluteUri("/addroom")).Build();
|
|
hubConnection.On<string>("NewRoom", name => {
|
|
rooms.Add(name);
|
|
rooms.Sort();
|
|
StateHasChanged();
|
|
});
|
|
var existing_rooms = await Http.GetFromJsonAsync<string[]>("Room");
|
|
|
|
if (existing_rooms != null) {
|
|
foreach (var room in existing_rooms)
|
|
{
|
|
rooms.Add(room);
|
|
rooms.Sort();
|
|
}
|
|
}
|
|
await hubConnection.StartAsync();
|
|
var roomName = NavigationManager.Uri.Split("/").LastOrDefault();
|
|
if (roomName.Length > 0) {
|
|
await hubConnection.SendAsync("AddRoom", NavigationManager.Uri.Split("/").LastOrDefault());
|
|
}
|
|
}
|
|
|
|
async Task EnterBar(KeyboardEventArgs e) {
|
|
if (e.Key.Equals("Enter")) {
|
|
Console.WriteLine(NewRoom);
|
|
await hubConnection.SendAsync("AddRoom", NewRoom);
|
|
NavigationManager.NavigateTo(NewRoom);
|
|
NewRoom = "";
|
|
NewRoomBox = "";
|
|
} else if (e.Key.Length == 1) {
|
|
NewRoom = NewRoom + e.Key;
|
|
}
|
|
}
|
|
|
|
public bool IsConnected =>
|
|
hubConnection.State == HubConnectionState.Connected;
|
|
|
|
public void Dispose() {
|
|
_ = hubConnection.DisposeAsync();
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
#nullable disable
|
|
[global::Microsoft.AspNetCore.Components.InjectAttribute] private HttpClient Http { get; set; }
|
|
[global::Microsoft.AspNetCore.Components.InjectAttribute] private NavigationManager NavigationManager { get; set; }
|
|
}
|
|
}
|
|
#pragma warning restore 1591
|