add: gitea tools
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
@rendermode InteractiveServer
|
@rendermode InteractiveServer
|
||||||
@inject IChatSessionService ChatSessionService
|
@inject IChatSessionService ChatSessionService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject IJSRuntime JSRuntime
|
||||||
@using Alchegos.HCI.Models
|
@using Alchegos.HCI.Models
|
||||||
@using Alchegos.HCI.Services
|
@using Alchegos.HCI.Services
|
||||||
@implements IAsyncDisposable
|
@implements IAsyncDisposable
|
||||||
@@ -15,7 +16,10 @@
|
|||||||
<input @bind="currentSessionIdInput" placeholder="Enter or Generate Session ID" />
|
<input @bind="currentSessionIdInput" placeholder="Enter or Generate Session ID" />
|
||||||
<button @onclick="LoadSession" disabled="@isLoading">Load / Start Session</button>
|
<button @onclick="LoadSession" disabled="@isLoading">Load / Start Session</button>
|
||||||
<button @onclick="GenerateSessionId" disabled="@isLoading">Generate New ID</button>
|
<button @onclick="GenerateSessionId" disabled="@isLoading">Generate New ID</button>
|
||||||
<input @bind="externalWebhookUrl" placeholder="Server url">
|
<input @bind="externalWebhookUrl"
|
||||||
|
@bind:event="oninput"
|
||||||
|
@onchange="SaveWebhookUrlToLocalStorage"
|
||||||
|
placeholder="Server url">
|
||||||
@if (!string.IsNullOrEmpty(activeSessionId))
|
@if (!string.IsNullOrEmpty(activeSessionId))
|
||||||
{
|
{
|
||||||
<span>Active Session: @activeSessionId</span>
|
<span>Active Session: @activeSessionId</span>
|
||||||
@@ -64,10 +68,26 @@ else if (sessionLoadAttempted)
|
|||||||
private bool isLoading = false;
|
private bool isLoading = false;
|
||||||
private bool sessionLoadAttempted = false;
|
private bool sessionLoadAttempted = false;
|
||||||
private string externalWebhookUrl { get; set; } = string.Empty;
|
private string externalWebhookUrl { get; set; } = string.Empty;
|
||||||
|
private const string WebhookUrlStorageKey = "chatPage_externalWebhookUrl";
|
||||||
|
private bool _hasLoadedFromLocalStorage = false;
|
||||||
private string? _previousSessionId = null;
|
private string? _previousSessionId = null;
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(InitialSessionId))
|
||||||
|
currentSessionIdInput = InitialSessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
Console.WriteLine("--- OnInitializedAsync START ---");
|
||||||
|
externalWebhookUrl = await JSRuntime.InvokeAsync<string>("localStorage.getItem", WebhookUrlStorageKey) ?? string.Empty;
|
||||||
|
Console.WriteLine($"Loaded externalWebhookUrl from localStorage: '{externalWebhookUrl}'");
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(InitialSessionId))
|
||||||
|
currentSessionIdInput = InitialSessionId;
|
||||||
|
Console.WriteLine("--- OnInitializedAsync END ---");
|
||||||
|
}*/
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
Console.WriteLine($"--- OnParametersSetAsync START. InitialSessionId: {InitialSessionId} ---");
|
Console.WriteLine($"--- OnParametersSetAsync START. InitialSessionId: {InitialSessionId} ---");
|
||||||
@@ -97,8 +117,6 @@ else if (sessionLoadAttempted)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
Console.WriteLine("!!! Failed to get/create session in OnParametersSetAsync!");
|
Console.WriteLine("!!! Failed to get/create session in OnParametersSetAsync!");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
Console.WriteLine("--- OnParametersSetAsync END. isLoading set to false ---");
|
Console.WriteLine("--- OnParametersSetAsync END. isLoading set to false ---");
|
||||||
@@ -124,16 +142,39 @@ else if (sessionLoadAttempted)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnInitialized()
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(InitialSessionId))
|
|
||||||
currentSessionIdInput = InitialSessionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
if (firstRender && !string.IsNullOrEmpty(activeSessionId))
|
if (firstRender && !string.IsNullOrEmpty(activeSessionId) && !_hasLoadedFromLocalStorage)
|
||||||
|
{
|
||||||
await RegisterCallbacksAsync();
|
await RegisterCallbacksAsync();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
externalWebhookUrl = await JSRuntime.InvokeAsync<string>("localStorage.getItem", WebhookUrlStorageKey) ?? string.Empty;
|
||||||
|
Console.WriteLine($"Loaded externalWebhookUrl from localStorage: '{externalWebhookUrl}'");
|
||||||
|
_hasLoadedFromLocalStorage = true;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error loading from localStorage in OnAfterRenderAsync: {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
await base.OnAfterRenderAsync(firstRender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveWebhookUrlToLocalStorage()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await JSRuntime.InvokeVoidAsync("localStorage.setItem", WebhookUrlStorageKey, externalWebhookUrl);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error saving to localStorage: {ex.Message}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user