diff --git a/Moonlight/App/Perms/Permissions.cs b/Moonlight/App/Perms/Permissions.cs index e612e231..8e5cb011 100644 --- a/Moonlight/App/Perms/Permissions.cs +++ b/Moonlight/App/Perms/Permissions.cs @@ -8,6 +8,104 @@ public static class Permissions Name = "Admin dashboard", Description = "See basic information about growth and status of the moonlight instance" }; + + public static Permission SystemDashboard = new() + { + Index = 1, + Name = "System information", + Description = "See information about the moonlight instance like the uptime and memory usage" + }; + + public static Permission SystemSentry = new() + { + Index = 2, + Name = "Settings for Sentry", + Description = "See information about the sentry status" + }; + + public static Permission SystemMalware = new() + { + Index = 3, + Name = "Server malware scanner", + Description = "Scan running servers for malware" + }; + + public static Permission SystemSecurity = new() + { + Index = 4, + Name = "System security settings", + Description = "Ban ip addresses and view the security logs" + }; + + public static Permission SystemResources = new() + { + Index = 5, + Name = "Resources", + Description = "Read and write moonlight resources like configuration files" + }; + + public static Permission DiscordBot = new() + { + Index = 6, + Name = "Discord bot actions", + Description = "Setup and remote control the discord bot if enabled" + }; + + public static Permission NewsMessages = new() + { + Index = 7, + Name = "News messages", + Description = "Edit, view and delete messages for the user dashboard" + }; + + public static Permission SystemConfiguration = new() + { + Index = 8, + Name = "System configuration", + Description = "Modify the moonlight configuration though the visual editor" + }; + + public static Permission SystemMail = new() + { + Index = 9, + Name = "System mail settings", + Description = "Modify the mail templates and send test mails" + }; + + public static Permission ServersOverview = new() + { + Index = 10, + Name = "Servers overview", + Description = "View all servers and their owners" + }; + + public static Permission ServerAdminEdit = new() + { + Index = 11, + Name = "Edit servers", + Description = "View all servers and their owners" + }; + + public static Permission ServerManager = new() + { + Index = 12, + Name = "Server manager", + Description = "View all servers are currently running and stop/kill all running servers" + }; + + public static Permission ServerCleanup = new() + { + Index = 13, + Name = "Server cleanup", + Description = "View the stats about the cleanup system" + }; + + public static Permission Nodes = new() + { + Index = 14, + Name = "Nodes", + Description = "View stats about the nodes" + }; public static Permission? FromString(string name) { diff --git a/Moonlight/Moonlight.csproj b/Moonlight/Moonlight.csproj index 9ef2f159..02cac376 100644 --- a/Moonlight/Moonlight.csproj +++ b/Moonlight/Moonlight.csproj @@ -77,6 +77,7 @@ <_ContentIncludedByDefault Remove="Shared\Views\Admin\Servers\Cleanup\Exceptions\Edit.razor" /> <_ContentIncludedByDefault Remove="Shared\Components\News\NewsEditor.razor" /> <_ContentIncludedByDefault Remove="Shared\News\Edit.razor" /> + <_ContentIncludedByDefault Remove="Shared\Views\Admin\AaPanels\Index.razor" /> diff --git a/Moonlight/Shared/Views/Admin/AaPanels/Index.razor b/Moonlight/Shared/Views/Admin/AaPanels/Index.razor deleted file mode 100644 index 17f952c3..00000000 --- a/Moonlight/Shared/Views/Admin/AaPanels/Index.razor +++ /dev/null @@ -1,2 +0,0 @@ -@page "/admin/aapanels" - diff --git a/Moonlight/Shared/Views/Admin/Index.razor b/Moonlight/Shared/Views/Admin/Index.razor index e9f46fa3..b8d1a686 100644 --- a/Moonlight/Shared/Views/Admin/Index.razor +++ b/Moonlight/Shared/Views/Admin/Index.razor @@ -17,118 +17,116 @@ @attribute [PermissionRequired(nameof(Permissions.AdminDashboard))] - - -
-
- -
-
-
-
- Servers -
- - @(ServerCount) - -
-
- - - -
+ +
+ + + @if (HealthCheckData == null) + { +
+
+
+ Moonlight health +
+
+
+
+ Unable to fetch health check data +
+
+
+ } + else + { + + }
- + @code { diff --git a/Moonlight/Shared/Views/Admin/Servers/Index.razor b/Moonlight/Shared/Views/Admin/Servers/Index.razor index d71c2992..2e5517c6 100644 --- a/Moonlight/Shared/Views/Admin/Servers/Index.razor +++ b/Moonlight/Shared/Views/Admin/Servers/Index.razor @@ -8,62 +8,64 @@ @inject ServerRepository ServerRepository @inject SmartTranslateService SmartTranslateService - -
- -
-
-

- Servers -

- -
-
- @if (Servers.Any()) - { -
- - - - - - - - - - - - - - - -
-
- } - else - { -
- No servers found -
- } +@attribute [PermissionRequired(nameof(Permissions.ServersOverview))] + +
+ +
+
+

+ + Servers + +

+
- -
- +
+ @if (Servers.Any()) + { +
+ + + + + + + + + + + + + + + +
+
+ } + else + { +
+ No servers found +
+ } +
+
+ +
@code { diff --git a/Moonlight/Shared/Views/Admin/Sys/AuditLog.razor b/Moonlight/Shared/Views/Admin/Sys/AuditLog.razor deleted file mode 100644 index bf6a4f28..00000000 --- a/Moonlight/Shared/Views/Admin/Sys/AuditLog.razor +++ /dev/null @@ -1,106 +0,0 @@ -@page "/admin/system/auditlog" - -@using Moonlight.Shared.Components.Navigations -@using Moonlight.App.Repositories.LogEntries -@using Moonlight.App.Services -@using Moonlight.App.Database.Entities.LogsEntries -@using BlazorTable -@using Moonlight.App.Helpers -@using Moonlight.App.Models.Misc -@using Moonlight.Shared.Components.AuditLogEntrys - -@inject AuditLogEntryRepository AuditLogEntryRepository - - - - -
-
-
- - - -

@(Formatter.FormatDateOnly(DateTime))

-
-
- -
-
-
- - @if (AuditLogEntries.Any()) - { -
- @foreach (var entry in AuditLogEntries) - { - switch (entry.Type) - { - case AuditLogType.Login: - - break; - case AuditLogType.Register: - - break; - case AuditLogType.ChangePassword: - - break; - case AuditLogType.ChangePowerState: - - break; - } - } -
- } - else - { -
- No records found for this day -
- } -
-
-
-
- -@code -{ - private AuditLogEntry[] AuditLogEntries; - private LazyLoader LazyLoader; - private DateTime DateTime = DateTime.Today; - - private Task Load(LazyLoader arg) - { - AuditLogEntries = AuditLogEntryRepository - .Get() - .Where(x => x.CreatedAt.Date == DateTime.Date) - .OrderByDescending(x => x.Id) - .ToArray(); - - return Task.CompletedTask; - } - - private async Task Left() - { - DateTime = DateTime.AddDays(1); - - await LazyLoader.Reload(); - } - - private async Task Right() - { - DateTime = DateTime.AddDays(-1); - - await LazyLoader.Reload(); - } -} \ No newline at end of file diff --git a/Moonlight/Shared/Views/Admin/Sys/Configuration.razor b/Moonlight/Shared/Views/Admin/Sys/Configuration.razor index 067fc902..eb945763 100644 --- a/Moonlight/Shared/Views/Admin/Sys/Configuration.razor +++ b/Moonlight/Shared/Views/Admin/Sys/Configuration.razor @@ -9,26 +9,26 @@ @inject ToastService ToastService @inject SmartTranslateService SmartTranslateService - - +@attribute [PermissionRequired(nameof(Permissions.SystemConfiguration))] - -
- -
- + + + +
+ +
+ +
+ - - +
+ +
+ @code { diff --git a/Moonlight/Shared/Views/Admin/Sys/DiscordBot.razor b/Moonlight/Shared/Views/Admin/Sys/DiscordBot.razor index fa8a0d20..037183a6 100644 --- a/Moonlight/Shared/Views/Admin/Sys/DiscordBot.razor +++ b/Moonlight/Shared/Views/Admin/Sys/DiscordBot.razor @@ -4,34 +4,34 @@ @inject DiscordBotService DiscordBotService - - +@attribute [PermissionRequired(nameof(Permissions.DiscordBot))] -
- - + - - -
-
+
+ + + + + +
@code { //ToDo: Ole muss ins Bett gehen //ToDo: Bot Info Card with Name, Bot Avatar, (RichPresence) Game Status, Activity Status - + private async Task RegisterCommands() { await DiscordBotService.CreateCommands(); } - + private Task VoidCommands() { DiscordBotService.RemoveCommandsModule.VoidCommands(); diff --git a/Moonlight/Shared/Views/Admin/Sys/Index.razor b/Moonlight/Shared/Views/Admin/Sys/Index.razor index 20af8f1f..9d6e6b03 100644 --- a/Moonlight/Shared/Views/Admin/Sys/Index.razor +++ b/Moonlight/Shared/Views/Admin/Sys/Index.razor @@ -7,92 +7,92 @@ @inject HostSystemHelper HostSystemHelper @inject MoonlightService MoonlightService - - +@attribute [PermissionRequired(nameof(Permissions.SystemDashboard))] - -
-
-
-
- - Version - -
-
- - You are running moonlight version - @(MoonlightService.AppVersion) - -
-
+ + + +
+
+
+
+ + Version +
-
-
-
- - Operating system - -
-
- - Moonlight is running on - @(HostSystemHelper.GetOsName()) - -
-
-
-
-
-
- - Memory usage - -
-
- - Moonlight is using - @(HostSystemHelper.GetMemoryUsage()) MB - of memory - -
-
-
-
-
-
- - Cpu usage - -
-
- - Moonlight is using - @(HostSystemHelper.GetCpuUsage()) % - -
-
-
-
-
-
- - Uptime - -
-
- - Moonlight is since - - @(Formatter.FormatUptime(DateTime.UtcNow - MoonlightService.StartTimestamp)) - - -
-
+
+ + You are running moonlight version + @(MoonlightService.AppVersion) +
- - +
+
+
+
+ + Operating system + +
+
+ + Moonlight is running on + @(HostSystemHelper.GetOsName()) + +
+
+
+
+
+
+ + Memory usage + +
+
+ + Moonlight is using + @(HostSystemHelper.GetMemoryUsage()) MB + of memory + +
+
+
+
+
+
+ + Cpu usage + +
+
+ + Moonlight is using + @(HostSystemHelper.GetCpuUsage()) % + +
+
+
+
+
+
+ + Uptime + +
+
+ + Moonlight is since + + @(Formatter.FormatUptime(DateTime.UtcNow - MoonlightService.StartTimestamp)) + + +
+
+
+
+ @code { @@ -100,4 +100,4 @@ { return Task.CompletedTask; } -} +} \ No newline at end of file diff --git a/Moonlight/Shared/Views/Admin/Sys/Mail.razor b/Moonlight/Shared/Views/Admin/Sys/Mail.razor index 538b65e8..6b918cfa 100644 --- a/Moonlight/Shared/Views/Admin/Sys/Mail.razor +++ b/Moonlight/Shared/Views/Admin/Sys/Mail.razor @@ -16,79 +16,79 @@ @inject AlertService AlertService @inject MailService MailService - - +@attribute [PermissionRequired(nameof(Permissions.SystemMail))] -
-
- - Actions - -
-
- - -
+ + +
+
+ + Actions +
+
+ + +
+
- - @if (CurrentMailTemplate == null) - { -
-
- - Mail templates - -
- - -
-
-
-
- - - - - - - - -
-
+ + @if (CurrentMailTemplate == null) + { +
+
+ + Mail templates + +
+ +
- } - else - { - - } - - +
+
+ + + + + + + + +
+
+
+
+ } + else + { + + } +
@code { diff --git a/Moonlight/Shared/Views/Admin/Sys/Malware.razor b/Moonlight/Shared/Views/Admin/Sys/Malware.razor index e5e5b9b2..97de8771 100644 --- a/Moonlight/Shared/Views/Admin/Sys/Malware.razor +++ b/Moonlight/Shared/Views/Admin/Sys/Malware.razor @@ -14,89 +14,89 @@ @implements IDisposable - - +@attribute [PermissionRequired(nameof(Permissions.SystemMalware))] -
-
-
-
- @if (MalwareScanService.IsRunning) - { - - } + - @(MalwareScanService.Status) -
- +
+
+
+
+ @if (MalwareScanService.IsRunning) + { + + } + + @(MalwareScanService.Status) +
+
-
-
-
- - Results - -
-
- -
- - - - - - + + +
+
+
- +
@code { diff --git a/Moonlight/Shared/Views/Admin/Sys/News/Edit.razor b/Moonlight/Shared/Views/Admin/Sys/News/Edit.razor index e26a0e6d..73424fa8 100644 --- a/Moonlight/Shared/Views/Admin/Sys/News/Edit.razor +++ b/Moonlight/Shared/Views/Admin/Sys/News/Edit.razor @@ -10,52 +10,52 @@ @inject NavigationManager NavigationManager @inject NewsEntryRepository NewsEntryRepository - - - @if (Entry == null) - { -
-
-

- No entry found -

- - We were not able to find the news entry with this id - +@attribute [PermissionRequired(nameof(Permissions.NewsMessages))] + + + @if (Entry == null) + { +
+
+

+ No entry found +

+ + We were not able to find the news entry with this id + +
+
+ } + else + { +
+
+

+ +

+
+ @(Formatter.FormatDateOnly(Entry.Date))
- } - else - { -
-
-

- -

-
- @(Formatter.FormatDateOnly(Entry.Date)) -
-
-
- -
- +
+
- } - - + +
+ } + @code { [Parameter] public int Id { get; set; } - + private NewsEntry? Entry; private FileEditor FileEditor; @@ -63,16 +63,16 @@ private async Task Save() { Entry!.Markdown = await FileEditor.GetData(); - + NewsEntryRepository.Update(Entry); - + NavigationManager.NavigateTo("/admin/system/news"); } private Task Load(LazyLoader arg) { Entry = NewsEntryRepository.Get().FirstOrDefault(x => x.Id == Id); - + return Task.CompletedTask; } } \ No newline at end of file diff --git a/Moonlight/Shared/Views/Admin/Sys/News/Index.razor b/Moonlight/Shared/Views/Admin/Sys/News/Index.razor index 337210d8..afe40a7e 100644 --- a/Moonlight/Shared/Views/Admin/Sys/News/Index.razor +++ b/Moonlight/Shared/Views/Admin/Sys/News/Index.razor @@ -12,50 +12,50 @@ @inject SmartTranslateService SmartTranslateService @inject AlertService AlertService - - - -
- +@attribute [PermissionRequired(nameof(Permissions.NewsMessages))] + + + + - - @foreach (var entry in Entries) - { -
-
-

@entry.Title

-
- - - + + @foreach (var entry in Entries) + { +
+
+

@entry.Title

+
+ + + - - + + - @(Formatter.FormatDateOnly(entry.Date)) -
-
-
- @{ - var html = (MarkupString)Markdown.ToHtml(entry.Markdown); - } - - @(html) + @(Formatter.FormatDateOnly(entry.Date))
- } -
- +
+ @{ + var html = (MarkupString)Markdown.ToHtml(entry.Markdown); + } + + @(html) +
+
+ } + @code { diff --git a/Moonlight/Shared/Views/Admin/Sys/News/New.razor b/Moonlight/Shared/Views/Admin/Sys/News/New.razor index 64da8468..d6e28ca7 100644 --- a/Moonlight/Shared/Views/Admin/Sys/News/New.razor +++ b/Moonlight/Shared/Views/Admin/Sys/News/New.razor @@ -9,28 +9,28 @@ @inject NavigationManager NavigationManager @inject NewsEntryRepository NewsEntryRepository - -
-
-

- -

-
- @(Formatter.FormatDateOnly(Model.Date)) -
-
-
- -
-