Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f9508f30b | ||
|
|
428e2668d3 | ||
|
|
c1cfb35c86 | ||
|
|
d6777c463e | ||
|
|
f9126bffe0 | ||
|
|
0488e83a38 | ||
|
|
d87ddc90e3 | ||
|
|
151bc82998 | ||
|
|
e4c21c74a5 | ||
|
|
13741a2be9 | ||
|
|
c866e89b72 | ||
|
|
8be93bc53c | ||
|
|
384b6a3e7d | ||
|
|
ba2de54c60 | ||
|
|
bd5567e24f | ||
|
|
b8e39824b5 | ||
|
|
d8c9bdbd8d | ||
|
|
80eb210af0 |
@@ -17,6 +17,8 @@ public class ConfigV1
|
|||||||
[Description("The url moonlight is accesible with from the internet")]
|
[Description("The url moonlight is accesible with from the internet")]
|
||||||
public string AppUrl { get; set; } = "http://your-moonlight-url-without-slash";
|
public string AppUrl { get; set; } = "http://your-moonlight-url-without-slash";
|
||||||
|
|
||||||
|
[JsonProperty("Auth")] public AuthData Auth { get; set; } = new();
|
||||||
|
|
||||||
[JsonProperty("Database")] public DatabaseData Database { get; set; } = new();
|
[JsonProperty("Database")] public DatabaseData Database { get; set; } = new();
|
||||||
|
|
||||||
[JsonProperty("DiscordBotApi")] public DiscordBotApiData DiscordBotApi { get; set; } = new();
|
[JsonProperty("DiscordBotApi")] public DiscordBotApiData DiscordBotApi { get; set; } = new();
|
||||||
@@ -39,8 +41,7 @@ public class ConfigV1
|
|||||||
|
|
||||||
[JsonProperty("Subscriptions")] public SubscriptionsData Subscriptions { get; set; } = new();
|
[JsonProperty("Subscriptions")] public SubscriptionsData Subscriptions { get; set; } = new();
|
||||||
|
|
||||||
[JsonProperty("DiscordNotifications")]
|
[JsonProperty("DiscordNotifications")] public DiscordNotificationsData DiscordNotifications { get; set; } = new();
|
||||||
public DiscordNotificationsData DiscordNotifications { get; set; } = new();
|
|
||||||
|
|
||||||
[JsonProperty("Statistics")] public StatisticsData Statistics { get; set; } = new();
|
[JsonProperty("Statistics")] public StatisticsData Statistics { get; set; } = new();
|
||||||
|
|
||||||
@@ -51,6 +52,17 @@ public class ConfigV1
|
|||||||
[JsonProperty("Sentry")] public SentryData Sentry { get; set; } = new();
|
[JsonProperty("Sentry")] public SentryData Sentry { get; set; } = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AuthData
|
||||||
|
{
|
||||||
|
[JsonProperty("DenyLogin")]
|
||||||
|
[Description("Prevent every new login")]
|
||||||
|
public bool DenyLogin { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonProperty("DenyRegister")]
|
||||||
|
[Description("Prevent every new user to register")]
|
||||||
|
public bool DenyRegister { get; set; } = false;
|
||||||
|
}
|
||||||
|
|
||||||
public class CleanupData
|
public class CleanupData
|
||||||
{
|
{
|
||||||
[JsonProperty("Cpu")]
|
[JsonProperty("Cpu")]
|
||||||
|
|||||||
71
Moonlight/App/Helpers/EggConverter.cs
Normal file
71
Moonlight/App/Helpers/EggConverter.cs
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
using System.Text;
|
||||||
|
using Moonlight.App.Database.Entities;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace Moonlight.App.Helpers;
|
||||||
|
|
||||||
|
public static class EggConverter
|
||||||
|
{
|
||||||
|
public static Image Convert(string json)
|
||||||
|
{
|
||||||
|
var result = new Image();
|
||||||
|
|
||||||
|
var data = new ConfigurationBuilder().AddJsonStream(
|
||||||
|
new MemoryStream(Encoding.ASCII.GetBytes(json))
|
||||||
|
).Build();
|
||||||
|
|
||||||
|
result.Allocations = 1;
|
||||||
|
result.Description = data.GetValue<string>("description") ?? "";
|
||||||
|
result.Uuid = Guid.NewGuid();
|
||||||
|
result.Startup = data.GetValue<string>("startup") ?? "";
|
||||||
|
result.Name = data.GetValue<string>("name") ?? "Ptero Egg";
|
||||||
|
|
||||||
|
foreach (var variable in data.GetSection("variables").GetChildren())
|
||||||
|
{
|
||||||
|
result.Variables.Add(new()
|
||||||
|
{
|
||||||
|
Key = variable.GetValue<string>("env_variable") ?? "",
|
||||||
|
DefaultValue = variable.GetValue<string>("default_value") ?? ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var configData = data.GetSection("config");
|
||||||
|
|
||||||
|
result.ConfigFiles = configData.GetValue<string>("files") ?? "{}";
|
||||||
|
|
||||||
|
var dImagesData = JObject.Parse(json);
|
||||||
|
var dImages = (JObject)dImagesData["docker_images"]!;
|
||||||
|
|
||||||
|
foreach (var dockerImage in dImages)
|
||||||
|
{
|
||||||
|
var di = new DockerImage()
|
||||||
|
{
|
||||||
|
Default = dockerImage.Key == dImages.Properties().Last().Name,
|
||||||
|
Name = dockerImage.Value!.ToString()
|
||||||
|
};
|
||||||
|
|
||||||
|
result.DockerImages.Add(di);
|
||||||
|
}
|
||||||
|
|
||||||
|
var installSection = data.GetSection("scripts").GetSection("installation");
|
||||||
|
|
||||||
|
result.InstallEntrypoint = installSection.GetValue<string>("entrypoint") ?? "bash";
|
||||||
|
result.InstallScript = installSection.GetValue<string>("script") ?? "";
|
||||||
|
result.InstallDockerImage = installSection.GetValue<string>("container") ?? "";
|
||||||
|
|
||||||
|
var rawJson = configData.GetValue<string>("startup");
|
||||||
|
|
||||||
|
var startupData = new ConfigurationBuilder().AddJsonStream(
|
||||||
|
new MemoryStream(Encoding.ASCII.GetBytes(rawJson!))
|
||||||
|
).Build();
|
||||||
|
|
||||||
|
result.StartupDetection = startupData.GetValue<string>("done", "") ?? "";
|
||||||
|
result.StopCommand = configData.GetValue<string>("stop") ?? "";
|
||||||
|
|
||||||
|
result.TagsJson = "[]";
|
||||||
|
result.BackgroundImageUrl = "";
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ namespace Moonlight.App.Services;
|
|||||||
public class DomainService
|
public class DomainService
|
||||||
{
|
{
|
||||||
private readonly DomainRepository DomainRepository;
|
private readonly DomainRepository DomainRepository;
|
||||||
|
private readonly ConfigService ConfigService;
|
||||||
private readonly SharedDomainRepository SharedDomainRepository;
|
private readonly SharedDomainRepository SharedDomainRepository;
|
||||||
private readonly CloudFlareClient Client;
|
private readonly CloudFlareClient Client;
|
||||||
private readonly string AccountId;
|
private readonly string AccountId;
|
||||||
@@ -29,6 +30,7 @@ public class DomainService
|
|||||||
DomainRepository domainRepository,
|
DomainRepository domainRepository,
|
||||||
SharedDomainRepository sharedDomainRepository)
|
SharedDomainRepository sharedDomainRepository)
|
||||||
{
|
{
|
||||||
|
ConfigService = configService;
|
||||||
DomainRepository = domainRepository;
|
DomainRepository = domainRepository;
|
||||||
SharedDomainRepository = sharedDomainRepository;
|
SharedDomainRepository = sharedDomainRepository;
|
||||||
|
|
||||||
@@ -48,6 +50,9 @@ public class DomainService
|
|||||||
|
|
||||||
public Task<Domain> Create(string domain, SharedDomain sharedDomain, User user)
|
public Task<Domain> Create(string domain, SharedDomain sharedDomain, User user)
|
||||||
{
|
{
|
||||||
|
if (!ConfigService.Get().Moonlight.Domains.Enable)
|
||||||
|
throw new DisplayException("This operation is disabled");
|
||||||
|
|
||||||
if (DomainRepository.Get().Where(x => x.SharedDomain.Id == sharedDomain.Id).Any(x => x.Name == domain))
|
if (DomainRepository.Get().Where(x => x.SharedDomain.Id == sharedDomain.Id).Any(x => x.Name == domain))
|
||||||
throw new DisplayException("A domain with this name does already exist for this shared domain");
|
throw new DisplayException("A domain with this name does already exist for this shared domain");
|
||||||
|
|
||||||
@@ -63,6 +68,9 @@ public class DomainService
|
|||||||
|
|
||||||
public Task Delete(Domain domain)
|
public Task Delete(Domain domain)
|
||||||
{
|
{
|
||||||
|
if (!ConfigService.Get().Moonlight.Domains.Enable)
|
||||||
|
throw new DisplayException("This operation is disabled");
|
||||||
|
|
||||||
DomainRepository.Delete(domain);
|
DomainRepository.Delete(domain);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
@@ -71,6 +79,9 @@ public class DomainService
|
|||||||
public async Task<Zone[]>
|
public async Task<Zone[]>
|
||||||
GetAvailableDomains() // This method returns all available domains which are not added as a shared domain
|
GetAvailableDomains() // This method returns all available domains which are not added as a shared domain
|
||||||
{
|
{
|
||||||
|
if (!ConfigService.Get().Moonlight.Domains.Enable)
|
||||||
|
return Array.Empty<Zone>();
|
||||||
|
|
||||||
var domains = GetData(
|
var domains = GetData(
|
||||||
await Client.Zones.GetAsync(new()
|
await Client.Zones.GetAsync(new()
|
||||||
{
|
{
|
||||||
@@ -93,6 +104,9 @@ public class DomainService
|
|||||||
|
|
||||||
public async Task<DnsRecord[]> GetDnsRecords(Domain d)
|
public async Task<DnsRecord[]> GetDnsRecords(Domain d)
|
||||||
{
|
{
|
||||||
|
if (!ConfigService.Get().Moonlight.Domains.Enable)
|
||||||
|
return Array.Empty<DnsRecord>();
|
||||||
|
|
||||||
var domain = EnsureData(d);
|
var domain = EnsureData(d);
|
||||||
|
|
||||||
var records = new List<CloudFlare.Client.Api.Zones.DnsRecord.DnsRecord>();
|
var records = new List<CloudFlare.Client.Api.Zones.DnsRecord.DnsRecord>();
|
||||||
@@ -146,7 +160,7 @@ public class DomainService
|
|||||||
Type = record.Type
|
Type = record.Type
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (record.Name.EndsWith(rname))
|
else if (record.Name == rname)
|
||||||
{
|
{
|
||||||
result.Add(new()
|
result.Add(new()
|
||||||
{
|
{
|
||||||
@@ -166,6 +180,9 @@ public class DomainService
|
|||||||
|
|
||||||
public async Task AddDnsRecord(Domain d, DnsRecord dnsRecord)
|
public async Task AddDnsRecord(Domain d, DnsRecord dnsRecord)
|
||||||
{
|
{
|
||||||
|
if (!ConfigService.Get().Moonlight.Domains.Enable)
|
||||||
|
throw new DisplayException("This operation is disabled");
|
||||||
|
|
||||||
var domain = EnsureData(d);
|
var domain = EnsureData(d);
|
||||||
|
|
||||||
var rname = $"{domain.Name}.{domain.SharedDomain.Name}";
|
var rname = $"{domain.Name}.{domain.SharedDomain.Name}";
|
||||||
@@ -225,6 +242,9 @@ public class DomainService
|
|||||||
|
|
||||||
public async Task UpdateDnsRecord(Domain d, DnsRecord dnsRecord)
|
public async Task UpdateDnsRecord(Domain d, DnsRecord dnsRecord)
|
||||||
{
|
{
|
||||||
|
if (!ConfigService.Get().Moonlight.Domains.Enable)
|
||||||
|
throw new DisplayException("This operation is disabled");
|
||||||
|
|
||||||
var domain = EnsureData(d);
|
var domain = EnsureData(d);
|
||||||
|
|
||||||
var rname = $"{domain.Name}.{domain.SharedDomain.Name}";
|
var rname = $"{domain.Name}.{domain.SharedDomain.Name}";
|
||||||
@@ -255,6 +275,9 @@ public class DomainService
|
|||||||
|
|
||||||
public async Task DeleteDnsRecord(Domain d, DnsRecord dnsRecord)
|
public async Task DeleteDnsRecord(Domain d, DnsRecord dnsRecord)
|
||||||
{
|
{
|
||||||
|
if (!ConfigService.Get().Moonlight.Domains.Enable)
|
||||||
|
throw new DisplayException("This operation is disabled");
|
||||||
|
|
||||||
var domain = EnsureData(d);
|
var domain = EnsureData(d);
|
||||||
|
|
||||||
GetData(
|
GetData(
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ public class SessionClientService
|
|||||||
public readonly Guid Uuid = Guid.NewGuid();
|
public readonly Guid Uuid = Guid.NewGuid();
|
||||||
public readonly DateTime CreateTimestamp = DateTime.UtcNow;
|
public readonly DateTime CreateTimestamp = DateTime.UtcNow;
|
||||||
public User? User { get; private set; }
|
public User? User { get; private set; }
|
||||||
|
public string Ip { get; private set; } = "N/A";
|
||||||
|
public string Device { get; private set; } = "N/A";
|
||||||
|
|
||||||
public readonly IdentityService IdentityService;
|
public readonly IdentityService IdentityService;
|
||||||
public readonly AlertService AlertService;
|
public readonly AlertService AlertService;
|
||||||
@@ -39,6 +41,8 @@ public class SessionClientService
|
|||||||
public async Task Start()
|
public async Task Start()
|
||||||
{
|
{
|
||||||
User = await IdentityService.Get();
|
User = await IdentityService.Get();
|
||||||
|
Ip = IdentityService.GetIp();
|
||||||
|
Device = IdentityService.GetDevice();
|
||||||
|
|
||||||
if (User != null) // Track users last visit
|
if (User != null) // Track users last visit
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public class UserService
|
|||||||
private readonly IdentityService IdentityService;
|
private readonly IdentityService IdentityService;
|
||||||
private readonly IpLocateService IpLocateService;
|
private readonly IpLocateService IpLocateService;
|
||||||
private readonly DateTimeService DateTimeService;
|
private readonly DateTimeService DateTimeService;
|
||||||
|
private readonly ConfigService ConfigService;
|
||||||
|
|
||||||
private readonly string JwtSecret;
|
private readonly string JwtSecret;
|
||||||
|
|
||||||
@@ -32,6 +33,7 @@ public class UserService
|
|||||||
{
|
{
|
||||||
UserRepository = userRepository;
|
UserRepository = userRepository;
|
||||||
TotpService = totpService;
|
TotpService = totpService;
|
||||||
|
ConfigService = configService;
|
||||||
MailService = mailService;
|
MailService = mailService;
|
||||||
IdentityService = identityService;
|
IdentityService = identityService;
|
||||||
IpLocateService = ipLocateService;
|
IpLocateService = ipLocateService;
|
||||||
@@ -44,6 +46,9 @@ public class UserService
|
|||||||
|
|
||||||
public async Task<string> Register(string email, string password, string firstname, string lastname)
|
public async Task<string> Register(string email, string password, string firstname, string lastname)
|
||||||
{
|
{
|
||||||
|
if (ConfigService.Get().Moonlight.Auth.DenyRegister)
|
||||||
|
throw new DisplayException("This operation was disabled");
|
||||||
|
|
||||||
// Check if the email is already taken
|
// Check if the email is already taken
|
||||||
var emailTaken = UserRepository.Get().FirstOrDefault(x => x.Email == email) != null;
|
var emailTaken = UserRepository.Get().FirstOrDefault(x => x.Email == email) != null;
|
||||||
|
|
||||||
@@ -108,6 +113,9 @@ public class UserService
|
|||||||
|
|
||||||
public async Task<string> Login(string email, string password, string totpCode = "")
|
public async Task<string> Login(string email, string password, string totpCode = "")
|
||||||
{
|
{
|
||||||
|
if (ConfigService.Get().Moonlight.Auth.DenyLogin)
|
||||||
|
throw new DisplayException("This operation was disabled");
|
||||||
|
|
||||||
// First password check and check if totp is enabled
|
// First password check and check if totp is enabled
|
||||||
var needTotp = await CheckTotp(email, password);
|
var needTotp = await CheckTotp(email, password);
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<TL>New image</TL>
|
<TL>New image</TL>
|
||||||
</a>
|
</a>
|
||||||
<InputFile OnChange="OnFileChanged" type="file" id="fileUpload" hidden="" multiple=""/>
|
<InputFile OnChange="OnFileChanged" type="file" id="fileUpload" hidden="" multiple=""/>
|
||||||
<label for="fileUpload" class="btn btn-sm btn-light-primary">
|
<label for="fileUpload" class="btn btn-sm btn-light-primary me-3">
|
||||||
<span class="svg-icon svg-icon-2">
|
<span class="svg-icon svg-icon-2">
|
||||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path opacity="0.3" d="M10 4H21C21.6 4 22 4.4 22 5V7H10V4Z" fill="currentColor"></path>
|
<path opacity="0.3" d="M10 4H21C21.6 4 22 4.4 22 5V7H10V4Z" fill="currentColor"></path>
|
||||||
@@ -42,6 +42,17 @@
|
|||||||
</span>
|
</span>
|
||||||
<TL>Import</TL>
|
<TL>Import</TL>
|
||||||
</label>
|
</label>
|
||||||
|
<InputFile OnChange="OnEggFileChanged" type="file" id="eggFileUpload" hidden="" multiple=""/>
|
||||||
|
<label for="eggFileUpload" class="btn btn-sm btn-light-primary">
|
||||||
|
<span class="svg-icon svg-icon-2">
|
||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path opacity="0.3" d="M10 4H21C21.6 4 22 4.4 22 5V7H10V4Z" fill="currentColor"></path>
|
||||||
|
<path d="M10.4 3.60001L12 6H21C21.6 6 22 6.4 22 7V19C22 19.6 21.6 20 21 20H3C2.4 20 2 19.6 2 19V4C2 3.4 2.4 3 3 3H9.20001C9.70001 3 10.2 3.20001 10.4 3.60001ZM16 11.6L12.7 8.29999C12.3 7.89999 11.7 7.89999 11.3 8.29999L8 11.6H11V17C11 17.6 11.4 18 12 18C12.6 18 13 17.6 13 17V11.6H16Z" fill="currentColor"></path>
|
||||||
|
<path opacity="0.3" d="M11 11.6V17C11 17.6 11.4 18 12 18C12.6 18 13 17.6 13 17V11.6H11Z" fill="currentColor"></path>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<TL>Import pterodactyl egg</TL>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body pt-0">
|
<div class="card-body pt-0">
|
||||||
@@ -173,4 +184,44 @@
|
|||||||
|
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task OnEggFileChanged(InputFileChangeEventArgs arg)
|
||||||
|
{
|
||||||
|
var b = await AlertService.YesNo(
|
||||||
|
SmartTranslateService.Translate("Attention"),
|
||||||
|
SmartTranslateService.Translate("Imported pterodactyl eggs can result in broken images. We do not support pterodactyl eggs"),
|
||||||
|
SmartTranslateService.Translate("I take the risk"),
|
||||||
|
SmartTranslateService.Translate("Cancel")
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!b)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var browserFile in arg.GetMultipleFiles())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var stream = browserFile.OpenReadStream(1024 * 1024 * 100);
|
||||||
|
var data = new byte[browserFile.Size];
|
||||||
|
_ = await stream.ReadAsync(data, 0, data.Length);
|
||||||
|
|
||||||
|
var json = Encoding.UTF8.GetString(data);
|
||||||
|
|
||||||
|
var image = EggConverter.Convert(json);
|
||||||
|
|
||||||
|
ImageRepository.Add(image);
|
||||||
|
|
||||||
|
await AlertService.Success(SmartTranslateService.Translate("Successfully imported image"));
|
||||||
|
await LazyLoader.Reload();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
await AlertService.Error(SmartTranslateService.Translate("An unknown error occured while uploading and importing the image"));
|
||||||
|
Logger.Error("Error importing image");
|
||||||
|
Logger.Error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -60,13 +60,13 @@
|
|||||||
</Column>
|
</Column>
|
||||||
<Column TableItem="SessionClientService" Title="@(SmartTranslateService.Translate("IP"))" Field="@(x => x.Uuid)" Sortable="false" Filterable="false" Width="10%">
|
<Column TableItem="SessionClientService" Title="@(SmartTranslateService.Translate("IP"))" Field="@(x => x.Uuid)" Sortable="false" Filterable="false" Width="10%">
|
||||||
<Template>
|
<Template>
|
||||||
@(context.IdentityService.GetIp())
|
@(context.Ip)
|
||||||
</Template>
|
</Template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column TableItem="SessionClientService" Title="@(SmartTranslateService.Translate("URL"))" Field="@(x => x.NavigationManager.Uri)" Sortable="true" Filterable="true" Width="10%"/>
|
<Column TableItem="SessionClientService" Title="@(SmartTranslateService.Translate("URL"))" Field="@(x => x.NavigationManager.Uri)" Sortable="true" Filterable="true" Width="10%"/>
|
||||||
<Column TableItem="SessionClientService" Title="@(SmartTranslateService.Translate("Device"))" Field="@(x => x.Uuid)" Sortable="false" Filterable="false" Width="10%">
|
<Column TableItem="SessionClientService" Title="@(SmartTranslateService.Translate("Device"))" Field="@(x => x.Uuid)" Sortable="false" Filterable="false" Width="10%">
|
||||||
<Template>
|
<Template>
|
||||||
@(context.IdentityService.GetDevice())
|
@(context.Device)
|
||||||
</Template>
|
</Template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column TableItem="SessionClientService" Title="@(SmartTranslateService.Translate("Time"))" Field="@(x => x.CreateTimestamp)" Sortable="true" Filterable="true" Width="10%">
|
<Column TableItem="SessionClientService" Title="@(SmartTranslateService.Translate("Time"))" Field="@(x => x.CreateTimestamp)" Sortable="true" Filterable="true" Width="10%">
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<LazyLoader Load="LoadData">
|
<LazyLoader Load="LoadData">
|
||||||
@if (CurrentServer == null)
|
@if (CurrentServer == null)
|
||||||
{
|
{
|
||||||
<NotFoundAlert />
|
<NotFoundAlert/>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -34,34 +34,17 @@
|
|||||||
{
|
{
|
||||||
if (Console.ConsoleState == ConsoleState.Connected)
|
if (Console.ConsoleState == ConsoleState.Connected)
|
||||||
{
|
{
|
||||||
if (Console.ServerState == ServerState.Installing)
|
if (Console.ServerState == ServerState.Installing || CurrentServer.Installing)
|
||||||
{
|
{
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="mb-10">
|
<div class="fs-2hx fw-bold text-gray-800 text-center mb-5">
|
||||||
<div class="fs-2hx fw-bold text-gray-800 text-center mb-13">
|
|
||||||
<span class="me-2">
|
|
||||||
<TL>Server installation is currently running</TL>
|
<TL>Server installation is currently running</TL>
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="rounded bg-black p-3">
|
||||||
<Terminal @ref="InstallConsole"></Terminal>
|
<Terminal @ref="InstallConsole"></Terminal>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
|
||||||
else if (CurrentServer.Installing)
|
|
||||||
{
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="mb-10">
|
|
||||||
<div class="fs-2hx fw-bold text-gray-800 text-center mb-13">
|
|
||||||
<span class="me-2">
|
|
||||||
<TL>Server installation is currently running</TL>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<Terminal @ref="InstallConsole"></Terminal>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
else if (CurrentServer.IsArchived)
|
else if (CurrentServer.IsArchived)
|
||||||
|
|||||||
@@ -25,11 +25,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-4 d-flex flex-column flex-end mb-1">
|
<div class="col-4 d-flex flex-column flex-end mb-1">
|
||||||
<div class="btn-group btn-group-sm">
|
<div class="btn-group btn-group-sm">
|
||||||
<button class="w-100 nav-link btn btn-sm btn-success fw-bold px-4 me-1 @(Console.ServerState == ServerState.Offline ? "" : "disabled")" aria-selected="true" role="tab" @onclick="Start"><TL>Start</TL></button>
|
<button class="w-100 nav-link btn btn-sm btn-success fw-bold px-4 me-1 @(Console.ServerState == ServerState.Offline ? "" : "disabled")" aria-selected="true" role="tab" @onclick="Start">
|
||||||
<button class="w-100 nav-link btn btn-sm btn-primary fw-bold px-4 me-1 @(Console.ServerState == ServerState.Running ? "" : "disabled")" aria-selected="true" role="tab" @onclick="Restart"><TL>Restart</TL></button>
|
<TL>Start</TL>
|
||||||
|
</button>
|
||||||
|
<button class="w-100 nav-link btn btn-sm btn-primary fw-bold px-4 me-1 @(Console.ServerState == ServerState.Running ? "" : "disabled")" aria-selected="true" role="tab" @onclick="Restart">
|
||||||
|
<TL>Restart</TL>
|
||||||
|
</button>
|
||||||
@if (Console.ServerState == ServerState.Stopping)
|
@if (Console.ServerState == ServerState.Stopping)
|
||||||
{
|
{
|
||||||
<button class="w-100 nav-link btn btn-sm btn-danger fw-bold px-4 me-1" aria-selected="true" role="tab" @onclick="Kill"><TL>Kill</TL></button>
|
<button class="w-100 nav-link btn btn-sm btn-danger fw-bold px-4 me-1" aria-selected="true" role="tab" @onclick="Kill">
|
||||||
|
<TL>Kill</TL>
|
||||||
|
</button>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -47,7 +53,7 @@
|
|||||||
<div class="row align-items-center">
|
<div class="row align-items-center">
|
||||||
<div class="col fs-5">
|
<div class="col fs-5">
|
||||||
<span class="fw-bold"><TL>Shared IP</TL>:</span>
|
<span class="fw-bold"><TL>Shared IP</TL>:</span>
|
||||||
<span class="ms-1 text-muted @(User.StreamerMode ? "blur" : "")">@($"{CurrentServer.Node.Fqdn}:{CurrentServer.MainAllocation.Port}")</span>
|
<span class="ms-1 text-muted @(User.StreamerMode ? "blur" : "")">@($"{CurrentServer.Node.Fqdn}:{CurrentServer.MainAllocation?.Port ?? 0}")</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col fs-5">
|
<div class="col fs-5">
|
||||||
<span class="fw-bold"><TL>Server ID</TL>:</span>
|
<span class="fw-bold"><TL>Server ID</TL>:</span>
|
||||||
@@ -68,21 +74,29 @@
|
|||||||
@switch (Console.ServerState)
|
@switch (Console.ServerState)
|
||||||
{
|
{
|
||||||
case ServerState.Offline:
|
case ServerState.Offline:
|
||||||
<span class="text-danger"><TL>Offline</TL></span>
|
<span class="text-danger">
|
||||||
|
<TL>Offline</TL>
|
||||||
|
</span>
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ServerState.Starting:
|
case ServerState.Starting:
|
||||||
<span class="text-warning"><TL>Starting</TL></span>
|
<span class="text-warning">
|
||||||
|
<TL>Starting</TL>
|
||||||
|
</span>
|
||||||
<span class="text-gray-700 pt-1 fw-semibold">(@(Formatter.FormatUptime(Console.Resource.Uptime)))</span>
|
<span class="text-gray-700 pt-1 fw-semibold">(@(Formatter.FormatUptime(Console.Resource.Uptime)))</span>
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ServerState.Stopping:
|
case ServerState.Stopping:
|
||||||
<span class="text-warning"><TL>Stopping</TL></span>
|
<span class="text-warning">
|
||||||
|
<TL>Stopping</TL>
|
||||||
|
</span>
|
||||||
<span class="text-gray-700 pt-1 fw-semibold">(@(Formatter.FormatUptime(Console.Resource.Uptime)))</span>
|
<span class="text-gray-700 pt-1 fw-semibold">(@(Formatter.FormatUptime(Console.Resource.Uptime)))</span>
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ServerState.Running:
|
case ServerState.Running:
|
||||||
<span class="text-success"><TL>Online</TL></span>
|
<span class="text-success">
|
||||||
|
<TL>Online</TL>
|
||||||
|
</span>
|
||||||
<span class="text-gray-700 pt-1 fw-semibold">(@(Formatter.FormatUptime(Console.Resource.Uptime)))</span>
|
<span class="text-gray-700 pt-1 fw-semibold">(@(Formatter.FormatUptime(Console.Resource.Uptime)))</span>
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -110,7 +124,9 @@
|
|||||||
<a href="/server/@(CurrentServer.Uuid)/" class="nav-link w-100 btn btn-flex @(Index == 0 ? "active" : "") btn-active-light-primary">
|
<a href="/server/@(CurrentServer.Uuid)/" class="nav-link w-100 btn btn-flex @(Index == 0 ? "active" : "") btn-active-light-primary">
|
||||||
<i class="bx bx-terminal bx-sm me-2"></i>
|
<i class="bx bx-terminal bx-sm me-2"></i>
|
||||||
<span class="d-flex flex-column align-items-start">
|
<span class="d-flex flex-column align-items-start">
|
||||||
<span class="fs-5"><TL>Console</TL></span>
|
<span class="fs-5">
|
||||||
|
<TL>Console</TL>
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -118,7 +134,9 @@
|
|||||||
<a href="/server/@(CurrentServer.Uuid)/files" class="nav-link w-100 btn btn-flex @(Index == 1 ? "active" : "") btn-active-light-primary">
|
<a href="/server/@(CurrentServer.Uuid)/files" class="nav-link w-100 btn btn-flex @(Index == 1 ? "active" : "") btn-active-light-primary">
|
||||||
<i class="bx bx-folder bx-sm me-2"></i>
|
<i class="bx bx-folder bx-sm me-2"></i>
|
||||||
<span class="d-flex flex-column align-items-start">
|
<span class="d-flex flex-column align-items-start">
|
||||||
<span class="fs-5"><TL>Files</TL></span>
|
<span class="fs-5">
|
||||||
|
<TL>Files</TL>
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -126,7 +144,9 @@
|
|||||||
<a href="/server/@(CurrentServer.Uuid)/backups" class="nav-link w-100 btn btn-flex @(Index == 2 ? "active" : "") btn-active-light-primary">
|
<a href="/server/@(CurrentServer.Uuid)/backups" class="nav-link w-100 btn btn-flex @(Index == 2 ? "active" : "") btn-active-light-primary">
|
||||||
<i class="bx bx-box bx-sm me-2"></i>
|
<i class="bx bx-box bx-sm me-2"></i>
|
||||||
<span class="d-flex flex-column align-items-start">
|
<span class="d-flex flex-column align-items-start">
|
||||||
<span class="fs-5"><TL>Backups</TL></span>
|
<span class="fs-5">
|
||||||
|
<TL>Backups</TL>
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -134,7 +154,9 @@
|
|||||||
<a href="/server/@(CurrentServer.Uuid)/network" class="nav-link w-100 btn btn-flex @(Index == 3 ? "active" : "") btn-active-light-primary">
|
<a href="/server/@(CurrentServer.Uuid)/network" class="nav-link w-100 btn btn-flex @(Index == 3 ? "active" : "") btn-active-light-primary">
|
||||||
<i class="bx bx-wifi bx-sm me-2"></i>
|
<i class="bx bx-wifi bx-sm me-2"></i>
|
||||||
<span class="d-flex flex-column align-items-start">
|
<span class="d-flex flex-column align-items-start">
|
||||||
<span class="fs-5"><TL>Network</TL></span>
|
<span class="fs-5">
|
||||||
|
<TL>Network</TL>
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -142,7 +164,9 @@
|
|||||||
<a href="/server/@(CurrentServer.Uuid)/addons" class="nav-link w-100 btn btn-flex @(Index == 4 ? "active" : "") btn-active-light-primary">
|
<a href="/server/@(CurrentServer.Uuid)/addons" class="nav-link w-100 btn btn-flex @(Index == 4 ? "active" : "") btn-active-light-primary">
|
||||||
<i class="bx bx-plug bx-sm me-2"></i>
|
<i class="bx bx-plug bx-sm me-2"></i>
|
||||||
<span class="d-flex flex-column align-items-start">
|
<span class="d-flex flex-column align-items-start">
|
||||||
<span class="fs-5"><TL>Addons</TL></span>
|
<span class="fs-5">
|
||||||
|
<TL>Addons</TL>
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -150,7 +174,9 @@
|
|||||||
<a href="/server/@(CurrentServer.Uuid)/settings" class="nav-link w-100 btn btn-flex @(Index == 5 ? "active" : "") btn-active-light-primary">
|
<a href="/server/@(CurrentServer.Uuid)/settings" class="nav-link w-100 btn btn-flex @(Index == 5 ? "active" : "") btn-active-light-primary">
|
||||||
<i class="bx bx-cog bx-sm me-2"></i>
|
<i class="bx bx-cog bx-sm me-2"></i>
|
||||||
<span class="d-flex flex-column align-items-start">
|
<span class="d-flex flex-column align-items-start">
|
||||||
<span class="fs-5"><TL>Settings</TL></span>
|
<span class="fs-5">
|
||||||
|
<TL>Settings</TL>
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -48,7 +48,9 @@
|
|||||||
<div class="card-body pt-0">
|
<div class="card-body pt-0">
|
||||||
<div class="d-flex flex-column gap-10">
|
<div class="d-flex flex-column gap-10">
|
||||||
<div class="fv-row">
|
<div class="fv-row">
|
||||||
<label class="form-label"><TL>Node</TL></label>
|
<label class="form-label">
|
||||||
|
<TL>Node</TL>
|
||||||
|
</label>
|
||||||
<div class="fw-bold fs-3">@(DeployNode.Name)</div>
|
<div class="fw-bold fs-3">@(DeployNode.Name)</div>
|
||||||
</div>
|
</div>
|
||||||
@if (Model.Image != null)
|
@if (Model.Image != null)
|
||||||
@@ -56,12 +58,16 @@
|
|||||||
var limit = Images[Model.Image];
|
var limit = Images[Model.Image];
|
||||||
|
|
||||||
<div class="fv-row">
|
<div class="fv-row">
|
||||||
<label class="form-label"><TL>Image</TL></label>
|
<label class="form-label">
|
||||||
|
<TL>Image</TL>
|
||||||
|
</label>
|
||||||
<div class="fw-bold fs-3">@(Model.Image.Name)</div>
|
<div class="fw-bold fs-3">@(Model.Image.Name)</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="fv-row">
|
<div class="fv-row">
|
||||||
<label class="form-label"><TL>CPU</TL></label>
|
<label class="form-label">
|
||||||
|
<TL>CPU</TL>
|
||||||
|
</label>
|
||||||
<div class="fw-bold fs-3">
|
<div class="fw-bold fs-3">
|
||||||
@{
|
@{
|
||||||
var cpu = limit.ReadValue("cpu");
|
var cpu = limit.ReadValue("cpu");
|
||||||
@@ -76,12 +82,16 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="fv-row">
|
<div class="fv-row">
|
||||||
<label class="form-label"><TL>Memory</TL></label>
|
<label class="form-label">
|
||||||
|
<TL>Memory</TL>
|
||||||
|
</label>
|
||||||
<div class="fw-bold fs-3">@(limit.ReadValue("memory")) MB</div>
|
<div class="fw-bold fs-3">@(limit.ReadValue("memory")) MB</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="fv-row">
|
<div class="fv-row">
|
||||||
<label class="form-label"><TL>Disk</TL></label>
|
<label class="form-label">
|
||||||
|
<TL>Disk</TL>
|
||||||
|
</label>
|
||||||
<div class="fw-bold fs-3">@(limit.ReadValue("disk")) MB</div>
|
<div class="fw-bold fs-3">@(limit.ReadValue("disk")) MB</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -108,15 +118,6 @@
|
|||||||
</div>
|
</div>
|
||||||
@if (Images.Any())
|
@if (Images.Any())
|
||||||
{
|
{
|
||||||
<label class="form-label">
|
|
||||||
<TL>Image</TL>
|
|
||||||
</label>
|
|
||||||
<SmartSelect TField="Image"
|
|
||||||
@bind-Value="Model.Image"
|
|
||||||
Items="Images.Keys.ToArray()"
|
|
||||||
DisplayField="@(x => x.Name)">
|
|
||||||
</SmartSelect>
|
|
||||||
|
|
||||||
<button type="submit" class="mt-5 float-end btn btn-primary">
|
<button type="submit" class="mt-5 float-end btn btn-primary">
|
||||||
<TL>Create</TL>
|
<TL>Create</TL>
|
||||||
</button>
|
</button>
|
||||||
@@ -125,13 +126,45 @@
|
|||||||
{
|
{
|
||||||
<div class="alert alert-warning d-flex align-items-center p-5 mb-10">
|
<div class="alert alert-warning d-flex align-items-center p-5 mb-10">
|
||||||
<span>
|
<span>
|
||||||
<TL>You reached the maximum amount of servers for every image of your subscription</TL>: @(Subscription == null ? SmartTranslateService.Translate("Default") : Subscription.Name)
|
<TL>We could not find any image in your subscription you have access to</TL>: @(Subscription == null ? SmartTranslateService.Translate("Default") : Subscription.Name)
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</SmartForm>
|
</SmartForm>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
@foreach (var keyValuePair in Images)
|
||||||
|
{
|
||||||
|
bool selected = Model.Image != null && Model.Image.Id == keyValuePair.Key.Id;
|
||||||
|
|
||||||
|
<div class="col-12 col-md-4">
|
||||||
|
@if (ServerCounts[keyValuePair.Key] > keyValuePair.Value.Amount)
|
||||||
|
{
|
||||||
|
<div class="m-2 card blur">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title text-center">@(keyValuePair.Key.Name)</h5>
|
||||||
|
<p class="card-text">
|
||||||
|
@(keyValuePair.Key.Description)
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<a href="#" class="m-2 card @(selected ? "border border-2 border-primary" : "") invisible-a" @onclick:preventDefault @onclick="() => SelectImage(keyValuePair.Key)">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title text-center">@(keyValuePair.Key.Name)</h5>
|
||||||
|
<p class="card-text">
|
||||||
|
@(keyValuePair.Key.Description)
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -146,6 +179,7 @@
|
|||||||
private Subscription? Subscription;
|
private Subscription? Subscription;
|
||||||
|
|
||||||
private Dictionary<Image, SubscriptionLimit> Images = new();
|
private Dictionary<Image, SubscriptionLimit> Images = new();
|
||||||
|
private Dictionary<Image, int> ServerCounts = new();
|
||||||
|
|
||||||
private ServerOrderDataModel Model = new();
|
private ServerOrderDataModel Model = new();
|
||||||
|
|
||||||
@@ -177,8 +211,8 @@
|
|||||||
.Where(x => x.Owner.Id == User.Id)
|
.Where(x => x.Owner.Id == User.Id)
|
||||||
.Count(x => x.Image.Id == image.Id);
|
.Count(x => x.Image.Id == image.Id);
|
||||||
|
|
||||||
if(serversCount < limit.Amount)
|
|
||||||
Images.Add(image, limit);
|
Images.Add(image, limit);
|
||||||
|
ServerCounts.Add(image, serversCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,7 +232,7 @@
|
|||||||
|
|
||||||
if (serversCount < limit.Amount)
|
if (serversCount < limit.Amount)
|
||||||
{
|
{
|
||||||
if(int.TryParse(limit.ReadValue("cpu"), out int cpu) &&
|
if (int.TryParse(limit.ReadValue("cpu"), out int cpu) &&
|
||||||
int.TryParse(limit.ReadValue("memory"), out int memory) &&
|
int.TryParse(limit.ReadValue("memory"), out int memory) &&
|
||||||
int.TryParse(limit.ReadValue("disk"), out int disk))
|
int.TryParse(limit.ReadValue("disk"), out int disk))
|
||||||
{
|
{
|
||||||
@@ -221,4 +255,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task SelectImage(Image image)
|
||||||
|
{
|
||||||
|
Model.Image = image;
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -221,6 +221,8 @@
|
|||||||
{
|
{
|
||||||
ServerGroups = (JsonConvert.DeserializeObject<ServerGroup[]>(
|
ServerGroups = (JsonConvert.DeserializeObject<ServerGroup[]>(
|
||||||
User.ServerListLayoutJson) ?? Array.Empty<ServerGroup>()).ToList();
|
User.ServerListLayoutJson) ?? Array.Empty<ServerGroup>()).ToList();
|
||||||
|
|
||||||
|
await CheckServerGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var server in AllServers)
|
foreach (var server in AllServers)
|
||||||
@@ -256,8 +258,8 @@
|
|||||||
private async Task RemoveGroup(ServerGroup group)
|
private async Task RemoveGroup(ServerGroup group)
|
||||||
{
|
{
|
||||||
ServerGroups.Remove(group);
|
ServerGroups.Remove(group);
|
||||||
await EnsureAllServersInGroups();
|
|
||||||
|
|
||||||
|
await CheckServerGroups();
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
await JsRuntime.InvokeVoidAsync("moonlight.serverList.init");
|
await JsRuntime.InvokeVoidAsync("moonlight.serverList.init");
|
||||||
@@ -266,11 +268,10 @@
|
|||||||
private async Task SetEditMode(bool toggle)
|
private async Task SetEditMode(bool toggle)
|
||||||
{
|
{
|
||||||
EditMode = toggle;
|
EditMode = toggle;
|
||||||
await InvokeAsync(StateHasChanged);
|
|
||||||
|
|
||||||
if (EditMode)
|
if (EditMode)
|
||||||
{
|
{
|
||||||
await EnsureAllServersInGroups();
|
await CheckServerGroups();
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
await JsRuntime.InvokeVoidAsync("moonlight.serverList.init");
|
await JsRuntime.InvokeVoidAsync("moonlight.serverList.init");
|
||||||
@@ -278,6 +279,9 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var json = JsonConvert.SerializeObject(await GetGroupsFromClient());
|
var json = JsonConvert.SerializeObject(await GetGroupsFromClient());
|
||||||
|
|
||||||
|
await CheckServerGroups();
|
||||||
|
|
||||||
User.ServerListLayoutJson = json;
|
User.ServerListLayoutJson = json;
|
||||||
UserRepository.Update(User);
|
UserRepository.Update(User);
|
||||||
|
|
||||||
@@ -297,62 +301,90 @@
|
|||||||
Logger.Verbose("Server list group lenght too long");
|
Logger.Verbose("Server list group lenght too long");
|
||||||
return Array.Empty<ServerGroup>();
|
return Array.Empty<ServerGroup>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverGroup.Servers.Any(x => AllServers.All(y => y.Id.ToString() != x)))
|
|
||||||
{
|
|
||||||
Logger.Verbose("User tried to add a server in his server list which he has no access to");
|
|
||||||
return Array.Empty<ServerGroup>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return serverGroups;
|
return serverGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task EnsureAllServersInGroups()
|
private Task CheckServerGroups()
|
||||||
{
|
{
|
||||||
var presentInGroup = new List<Server>();
|
var result = new List<ServerGroup>();
|
||||||
|
|
||||||
|
// Reconstruct the data with checking for invalid server ids
|
||||||
foreach (var group in ServerGroups)
|
foreach (var group in ServerGroups)
|
||||||
|
{
|
||||||
|
var checkedGroup = new ServerGroup()
|
||||||
|
{
|
||||||
|
Name = group.Name
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var server in group.Servers)
|
||||||
|
{
|
||||||
|
var s = AllServers.FirstOrDefault(x => x.Id.ToString() == server);
|
||||||
|
|
||||||
|
if (s != null) // This is a check for invalid server ids
|
||||||
|
{
|
||||||
|
checkedGroup.Servers.Add(s.Id.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Add(checkedGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
var presentInGroup = new List<Server>();
|
||||||
|
|
||||||
|
// Copy all servers to preset in group if they are in the users servers
|
||||||
|
foreach (var group in result)
|
||||||
{
|
{
|
||||||
foreach (var id in group.Servers)
|
foreach (var id in group.Servers)
|
||||||
presentInGroup.Add(AllServers.First(x => x.Id.ToString() == id));
|
{
|
||||||
|
var s = AllServers.First(x => x.Id.ToString() == id);
|
||||||
|
presentInGroup.Add(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var serversMissing = new List<Server>();
|
var serversMissing = new List<Server>();
|
||||||
|
|
||||||
|
// Make a list of missing servers
|
||||||
foreach (var server in AllServers)
|
foreach (var server in AllServers)
|
||||||
{
|
{
|
||||||
if (presentInGroup.All(x => x.Id != server.Id))
|
if (presentInGroup.All(x => x.Id != server.Id))
|
||||||
serversMissing.Add(server);
|
serversMissing.Add(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add all missing servers into the default group
|
||||||
if (serversMissing.Any())
|
if (serversMissing.Any())
|
||||||
{
|
{
|
||||||
var defaultGroup = ServerGroups.FirstOrDefault(x => x.Name == "");
|
var defaultGroup = result.FirstOrDefault(x => x.Name == "");
|
||||||
|
|
||||||
if (defaultGroup == null)
|
if (defaultGroup == null) // If group does not exist, create it
|
||||||
{
|
{
|
||||||
defaultGroup = new ServerGroup()
|
defaultGroup = new ServerGroup()
|
||||||
{
|
{
|
||||||
Name = ""
|
Name = ""
|
||||||
};
|
};
|
||||||
|
|
||||||
ServerGroups.Add(defaultGroup);
|
result.Add(defaultGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var server in serversMissing)
|
foreach (var server in serversMissing)
|
||||||
defaultGroup.Servers.Add(server.Id.ToString());
|
defaultGroup.Servers.Add(server.Id.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ServerGroups = result;
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddStatus(Server server, string status)
|
private void AddStatus(Server server, string status)
|
||||||
{
|
{
|
||||||
lock (StatusCache)
|
lock (StatusCache)
|
||||||
|
{
|
||||||
|
if (!StatusCache.ContainsKey(server))
|
||||||
{
|
{
|
||||||
StatusCache.Add(server, status);
|
StatusCache.Add(server, status);
|
||||||
InvokeAsync(StateHasChanged);
|
InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
.components-reconnect-rejected > .rejected {
|
.components-reconnect-rejected > .rejected {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.components-reconnect-hide > div {
|
.components-reconnect-hide > div {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@@ -56,3 +57,16 @@
|
|||||||
.components-reconnect-rejected {
|
.components-reconnect-rejected {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
width: 12px;
|
||||||
|
background: var(--kt-card-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-thumb {
|
||||||
|
background: #6964E4;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: #6964E4;
|
||||||
|
}
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
Moonlight is a new free and open source alternative to pterodactyl allowing users to create their own hosting platform and host all sorts of gameservers in docker containers. With a simple migration from pterodactyl to moonlight (migrator will be open source soon) you can easily switch to moonlight and use its features like a server manager, cleanup system and automatic version switcher, just to name a few.
|
Moonlight is a new free and open source alternative to pterodactyl allowing users to create their own hosting platform and host all sorts of gameservers in docker containers. With a simple migration from pterodactyl to moonlight ([see guide](https://docs.moonlightpanel.xyz/migrating-from-pterodactyl)) you can easily switch to moonlight and use its features like a server manager, cleanup system and automatic version switcher, just to name a few.
|
||||||
|
|
||||||
Moonlight's core features are
|
Moonlight's core features are
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user