Download plugin have progress status

This commit is contained in:
2024-12-25 15:05:20 +02:00
parent a754b0e5a9
commit 49fe637455
10 changed files with 146 additions and 57 deletions

View File

@@ -0,0 +1,32 @@
@using DiscordBotWebUI.ServerCommunication.Sockets
@inject DialogService DialogService
<RadzenProgressBar Value="progressValue" ShowValue="false"/>
@code {
private float progressValue = 0f;
[Parameter]
public string ProgressUrl { get; set; }
[Parameter]
public string FirstMessage { get; set; }
protected override async Task OnInitializedAsync()
{
WebSocketClientService service = new WebSocketClientService();
await service.ConnectAsync(ProgressUrl);
await Task.Delay(1000);
await service.SendMessageAsync(FirstMessage);
service.OnMessageReceived += (msg) =>
{
progressValue = float.Parse(msg);
StateHasChanged();
};
await service.ReceiveMessages();
await Task.Delay(500);
DialogService.Close();
}
}

View File

@@ -2,6 +2,7 @@
@using DiscordBotWebUI.Components.CustomTags
@using DiscordBotWebUI.Models
@using DiscordBotWebUI.ServerCommunication
@inject DialogService DialogService
<Marketplace PluginModels="_PluginModels" OnPluginDownloadClick="OnModelSelected"/>
@@ -20,12 +21,22 @@
});
if(!response.Success)
{
Console.WriteLine(response.Message);
return;
}
Console.WriteLine("Plugin installed");
await DialogService.OpenAsync<ProgressDialog>($"Installing {itemName}", new Dictionary<string, object>()
{
{"ProgressUrl", "/plugin/download/progress"},
{"FirstMessage", itemName}
}, new DialogOptions()
{
Draggable = false,
CloseDialogOnEsc = false,
CloseDialogOnOverlayClick = false,
ShowClose = false
});
}
protected override async Task OnInitializedAsync()