Refactored project to module structure

This commit is contained in:
2026-03-12 22:50:15 +01:00
parent 93de9c5d00
commit 1257e8b950
219 changed files with 1231 additions and 1259 deletions

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.Shared.Http.Requests.Seup;
namespace Moonlight.Shared.Admin.Setup;
public class ApplySetupDto
{
@@ -8,11 +8,9 @@ public class ApplySetupDto
[MinLength(3)]
[MaxLength(32)]
public string AdminUsername { get; set; }
[Required]
[EmailAddress]
public string AdminEmail { get; set; }
[Required] [EmailAddress] public string AdminEmail { get; set; }
[Required]
[MinLength(8)]
[MaxLength(64)]

View File

@@ -0,0 +1,11 @@
namespace Moonlight.Shared.Admin.Sys.ApiKeys;
public record ApiKeyDto(
int Id,
string Name,
string Description,
string[] Permissions,
DateTimeOffset ValidUntil,
string Key,
DateTimeOffset CreatedAt,
DateTimeOffset UpdatedAt);

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.Shared.Http.Requests.Admin.ApiKeys;
namespace Moonlight.Shared.Admin.Sys.ApiKeys;
public class CreateApiKeyDto
{

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.Shared.Http.Requests.Admin.ApiKeys;
namespace Moonlight.Shared.Admin.Sys.ApiKeys;
public class UpdateApiKeyDto
{

View File

@@ -1,3 +1,3 @@
namespace Moonlight.Shared.Http.Responses.Admin;
namespace Moonlight.Shared.Admin.Sys.ContainerHelper;
public record ContainerHelperStatusDto(bool IsEnabled, bool IsReachable);

View File

@@ -0,0 +1,18 @@
using System.Text.Json.Serialization;
namespace Moonlight.Shared.Admin.Sys.ContainerHelper;
public struct RebuildEventDto
{
[JsonPropertyName("type")] public RebuildEventType Type { get; set; }
[JsonPropertyName("data")] public string Data { get; set; }
}
public enum RebuildEventType
{
Log = 0,
Failed = 1,
Succeeded = 2,
Step = 3
}

View File

@@ -1,9 +1,7 @@
namespace Moonlight.Shared.Http.Requests.Admin.ContainerHelper;
namespace Moonlight.Shared.Admin.Sys.ContainerHelper;
public class RequestRebuildDto
{
public bool NoBuildCache { get; set; }
public RequestRebuildDto()
{
}
@@ -12,4 +10,6 @@ public class RequestRebuildDto
{
NoBuildCache = noBuildCache;
}
public bool NoBuildCache { get; set; }
}

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.Shared.Http.Requests.Admin.ContainerHelper;
namespace Moonlight.Shared.Admin.Sys.ContainerHelper;
public class SetVersionDto
{

View File

@@ -0,0 +1,17 @@
namespace Moonlight.Shared.Admin.Sys.Diagnose;
public record DiagnoseResultDto(
DiagnoseLevel Level,
string Title,
string[] Tags,
string? Message,
string? StackStrace,
string? SolutionUrl,
string? ReportUrl);
public enum DiagnoseLevel
{
Error = 0,
Warning = 1,
Healthy = 2
}

View File

@@ -0,0 +1,8 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.Shared.Admin.Sys.Settings;
public class SetWhiteLabelingDto
{
[Required] public string Name { get; set; }
}

View File

@@ -1,4 +1,4 @@
namespace Moonlight.Shared.Http.Responses.Admin.Settings;
namespace Moonlight.Shared.Admin.Sys.Settings;
public class WhiteLabelingDto
{

View File

@@ -0,0 +1,9 @@
namespace Moonlight.Shared.Admin.Sys;
public record SystemInfoDto(
double CpuUsage,
long MemoryUsage,
string OperatingSystem,
TimeSpan Uptime,
string VersionName,
bool IsUpToDate);

View File

@@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.Shared.Admin.Sys.Themes;
public class CreateThemeDto
{
[Required] [MaxLength(30)] public string Name { get; set; }
[Required] [MaxLength(30)] public string Version { get; set; }
[Required] [MaxLength(30)] public string Author { get; set; }
public bool IsEnabled { get; set; }
[Required] [MaxLength(20_000)] public string CssContent { get; set; }
}

View File

@@ -1,3 +1,3 @@
namespace Moonlight.Shared.Http.Responses.Admin.Themes;
namespace Moonlight.Shared.Admin.Sys.Themes;
public record ThemeDto(int Id, string Name, string Author, string Version, string CssContent, bool IsEnabled);

View File

@@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.Shared.Admin.Sys.Themes;
public class UpdateThemeDto
{
[Required] [MaxLength(30)] public string Name { get; set; }
[Required] [MaxLength(30)] public string Version { get; set; }
[Required] [MaxLength(30)] public string Author { get; set; }
public bool IsEnabled { get; set; }
[Required] [MaxLength(20_000)] public string CssContent { get; set; }
}

View File

@@ -1,3 +1,3 @@
namespace Moonlight.Shared.Http.Responses.Admin;
namespace Moonlight.Shared.Admin.Sys.Versions;
public record VersionDto(string Identifier, bool IsPreRelease, bool IsDevelopment, DateTimeOffset CreatedAt);

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.Shared.Http.Requests.Admin.Roles;
namespace Moonlight.Shared.Admin.Users.Roles;
public class CreateRoleDto
{

View File

@@ -0,0 +1,10 @@
namespace Moonlight.Shared.Admin.Users.Roles;
public record RoleDto(
int Id,
string Name,
string Description,
string[] Permissions,
int MemberCount,
DateTimeOffset CreatedAt,
DateTimeOffset UpdatedAt);

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.Shared.Http.Requests.Admin.Roles;
namespace Moonlight.Shared.Admin.Users.Roles;
public class UpdateRoleDto
{

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.Shared.Http.Requests.Admin.Users;
namespace Moonlight.Shared.Admin.Users.Users;
public class CreateUserDto
{

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.Shared.Http.Requests.Admin.Users;
namespace Moonlight.Shared.Admin.Users.Users;
public class UpdateUserDto
{

View File

@@ -1,3 +1,3 @@
namespace Moonlight.Shared.Http.Responses.Admin.Users;
namespace Moonlight.Shared.Admin.Users.Users;
public record UserDto(int Id, string Username, string Email, DateTimeOffset CreatedAt, DateTimeOffset UpdatedAt);

View File

@@ -1,20 +0,0 @@
using System.Text.Json.Serialization;
namespace Moonlight.Shared.Http.Events;
public struct RebuildEventDto
{
[JsonPropertyName("type")]
public RebuildEventType Type { get; set; }
[JsonPropertyName("data")]
public string Data { get; set; }
}
public enum RebuildEventType
{
Log = 0,
Failed = 1,
Succeeded = 2,
Step = 3
}

View File

@@ -1,9 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.Shared.Http.Requests.Admin.Settings;
public class SetWhiteLabelingDto
{
[Required]
public string Name { get; set; }
}

View File

@@ -1,23 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.Shared.Http.Requests.Admin.Themes;
public class CreateThemeDto
{
[Required]
[MaxLength(30)]
public string Name { get; set; }
[Required]
[MaxLength(30)]
public string Version { get; set; }
[Required]
[MaxLength(30)]
public string Author { get; set; }
public bool IsEnabled { get; set; }
[Required]
[MaxLength(20_000)]
public string CssContent { get; set; }
}

View File

@@ -1,23 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.Shared.Http.Requests.Admin.Themes;
public class UpdateThemeDto
{
[Required]
[MaxLength(30)]
public string Name { get; set; }
[Required]
[MaxLength(30)]
public string Version { get; set; }
[Required]
[MaxLength(30)]
public string Author { get; set; }
public bool IsEnabled { get; set; }
[Required]
[MaxLength(20_000)]
public string CssContent { get; set; }
}

View File

@@ -1,3 +0,0 @@
namespace Moonlight.Shared.Http.Responses.Admin.ApiKeys;
public record ApiKeyDto(int Id, string Name, string Description, string[] Permissions, DateTimeOffset ValidUntil, string Key, DateTimeOffset CreatedAt, DateTimeOffset UpdatedAt);

View File

@@ -1,3 +0,0 @@
namespace Moonlight.Shared.Http.Responses.Admin.Auth;
public record ClaimDto(string Type, string Value);

View File

@@ -1,10 +0,0 @@
namespace Moonlight.Shared.Http.Responses.Admin;
public record DiagnoseResultDto(DiagnoseLevel Level, string Title, string[] Tags, string? Message, string? StackStrace, string? SolutionUrl, string? ReportUrl);
public enum DiagnoseLevel
{
Error = 0,
Warning = 1,
Healthy = 2
}

View File

@@ -1,3 +0,0 @@
namespace Moonlight.Shared.Http.Responses.Admin;
public record RoleDto(int Id, string Name, string Description, string[] Permissions, int MemberCount, DateTimeOffset CreatedAt, DateTimeOffset UpdatedAt);

View File

@@ -1,3 +0,0 @@
namespace Moonlight.Shared.Http.Responses.Admin;
public record SystemInfoDto(double CpuUsage, long MemoryUsage, string OperatingSystem, TimeSpan Uptime, string VersionName, bool IsUpToDate);

View File

@@ -17,5 +17,9 @@
<RepositoryUrl>https://git.battlestati.one/Moonlight-Panel/Moonlight</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
<ItemGroup>
<Folder Include="Client\"/>
</ItemGroup>
</Project>

View File

@@ -4,53 +4,53 @@ public static class Permissions
{
public const string Prefix = "Permissions:";
public const string ClaimType = "Permissions";
public static class Users
{
private const string Section = "Users";
public const string View = $"{Prefix}{Section}.{nameof(View)}";
public const string Edit = $"{Prefix}{Section}.{nameof(Edit)}";
public const string Create = $"{Prefix}{Section}.{nameof(Create)}";
public const string Delete = $"{Prefix}{Section}.{nameof(Delete)}";
public const string Logout = $"{Prefix}{Section}.{nameof(Logout)}";
}
public static class ApiKeys
{
private const string Section = "ApiKeys";
public const string View = $"{Prefix}{Section}.{nameof(View)}";
public const string Edit = $"{Prefix}{Section}.{nameof(Edit)}";
public const string Create = $"{Prefix}{Section}.{nameof(Create)}";
public const string Delete = $"{Prefix}{Section}.{nameof(Delete)}";
}
public static class Roles
{
private const string Section = "Roles";
public const string View = $"{Prefix}{Section}.{nameof(View)}";
public const string Edit = $"{Prefix}{Section}.{nameof(Edit)}";
public const string Create = $"{Prefix}{Section}.{nameof(Create)}";
public const string Delete = $"{Prefix}{Section}.{nameof(Delete)}";
public const string Members = $"{Prefix}{Section}.{nameof(Members)}";
}
public static class Themes
{
private const string Section = "Themes";
public const string View = $"{Prefix}{Section}.{nameof(View)}";
public const string Edit = $"{Prefix}{Section}.{nameof(Edit)}";
public const string Create = $"{Prefix}{Section}.{nameof(Create)}";
public const string Delete = $"{Prefix}{Section}.{nameof(Delete)}";
}
public static class System
{
private const string Section = "System";
public const string Info = $"{Prefix}{Section}.{nameof(Info)}";
public const string Diagnose = $"{Prefix}{Section}.{nameof(Diagnose)}";
public const string Versions = $"{Prefix}{Section}.{nameof(Versions)}";

View File

@@ -1,21 +1,18 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Moonlight.Shared.Http.Events;
using Moonlight.Shared.Http.Requests.Admin.ApiKeys;
using Moonlight.Shared.Http.Requests.Admin.ContainerHelper;
using Moonlight.Shared.Http.Requests.Admin.Roles;
using Moonlight.Shared.Http.Requests.Admin.Settings;
using Moonlight.Shared.Http.Requests.Admin.Themes;
using Moonlight.Shared.Http.Requests.Admin.Users;
using Moonlight.Shared.Http.Responses;
using Moonlight.Shared.Http.Responses.Admin;
using Moonlight.Shared.Http.Responses.Admin.ApiKeys;
using Moonlight.Shared.Http.Responses.Admin.Auth;
using Moonlight.Shared.Http.Responses.Admin.Settings;
using Moonlight.Shared.Http.Responses.Admin.Themes;
using Moonlight.Shared.Http.Responses.Admin.Users;
using Moonlight.Shared.Admin.Sys;
using Moonlight.Shared.Admin.Sys.ApiKeys;
using Moonlight.Shared.Admin.Sys.ContainerHelper;
using Moonlight.Shared.Admin.Sys.Diagnose;
using Moonlight.Shared.Admin.Sys.Settings;
using Moonlight.Shared.Admin.Sys.Themes;
using Moonlight.Shared.Admin.Sys.Versions;
using Moonlight.Shared.Admin.Users.Roles;
using Moonlight.Shared.Admin.Users.Users;
using Moonlight.Shared.Shared;
using Moonlight.Shared.Shared.Auth;
namespace Moonlight.Shared.Http;
namespace Moonlight.Shared;
// Users
[JsonSerializable(typeof(CreateUserDto))]
@@ -64,9 +61,7 @@ namespace Moonlight.Shared.Http;
// Settings - White Labeling
[JsonSerializable(typeof(WhiteLabelingDto))]
[JsonSerializable(typeof(SetWhiteLabelingDto))]
[JsonSourceGenerationOptions(JsonSerializerDefaults.Web)]
public partial class SerializationContext : JsonSerializerContext
{
}

View File

@@ -0,0 +1,3 @@
namespace Moonlight.Shared.Shared.Auth;
public record ClaimDto(string Type, string Value);

View File

@@ -1,3 +1,3 @@
namespace Moonlight.Shared.Http.Responses.Admin.Auth;
namespace Moonlight.Shared.Shared.Auth;
public record SchemeDto(string Name, string DisplayName);

View File

@@ -1,14 +1,12 @@
using System.Diagnostics.CodeAnalysis;
namespace Moonlight.Shared.Http.Requests;
namespace Moonlight.Shared.Shared;
public class FilterOptions : IParsable<FilterOptions>
{
public Dictionary<string, string> Filters { get; set; }
public FilterOptions()
{
Filters = new();
Filters = new Dictionary<string, string>();
}
public FilterOptions(Dictionary<string, string> filters)
@@ -16,6 +14,8 @@ public class FilterOptions : IParsable<FilterOptions>
Filters = filters;
}
public Dictionary<string, string> Filters { get; set; }
public static FilterOptions Parse(string s, IFormatProvider? provider)
{
if (!TryParse(s, provider, out var result))
@@ -30,7 +30,7 @@ public class FilterOptions : IParsable<FilterOptions>
[MaybeNullWhen(false)] out FilterOptions result
)
{
result = new();
result = new FilterOptions();
if (string.IsNullOrEmpty(input))
return true;

View File

@@ -1,3 +1,3 @@
namespace Moonlight.Shared.Http.Responses.Admin.Frontend;
namespace Moonlight.Shared.Shared.Frontend;
public record FrontendConfigDto(string Name, string? ThemeCss);

View File

@@ -1,3 +1,3 @@
namespace Moonlight.Shared.Http.Responses;
namespace Moonlight.Shared.Shared;
public record PagedData<T>(T[] Data, int TotalLength);

View File

@@ -1,4 +1,4 @@
namespace Moonlight.Shared.Http.Responses;
namespace Moonlight.Shared.Shared;
public class ProblemDetails
{