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

@@ -25,7 +25,6 @@ public class ApiManager
AddEndpoint(new PluginListEndpoint());
AddEndpoint(new PluginListInstalledEndpoint());
AddEndpoint(new PluginInstallEndpoint());
AddEndpoint(new PluginInstallGetProgressEndpoint());
AddEndpoint(new SettingsChangeEndpoint());
AddEndpoint(new SettingsGetEndpoint());

View File

@@ -23,7 +23,7 @@ public class PluginInstallEndpoint : IEndpoint
return ApiResponse.Fail("Plugin not found.");
}
await Application.CurrentApplication.PluginManager.InstallPluginWithNoProgress(pluginInfo);
Application.CurrentApplication.PluginManager.InstallPluginWithNoProgress(pluginInfo);
return ApiResponse.Ok();
}
}

View File

@@ -1,29 +0,0 @@
using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;
using DiscordBotCore.Interfaces.API;
using DiscordBotCore.Others;
namespace DiscordBotCore.API.Endpoints.PluginManagement;
public class PluginInstallGetProgressEndpoint : IEndpoint
{
public string Path => "/api/plugin/install/progress";
public EndpointType HttpMethod => EndpointType.Get;
public async Task<ApiResponse> HandleRequest(string? jsonRequest)
{
if (!Application.CurrentApplication.PluginManager.InstallingPluginInformation.IsInstalling)
{
return ApiResponse.Fail("No plugin is currently being installed.");
}
var progress = Application.CurrentApplication.PluginManager.InstallingPluginInformation.InstallationProgress;
string stringProgress = progress.ToString(CultureInfo.InvariantCulture);
var response = new Dictionary<string, string>
{
{"progress", stringProgress},
{"pluginName", Application.CurrentApplication.PluginManager.InstallingPluginInformation.PluginName}
};
return ApiResponse.From(await JsonManager.ConvertToJsonString(response), true);
}
}