Revert "update my DiscordBot branch"

This commit is contained in:
Spielepapagei
2023-04-29 10:09:40 +02:00
committed by GitHub
parent 7960c40ed0
commit 411cf63d74
152 changed files with 3249 additions and 9157 deletions

View File

@@ -2,7 +2,6 @@
@using Moonlight.App.Exceptions
@using Moonlight.App.Services
@using Logging.Net
@using Moonlight.App.ApiClients.CloudPanel
@inherits ErrorBoundaryBase
@inject AlertService AlertService
@@ -58,16 +57,12 @@ else
SmartTranslateService.Translate("Error from daemon"),
wingsException.Message
);
//TODO: Error log service
Logger.Warn($"Wings exception status code: {wingsException.StatusCode}");
}
else if (exception is CloudPanelException cloudPanelException)
else if (exception is PleskException pleskException)
{
await AlertService.Error(
SmartTranslateService.Translate("Error from cloud panel"),
cloudPanelException.Message
SmartTranslateService.Translate("Error from plesk"),
pleskException.Message
);
}
else if (exception is NotImplementedException)

View File

@@ -71,7 +71,7 @@
{
if (firstRender)
{
await JsRuntime.InvokeVoidAsync("moonlight.loading.loadMonaco");
await JsRuntime.InvokeVoidAsync("initMonacoTheme");
Editor.OnDidInit = new EventCallback<MonacoEditorBase>(this, async () =>
{

View File

@@ -1,5 +1,4 @@
@using Moonlight.App.Helpers.Files
@using Logging.Net
<div class="badge badge-lg badge-light-primary">
<div class="d-flex align-items-center flex-wrap">

View File

@@ -35,90 +35,88 @@
<table class="table align-middle table-row-dashed fs-6 gy-5 dataTable no-footer" style="width: 100%;">
<tbody class="fw-semibold text-gray-600">
<LazyLoader Load="Load">
<ContentBlock @ref="ContentBlock" AllowContentOverride="true">
<tr class="even">
<td class="w-10px">
</td>
<td>
<div class="d-flex align-items-center">
<span class="icon-wrapper">
<i class="bx bx-md bx-up-arrow-alt text-primary"></i>
</span>
<a href="#" @onclick:preventDefault @onclick="GoUp" class="ms-3 text-gray-800 text-hover-primary">
<TL>Go up</TL>
</a>
</div>
</td>
<td></td>
<td class="text-end">
<div class="d-flex justify-content-end">
<div class="ms-2">
</div>
</div>
</td>
</tr>
@foreach (var file in Data)
{
<tr class="even">
<td class="w-10px">
@if (!HideSelect)
{
<div class="form-check form-check-sm form-check-custom form-check-solid">
@{
var toggle = ToggleStatusCache.ContainsKey(file) && ToggleStatusCache[file];
}
@if (toggle)
{
<input @onclick="() => SetToggleState(file, false)" class="form-check-input" type="checkbox" checked="checked">
}
else
{
<input @onclick="() => SetToggleState(file, true)" class="form-check-input" type="checkbox">
}
</div>
}
</td>
<td>
<div class="d-flex align-items-center">
<span class="icon-wrapper">
<i class="bx bx-md bx-up-arrow-alt text-primary"></i>
@if (file.IsFile)
{
<i class="bx bx-md bx-file text-primary"></i>
}
else
{
<i class="bx bx-md bx-folder text-primary"></i>
}
</span>
<a href="#" @onclick:preventDefault @onclick="GoUp" class="ms-3 text-gray-800 text-hover-primary">
<TL>Go up</TL>
</a>
<a href="#" @onclick:preventDefault @onclick="() => OnClicked(file)" class="ms-3 text-gray-800 text-hover-primary">@(file.Name)</a>
</div>
</td>
<td></td>
<td>@(Formatter.FormatSize(file.Size))</td>
<td class="text-end">
<div class="d-flex justify-content-end">
<div class="ms-2">
<div class="ms-2 me-6">
@if (ContextActions.Any())
{
<ContextMenuTrigger MenuId="triggerMenu" MouseButtonTrigger="MouseButtonTrigger.Both" Data="file">
<button class="btn btn-sm btn-icon btn-light btn-active-light-primary me-2">
<span class="svg-icon svg-icon-5 m-0">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="10" y="10" width="4" height="4" rx="2" fill="currentColor"></rect>
<rect x="17" y="10" width="4" height="4" rx="2" fill="currentColor"></rect>
<rect x="3" y="10" width="4" height="4" rx="2" fill="currentColor"></rect>
</svg>
</span>
</button>
</ContextMenuTrigger>
}
</div>
</div>
</td>
</tr>
@foreach (var file in Data)
{
<tr class="even">
<td class="w-10px">
@if (!HideSelect)
{
<div class="form-check form-check-sm form-check-custom form-check-solid">
@{
var toggle = ToggleStatusCache.ContainsKey(file) && ToggleStatusCache[file];
}
@if (toggle)
{
<input @onclick="() => SetToggleState(file, false)" class="form-check-input" type="checkbox" checked="checked">
}
else
{
<input @onclick="() => SetToggleState(file, true)" class="form-check-input" type="checkbox">
}
</div>
}
</td>
<td>
<div class="d-flex align-items-center">
<span class="icon-wrapper">
@if (file.IsFile)
{
<i class="bx bx-md bx-file text-primary"></i>
}
else
{
<i class="bx bx-md bx-folder text-primary"></i>
}
</span>
<a href="#" @onclick:preventDefault @onclick="() => OnClicked(file)" class="ms-3 text-gray-800 text-hover-primary">@(file.Name)</a>
</div>
</td>
<td>@(Formatter.FormatSize(file.Size))</td>
<td class="text-end">
<div class="d-flex justify-content-end">
<div class="ms-2 me-6">
@if (ContextActions.Any())
{
<ContextMenuTrigger MenuId="triggerMenu" MouseButtonTrigger="MouseButtonTrigger.Both" Data="file">
<button class="btn btn-sm btn-icon btn-light btn-active-light-primary me-2">
<span class="svg-icon svg-icon-5 m-0">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="10" y="10" width="4" height="4" rx="2" fill="currentColor"></rect>
<rect x="17" y="10" width="4" height="4" rx="2" fill="currentColor"></rect>
<rect x="3" y="10" width="4" height="4" rx="2" fill="currentColor"></rect>
</svg>
</span>
</button>
</ContextMenuTrigger>
}
</div>
</div>
</td>
</tr>
}
</ContentBlock>
}
</LazyLoader>
</tbody>
</table>
@@ -140,13 +138,12 @@
@code
{
[Parameter]
public FileAccess Access { get; set; }
[Parameter]
public Func<FileData, Task<bool>>? OnElementClicked { get; set; }
[Parameter]
public Func<Task>? OnSelectionChanged { get; set; }
@@ -158,7 +155,7 @@
[Parameter]
public bool DisableScrolling { get; set; } = false;
[Parameter]
public Func<FileData, bool>? Filter { get; set; }
@@ -172,19 +169,15 @@
private Dictionary<FileData, bool> ToggleStatusCache = new();
private bool AllToggled = false;
private ContentBlock ContentBlock;
public async Task Refresh()
{
ContentBlock?.SetBlocking(true);
var list = new List<FileData>();
foreach (var fileData in await Access.Ls())
{
if (Filter != null)
{
if (Filter.Invoke(fileData))
if(Filter.Invoke(fileData))
list.Add(fileData);
}
else
@@ -192,7 +185,7 @@
}
Data = list.ToArray();
ToggleStatusCache.Clear();
AllToggled = false;
@@ -203,8 +196,6 @@
await InvokeAsync(StateHasChanged);
OnSelectionChanged?.Invoke();
ContentBlock?.SetBlocking(false);
}
private async Task Load(LazyLoader arg)
@@ -266,7 +257,7 @@
if (canceled)
return;
}
await Access.Up();
await Refresh();
}
@@ -282,4 +273,4 @@
return Task.CompletedTask;
}
}
}

View File

@@ -2,13 +2,13 @@
<div class="card-body pt-0 pb-0">
<ul class="nav nav-stretch nav-line-tabs nav-line-tabs-2x border-transparent fs-5 fw-bold">
<li class="nav-item mt-2">
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 0 ? "active" : "")" href="/admin/webspaces">
<TL>Webspaces</TL>
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 0 ? "active" : "")" href="/admin/websites">
<TL>Websites</TL>
</a>
</li>
<li class="nav-item mt-2">
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 1 ? "active" : "")" href="/admin/webspaces/servers">
<TL>Cloud panels</TL>
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 1 ? "active" : "")" href="/admin/websites/servers">
<TL>Plesk servers</TL>
</a>
</li>
</ul>

View File

@@ -1,52 +0,0 @@
@if (AllowContentOverride)
{
if (IsBlocking)
{
<div class="overlay overlay-block">
<div class="overlay-wrapper p-5">
@(ChildContent)
</div>
<div class="overlay-layer">
<div class="spinner-border text-primary" role="status">
</div>
</div>
</div>
}
else
{
@ChildContent
}
}
else
{
<div class="@(IsBlocking ? "overlay overlay-block" : "")">
<div class="@(IsBlocking ? "overlay-wrapper p-5" : "")">
@(ChildContent)
</div>
@if (IsBlocking)
{
<div class="overlay-layer">
<div class="spinner-border text-primary" role="status">
</div>
</div>
}
</div>
}
@code
{
[Parameter]
public RenderFragment ChildContent { get; set; }
[Parameter]
public bool AllowContentOverride { get; set; } = false;
private bool IsBlocking = false;
public async Task SetBlocking(bool b)
{
IsBlocking = b;
await InvokeAsync(StateHasChanged);
}
}

View File

@@ -9,36 +9,33 @@
@inject NavigationManager NavigationManager
@inject CookieService CookieService
@if (User != null)
{
<div class="menu menu-column justify-content-center"
data-kt-menu="true">
<div class="menu-item">
<div class="dropdown">
<button class="btn btn-success dropdown-toggle" type="button" data-bs-toggle="dropdown">
<TL>Create</TL>
</button>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item py-2" href="/servers/create">
<TL>Server</TL>
</a>
</li>
<li>
<a class="dropdown-item py-2" href="/domains/create">
<TL>Domain</TL>
</a>
</li>
<li>
<a class="dropdown-item py-2" href="/webspaces/create">
<TL>Webspace</TL>
</a>
</li>
</ul>
</div>
<div class="menu menu-column justify-content-center"
data-kt-menu="true">
<div class="menu-item">
<div class="dropdown">
<button class="btn btn-success dropdown-toggle" type="button" data-bs-toggle="dropdown">
<TL>Create</TL>
</button>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item py-2" href="/servers/create">
<TL>Server</TL>
</a>
</li>
<li>
<a class="dropdown-item py-2" href="/domains/create">
<TL>Domain</TL>
</a>
</li>
<li>
<a class="dropdown-item py-2" href="/websites/create">
<TL>Website</TL>
</a>
</li>
</ul>
</div>
</div>
}
</div>
<div class="app-navbar flex-shrink-0">
<div class="app-navbar-item ms-1 ms-lg-3">

View File

@@ -45,11 +45,11 @@ else
</a>
</div>
<div class="menu-item">
<a class="menu-link" href="/webspaces">
<a class="menu-link" href="/websites">
<span class="menu-icon">
<i class="bx bx-globe"></i>
</span>
<span class="menu-title"><TL>Webspaces</TL></span>
<span class="menu-title"><TL>Websites</TL></span>
</a>
</div>
<div class="menu-item">
@@ -148,11 +148,11 @@ else
</div>
</div>
<div class="menu-item">
<a class="menu-link" href="/admin/webspaces">
<a class="menu-link" href="/admin/websites">
<span class="menu-icon">
<i class="bx bx-globe"></i>
</span>
<span class="menu-title"><TL>Webspaces</TL></span>
<span class="menu-title"><TL>Websites</TL></span>
</a>
</div>
<div class="menu-item">

View File

@@ -47,6 +47,6 @@
private async void TriggerFlashbang()
{
await JsRuntime.InvokeVoidAsync("moonlight.flashbang.run");
await JsRuntime.InvokeVoidAsync("flashbang");
}
}

View File

@@ -5,7 +5,6 @@
@using Logging.Net
@using BlazorContextMenu
@using Moonlight.App.Database.Entities
@using Moonlight.App.Events
@using Moonlight.App.Services.Interop
@inject ServerService ServerService
@@ -13,7 +12,7 @@
@inject AlertService AlertService
@inject ToastService ToastService
@inject ClipboardService ClipboardService
@inject EventSystem Event
@inject MessageService MessageService
@inject SmartTranslateService SmartTranslateService
@implements IDisposable
@@ -113,51 +112,64 @@
protected override void OnInitialized()
{
Event.On<ServerBackup>("wings.backups.create", this, async (backup) =>
MessageService.Subscribe<ServerBackups, ServerBackup>("wings.backups.create", this, (backup) =>
{
if (AllBackups == null)
return Task.CompletedTask;
if (AllBackups.Any(x => x.Id == backup.Id))
{
Task.Run(async () =>
{
await Task.Delay(TimeSpan.FromSeconds(1));
await ToastService.Success(SmartTranslateService.Translate("Backup successfully created"));
await LazyLoader.Reload();
});
}
return Task.CompletedTask;
});
MessageService.Subscribe<ServerBackups, ServerBackup>("wings.backups.createfailed", this, (backup) =>
{
if (AllBackups == null)
return Task.CompletedTask;
if (AllBackups.Any(x => x.Id == backup.Id))
{
Task.Run(async () =>
{
await ToastService.Error(SmartTranslateService.Translate("Backup creation failed"));
await LazyLoader.Reload();
});
}
return Task.CompletedTask;
});
MessageService.Subscribe<ServerBackups, ServerBackup>("wings.backups.delete", this, async (backup) =>
{
if (AllBackups == null)
return;
if (AllBackups.Any(x => x.Id == backup.Id))
{
await Task.Delay(TimeSpan.FromSeconds(1));
await ToastService.Success(SmartTranslateService.Translate("Backup successfully created"));
await LazyLoader.Reload();
Task.Run(async () =>
{
await ToastService.Success(SmartTranslateService.Translate("Backup successfully deleted"));
await LazyLoader.Reload();
});
}
});
Event.On<ServerBackup>("wings.backups.createFailed", this, async (backup) =>
MessageService.Subscribe<ServerBackups, ServerBackup>("wings.backups.restore", this, async (backup) =>
{
if (AllBackups == null)
return;
if (AllBackups.Any(x => x.Id == backup.Id))
{
await ToastService.Error(SmartTranslateService.Translate("Backup creation failed"));
await LazyLoader.Reload();
}
});
Event.On<ServerBackup>("wings.backups.delete", this, async (backup) =>
{
if (AllBackups == null)
return;
if (AllBackups.Any(x => x.Id == backup.Id))
{
await ToastService.Success(SmartTranslateService.Translate("Backup successfully deleted"));
await LazyLoader.Reload();
}
});
Event.On<ServerBackup>("wings.backups.restore", this, async (backup) =>
{
if (AllBackups == null)
return;
if (AllBackups.Any(x => x.Id == backup.Id))
{
await ToastService.Success(SmartTranslateService.Translate("Backup successfully restored"));
Task.Run(async () => { await ToastService.Success(SmartTranslateService.Translate("Backup successfully restored")); });
}
});
}
@@ -174,102 +186,95 @@
private async Task Download(ServerBackup serverBackup)
{
var url = await ServerService.DownloadBackup(CurrentServer, serverBackup);
NavigationManager.NavigateTo(url);
await ToastService.Success(SmartTranslateService.Translate("Backup download successfully started"));
/*
try
{
var url = await ServerService.DownloadBackup(CurrentServer, serverBackup);
NavigationManager.NavigateTo(url);
await ToastService.Success(SmartTranslateService.Translate("Backup download successfully started"));
}
catch (Exception e)
{
Logger.Warn("Error starting backup download");
Logger.Warn(e);
await ToastService.Error(SmartTranslateService.Translate("Backup download failed"));
}*/
}
}
private async Task CopyUrl(ServerBackup serverBackup)
{
var url = await ServerService.DownloadBackup(CurrentServer, serverBackup);
await ClipboardService.Copy(url);
await AlertService.Success(
SmartTranslateService.Translate("Success"),
SmartTranslateService.Translate("Backup URL successfully copied to your clipboard"));
/*
try
{
var url = await ServerService.DownloadBackup(CurrentServer, serverBackup);
await ClipboardService.CopyToClipboard(url);
await AlertService.Success(
SmartTranslateService.Translate("Success"),
SmartTranslateService.Translate("Backup URL successfully copied to your clipboard"));
}
catch (Exception e)
{
Logger.Warn("Error copying backup url");
Logger.Warn(e);
await ToastService.Error(SmartTranslateService.Translate("An unknown error occured while generating backup url"));
}*/
}
}
private async Task Delete(ServerBackup serverBackup)
{
await ToastService.Info(SmartTranslateService.Translate("Backup deletion started"));
await ServerService.DeleteBackup(CurrentServer, serverBackup);
/*
try
{
await ToastService.Info(SmartTranslateService.Translate("Backup deletion started"));
await ServerService.DeleteBackup(CurrentServer, serverBackup);
}
catch (Exception e)
{
Logger.Warn("Error deleting backup");
Logger.Warn(e);
await ToastService.Error(SmartTranslateService.Translate("An unknown error occured while starting backup deletion"));
}*/
}
}
private async Task Restore(ServerBackup serverBackup)
{
await ServerService.RestoreBackup(CurrentServer, serverBackup);
await ToastService.Info(SmartTranslateService.Translate("Backup restore started"));
/*
try
{
await ServerService.RestoreBackup(CurrentServer, serverBackup);
await ToastService.Info(SmartTranslateService.Translate("Backup restore started"));
}
catch (Exception e)
{
Logger.Warn("Error restoring backup");
Logger.Warn(e);
await ToastService.Error(SmartTranslateService.Translate("An unknown error occured while restoring a backup"));
}*/
}
}
private async Task Create()
{
await ToastService.Info(SmartTranslateService.Translate("Started backup creation"));
await ServerService.CreateBackup(CurrentServer);
await LazyLoader.Reload();
/*
try
{
await ToastService.Info(SmartTranslateService.Translate("Started backup creation"));
var backup = await ServerService.CreateBackup(CurrentServer);
/*
// Modify the backup list so no reload needed. Also the create event will work
//var list = AllBackups!.ToList();
//list.Add(backup);
//AllBackups = list.ToArray();
var list = AllBackups!.ToList();
list.Add(backup);
AllBackups = list.ToArray();
*/
await LazyLoader.Reload();
}
catch (Exception e)
{
Logger.Warn("Error creating backup");
Logger.Warn(e);
await ToastService.Error(SmartTranslateService.Translate("An unknown error has occured while creating a backup"));
}*/
}
}
private async Task OnContextMenuClick(ItemClickEventArgs args)
@@ -295,11 +300,11 @@
await Refresh(LazyLoader);
}
public async void Dispose()
public void Dispose()
{
await Event.Off("wings.backups.create", this);
await Event.Off("wings.backups.createFailed", this);
await Event.Off("wings.backups.restore", this);
await Event.Off("wings.backups.delete", this);
MessageService.Unsubscribe("wings.backups.create", this);
MessageService.Unsubscribe("wings.backups.createfailed", this);
MessageService.Unsubscribe("wings.backups.restore", this);
MessageService.Unsubscribe("wings.backups.delete", this);
}
}

View File

@@ -55,16 +55,7 @@
</div>
<div class="col fs-5">
<span class="fw-bold"><TL>Server ID</TL>:</span>
<span class="ms-1 text-muted">
@if (User.Admin)
{
<a href="/admin/servers/edit/@(CurrentServer.Id)">@(CurrentServer.Id)</a>
}
else
{
@(CurrentServer.Id)
}
</span>
<span class="ms-1 text-muted">@(CurrentServer.Id)</span>
</div>
<div class="col fs-5">
<span class="fw-bold"><TL>Status</TL>:</span>
@@ -173,9 +164,6 @@
{
[CascadingParameter]
public Server CurrentServer { get; set; }
[CascadingParameter]
public User User { get; set; }
[CascadingParameter]
public PteroConsole Console { get; set; }

View File

@@ -37,12 +37,6 @@
if(Tags.Contains("paperversion"))
Settings.Add("Paper version", typeof(PaperVersionSetting));
if(Tags.Contains("forgeversion"))
Settings.Add("Forge version", typeof(ForgeVersionSetting));
if(Tags.Contains("fabricversion"))
Settings.Add("Fabric version", typeof(FabricVersionSetting));
if(Tags.Contains("join2start"))
Settings.Add("Join2Start", typeof(Join2StartSetting));

View File

@@ -1,173 +0,0 @@
@using Moonlight.App.Services
@using Microsoft.EntityFrameworkCore
@using Moonlight.App.Database.Entities
@using Moonlight.App.Repositories
@using Moonlight.App.Repositories.Servers
@using Moonlight.App.Helpers
@inject ServerService ServerService
@inject ServerRepository ServerRepository
@inject ImageRepository ImageRepository
@inject FabricService FabricService
@inject SmartTranslateService TranslationService
<div class="col">
<div class="card card-body">
<LazyLoader Load="Load">
<label class="mb-2 form-label">
<TL>Fabric version</TL>
</label>
<input class="mb-2 form-control" disabled="" value="@(FabricVersion)"/>
<label class="mb-2 form-label">
<TL>Fabric loader version</TL>
</label>
<input class="mb-2 form-control" disabled="" value="@(LoaderVersion)"/>
<label class="mb-2 form-label">
<TL>Minecraft version</TL>
</label>
<select class="mb-2 form-select" @bind="CurrentVersion">
@foreach (var version in Versions)
{
if (version == CurrentVersion)
{
<option value="@(version)" selected="">@(version)</option>
}
else
{
<option value="@(version)">@(version)</option>
}
}
</select>
<WButton
OnClick="Save"
Text="@(TranslationService.Translate("Change"))"
WorkingText="@(TranslationService.Translate("Changing"))"
CssClasses="btn-primary">
</WButton>
</LazyLoader>
</div>
</div>
@code
{
[CascadingParameter]
public Server CurrentServer { get; set; }
private string[] Versions = Array.Empty<string>();
private string CurrentVersion = "";
private string FabricVersion = "";
private string LoaderVersion = "";
private async Task Load(LazyLoader lazyLoader)
{
// Fabric version
var fabricVersion = LiveMigrateVar(
"FABRIC_VERSION",
await FabricService.GetLatestInstallerVersion(),
true
);
FabricVersion = fabricVersion.Value;
// Fabric loader version
var loaderVersion = LiveMigrateVar(
"LOADER_VERSION",
await FabricService.GetLatestLoaderVersion(),
true
);
LoaderVersion = loaderVersion.Value;
// Minecraft versions
Versions = await FabricService.GetGameVersions();
var mcVersion = LiveMigrateVar(
"MC_VERSION",
Versions.First()
);
CurrentVersion = mcVersion.Value;
await InvokeAsync(StateHasChanged);
}
private ServerVariable LiveMigrateVar(string key, string value, bool overwrite = false)
{
var v = CurrentServer.Variables.FirstOrDefault(x => x.Key == key);
if (v == null)
{
CurrentServer.Variables.Add(new()
{
Key = key,
Value = value
});
ServerRepository.Update(CurrentServer);
return CurrentServer.Variables.First(x => x.Key == key);
}
else
{
if (string.IsNullOrEmpty(v.Value) || overwrite)
{
v.Value = value;
ServerRepository.Update(CurrentServer);
}
return v;
}
}
private async Task Save()
{
var vars = CurrentServer.Variables;
var versionVar = vars.First(x => x.Key == "MC_VERSION");
versionVar.Value = CurrentVersion;
// This searches for the display name of a version using the constructed full version
var version = ParseHelper.MinecraftToInt(CurrentVersion);
var serverImage = ImageRepository
.Get()
.Include(x => x.DockerImages)
.First(x => x.Id == CurrentServer.Image.Id);
var dockerImages = serverImage.DockerImages;
var dockerImageToUpdate = dockerImages.Last();
if (version < 1130)
{
dockerImageToUpdate = dockerImages.First(x => x.Name.Contains("8"));
}
if (version >= 1130)
{
dockerImageToUpdate = dockerImages.First(x => x.Name.Contains("11"));
}
if (version >= 1170)
{
dockerImageToUpdate = dockerImages.First(x => x.Name.Contains("16"));
}
if (version >= 1190)
{
dockerImageToUpdate = dockerImages.First(x => x.Name.Contains("17"));
}
CurrentServer.DockerImageIndex = dockerImages.IndexOf(dockerImageToUpdate);
ServerRepository.Update(CurrentServer);
await ServerService.Reinstall(CurrentServer);
}
}

View File

@@ -1,147 +0,0 @@
@using Moonlight.App.Services
@using Microsoft.EntityFrameworkCore
@using Moonlight.App.Database.Entities
@using Moonlight.App.Repositories
@using Moonlight.App.Repositories.Servers
@using Logging.Net
@using Moonlight.App.Helpers
@inject ServerService ServerService
@inject ServerRepository ServerRepository
@inject ImageRepository ImageRepository
@inject ForgeService ForgeService
@inject SmartTranslateService TranslationService
<div class="col">
<div class="card card-body">
<LazyLoader Load="Load">
<label class="mb-2 form-label"><TL>Forge version</TL></label>
<select class="mb-2 form-select" @bind="CurrentVersion">
@foreach (var version in Versions.Keys)
{
if (DisplayToData(version) == CurrentVersion)
{
<option value="@(DisplayToData(version))" selected="">@(version)</option>
}
else
{
<option value="@(DisplayToData(version))">@(version)</option>
}
}
</select>
<WButton
OnClick="Save"
Text="@(TranslationService.Translate("Change"))"
WorkingText="@(TranslationService.Translate("Changing"))"
CssClasses="btn-primary">
</WButton>
</LazyLoader>
</div>
</div>
@code
{
[CascadingParameter]
public Server CurrentServer { get; set; }
private Dictionary<string, string> Versions = new();
private string CurrentVersion = "";
private async Task Load(LazyLoader lazyLoader)
{
Versions = await ForgeService.GetVersions();
var vars = CurrentServer.Variables;
var versionVar = vars.FirstOrDefault(x => x.Key == "FORGE_VERSION");
// Live migration
if (versionVar == null)
{
CurrentServer.Variables.Add(new ()
{
Key = "FORGE_VERSION",
Value = LatestVersion()
});
ServerRepository.Update(CurrentServer);
versionVar = vars.First(x => x.Key == "FORGE_VERSION");
}
else
{
if (string.IsNullOrEmpty(versionVar.Value))
{
versionVar.Value = LatestVersion();
ServerRepository.Update(CurrentServer);
}
}
CurrentVersion = versionVar.Value;
await InvokeAsync(StateHasChanged);
}
private string DisplayToData(string display)
{
return display
.Replace("-recommended", "")
.Replace("-latest", "") + "-" + Versions[display];
}
private string LatestVersion()
{
var versionsSorted = Versions.Keys
.OrderByDescending(ParseHelper.MinecraftToInt);
return DisplayToData(versionsSorted.First());
}
private async Task Save()
{
var vars = CurrentServer.Variables;
var versionVar = vars.First(x => x.Key == "FORGE_VERSION");
versionVar.Value = CurrentVersion;
// This searches for the display name of a version using the constructed full version
var version = ParseHelper.MinecraftToInt(
Versions.First(
x => DisplayToData(x.Key) == CurrentVersion).Key);
var serverImage = ImageRepository
.Get()
.Include(x => x.DockerImages)
.First(x => x.Id == CurrentServer.Image.Id);
var dockerImages = serverImage.DockerImages;
var dockerImageToUpdate = dockerImages.Last();
if (version < 1130)
{
dockerImageToUpdate = dockerImages.First(x => x.Name.Contains("8"));
}
if (version >= 1130)
{
dockerImageToUpdate = dockerImages.First(x => x.Name.Contains("11"));
}
if (version >= 1170)
{
dockerImageToUpdate = dockerImages.First(x => x.Name.Contains("16"));
}
if (version >= 1190)
{
dockerImageToUpdate = dockerImages.First(x => x.Name.Contains("17"));
}
CurrentServer.DockerImageIndex = dockerImages.IndexOf(dockerImageToUpdate);
ServerRepository.Update(CurrentServer);
await ServerService.Reinstall(CurrentServer);
}
}

View File

@@ -1,60 +0,0 @@
@using Moonlight.App.Database.Entities
@using Moonlight.App.Services
@using Moonlight.App.Services.Interop
@inject WebSpaceService WebSpaceService
@inject SmartTranslateService SmartTranslateService
@inject AlertService AlertService
<div class="row gy-5 g-xl-10">
<div class="col-xl-4 mb-xl-10">
<div class="card h-md-100">
<div class="card-body d-flex flex-column flex-center">
<img class="img-fluid" src="https://image.thum.io/get/http://@(CurrentWebSpace.Domain)" alt="Website screenshot"/>
</div>
</div>
</div>
<div class="col-xl-8 mb-5 mb-xl-10">
<div class="card card-flush h-xl-100">
<div class="card-body pt-2">
<LazyLoader @ref="LazyLoader" Load="Load">
<div class="row mt-5">
<div class="card border">
<div class="card-header">
<span class="card-title">
<TL>SSL certificates</TL>
</span>
<div class="card-toolbar">
<WButton Text="@(SmartTranslateService.Translate("Issue certificate"))"
WorkingText="@(SmartTranslateService.Translate("Working"))"
CssClasses="btn-success"
OnClick="IssueCertificate">
</WButton>
</div>
</div>
</div>
</div>
</LazyLoader>
</div>
</div>
</div>
</div>
@code
{
[CascadingParameter]
public WebSpace CurrentWebSpace { get; set; }
private LazyLoader LazyLoader;
private Task Load(LazyLoader lazyLoader)
{
return Task.CompletedTask;
}
private async Task IssueCertificate()
{
await WebSpaceService.IssueSslCertificate(CurrentWebSpace);
await AlertService.Success(SmartTranslateService.Translate("Lets Encrypt certificate successfully issued"));
}
}

View File

@@ -1,55 +0,0 @@
@using Moonlight.App.Database.Entities
@using Moonlight.App.Services
@inject WebSpaceService WebSpaceService
<div class="card card-flush h-xl-100">
<div class="card-body pt-2">
<div class="mt-7 row fv-row mb-7">
<div class="col-md-3 text-md-start">
<label class="fs-6 fw-semibold form-label mt-3">
<TL>Sftp Host</TL>
</label>
</div>
<div class="col-md-9">
<input type="text" class="form-control form-control-solid disabled" disabled="disabled" value="@(CurrentWebSpace.CloudPanel.Host)">
</div>
</div>
<div class="row fv-row mb-7">
<div class="col-md-3 text-md-start">
<label class="fs-6 fw-semibold form-label mt-3">
<TL>Sftp Port</TL>
</label>
</div>
<div class="col-md-9">
<input type="text" class="form-control form-control-solid disabled" disabled="disabled" value="21">
</div>
</div>
<div class="row fv-row mb-7">
<div class="col-md-3 text-md-start">
<label class="fs-6 fw-semibold form-label mt-3">
<TL>Sftp Username</TL>
</label>
</div>
<div class="col-md-9">
<input type="text" class="form-control form-control-solid disabled" disabled="disabled" value="@(CurrentWebSpace.UserName)">
</div>
</div>
<div class="row fv-row mb-7">
<div class="col-md-3 text-md-start">
<label class="fs-6 fw-semibold form-label mt-3">
<TL>Sftp Password</TL>
</label>
</div>
<div class="col-md-9">
<input type="text" class="form-control form-control-solid disabled blur-unless-hover" disabled="disabled" value="@(CurrentWebSpace.Password)">
</div>
</div>
</div>
</div>
@code
{
[CascadingParameter]
public WebSpace CurrentWebSpace { get; set; }
}

View File

@@ -0,0 +1,111 @@
@using Moonlight.App.Database.Entities
@using Moonlight.App.Services
@inject WebsiteService WebsiteService
@inject SmartTranslateService SmartTranslateService
<div class="row gy-5 g-xl-10">
<div class="col-xl-4 mb-xl-10">
<div class="card h-md-100">
<div class="card-body d-flex flex-column flex-center">
<img class="img-fluid" src="https://image.thum.io/get/http://@(CurrentWebsite.BaseDomain)" alt="Website screenshot"/>
</div>
</div>
</div>
<div class="col-xl-8 mb-5 mb-xl-10">
<div class="card card-flush h-xl-100">
<div class="card-body pt-2">
<LazyLoader @ref="LazyLoader" Load="Load">
<div class="row mt-5">
<div class="card border">
<div class="card-header">
<span class="card-title">
<TL>SSL certificates</TL>
</span>
<div class="card-toolbar">
<WButton Text="@(SmartTranslateService.Translate("Issue certificate"))"
WorkingText="@(SmartTranslateService.Translate("Working"))"
CssClasses="btn-success"
OnClick="CreateCertificate">
</WButton>
</div>
</div>
<div class="card-body">
@if (Certs.Any())
{
<table class="table align-middle gs-0 gy-3">
<thead>
<tr>
<th class="p-0 w-50px"></th>
<th class="p-0 min-w-150px"></th>
<th class="p-0 min-w-120px"></th>
</tr>
</thead>
<tbody>
@foreach (var cert in Certs)
{
<tr>
<td>
<div class="symbol symbol-50px me-2">
<span class="symbol-label">
<i class="bx bx-md bx-receipt text-dark"></i>
</span>
</div>
</td>
<td>
<span class="text-dark fw-bold fs-6">@(cert)</span>
</td>
<td class="text-end">
<WButton Text="@(SmartTranslateService.Translate("Delete"))"
WorkingText="@(SmartTranslateService.Translate("Working"))"
CssClasses="btn btn-danger"
OnClick="() => DeleteCertificate(cert)">
</WButton>
</td>
</tr>
}
</tbody>
</table>
}
else
{
<div class="alert alert-warning">
<TL>No SSL certificates found</TL>
</div>
}
</div>
</div>
</div>
</LazyLoader>
</div>
</div>
</div>
</div>
@code
{
[CascadingParameter]
public Website CurrentWebsite { get; set; }
private string[] Certs;
private LazyLoader LazyLoader;
private async Task Load(LazyLoader lazyLoader)
{
await lazyLoader.SetText("Loading certificates");
Certs = await WebsiteService.GetSslCertificates(CurrentWebsite);
}
private async Task CreateCertificate()
{
await WebsiteService.CreateSslCertificate(CurrentWebsite);
await LazyLoader.Reload();
}
private async Task DeleteCertificate(string name)
{
await WebsiteService.DeleteSslCertificate(CurrentWebsite, name);
await LazyLoader.Reload();
}
}

View File

@@ -4,12 +4,12 @@
@using Moonlight.App.Services
@inject SmartTranslateService SmartTranslateService
@inject WebSpaceService WebSpaceService
@inject WebsiteService WebsiteService
<LazyLoader @ref="LazyLoader" Load="Load">
<div class="card w-100 mb-4">
<div class="card-body py-2">
<div class="my-4 w-100">
<SmartForm Model="Model" OnValidSubmit="OnValidSubmit">
<div class="input-group">
@@ -34,7 +34,7 @@
<div class="card">
<div class="card-header">
<div class="card-title">
<span>@(database.UserName) - @(database.UserName.ToUpper().Replace("MYSQL", "MySQL"))</span>
<span>@(database.Name) - @(database.Type.ToUpper().Replace("MYSQL", "MySQL"))</span>
</div>
</div>
<div class="card-body me-1">
@@ -46,7 +46,7 @@
</label>
</td>
<td class="pb-2">
<input type="text" class="form-control form-control-solid disabled" disabled="disabled" value="@(CurrentWebSpace.CloudPanel.Host)">
<input type="text" class="form-control form-control-solid disabled" disabled="disabled" value="@(Host)">
</td>
</tr>
<tr>
@@ -56,7 +56,7 @@
</label>
</td>
<td class="pb-2">
<input type="text" class="form-control form-control-solid disabled" disabled="disabled" value="3306">
<input type="text" class="form-control form-control-solid disabled" disabled="disabled" value="@(DatabaseServer.Port)">
</td>
</tr>
<tr>
@@ -66,17 +66,7 @@
</label>
</td>
<td class="pb-2">
<input type="text" class="form-control form-control-solid disabled" disabled="disabled" value="@(database.UserName)">
</td>
</tr>
<tr>
<td>
<label class="fs-6 fw-semibold form-label mt-3">
<TL>Password</TL>
</label>
</td>
<td class="pb-2">
<input type="text" class="form-control form-control-solid disabled blur-unless-hover" disabled="disabled" value="@(database.Password)">
<input type="text" class="form-control form-control-solid disabled" disabled="disabled" value="@(database.Name)">
</td>
</tr>
<tr>
@@ -86,7 +76,7 @@
</label>
</td>
<td class="pb-2">
<input type="text" class="form-control form-control-solid disabled" disabled="disabled" value="@(database.UserName)">
<input type="text" class="form-control form-control-solid disabled" disabled="disabled" value="@(database.Name)">
</td>
</tr>
</table>
@@ -103,7 +93,7 @@
else
{
<div class="alert alert-warning">
<TL>No databases found for this webspace</TL>
<TL>No databases found for this website</TL>
</div>
}
</LazyLoader>
@@ -111,28 +101,36 @@
@code
{
[CascadingParameter]
public WebSpace CurrentWebSpace { get; set; }
public Website CurrentWebsite { get; set; }
private LazyLoader LazyLoader;
private MySqlDatabase[] Databases;
private Database[] Databases;
private DatabaseServer DatabaseServer;
private string Host;
private DatabaseDataModel Model = new();
private async Task Load(LazyLoader arg)
{
Databases = await WebSpaceService.GetDatabases(CurrentWebSpace);
Databases = await WebsiteService.GetDatabases(CurrentWebsite);
if (Databases.Any())
{
DatabaseServer = (await WebsiteService.GetDefaultDatabaseServer(CurrentWebsite))!;
Host = await WebsiteService.GetHost(CurrentWebsite);
}
}
private async Task OnValidSubmit()
{
await WebSpaceService.CreateDatabase(CurrentWebSpace, Model.Name, Model.Password);
await WebsiteService.CreateDatabase(CurrentWebsite, Model.Name, Model.Password);
Model = new();
await LazyLoader.Reload();
}
private async Task DeleteDatabase(MySqlDatabase database)
private async Task DeleteDatabase(Database database)
{
await WebSpaceService.DeleteDatabase(CurrentWebSpace, database);
await WebsiteService.DeleteDatabase(CurrentWebsite, database);
await LazyLoader.Reload();
}
}

View File

@@ -3,7 +3,7 @@
@using Moonlight.App.Services
@using Moonlight.Shared.Components.FileManagerPartials
@inject WebSpaceService WebSpaceService
@inject WebsiteService WebsiteService
<LazyLoader Load="Load">
<FileManager Access="Access">
@@ -13,12 +13,12 @@
@code
{
[CascadingParameter]
public WebSpace CurrentWebSpace { get; set; }
public Website CurrentWebsite { get; set; }
private FileAccess Access;
private async Task Load(LazyLoader arg)
{
Access = await WebSpaceService.CreateFileAccess(CurrentWebSpace);
Access = await WebsiteService.CreateFileAccess(CurrentWebsite);
}
}

View File

@@ -0,0 +1,64 @@
@using Moonlight.App.Database.Entities
@using Moonlight.App.Services
@inject WebsiteService WebsiteService
<div class="card card-flush h-xl-100">
<div class="card-body pt-2">
<LazyLoader Load="Load">
<div class="mt-7 row fv-row mb-7">
<div class="col-md-3 text-md-start">
<label class="fs-6 fw-semibold form-label mt-3">
<TL>Ftp Host</TL>
</label>
</div>
<div class="col-md-9">
<input type="text" class="form-control form-control-solid disabled" disabled="disabled" value="@(FtpHost)">
</div>
</div>
<div class="row fv-row mb-7">
<div class="col-md-3 text-md-start">
<label class="fs-6 fw-semibold form-label mt-3">
<TL>Ftp Port</TL>
</label>
</div>
<div class="col-md-9">
<input type="text" class="form-control form-control-solid disabled" disabled="disabled" value="21">
</div>
</div>
<div class="row fv-row mb-7">
<div class="col-md-3 text-md-start">
<label class="fs-6 fw-semibold form-label mt-3">
<TL>Ftp Username</TL>
</label>
</div>
<div class="col-md-9">
<input type="text" class="form-control form-control-solid disabled" disabled="disabled" value="@(Website.FtpLogin)">
</div>
</div>
<div class="row fv-row mb-7">
<div class="col-md-3 text-md-start">
<label class="fs-6 fw-semibold form-label mt-3">
<TL>Ftp Password</TL>
</label>
</div>
<div class="col-md-9">
<input type="text" class="form-control form-control-solid disabled blur-unless-hover" disabled="disabled" value="@(Website.FtpPassword)">
</div>
</div>
</LazyLoader>
</div>
</div>
@code
{
[CascadingParameter]
public Website Website { get; set; }
private string FtpHost = "N/A";
private async Task Load(LazyLoader arg)
{
FtpHost = await WebsiteService.GetHost(Website.PleskServer);
}
}

View File

@@ -10,8 +10,8 @@
</div>
</div>
<div class="d-flex flex-column">
<div class="mb-1 fs-4">@(WebSpace.Domain)</div>
<div class="text-muted fs-5">@(WebSpace.CloudPanel.Name)</div>
<div class="mb-1 fs-4">@(Website.BaseDomain)</div>
<div class="text-muted fs-5">@(Website.PleskServer.Name)</div>
</div>
</div>
</div>
@@ -24,22 +24,22 @@
<div class="card-body pt-0 pb-0">
<ul class="nav nav-stretch nav-line-tabs nav-line-tabs-2x border-transparent fs-5 fw-bold">
<li class="nav-item mt-2">
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 0 ? "active" : "")" href="/webspace/@(WebSpace.Id)">
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 0 ? "active" : "")" href="/website/@(Website.Id)">
<TL>Dashboard</TL>
</a>
</li>
<li class="nav-item mt-2">
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 1 ? "active" : "")" href="/webspace/@(WebSpace.Id)/files">
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 1 ? "active" : "")" href="/website/@(Website.Id)/files">
<TL>Files</TL>
</a>
</li>
<li class="nav-item mt-2">
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 2 ? "active" : "")" href="/webspace/@(WebSpace.Id)/sftp">
<TL>Sftp</TL>
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 2 ? "active" : "")" href="/website/@(Website.Id)/ftp">
<TL>Ftp</TL>
</a>
</li>
<li class="nav-item mt-2">
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 3 ? "active" : "")" href="/webspace/@(WebSpace.Id)/databases">
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 3 ? "active" : "")" href="/website/@(Website.Id)/databases">
<TL>Databases</TL>
</a>
</li>
@@ -53,5 +53,5 @@
public int Index { get; set; }
[Parameter]
public WebSpace WebSpace { get; set; }
public Website Website { get; set; }
}

View File

@@ -16,7 +16,7 @@
[Parameter]
public Action RunOnFirstRender { get; set; }
private TerminalOptions TerminalOptions = new()
private TerminalOptions TerminalOptions = new TerminalOptions
{
CursorBlink = false,
CursorStyle = CursorStyle.Underline,
@@ -33,7 +33,6 @@
}
catch (Exception)
{
// ignored
}
}
@@ -51,7 +50,6 @@
}
catch (Exception)
{
// ignored
}
}
}