Fixed UI crash when trying to open other pages then home while bot is offline
This commit is contained in:
@@ -1,25 +0,0 @@
|
|||||||
**/.dockerignore
|
|
||||||
**/.env
|
|
||||||
**/.git
|
|
||||||
**/.gitignore
|
|
||||||
**/.project
|
|
||||||
**/.settings
|
|
||||||
**/.toolstarget
|
|
||||||
**/.vs
|
|
||||||
**/.vscode
|
|
||||||
**/.idea
|
|
||||||
**/*.*proj.user
|
|
||||||
**/*.dbmdl
|
|
||||||
**/*.jfm
|
|
||||||
**/azds.yaml
|
|
||||||
**/bin
|
|
||||||
**/charts
|
|
||||||
**/docker-compose*
|
|
||||||
**/Dockerfile*
|
|
||||||
**/node_modules
|
|
||||||
**/npm-debug.log
|
|
||||||
**/obj
|
|
||||||
**/secrets.dev.yaml
|
|
||||||
**/values.dev.yaml
|
|
||||||
LICENSE
|
|
||||||
README.md
|
|
||||||
@@ -31,6 +31,8 @@ namespace DiscordBotCore
|
|||||||
|
|
||||||
public static Application CurrentApplication { get; private set; } = null!;
|
public static Application CurrentApplication { get; private set; } = null!;
|
||||||
|
|
||||||
|
public static bool IsRunning { get; private set; }
|
||||||
|
|
||||||
private static readonly string _ConfigFile = "./Data/Resources/config.json";
|
private static readonly string _ConfigFile = "./Data/Resources/config.json";
|
||||||
private static readonly string _PluginsDatabaseFile = "./Data/Resources/plugins.json";
|
private static readonly string _PluginsDatabaseFile = "./Data/Resources/plugins.json";
|
||||||
|
|
||||||
@@ -101,6 +103,8 @@ namespace DiscordBotCore
|
|||||||
|
|
||||||
CurrentApplication.InternalActionManager = new InternalActionManager();
|
CurrentApplication.InternalActionManager = new InternalActionManager();
|
||||||
await CurrentApplication.InternalActionManager.Initialize();
|
await CurrentApplication.InternalActionManager.Initialize();
|
||||||
|
|
||||||
|
IsRunning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -17,6 +17,12 @@
|
|||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (!Application.IsRunning)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var modules = await Application.CurrentApplication.ModuleManager.ServerGetAllModules();
|
var modules = await Application.CurrentApplication.ModuleManager.ServerGetAllModules();
|
||||||
foreach(var onlineModule in modules)
|
foreach(var onlineModule in modules)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,6 +18,12 @@
|
|||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(!Application.IsRunning)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var plugins = await Application.CurrentApplication.PluginManager.GetPluginsList();
|
var plugins = await Application.CurrentApplication.PluginManager.GetPluginsList();
|
||||||
|
|
||||||
if(plugins is null)
|
if(plugins is null)
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
@inject NotificationService NotificationService
|
@inject NotificationService NotificationService
|
||||||
@inject DialogService DialogService
|
@inject DialogService DialogService
|
||||||
|
|
||||||
<RadzenPanel>
|
@if (Application.IsRunning)
|
||||||
|
{
|
||||||
|
<RadzenPanel>
|
||||||
<HeaderTemplate>
|
<HeaderTemplate>
|
||||||
<RadzenText>Discord Bot requires a Bot Token, a prefix for normal commands and the server Ids on the servers it will be in</RadzenText>
|
<RadzenText>Discord Bot requires a Bot Token, a prefix for normal commands and the server Ids on the servers it will be in</RadzenText>
|
||||||
</HeaderTemplate>
|
</HeaderTemplate>
|
||||||
@@ -39,7 +41,13 @@
|
|||||||
<FooterTemplate>
|
<FooterTemplate>
|
||||||
<RadzenButton Text="Save" Click="SaveChanges"></RadzenButton>
|
<RadzenButton Text="Save" Click="SaveChanges"></RadzenButton>
|
||||||
</FooterTemplate>
|
</FooterTemplate>
|
||||||
</RadzenPanel>
|
</RadzenPanel>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<RadzenText>The application is not running. Please start the application first from the Home page</RadzenText>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string _Token = string.Empty;
|
private string _Token = string.Empty;
|
||||||
@@ -50,6 +58,11 @@
|
|||||||
{
|
{
|
||||||
base.OnInitialized();
|
base.OnInitialized();
|
||||||
|
|
||||||
|
if (!Application.IsRunning)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(Application.CurrentApplication.ApplicationEnvironmentVariables.TryGetValue("token", out var token))
|
if(Application.CurrentApplication.ApplicationEnvironmentVariables.TryGetValue("token", out var token))
|
||||||
{
|
{
|
||||||
_Token = token as string;
|
_Token = token as string;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class DiscordApplication
|
|||||||
|
|
||||||
private async Task<bool> LoadComponents()
|
private async Task<bool> LoadComponents()
|
||||||
{
|
{
|
||||||
await Application.CreateApplication(RequirementsSolver); // This is a placeholder for the RequirementsSolver delegate
|
await Application.CreateApplication(RequirementsSolver);
|
||||||
Application.Logger.SetOutFunction(LogWriter);
|
Application.Logger.SetOutFunction(LogWriter);
|
||||||
|
|
||||||
return Application.CurrentApplication.ApplicationEnvironmentVariables.ContainsKey("ServerID") &&
|
return Application.CurrentApplication.ApplicationEnvironmentVariables.ContainsKey("ServerID") &&
|
||||||
@@ -33,9 +33,9 @@ public class DiscordApplication
|
|||||||
|
|
||||||
public async Task Start()
|
public async Task Start()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!await LoadComponents())
|
if (!await LoadComponents())
|
||||||
{
|
{
|
||||||
|
Application.Logger.Log("Some required components are missing", LogType.Critical);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,6 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Remove="Data\**" />
|
<Content Remove="Data\**" />
|
||||||
<Content Include="..\.dockerignore">
|
|
||||||
<Link>.dockerignore</Link>
|
|
||||||
</Content>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
|
||||||
USER $APP_UID
|
|
||||||
WORKDIR /app
|
|
||||||
EXPOSE 8080
|
|
||||||
EXPOSE 8081
|
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
|
||||||
ARG BUILD_CONFIGURATION=Release
|
|
||||||
WORKDIR /src
|
|
||||||
COPY ["DiscordBotWebUI/DiscordBotWebUI.csproj", "DiscordBotWebUI/"]
|
|
||||||
COPY ["DiscordBotCore/DiscordBotCore.csproj", "DiscordBotCore/"]
|
|
||||||
RUN dotnet restore "DiscordBotWebUI/DiscordBotWebUI.csproj"
|
|
||||||
COPY . .
|
|
||||||
WORKDIR "/src/DiscordBotWebUI"
|
|
||||||
RUN dotnet build "DiscordBotWebUI.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
|
||||||
|
|
||||||
FROM build AS publish
|
|
||||||
ARG BUILD_CONFIGURATION=Release
|
|
||||||
RUN dotnet publish "DiscordBotWebUI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
|
||||||
|
|
||||||
FROM base AS final
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=publish /app/publish .
|
|
||||||
ENTRYPOINT ["dotnet", "DiscordBotWebUI.dll"]
|
|
||||||
@@ -32,11 +32,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscordBotWebUI", "DiscordB
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CppCompatibilityModule", "Modules\CppCompatibilityModule\CppCompatibilityModule.csproj", "{C67908F9-4A55-4DD8-B993-C26C648226F1}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CppCompatibilityModule", "Modules\CppCompatibilityModule\CppCompatibilityModule.csproj", "{C67908F9-4A55-4DD8-B993-C26C648226F1}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6D42702D-C449-40FD-9AE6-3FC407923A8B}"
|
|
||||||
ProjectSection(SolutionItems) = preProject
|
|
||||||
docker-compose.yml = docker-compose.yml
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|||||||
Reference in New Issue
Block a user