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 bool IsRunning { get; private set; }
|
||||
|
||||
private static readonly string _ConfigFile = "./Data/Resources/config.json";
|
||||
private static readonly string _PluginsDatabaseFile = "./Data/Resources/plugins.json";
|
||||
|
||||
@@ -101,6 +103,8 @@ namespace DiscordBotCore
|
||||
|
||||
CurrentApplication.InternalActionManager = new InternalActionManager();
|
||||
await CurrentApplication.InternalActionManager.Initialize();
|
||||
|
||||
IsRunning = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -17,6 +17,12 @@
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
||||
if (!Application.IsRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var modules = await Application.CurrentApplication.ModuleManager.ServerGetAllModules();
|
||||
foreach(var onlineModule in modules)
|
||||
{
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
||||
if(!Application.IsRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var plugins = await Application.CurrentApplication.PluginManager.GetPluginsList();
|
||||
|
||||
if(plugins is null)
|
||||
|
||||
@@ -3,43 +3,51 @@
|
||||
@inject NotificationService NotificationService
|
||||
@inject DialogService DialogService
|
||||
|
||||
<RadzenPanel>
|
||||
<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>
|
||||
</HeaderTemplate>
|
||||
<ChildContent>
|
||||
<RadzenRow>
|
||||
<RadzenColumn>
|
||||
<RadzenText>Discord Bot Token</RadzenText>
|
||||
</RadzenColumn>
|
||||
<RadzenColumn>
|
||||
<RadzenTextBox Placeholder="Token..." Value="@_Token" ValueChanged="TokenValueChanged"></RadzenTextBox>
|
||||
</RadzenColumn>
|
||||
</RadzenRow>
|
||||
@if (Application.IsRunning)
|
||||
{
|
||||
<RadzenPanel>
|
||||
<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>
|
||||
</HeaderTemplate>
|
||||
<ChildContent>
|
||||
<RadzenRow>
|
||||
<RadzenColumn>
|
||||
<RadzenText>Discord Bot Token</RadzenText>
|
||||
</RadzenColumn>
|
||||
<RadzenColumn>
|
||||
<RadzenTextBox Placeholder="Token..." Value="@_Token" ValueChanged="TokenValueChanged"></RadzenTextBox>
|
||||
</RadzenColumn>
|
||||
</RadzenRow>
|
||||
|
||||
<RadzenRow>
|
||||
<RadzenColumn>
|
||||
<RadzenText>Bot prefix</RadzenText>
|
||||
</RadzenColumn>
|
||||
<RadzenColumn>
|
||||
<RadzenTextBox Placeholder="Bot prefix ..." MaxLength="1" Value="@_Prefix" ValueChanged="PrefixValueChanged"></RadzenTextBox>
|
||||
</RadzenColumn>
|
||||
</RadzenRow>
|
||||
<RadzenRow>
|
||||
<RadzenColumn>
|
||||
<RadzenText>Bot prefix</RadzenText>
|
||||
</RadzenColumn>
|
||||
<RadzenColumn>
|
||||
<RadzenTextBox Placeholder="Bot prefix ..." MaxLength="1" Value="@_Prefix" ValueChanged="PrefixValueChanged"></RadzenTextBox>
|
||||
</RadzenColumn>
|
||||
</RadzenRow>
|
||||
|
||||
<RadzenRow>
|
||||
<RadzenColumn>
|
||||
<RadzenText>Bot Server Ids:</RadzenText>
|
||||
</RadzenColumn>
|
||||
<RadzenColumn>
|
||||
<RadzenTextArea Placeholder="One per line ..." Value="@_ServerIds" ValueChanged="ServerIDsValueChanged"></RadzenTextArea>
|
||||
</RadzenColumn>
|
||||
</RadzenRow>
|
||||
</ChildContent>
|
||||
<RadzenRow>
|
||||
<RadzenColumn>
|
||||
<RadzenText>Bot Server Ids:</RadzenText>
|
||||
</RadzenColumn>
|
||||
<RadzenColumn>
|
||||
<RadzenTextArea Placeholder="One per line ..." Value="@_ServerIds" ValueChanged="ServerIDsValueChanged"></RadzenTextArea>
|
||||
</RadzenColumn>
|
||||
</RadzenRow>
|
||||
</ChildContent>
|
||||
|
||||
<FooterTemplate>
|
||||
<RadzenButton Text="Save" Click="SaveChanges"></RadzenButton>
|
||||
</FooterTemplate>
|
||||
</RadzenPanel>
|
||||
}
|
||||
else
|
||||
{
|
||||
<RadzenText>The application is not running. Please start the application first from the Home page</RadzenText>
|
||||
}
|
||||
|
||||
<FooterTemplate>
|
||||
<RadzenButton Text="Save" Click="SaveChanges"></RadzenButton>
|
||||
</FooterTemplate>
|
||||
</RadzenPanel>
|
||||
|
||||
@code {
|
||||
private string _Token = string.Empty;
|
||||
@@ -49,6 +57,11 @@
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
|
||||
if (!Application.IsRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(Application.CurrentApplication.ApplicationEnvironmentVariables.TryGetValue("token", out var token))
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ public class DiscordApplication
|
||||
|
||||
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);
|
||||
|
||||
return Application.CurrentApplication.ApplicationEnvironmentVariables.ContainsKey("ServerID") &&
|
||||
@@ -33,9 +33,9 @@ public class DiscordApplication
|
||||
|
||||
public async Task Start()
|
||||
{
|
||||
|
||||
if (!await LoadComponents())
|
||||
{
|
||||
Application.Logger.Log("Some required components are missing", LogType.Critical);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="Data\**" />
|
||||
<Content Include="..\.dockerignore">
|
||||
<Link>.dockerignore</Link>
|
||||
</Content>
|
||||
</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
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CppCompatibilityModule", "Modules\CppCompatibilityModule\CppCompatibilityModule.csproj", "{C67908F9-4A55-4DD8-B993-C26C648226F1}"
|
||||
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
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
||||
Reference in New Issue
Block a user