Added pages for module and plugin download
This commit is contained in:
@@ -13,6 +13,14 @@
|
||||
@code {
|
||||
private string? _TextValue;
|
||||
|
||||
private DiscordBotStartup _DiscordBotStartup = null!;
|
||||
|
||||
protected override async void OnInitialized()
|
||||
{
|
||||
_DiscordBotStartup = new DiscordBotStartup(FixModules);
|
||||
await _DiscordBotStartup.CreateApplication();
|
||||
}
|
||||
|
||||
private async Task FixModules(ModuleRequirement requirements)
|
||||
{
|
||||
if(!requirements.RequireAny)
|
||||
@@ -27,19 +35,17 @@
|
||||
}
|
||||
|
||||
private async void Initialize()
|
||||
{
|
||||
DiscordBotStartup setup = new DiscordBotStartup(FixModules);
|
||||
|
||||
setup.Log += async (sender, str) => {
|
||||
{
|
||||
_DiscordBotStartup.Log += async (sender, str) => {
|
||||
_TextValue += str + "\n";
|
||||
await InvokeAsync(StateHasChanged);
|
||||
};
|
||||
|
||||
dynamic result = await setup.LoadComponents();
|
||||
dynamic result = _DiscordBotStartup.LoadComponents();
|
||||
|
||||
if (!result)
|
||||
{
|
||||
result = await DialogService.OpenAsync<FirstSetup>("Please complete this setup before starting the bot", new Dictionary<string, object>());
|
||||
result = await DialogService.OpenAsync<Settings>("Please complete this setup before starting the bot", new Dictionary<string, object>());
|
||||
|
||||
if (result != true)
|
||||
{
|
||||
@@ -47,7 +53,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
await setup.PrepareBot();
|
||||
await setup.RefreshPlugins(false);
|
||||
await _DiscordBotStartup.PrepareBot();
|
||||
await _DiscordBotStartup.RefreshPlugins(false);
|
||||
}
|
||||
}
|
||||
26
DiscordBotWebUI/Components/Pages/ModulesMarket.razor
Normal file
26
DiscordBotWebUI/Components/Pages/ModulesMarket.razor
Normal file
@@ -0,0 +1,26 @@
|
||||
@page "/market/modules"
|
||||
@using DiscordBotCore
|
||||
@using DiscordBotWebUI.Types
|
||||
@using DiscordBotWebUI.Components.Items
|
||||
|
||||
@if(_MarketItems is not null && _MarketItems.Any())
|
||||
{
|
||||
<Marketplace ListedItems="_MarketItems"/>
|
||||
} else
|
||||
{
|
||||
<RadzenText Text="There are no modules available right now ..."></RadzenText>
|
||||
}
|
||||
|
||||
@code {
|
||||
private readonly List<MarketItem>? _MarketItems = new List<MarketItem>();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var modules = await Application.CurrentApplication.ModuleManager.ServerGetAllModules();
|
||||
foreach(var onlineModule in modules)
|
||||
{
|
||||
var item = new MarketItem(onlineModule.ModuleName, onlineModule.ModuleAuthor, onlineModule.ModuleDescription, ItemType.Module);
|
||||
_MarketItems.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
37
DiscordBotWebUI/Components/Pages/PluginsMarket.razor
Normal file
37
DiscordBotWebUI/Components/Pages/PluginsMarket.razor
Normal file
@@ -0,0 +1,37 @@
|
||||
@page "/market/plugins"
|
||||
@using DiscordBotCore
|
||||
@using DiscordBotWebUI.Types
|
||||
@using DiscordBotWebUI.Components.Items
|
||||
|
||||
@if(_MarketItems is null)
|
||||
{
|
||||
<RadzenText Text="There are no plugins available right now ..."></RadzenText>
|
||||
}
|
||||
|
||||
@if(_MarketItems is not null && _MarketItems.Any())
|
||||
{
|
||||
<Marketplace ListedItems="_MarketItems"/>
|
||||
}
|
||||
|
||||
@code {
|
||||
private List<MarketItem>? _MarketItems;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var plugins = await Application.CurrentApplication.PluginManager.GetPluginsList();
|
||||
|
||||
if(plugins is null)
|
||||
{
|
||||
_MarketItems = null;
|
||||
return;
|
||||
}
|
||||
|
||||
_MarketItems = new List<MarketItem>();
|
||||
|
||||
foreach (var onlinePlugin in plugins)
|
||||
{
|
||||
var marketItem = new MarketItem(onlinePlugin.Name, onlinePlugin.Author, onlinePlugin.Description, ItemType.Plugin);
|
||||
_MarketItems.Add(marketItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
@using DiscordBotCore
|
||||
@inject DialogService DialogService
|
||||
@page "/settings"
|
||||
@using DiscordBotCore
|
||||
|
||||
<RadzenPanel>
|
||||
<HeaderTemplate>
|
||||
@@ -14,7 +14,7 @@
|
||||
<RadzenTextBox Placeholder="Token..." Value="@_Token" ValueChanged="TokenValueChanged"></RadzenTextBox>
|
||||
</RadzenColumn>
|
||||
</RadzenRow>
|
||||
|
||||
|
||||
<RadzenRow>
|
||||
<RadzenColumn>
|
||||
<RadzenText>Bot prefix</RadzenText>
|
||||
@@ -23,7 +23,7 @@
|
||||
<RadzenTextBox Placeholder="Bot prefix ..." MaxLength="1" Value="@_Prefix" ValueChanged="PrefixValueChanged"></RadzenTextBox>
|
||||
</RadzenColumn>
|
||||
</RadzenRow>
|
||||
|
||||
|
||||
<RadzenRow>
|
||||
<RadzenColumn>
|
||||
<RadzenText>Bot Server Ids:</RadzenText>
|
||||
@@ -33,14 +33,13 @@
|
||||
</RadzenColumn>
|
||||
</RadzenRow>
|
||||
</ChildContent>
|
||||
|
||||
|
||||
<FooterTemplate>
|
||||
<RadzenButton Text="Save" Click="SaveChanges"></RadzenButton>
|
||||
</FooterTemplate>
|
||||
</RadzenPanel>
|
||||
|
||||
@code {
|
||||
|
||||
private string _Token = string.Empty;
|
||||
private string _Prefix = string.Empty;
|
||||
private string _ServerIds = string.Empty;
|
||||
@@ -64,8 +63,8 @@
|
||||
|
||||
await Application.CurrentApplication.ApplicationEnvironmentVariables.SaveToFile();
|
||||
|
||||
DialogService.Close(true);
|
||||
}
|
||||
|
||||
private void ServerIDsValueChanged(string obj)
|
||||
{
|
||||
_ServerIds = obj;
|
||||
Reference in New Issue
Block a user