Updated web ui

This commit is contained in:
2024-10-05 16:41:34 +03:00
parent 49403e70fd
commit c61a9d5e51
8 changed files with 68 additions and 7 deletions

View File

@@ -4,11 +4,6 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using DiscordBot.Utilities;
using DiscordBotCore;
using DiscordBotCore.Modules;
using DiscordBotCore.Others;
namespace DiscordBot; namespace DiscordBot;

View File

@@ -8,7 +8,6 @@ using DiscordBot.Utilities;
using DiscordBotCore; using DiscordBotCore;
using DiscordBotCore.Bot; using DiscordBotCore.Bot;
using DiscordBotCore.Others; using DiscordBotCore.Others;
using DiscordBotCore.Others.Exceptions;
using DiscordBotCore.Updater.Application; using DiscordBotCore.Updater.Application;
using Spectre.Console; using Spectre.Console;

View File

@@ -45,6 +45,12 @@ namespace DiscordBotCore.Modules
Modules = new(); Modules = new();
} }
public async Task<ModuleOnlineData?> ServerGetModuleWithName(string moduleName)
{
var modules = await ServerGetAllModules();
return modules.FirstOrDefault(module => module?.ModuleName == moduleName, null);
}
public async Task<List<ModuleOnlineData>> ServerGetAllModules(ModuleType? moduleTypeFilter = null) public async Task<List<ModuleOnlineData>> ServerGetAllModules(ModuleType? moduleTypeFilter = null)
{ {
string jsonDatabaseRemote = await ServerCom.GetAllTextFromUrl(_ModuleDatabase); string jsonDatabaseRemote = await ServerCom.GetAllTextFromUrl(_ModuleDatabase);

View File

@@ -0,0 +1,16 @@
@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,17 @@
<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 {
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 ...
";
}

View File

@@ -24,6 +24,13 @@
var modulesWithType = await Application.CurrentApplication.ModuleManager.ServerGetAllModules(requirement); var modulesWithType = await Application.CurrentApplication.ModuleManager.ServerGetAllModules(requirement);
AppendToList(modulesWithType); 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<ModuleOnlineData> listOfModules) private void AppendToList(List<ModuleOnlineData> listOfModules)

View File

@@ -0,0 +1,19 @@
@page "/welcome"
@using DiscordBotWebUI.Components.Items.Setup
@inject NavigationManager Navigation
<WelcomeComponent/>
<RadzenButton
Icon="arrow_forward"
ButtonStyle="ButtonStyle.Dark"
Style="position: absolute; right: -50px; top: 50%; transform: translateY(-50%); background-color: #2d3748; border: none; color: #63b3ed;"
Click="GoToNextPage" />
@code {
// Method to navigate to a new page
private void GoToNextPage()
{
Navigation.NavigateTo("/settings");
}
}

View File

@@ -23,7 +23,7 @@ public class Entry : ICommandAction
public bool RequireOtherThread => false; public bool RequireOtherThread => false;
public async Task Execute(string[]? args) public Task Execute(string[]? args)
{ {
try{ try{
string appUiComponent = "./Data/Test/libtestlib.dll"; string appUiComponent = "./Data/Test/libtestlib.dll";
@@ -49,5 +49,7 @@ public class Entry : ICommandAction
} catch (Exception dllException) { } catch (Exception dllException) {
Application.Logger.LogException(dllException, this); Application.Logger.LogException(dllException, this);
} }
return Task.CompletedTask;
} }
} }