From c61a9d5e512dba09ef51c555d2fb3791397050fa Mon Sep 17 00:00:00 2001 From: Andrei Tudor Date: Sat, 5 Oct 2024 16:41:34 +0300 Subject: [PATCH] Updated web ui --- DiscordBot/Entry.cs | 5 ----- DiscordBot/Program.cs | 1 - DiscordBotCore/Modules/ModuleManager.cs | 6 ++++++ .../Components/Items/Setup/ModuleSetup.razor | 16 ++++++++++++++++ .../Items/Setup/WelcomeComponent.razor | 17 +++++++++++++++++ .../Pages/Setup/InstallRequiredModules.razor | 7 +++++++ .../Components/Pages/Setup/Welcome.razor | 19 +++++++++++++++++++ Plugins/DiscordBotUI/Entry.cs | 4 +++- 8 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 DiscordBotWebUI/Components/Items/Setup/ModuleSetup.razor create mode 100644 DiscordBotWebUI/Components/Items/Setup/WelcomeComponent.razor create mode 100644 DiscordBotWebUI/Components/Pages/Setup/Welcome.razor diff --git a/DiscordBot/Entry.cs b/DiscordBot/Entry.cs index e0cdbaa..ebba9ca 100644 --- a/DiscordBot/Entry.cs +++ b/DiscordBot/Entry.cs @@ -4,11 +4,6 @@ using System.IO; using System.Linq; using System.Reflection; -using DiscordBot.Utilities; -using DiscordBotCore; -using DiscordBotCore.Modules; -using DiscordBotCore.Others; - namespace DiscordBot; diff --git a/DiscordBot/Program.cs b/DiscordBot/Program.cs index 187018a..69449c3 100644 --- a/DiscordBot/Program.cs +++ b/DiscordBot/Program.cs @@ -8,7 +8,6 @@ using DiscordBot.Utilities; using DiscordBotCore; using DiscordBotCore.Bot; using DiscordBotCore.Others; -using DiscordBotCore.Others.Exceptions; using DiscordBotCore.Updater.Application; using Spectre.Console; diff --git a/DiscordBotCore/Modules/ModuleManager.cs b/DiscordBotCore/Modules/ModuleManager.cs index c312a74..86a3679 100644 --- a/DiscordBotCore/Modules/ModuleManager.cs +++ b/DiscordBotCore/Modules/ModuleManager.cs @@ -45,6 +45,12 @@ namespace DiscordBotCore.Modules Modules = new(); } + public async Task ServerGetModuleWithName(string moduleName) + { + var modules = await ServerGetAllModules(); + return modules.FirstOrDefault(module => module?.ModuleName == moduleName, null); + } + public async Task> ServerGetAllModules(ModuleType? moduleTypeFilter = null) { string jsonDatabaseRemote = await ServerCom.GetAllTextFromUrl(_ModuleDatabase); diff --git a/DiscordBotWebUI/Components/Items/Setup/ModuleSetup.razor b/DiscordBotWebUI/Components/Items/Setup/ModuleSetup.razor new file mode 100644 index 0000000..0abc6c5 --- /dev/null +++ b/DiscordBotWebUI/Components/Items/Setup/ModuleSetup.razor @@ -0,0 +1,16 @@ +@using DiscordBotWebUI.Types + + + +@code { + private List Items = new List(); + + protected override void OnInitialized() + { + base.OnInitialized(); + + Items.Clear(); + + // Load items + } +} \ No newline at end of file diff --git a/DiscordBotWebUI/Components/Items/Setup/WelcomeComponent.razor b/DiscordBotWebUI/Components/Items/Setup/WelcomeComponent.razor new file mode 100644 index 0000000..7c57860 --- /dev/null +++ b/DiscordBotWebUI/Components/Items/Setup/WelcomeComponent.razor @@ -0,0 +1,17 @@ +
+ + + + +
+ +@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 ... +"; +} \ No newline at end of file diff --git a/DiscordBotWebUI/Components/Pages/Setup/InstallRequiredModules.razor b/DiscordBotWebUI/Components/Pages/Setup/InstallRequiredModules.razor index c1061dc..1e6bdfd 100644 --- a/DiscordBotWebUI/Components/Pages/Setup/InstallRequiredModules.razor +++ b/DiscordBotWebUI/Components/Pages/Setup/InstallRequiredModules.razor @@ -24,6 +24,13 @@ var modulesWithType = await Application.CurrentApplication.ModuleManager.ServerGetAllModules(requirement); AppendToList(modulesWithType); } + + foreach (var moduleName in Requirements.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 listOfModules) diff --git a/DiscordBotWebUI/Components/Pages/Setup/Welcome.razor b/DiscordBotWebUI/Components/Pages/Setup/Welcome.razor new file mode 100644 index 0000000..d40ccea --- /dev/null +++ b/DiscordBotWebUI/Components/Pages/Setup/Welcome.razor @@ -0,0 +1,19 @@ +@page "/welcome" +@using DiscordBotWebUI.Components.Items.Setup +@inject NavigationManager Navigation + + + + + +@code { + // Method to navigate to a new page + private void GoToNextPage() + { + Navigation.NavigateTo("/settings"); + } +} \ No newline at end of file diff --git a/Plugins/DiscordBotUI/Entry.cs b/Plugins/DiscordBotUI/Entry.cs index a295a6a..dddd0b7 100644 --- a/Plugins/DiscordBotUI/Entry.cs +++ b/Plugins/DiscordBotUI/Entry.cs @@ -23,7 +23,7 @@ public class Entry : ICommandAction public bool RequireOtherThread => false; - public async Task Execute(string[]? args) + public Task Execute(string[]? args) { try{ string appUiComponent = "./Data/Test/libtestlib.dll"; @@ -49,5 +49,7 @@ public class Entry : ICommandAction } catch (Exception dllException) { Application.Logger.LogException(dllException, this); } + + return Task.CompletedTask; } }