cleanup ui (part 1) + stupidity fix
This commit is contained in:
parent
dfda444956
commit
708ae080a3
|
@ -19,5 +19,8 @@ public enum AuditLogType
|
|||
AddDomainRecord,
|
||||
UpdateDomainRecord,
|
||||
DeleteDomainRecord,
|
||||
PasswordReset
|
||||
PasswordReset,
|
||||
CleanupEnabled,
|
||||
CleanupDisabled,
|
||||
CleanupTriggered,
|
||||
}
|
|
@ -37,12 +37,8 @@ public class CleanupService
|
|||
{
|
||||
ServiceScopeFactory = serviceScopeFactory;
|
||||
ConfigService = configService;
|
||||
|
||||
IConfiguration configuration = new ConfigurationBuilder()
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build();
|
||||
|
||||
var config = configuration.GetSection("Cleanup");
|
||||
var config = configService.GetSection("Moonlight").GetSection("Cleanup");
|
||||
|
||||
RequiredCpu = config.GetValue<int>("Cpu");
|
||||
RequiredMemory = config.GetValue<long>("Memory");
|
||||
|
@ -71,9 +67,9 @@ public class CleanupService
|
|||
|
||||
try
|
||||
{
|
||||
await Task.Delay((int)TimeSpan.FromMinutes(WaitTime).TotalMilliseconds);
|
||||
await Task.Delay((int) TimeSpan.FromMinutes(WaitTime).TotalMilliseconds);
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -338,7 +334,7 @@ public class CleanupService
|
|||
|
||||
watch.Stop();
|
||||
|
||||
Status = $"Cleanup finifhed. Duration: {Math.Round(TimeSpan.FromMilliseconds(watch.ElapsedMilliseconds).TotalMinutes, 2)} Minuten";
|
||||
Status = $"Cleanup finished. Duration: {Math.Round(TimeSpan.FromMilliseconds(watch.ElapsedMilliseconds).TotalMinutes, 2)} Minutes";
|
||||
PercentProgress = 100;
|
||||
OnUpdated?.Invoke(this, null);
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ namespace Moonlight
|
|||
builder.Services.AddScoped<AaPanelRepository>();
|
||||
builder.Services.AddScoped<WebsiteRepository>();
|
||||
builder.Services.AddScoped<DdosAttackRepository>();
|
||||
builder.Services.AddScoped<CleanupExceptionRepository>();
|
||||
|
||||
builder.Services.AddScoped<AuditLogEntryRepository>();
|
||||
builder.Services.AddScoped<ErrorLogEntryRepository>();
|
||||
|
|
185
Moonlight/Shared/Views/Admin/Servers/Cleanup.razor
Normal file
185
Moonlight/Shared/Views/Admin/Servers/Cleanup.razor
Normal file
|
@ -0,0 +1,185 @@
|
|||
@page "/admin/servers/cleanup"
|
||||
|
||||
@using Moonlight.App.Services
|
||||
@using Logging.Net
|
||||
@using Moonlight.App.Models.Misc
|
||||
@using Moonlight.App.Services.LogServices
|
||||
|
||||
@inject CleanupService CleanupService
|
||||
@inject AuditLogService AuditLogService
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
<PageTitle><TL>Cleanup</TL></PageTitle>
|
||||
|
||||
<IsAdmin>
|
||||
<div class="row g-5 g-xl-10 mb-5 mb-xl-10">
|
||||
<div class="col-xl-3">
|
||||
<div class="card card-flush bgi-no-repeat bgi-size-contain bgi-position-x-end h-xl-100" style="background-color: #170049;">
|
||||
<div class="card-header pt-5 mb-3">
|
||||
<div class="d-flex flex-center rounded-circle h-80px w-80px" style="border: 1px rgba(255, 255, 255, 0.4);background-color: #7239EA">
|
||||
<i class="text-white bx bxs-skull bx-lg"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body d-flex align-items-end mb-3">
|
||||
<div class="d-flex align-items-center">
|
||||
<span class="fs-4hx text-white fw-bold me-6">@(CleanupService.ServersCleaned)</span>
|
||||
<div class="fw-bold fs-6 text-white">
|
||||
<span class="d-block"><TL>Servers</TL></span>
|
||||
<span><TL>stopped</TL></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-3">
|
||||
<div class="card card-flush bgi-no-repeat bgi-size-contain bgi-position-x-end h-xl-100" style="background-color: #170049;">
|
||||
<div class="card-header pt-5 mb-3">
|
||||
<div class="d-flex flex-center rounded-circle h-80px w-80px" style="border: 1px rgba(255, 255, 255, 0.4);background-color: #7239EA">
|
||||
<i class="text-white bx bx-transfer bx-lg"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body d-flex align-items-end mb-3">
|
||||
<div class="d-flex align-items-center">
|
||||
<span class="fs-4hx text-white fw-bold me-6">@(CleanupService.CleanupsPerformed)</span>
|
||||
<div class="fw-bold fs-6 text-white">
|
||||
<span class="d-block"><TL>Cleanups</TL></span>
|
||||
<span><TL>executed</TL></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-3">
|
||||
<div class="card card-flush bgi-no-repeat bgi-size-contain bgi-position-x-end h-xl-100" style="background-color: #170049;">
|
||||
<div class="card-header pt-5 mb-3">
|
||||
<div class="d-flex flex-center rounded-circle h-80px w-80px" style="border: 1px rgba(255, 255, 255, 0.4);background-color: #7239EA">
|
||||
<i class="text-white bx bx-rocket bx-lg"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body d-flex align-items-end mb-3">
|
||||
<div class="d-flex align-items-center">
|
||||
<span class="fs-4hx text-white fw-bold me-6">@(CleanupService.ServersRunning)</span>
|
||||
<div class="fw-bold fs-6 text-white">
|
||||
<span class="d-block"><TL>Used clanup</TL></span>
|
||||
<span><TL>Servers</TL></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-3">
|
||||
<div class="card card-flush bgi-no-repeat bgi-size-contain bgi-position-x-end h-xl-100" style="background-color: #170049;">
|
||||
<div class="card-body d-flex align-items-end mb-3">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><TL>Status</TL>: <TL>@(CleanupService.Status)</TL></label>
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated bg-primary" role="progressbar" aria-valuenow="@(CleanupService.PercentProgress)" aria-valuemin="0" aria-valuemax="100" style="width: @(CleanupService.PercentProgress)%"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-3">
|
||||
<div class="card card-flush bgi-no-repeat bgi-size-contain bgi-position-x-end">
|
||||
<div class="card-body mb-3">
|
||||
<div class="align-items-top">
|
||||
<div class="fw-bold fs-6 text-white">
|
||||
<div class="row mb-3">
|
||||
@if (CleanupService.IsRunning)
|
||||
{
|
||||
<button class="btn btn-primary disabled" disabled="">
|
||||
<TL>Start</TL>
|
||||
</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button @onclick="Trigger" class="btn btn-primary">
|
||||
<TL>Start</TL>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
@if (CleanupService.Activated)
|
||||
{
|
||||
<button class="btn btn-success disabled" disabled="">
|
||||
<TL>Enable</TL>
|
||||
</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button @onclick="Enable" class="btn btn-success">
|
||||
<TL>Enable</TL>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
<div class="row">
|
||||
@if (CleanupService.Activated)
|
||||
{
|
||||
<button @onclick="Disabled" class="btn btn-danger">
|
||||
<TL>Disabble</TL>
|
||||
</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-danger disabled" disabled="">
|
||||
<TL>Disable</TL>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</IsAdmin>
|
||||
<NonAdmin>
|
||||
<UnauthorizedAlert></UnauthorizedAlert>
|
||||
</NonAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
protected async override Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
CleanupService.OnUpdated += OnUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUpdated(object? sender, EventArgs e)
|
||||
{
|
||||
Logger.Debug(CleanupService.PercentProgress);
|
||||
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
CleanupService.OnUpdated -= OnUpdated;
|
||||
}
|
||||
|
||||
private void Enable()
|
||||
{
|
||||
CleanupService.Activated = true;
|
||||
AuditLogService.Log(AuditLogType.CleanupEnabled, "The automatic cleanup has been activated");
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private void Disabled()
|
||||
{
|
||||
CleanupService.Activated = false;
|
||||
AuditLogService.Log(AuditLogType.CleanupDisabled, "The automatic cleanup has been disabled");
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async void Trigger()
|
||||
{
|
||||
await CleanupService.TriggerPerform();
|
||||
await AuditLogService.Log(AuditLogType.CleanupTriggered, "The automatic cleanup has been manually triggered");
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
|
@ -406,4 +406,24 @@ The City field is required.;The City field is required.
|
|||
The State field is required.;The State field is required.
|
||||
The Country field is required.;The Country field is required.
|
||||
Street and house number requered;Street and house number requered
|
||||
Max lenght reached;Max lenght reached
|
||||
Max lenght reached;Max lenght reached
|
||||
stopped;stopped
|
||||
Cleanups;Cleanups
|
||||
executed;executed
|
||||
Used clanup;Used clanup
|
||||
Checking Nodes;Checking Nodes
|
||||
Enable;Enable
|
||||
Disabble;Disabble
|
||||
Checking found servers;Checking found servers
|
||||
Scanning servers;Scanning servers
|
||||
Scanning code containers;Scanning code containers
|
||||
Cleanup finifhed. Duration: 0.08 Minuten;Cleanup finifhed. Duration: 0.08 Minuten
|
||||
Disable;Disable
|
||||
Cleanup finished. Duration: 0.08 Minuten;Cleanup finished. Duration: 0.08 Minuten
|
||||
Cleanup finished. Duration: 0.08 Minutes;Cleanup finished. Duration: 0.08 Minutes
|
||||
Cleanup finished. Duration: 0.13 Minutes;Cleanup finished. Duration: 0.13 Minutes
|
||||
Cleanup finished. Duration: 0.23 Minutes;Cleanup finished. Duration: 0.23 Minutes
|
||||
Cleanup finished. Duration: 0.14 Minutes;Cleanup finished. Duration: 0.14 Minutes
|
||||
Cleanup finished. Duration: 0.09 Minutes;Cleanup finished. Duration: 0.09 Minutes
|
||||
Cleanup finished. Duration: 0.1 Minutes;Cleanup finished. Duration: 0.1 Minutes
|
||||
Cleanup finished. Duration: 0.11 Minutes;Cleanup finished. Duration: 0.11 Minutes
|
||||
|
|
Loading…
Reference in a new issue