Implemented template crud, db entities, import/export, ptero and pelican import

This commit is contained in:
2026-03-12 13:00:32 +00:00
parent 7c5dc657dc
commit e7b1e77d0a
68 changed files with 4269 additions and 24 deletions

View File

@@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
namespace MoonlightServers.Shared.Admin.Templates;
public class CreateDockerImageDto
{
[Required, MaxLength(30)]
public string DisplayName { get; set; } = string.Empty;
[Required, MaxLength(255)]
public string ImageName { get; set; } = string.Empty;
public bool SkipPulling { get; set; }
}

View File

@@ -0,0 +1,24 @@
using System.ComponentModel.DataAnnotations;
namespace MoonlightServers.Shared.Admin.Templates;
public class CreateTemplateDto
{
[Required, MaxLength(30)]
public string Name { get; set; } = string.Empty;
[Required, MaxLength(255)]
public string Description { get; set; } = string.Empty;
[Required, MaxLength(30)]
public string Author { get; set; } = string.Empty;
[Required, MaxLength(30)]
public string Version { get; set; } = string.Empty;
[MaxLength(2048)]
public string? UpdateUrl { get; set; }
[MaxLength(2048)]
public string? DonateUrl { get; set; }
}

View File

@@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
namespace MoonlightServers.Shared.Admin.Templates;
public class CreateVariableDto
{
[Required, MaxLength(30)]
public string DisplayName { get; set; } = string.Empty;
[Required, MaxLength(255)]
public string Description { get; set; } = string.Empty;
[Required, MaxLength(60)]
public string EnvName { get; set; } = string.Empty;
[MaxLength(1024)]
public string? DefaultValue { get; set; } = string.Empty;
}

View File

@@ -0,0 +1,17 @@
namespace MoonlightServers.Shared.Admin.Templates;
public record DetailedTemplateDto(
int Id,
string Name,
string Description,
string Author,
string Version,
string? UpdateUrl,
string? DonateUrl,
FilesConfigDto FilesConfig,
LifecycleConfigDto LifecycleConfig,
InstallationConfigDto InstallationConfig,
MiscellaneousConfigDto MiscellaneousConfig,
bool AllowUserDockerImageChange,
int? DefaultDockerImageId
);

View File

@@ -0,0 +1,8 @@
namespace MoonlightServers.Shared.Admin.Templates;
public record DockerImageDto(
int Id,
string DisplayName,
string ImageName,
bool SkipPulling
);

View File

@@ -0,0 +1,20 @@
namespace MoonlightServers.Shared.Admin.Templates;
public class FilesConfigDto
{
public List<ConfigurationFileDto> ConfigurationFiles { get; set; } = new();
}
public class ConfigurationFileDto
{
public string Path { get; set; }
public string Parser { get; set; }
public List<ConfigurationFileMappingDto> Mappings { get; set; } = new();
}
public class ConfigurationFileMappingDto
{
public string Key { get; set; }
public string? Value { get; set; }
}

View File

@@ -0,0 +1,3 @@
namespace MoonlightServers.Shared.Admin.Templates;
public record InstallationConfigDto(string DockerImage, string Shell, string Script);

View File

@@ -0,0 +1,4 @@
namespace MoonlightServers.Shared.Admin.Templates;
public record LifecycleConfigDto(StartupCommandDto[] StartupCommands, string StopCommand, string[] OnlineLogPatterns);
public record StartupCommandDto(string DisplayName, string Command);

View File

@@ -0,0 +1,3 @@
namespace MoonlightServers.Shared.Admin.Templates;
public record MiscellaneousConfigDto(bool UseLegacyStartup);

View File

@@ -0,0 +1,11 @@
namespace MoonlightServers.Shared.Admin.Templates;
public record TemplateDto(
int Id,
string Name,
string Description,
string Author,
string Version,
string? UpdateUrl,
string? DonateUrl
);

View File

@@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
namespace MoonlightServers.Shared.Admin.Templates;
public class UpdateDockerImageDto
{
[Required, MaxLength(30)]
public string DisplayName { get; set; } = string.Empty;
[Required, MaxLength(255)]
public string ImageName { get; set; } = string.Empty;
public bool SkipPulling { get; set; }
}

View File

@@ -0,0 +1,27 @@
using System.ComponentModel.DataAnnotations;
namespace MoonlightServers.Shared.Admin.Templates;
public class UpdateFilesConfigDto
{
public List<UpdateConfigurationFileDto> ConfigurationFiles { get; set; } = [];
}
public class UpdateConfigurationFileDto
{
[Required]
public string Path { get; set; } = string.Empty;
[Required]
public string Parser { get; set; } = string.Empty;
public List<UpdateConfigurationFileMappingDto> Mappings { get; set; } = [];
}
public class UpdateConfigurationFileMappingDto
{
[Required]
public string Key { get; set; } = string.Empty;
public string? Value { get; set; } = string.Empty;
}

View File

@@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations;
namespace MoonlightServers.Shared.Admin.Templates;
public class UpdateInstallationConfigDto
{
[Required, MaxLength(30)]
public string Shell { get; set; } = string.Empty;
[Required, MaxLength(255)]
public string DockerImage { get; set; } = string.Empty;
[Required]
public string Script { get; set; } = string.Empty;
}

View File

@@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations;
namespace MoonlightServers.Shared.Admin.Templates;
public class UpdateLifecycleConfigDto
{
public List<UpdateStartupCommandDto> StartupCommands { get; set; } = [];
[Required]
public string StopCommand { get; set; } = string.Empty;
public List<string> OnlineLogPatterns { get; set; } = [];
}
public class UpdateStartupCommandDto
{
[Required]
public string Command { get; set; } = string.Empty;
[Required]
public string DisplayName { get; set; } = string.Empty;
}

View File

@@ -0,0 +1,6 @@
namespace MoonlightServers.Shared.Admin.Templates;
public class UpdateMiscellaneousConfigDto
{
public bool UseLegacyStartup { get; set; }
}

View File

@@ -0,0 +1,32 @@
using System.ComponentModel.DataAnnotations;
namespace MoonlightServers.Shared.Admin.Templates;
public class UpdateTemplateDto
{
[Required, MaxLength(30)]
public string Name { get; set; } = string.Empty;
[Required, MaxLength(255)]
public string Description { get; set; } = string.Empty;
[Required, MaxLength(30)]
public string Author { get; set; } = string.Empty;
[Required, MaxLength(30)]
public string Version { get; set; } = string.Empty;
[MaxLength(2048)]
public string? UpdateUrl { get; set; }
[MaxLength(2048)]
public string? DonateUrl { get; set; }
public UpdateFilesConfigDto FilesConfig { get; set; } = new();
public UpdateLifecycleConfigDto LifecycleConfig { get; set; } = new();
public UpdateInstallationConfigDto InstallationConfig { get; set; } = new();
public UpdateMiscellaneousConfigDto MiscellaneousConfig { get; set; } = new();
public bool AllowUserDockerImageChange { get; set; }
public int? DefaultDockerImageId { get; set; }
}

View File

@@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
namespace MoonlightServers.Shared.Admin.Templates;
public class UpdateVariableDto
{
[Required, MaxLength(30)]
public string DisplayName { get; set; } = string.Empty;
[Required, MaxLength(255)]
public string Description { get; set; }
[Required, MaxLength(60)]
public string EnvName { get; set; } = string.Empty;
[MaxLength(1024)]
public string? DefaultValue { get; set; } = string.Empty;
}

View File

@@ -0,0 +1,9 @@
namespace MoonlightServers.Shared.Admin.Templates;
public record VariableDto(
int Id,
string DisplayName,
string Description,
string EnvName,
string DefaultValue
);