Updated the web UI to use the API. Reworked the looks of web UI

This commit is contained in:
2024-12-14 17:31:36 +02:00
parent 9102cfaa47
commit 54be74b1cb
27 changed files with 227 additions and 738 deletions

View File

@@ -1,6 +1,4 @@
using System.Reflection;
using DiscordBotWebUI.Components;
using DiscordBotWebUI.StartupActions;
using Radzen;
@@ -17,43 +15,6 @@ string logo =
";
var currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += LoadFromSameFolder;
static Assembly LoadFromSameFolder(object sender, ResolveEventArgs args)
{
Directory.CreateDirectory("./Libraries");
string requestingAssembly = args.RequestingAssembly?.GetName().Name;
var folderPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, $"Libraries/{requestingAssembly}");
var assemblyName = new AssemblyName(args.Name).Name + ".dll";
var assemblyPath = Path.Combine(folderPath, assemblyName);
if (File.Exists(assemblyPath))
{
var fileAssembly = Assembly.LoadFrom(assemblyPath);
return fileAssembly;
}
return null;
}
// Start startup actions if any
if (args.Length > 0)
{
// get all classes that derive from IStartupAction
var startupActions = Assembly.GetExecutingAssembly()
.GetTypes()
.Where(t => t.IsSubclassOf(typeof(IStartupAction)))
.Select(t => Activator.CreateInstance(t) as IStartupAction)
.ToList();
foreach(var argument in args)
{
startupActions.FirstOrDefault(action => action?.Command == argument)?.RunAction(argument.Split(' ')[1..]);
}
}
Console.Clear();
Console.ForegroundColor = ConsoleColor.DarkYellow;
@@ -66,6 +27,12 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddRadzenCookieThemeService(options =>
{
options.Name = "RadzenTheme"; // The name of the cookie
options.Duration = TimeSpan.FromDays(365); // The duration of the cookie
});
builder.Services.AddRadzenComponents();
var app = builder.Build();