Fixed UI crash when trying to open other pages then home while bot is offline
This commit is contained in:
@@ -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"]
|
||||
Reference in New Issue
Block a user