mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
have akka.net and signalr communicating
This commit is contained in:
64
Management.Web/Pages/CanvasRequestsQueue.razor
Normal file
64
Management.Web/Pages/CanvasRequestsQueue.razor
Normal file
@@ -0,0 +1,64 @@
|
||||
@page "/test"
|
||||
@rendermode InteractiveServer
|
||||
|
||||
@using Microsoft.AspNetCore.SignalR.Client
|
||||
|
||||
@inject CanvasService canvas
|
||||
@inject CoursePlanner planner
|
||||
@inject FileStorageManager fileStorageManager
|
||||
@inject IActorBridge bridge
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
@code {
|
||||
private HubConnection? hubConnection;
|
||||
public string? CourseName = "1400";
|
||||
@* private bool loading = true; *@
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (planner.LocalCourse == null)
|
||||
{
|
||||
System.Diagnostics.Activity.Current = null;
|
||||
using var activity = DiagnosticsConfig.Source?.StartActivity("Loading Course");
|
||||
activity?.AddTag("CourseName", CourseName);
|
||||
var courses = await fileStorageManager.LoadSavedCourses();
|
||||
planner.LocalCourse = courses.First(c => c.Settings.Name == CourseName);
|
||||
}
|
||||
|
||||
|
||||
Console.WriteLine(Navigation.BaseUri + "SignalRHub");
|
||||
hubConnection = new HubConnectionBuilder()
|
||||
.WithUrl(Navigation.BaseUri + "SignalRHub")
|
||||
.WithAutomaticReconnect()
|
||||
.Build();
|
||||
|
||||
|
||||
hubConnection.On("SentFromActor", () =>
|
||||
{
|
||||
Console.WriteLine("recieved from actor");
|
||||
});
|
||||
|
||||
await hubConnection.StartAsync();
|
||||
|
||||
base.OnInitialized();
|
||||
@* loading = false; *@
|
||||
}
|
||||
|
||||
private async Task SendAkkaMessage()
|
||||
{
|
||||
System.Diagnostics.Activity.Current = null;
|
||||
using var activity = DiagnosticsConfig.Source?.StartActivity("sending akka message from blazor");
|
||||
|
||||
if (planner.LocalCourse != null && planner.LocalCourse.Settings.CanvasId != null && hubConnection?.ConnectionId != null)
|
||||
{
|
||||
ulong id = (ulong)planner.LocalCourse.Settings.CanvasId;
|
||||
|
||||
var message = new GetModulesMessage(0, id, (string)hubConnection.ConnectionId, activity?.TraceId, ParentSpan:
|
||||
activity?.SpanId);
|
||||
var response = await bridge.Ask<CanvasModulesMessage>(message);
|
||||
Console.WriteLine(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<button @onclick=SendAkkaMessage>test akka</button>
|
||||
@@ -6,12 +6,14 @@
|
||||
@using Management.Web.Pages.Course.Module.ModuleItems
|
||||
@using Management.Web.Shared.Components
|
||||
|
||||
|
||||
@inject FileStorageManager fileStorageManager
|
||||
@inject CanvasService canvas
|
||||
@inject CoursePlanner planner
|
||||
@inject NavigationManager navigtion
|
||||
@inject IConfiguration config
|
||||
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string? CourseName { get; set; }
|
||||
@@ -22,6 +24,9 @@
|
||||
{
|
||||
if (planner.LocalCourse == null)
|
||||
{
|
||||
System.Diagnostics.Activity.Current = null;
|
||||
using var activity = DiagnosticsConfig.Source?.StartActivity("Loading Course");
|
||||
activity?.AddTag("CourseName", CourseName);
|
||||
var courses = await fileStorageManager.LoadSavedCourses();
|
||||
planner.LocalCourse = courses.First(c => c.Settings.Name == CourseName);
|
||||
}
|
||||
@@ -38,37 +43,39 @@
|
||||
}
|
||||
|
||||
<PageTitle>@CourseName</PageTitle>
|
||||
|
||||
|
||||
<div style="height: 100vh;">
|
||||
|
||||
|
||||
@if (loading)
|
||||
{
|
||||
<Spinner />
|
||||
}
|
||||
@if (loading)
|
||||
{
|
||||
<Spinner />
|
||||
}
|
||||
|
||||
@if (planner.LocalCourse != null)
|
||||
{
|
||||
<div class="pb-3 d-flex justify-content-between" style="height: 4em;">
|
||||
<div class="my-auto">
|
||||
<button @onclick="selectNewCourse" class="btn btn-primary">
|
||||
Select New Course
|
||||
</button>
|
||||
<CourseSettings />
|
||||
<a class="btn btn-outline-secondary" target="_blank"
|
||||
href="@($"{config["CANVAS_URL"]}/courses/{planner.LocalCourse.Settings.CanvasId}")">
|
||||
View In Canvas
|
||||
</a>
|
||||
<div class="my-auto ms-2 d-inline">
|
||||
@planner.LocalCourse.Settings.Name
|
||||
@if (planner.LocalCourse != null)
|
||||
{
|
||||
<div class="pb-3 d-flex justify-content-between" style="height: 4em;">
|
||||
<div class="my-auto">
|
||||
<button @onclick="selectNewCourse" class="btn btn-primary">
|
||||
Select New Course
|
||||
</button>
|
||||
<CourseSettings />
|
||||
<a class="btn btn-outline-secondary" target="_blank"
|
||||
href="@($"{config["CANVAS_URL"]}/courses/{planner.LocalCourse.Settings.CanvasId}")">
|
||||
View In Canvas
|
||||
</a>
|
||||
<div class="my-auto ms-2 d-inline">
|
||||
@planner.LocalCourse.Settings.Name
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (planner.LoadingCanvasData)
|
||||
{
|
||||
<Spinner />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (planner.LoadingCanvasData)
|
||||
{
|
||||
<Spinner />
|
||||
}
|
||||
</div>
|
||||
<CourseDetails />
|
||||
}
|
||||
<CourseDetails />
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
@@ -34,7 +34,9 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
private int refreshKey;
|
||||
|
||||
}
|
||||
|
||||
<PageTitle>Index</PageTitle>
|
||||
|
||||
<br>
|
||||
|
||||
Reference in New Issue
Block a user