Download plugin have progress status
This commit is contained in:
32
DiscordBotWebUI/Components/CustomTags/ProgressDialog.razor
Normal file
32
DiscordBotWebUI/Components/CustomTags/ProgressDialog.razor
Normal 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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user