Merge branch 'v2' into AddTicketSystem
This commit is contained in:
commit
0e43278bdd
8 changed files with 98 additions and 9 deletions
|
@ -23,4 +23,5 @@ public class Events
|
|||
public static EventHandler<Ticket> OnTicketCreated;
|
||||
public static EventHandler<TicketMessageEventArgs> OnTicketMessage;
|
||||
public static EventHandler<Ticket> OnTicketUpdated;
|
||||
public static EventHandler OnMoonlightRestart;
|
||||
}
|
27
Moonlight/App/Services/Sys/MoonlightService.cs
Normal file
27
Moonlight/App/Services/Sys/MoonlightService.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using Moonlight.App.Event;
|
||||
using Moonlight.App.Extensions;
|
||||
using Moonlight.App.Helpers;
|
||||
|
||||
namespace Moonlight.App.Services.Sys;
|
||||
|
||||
public class MoonlightService // This service can be used to perform strictly panel specific actions
|
||||
{
|
||||
private readonly ConfigService ConfigService;
|
||||
public WebApplication Application { get; set; } // Do NOT modify using a plugin
|
||||
|
||||
public MoonlightService(ConfigService configService)
|
||||
{
|
||||
ConfigService = configService;
|
||||
}
|
||||
|
||||
public async Task Restart()
|
||||
{
|
||||
Logger.Info("Restarting moonlight");
|
||||
|
||||
// Notify all users that this instance will restart
|
||||
await Events.OnMoonlightRestart.InvokeAsync();
|
||||
await Task.Delay(TimeSpan.FromSeconds(3));
|
||||
|
||||
await Application.StopAsync();
|
||||
}
|
||||
}
|
|
@ -13,10 +13,14 @@ using Moonlight.App.Services.Interop;
|
|||
using Moonlight.App.Services.ServiceManage;
|
||||
using Moonlight.App.Services.Store;
|
||||
using Moonlight.App.Services.Ticketing;
|
||||
using Moonlight.App.Services.Sys;
|
||||
using Moonlight.App.Services.Users;
|
||||
using Moonlight.App.Services.Utils;
|
||||
using Serilog;
|
||||
|
||||
var configService = new ConfigService();
|
||||
var moonlightService = new MoonlightService(configService);
|
||||
|
||||
Directory.CreateDirectory(PathBuilder.Dir("storage"));
|
||||
Directory.CreateDirectory(PathBuilder.Dir("storage", "logs"));
|
||||
|
||||
|
@ -84,10 +88,11 @@ builder.Services.AddScoped<TicketCreateService>();
|
|||
|
||||
// Services
|
||||
builder.Services.AddScoped<IdentityService>();
|
||||
builder.Services.AddSingleton<ConfigService>();
|
||||
builder.Services.AddSingleton(configService);
|
||||
builder.Services.AddSingleton<SessionService>();
|
||||
builder.Services.AddSingleton<BucketService>();
|
||||
builder.Services.AddSingleton<MailService>();
|
||||
builder.Services.AddSingleton(moonlightService);
|
||||
|
||||
builder.Services.AddRazorPages();
|
||||
builder.Services.AddServerSideBlazor();
|
||||
|
@ -104,6 +109,7 @@ var config =
|
|||
builder.Logging.AddConfiguration(config.Build());
|
||||
|
||||
var app = builder.Build();
|
||||
moonlightService.Application = app;
|
||||
|
||||
app.UseStaticFiles();
|
||||
app.UseRouting();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "http://localhost:5132",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
|
|
18
Moonlight/Shared/Components/Alerts/RestartAlert.razor
Normal file
18
Moonlight/Shared/Components/Alerts/RestartAlert.razor
Normal file
|
@ -0,0 +1,18 @@
|
|||
@inject NavigationManager Navigation
|
||||
|
||||
<div class="w-100">
|
||||
<div class="card-body">
|
||||
<div class="text-start mb-8">
|
||||
<h1 class="text-dark mb-3 fs-3x">
|
||||
Restarting
|
||||
</h1>
|
||||
<div class="text-gray-400 fw-semibold fs-6">
|
||||
The panel is restarting. This may take a moment
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-stack">
|
||||
<a href="javascript:location.reload()" class="btn btn-primary me-2 flex-shrink-0">Reconnect</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -2,6 +2,7 @@
|
|||
@using Moonlight.App.Models.Abstractions
|
||||
@using Moonlight.App.Models.Enums
|
||||
@using Moonlight.Shared.Components.Auth
|
||||
@using Moonlight.App.Event
|
||||
|
||||
@inherits LayoutComponentBase
|
||||
@implements IDisposable
|
||||
|
@ -11,6 +12,7 @@
|
|||
@inject IdentityService IdentityService
|
||||
@inject SessionService SessionService
|
||||
@inject NavigationManager Navigation
|
||||
@inject IJSRuntime JsRuntime
|
||||
|
||||
@{
|
||||
var url = new Uri(Navigation.Uri);
|
||||
|
@ -32,6 +34,12 @@
|
|||
<ChangePassword/>
|
||||
</OverlayLayout>
|
||||
}
|
||||
else if (RestartLock)
|
||||
{
|
||||
<OverlayLayout>
|
||||
<RestartAlert/>
|
||||
</OverlayLayout>
|
||||
}
|
||||
else
|
||||
{
|
||||
<DefaultLayout>
|
||||
|
@ -90,6 +98,7 @@ else
|
|||
@code
|
||||
{
|
||||
private bool Initialized = false;
|
||||
private bool RestartLock = false;
|
||||
|
||||
private Session? MySession;
|
||||
|
||||
|
@ -114,6 +123,12 @@ else
|
|||
MySession.UpdatedAt = DateTime.UtcNow;
|
||||
}
|
||||
};
|
||||
|
||||
Events.OnMoonlightRestart += async (_, _) =>
|
||||
{
|
||||
RestartLock = true;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
};
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
|
|
|
@ -1,4 +1,14 @@
|
|||
<div class="d-flex flex-column flex-root" id="kt_app_root">
|
||||
@* disable any reconnect screens *@
|
||||
|
||||
<style>
|
||||
#components-reconnect-modal
|
||||
{
|
||||
display: none !important;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="d-flex flex-column flex-root" id="kt_app_root">
|
||||
<div class="d-flex flex-column flex-lg-row flex-column-fluid">
|
||||
<a href="/" class="d-block d-lg-none mx-auto py-20">
|
||||
<img alt="Logo" src="/metronic8/demo38/assets/media/logos/default.svg" class="theme-light-show h-25px">
|
||||
|
|
|
@ -2,7 +2,19 @@
|
|||
|
||||
@using Moonlight.App.Extensions.Attributes
|
||||
@using Moonlight.App.Models.Enums
|
||||
@using Moonlight.App.Services
|
||||
@using Moonlight.App.Services.Sys
|
||||
|
||||
@attribute [RequirePermission(Permission.AdminRoot)]
|
||||
|
||||
@inject MoonlightService MoonlightService
|
||||
|
||||
<AdminSysNavigation Index="0" />
|
||||
|
||||
<div class="row mt-5">
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="card card-body">
|
||||
<ConfirmButton OnClick="MoonlightService.Restart" Text="Restart" CssClasses="btn-danger" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in a new issue