Improved web ui

This commit is contained in:
2024-10-23 20:06:36 +03:00
parent c2dc01cbbb
commit cfcfecd4bc
19 changed files with 271 additions and 197 deletions

View File

@@ -0,0 +1,8 @@
@code {
[Parameter] public Action CompleteSetup { get; set; }
}
<RadzenHeading Size="H4">Final Setup</RadzenHeading>
<p>Your bot is almost ready! Click 'Finish' to complete the setup.</p>
<RadzenButton Text="Finish" Click="CompleteSetup" Style="margin-top: 20px;" />

View File

@@ -1,16 +0,0 @@
@using DiscordBotWebUI.Types
<Marketplace ListedItems="Items"/>
@code {
private List<MarketItem> Items = new List<MarketItem>();
protected override void OnInitialized()
{
base.OnInitialized();
Items.Clear();
// Load items
}
}

View File

@@ -0,0 +1,48 @@
@using DiscordBotCore
@using DiscordBotCore.Modules
@using DiscordBotCore.Others.Exceptions
@using DiscordBotWebUI.Types
@code {
[Parameter] public Action NextStep { get; set; }
[Parameter] public ModuleRequirement ModuleRequirementReference { get; set; }
private List<MarketItem> MarketItems = new List<MarketItem>();
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
foreach(var requirement in ModuleRequirementReference.RequiredModulesWithTypes)
{
var modulesWithType = await Application.CurrentApplication.ModuleManager.ServerGetAllModules(requirement);
AppendToList(modulesWithType);
}
foreach (var moduleName in ModuleRequirementReference.RequiredModulesWithNames)
{
var module = await Application.CurrentApplication.ModuleManager.ServerGetModuleWithName(moduleName);
MarketItem item = new MarketItem(module.ModuleName, module.ModuleAuthor, module.ModuleDescription, ItemType.Module);
MarketItems.Add(item);
}
}
private void AppendToList(List<ModuleOnlineData> listOfModules)
{
foreach (var module in listOfModules)
{
MarketItem item = new MarketItem(module.ModuleName, module.ModuleAuthor, module.ModuleDescription, ItemType.Module);
MarketItems.Add(item);
}
}
}
<RadzenHeading Size="H4">Download Dependencies</RadzenHeading>
<p>The bot needs to download certain files to function properly.</p>
@if (MarketItems.Any())
{
<Marketplace ListedItems="MarketItems"/>
}
<RadzenButton Click="NextStep" Text="Next"/>

View File

@@ -0,0 +1,60 @@
@using DiscordBotCore
@code {
[Parameter] public Action NextStep { get; set; }
private string BotToken { get; set; }
private string BotPrefix { get; set; }
private List<ulong> BotServers { get; set; }
private string BotServersString { get; set; }
private async void DoNextStep()
{
if(string.IsNullOrEmpty(BotToken) || string.IsNullOrEmpty(BotPrefix) || string.IsNullOrEmpty(BotServersString))
{
return;
}
if(BotServersString.Contains(","))
{
BotServersString = BotServersString.Replace(",", ";");
}
var stringList = BotServersString.Split(';');
BotServers = new List<ulong>();
foreach(var serverId in stringList)
{
if(ulong.TryParse(serverId, out ulong id))
{
BotServers.Add(id);
}
}
if (!BotServers.Any())
{
return;
}
Application.CurrentApplication.ApplicationEnvironmentVariables.Add("token", BotToken);
Application.CurrentApplication.ApplicationEnvironmentVariables.Add("prefix", BotPrefix);
Application.CurrentApplication.ApplicationEnvironmentVariables.Add("ServerID", BotServers);
await Application.CurrentApplication.ApplicationEnvironmentVariables.SaveToFile();
NextStep.Invoke();
}
}
<RadzenHeading Size="H4">Basic Configuration</RadzenHeading>
<p>Please provide some basic settings to get started.</p>
<RadzenLabel Text="Token" />
<RadzenTextBox @bind-Value="BotToken" Placeholder="Enter bot token here" Style="width: 100%;" />
<RadzenLabel Text="Prefix" Style="margin-top: 10px;" />
<RadzenTextBox @bind-Value="BotPrefix" Placeholder="Enter the prefix here" Style="width: 100%;" />
<RadzenLabel Text="Server Ids separated by ;" Style="margin-top: 20px;" />
<RadzenTextBox @bind-Value="BotServersString" Placeholder="Enter Server Ids here. Separated by commas (;)" Style="width: 100%;" />
<RadzenButton Text="Next" Click="DoNextStep" Style="margin-top: 30px;" />

View File

@@ -1,17 +1,7 @@
<div style="display: flex; justify-content: center; align-items: center; height: 100vh;">
<RadzenCard Style="position: relative; background-color: #2d3748; color: #fff; max-width: 450px; padding: 30px; box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3); border-radius: 12px;">
<RadzenHeading Size="H2" Text=@_Title Style="text-align: center; color: #e2e8f0;" />
<RadzenText Text=@_Text Style="text-align: center; color: #a0aec0;" />
</RadzenCard>
</div>
@code {
[Parameter] public Action NextStep { get; set; }
}
@code {
private static readonly string _Title = "Welcome to Seth Discord Bot setup page";
private static readonly string _Text =
@"
Seth Discord Bot is a small yet powerful Discord Bot that allows you to integrate custom commands and events into your Discord server.
But let's start with the configuration first. Please click the arrow to the right to begin ...
";
}
<RadzenHeading Size="H4">Welcome to the Bot Setup Wizard</RadzenHeading>
<p>This setup wizard will guide you through the process of configuring your bot and downloading the necessary dependencies.</p>
<RadzenButton Text="Start Setup" Click="NextStep" Style="margin-top: 20px;" />