Browse Source

Merge branch 'main' into NewsPage

Daniel Balk 2 years ago
parent
commit
17fd6aa267

+ 3 - 1
Moonlight/App/Helpers/SmartTranslateHelper.cs

@@ -21,7 +21,9 @@ public class SmartTranslateHelper
                 foreach (var line in lines)
                 {
                     var parts = line.Split(";");
-                    content.Add(parts[0], parts[1]);
+                    
+                    if(!content.ContainsKey(parts[0]))
+                        content.Add(parts[0], parts[1]);
                 }
                 
                 Languages.Add(langKey, content);

+ 1 - 4
Moonlight/Shared/Components/ErrorBoundaries/GlobalErrorBoundary.razor

@@ -52,10 +52,7 @@ else
     {
         receivedExceptions.Add(exception);
         
-        var user = await IdentityService.Get();
-        var id = user == null ? -1 : user.Id;
-
-        Logger.Error($"[{id}] An unhanded exception occured:");
+        Logger.Error($"An unhanded exception occured:");
         Logger.Error(exception);
 
         await base.OnErrorAsync(exception);

+ 18 - 11
Moonlight/Shared/Views/Admin/Servers/Manager.razor

@@ -100,23 +100,30 @@
         {
             await lazyLoader.SetText(node.Name);
 
-            var containerStats = await NodeService.GetContainerStats(node);
-
-            foreach (var container in containerStats.Containers)
+            try
             {
-                if (Guid.TryParse(container.Name, out Guid uuid))
-                {
-                    var server = ServerRepository
-                        .Get()
-                        .Include(x => x.Owner)
-                        .FirstOrDefault(x => x.Uuid == uuid);
+                var containerStats = await NodeService.GetContainerStats(node);
 
-                    if (server != null)
+                foreach (var container in containerStats.Containers)
+                {
+                    if (Guid.TryParse(container.Name, out Guid uuid))
                     {
-                        Containers.Add(server, container);
+                        var server = ServerRepository
+                            .Get()
+                            .Include(x => x.Owner)
+                            .FirstOrDefault(x => x.Uuid == uuid);
+
+                        if (server != null)
+                        {
+                            Containers.Add(server, container);
+                        }
                     }
                 }
             }
+            catch (Exception)
+            {
+                // ignored
+            }
         }
     }
 

+ 42 - 22
Moonlight/Shared/Views/Domains/Index.razor

@@ -3,49 +3,69 @@
 @using Moonlight.App.Repositories.Domains
 @using Moonlight.App.Database.Entities
 @using Microsoft.EntityFrameworkCore
-@using BlazorTable
-@using Moonlight.App.Services
-@using domain = Moonlight.App.Database.Entities.Domain
 
 @inject DomainRepository DomainRepository
-@inject DomainService DomainService
-@inject SmartTranslateService SmartTranslateService
 
 <LazyLoader Load="Load">
-    @foreach (var domain in domains)
+    @if (Domains.Any())
     {
-        <div class="row px-5 mb-5">
-            <div class="card card-body">
-                <div class="row">
-                    <div class="col">
-                        <div class="d-flex align-items-center">
-                            <div class="symbol symbol-50px me-3">
-                                <i class="bx bx-md bx-purchase-tag"></i>
-                            </div>
-                            <div class="d-flex justify-content-start flex-column">
-                                <a href="/domain/@domain.Id" class="text-gray-800 text-hover-primary mb-1 fs-5">@domain.Name.@domain.SharedDomain.Name</a>
+        foreach (var domain in Domains)
+        {
+            <div class="row px-5 mb-5">
+                <a href="/domain/@(domain.Id)" class="card card-body">
+                    <div class="row">
+                        <div class="col">
+                            <div class="d-flex align-items-center">
+                                <div class="symbol symbol-50px me-3">
+                                    <i class="bx bx-md bx-purchase-tag"></i>
+                                </div>
+                                <div class="d-flex justify-content-start flex-column">
+                                    <span class="text-gray-800 text-hover-primary mb-1 fs-5">
+                                        @(domain.Name)
+                                    </span>
+                                    <span class="text-gray-400 fw-semibold d-block fs-6">
+                                        <span class="text-gray-700">@(domain.SharedDomain.Name)</span>
+                                    </span>
+                                </div>
                             </div>
                         </div>
                     </div>
-                </div>
+                </a>
+            </div>
+        }
+    }
+    else
+    {
+        <div class="alert bg-info d-flex flex-column flex-sm-row w-100 p-5">
+            <div class="d-flex flex-column pe-0 pe-sm-10">
+                <h4 class="fw-semibold">
+                    <TL>You have no domains</TL>
+                </h4>
+                <span>
+                    <TL>We were not able to find any domains associated with your account</TL>
+                </span>
             </div>
         </div>
     }
 </LazyLoader>
 
 @code {
+
     [CascadingParameter]
     public User? User { get; set; }
-    
-    private domain[] domains { get; set; }
-    
-    public async Task Load(LazyLoader loader)
+
+    private Domain[] Domains { get; set; }
+
+    private Task Load(LazyLoader loader)
     {
-        domains = DomainRepository
+        Domains = DomainRepository
             .Get()
             .Include(x => x.SharedDomain)
             .Include(x => x.Owner)
             .Where(x => x.Owner == User)
             .ToArray();
+
+        return Task.CompletedTask;
     }
+
 }

+ 11 - 4
Moonlight/Shared/Views/Servers/Index.razor

@@ -73,8 +73,15 @@
     }
     else
     {
-        <div class="alert alert-info">
-            No servers found
+        <div class="alert bg-info d-flex flex-column flex-sm-row w-100 p-5">
+            <div class="d-flex flex-column pe-0 pe-sm-10">
+                <h4 class="fw-semibold">
+                    <TL>You have no servers</TL>
+                </h4>
+                <span>
+                    <TL>We were not able to find any servers associated with your account</TL>
+                </span>
+            </div>
         </div>
     }
 </LazyLoader>
@@ -84,8 +91,8 @@
     [CascadingParameter]
     public User User { get; set; }
     
-    private App.Database.Entities.Server[] AllServers;
-    private readonly Dictionary<App.Database.Entities.Server, string> StatusCache = new();
+    private Server[] AllServers;
+    private readonly Dictionary<Server, string> StatusCache = new();
 
     private Task Load(LazyLoader arg)
     {

+ 69 - 1
Moonlight/Shared/Views/Websites/Index.razor

@@ -1 +1,69 @@
-@page "/websites"
+@page "/websites"
+@using Moonlight.App.Database.Entities
+@using Moonlight.App.Repositories
+@using Microsoft.EntityFrameworkCore
+
+@inject WebsiteRepository WebsiteRepository
+
+<LazyLoader Load="Load">
+    @if (Websites.Any())
+    {
+        foreach (var website in Websites)
+        {
+            <div class="row px-5 mb-5">
+                <a class="card card-body" href="/website/@(website.Id)">
+                    <div class="row">
+                        <div class="col">
+                            <div class="d-flex align-items-center">
+                                <div class="symbol symbol-50px me-3">
+                                    <i class="bx bx-md bx-globe"></i>
+                                </div>
+                                <div class="d-flex justify-content-start flex-column">
+                                    <span class="text-gray-800 text-hover-primary mb-1 fs-5">
+                                        @(website.BaseDomain)
+                                    </span>
+                                    <span class="text-gray-400 fw-semibold d-block fs-6">
+                                        <span class="text-gray-700">@(website.PleskServer.Name)</span>
+                                    </span>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </a>
+            </div>
+        }
+    }
+    else
+    {
+        <div class="alert bg-info d-flex flex-column flex-sm-row w-100 p-5">
+            <div class="d-flex flex-column pe-0 pe-sm-10">
+                <h4 class="fw-semibold">
+                    <TL>You have no websites</TL>
+                </h4>
+                <span>
+                    <TL>We were not able to find any websites associated with your account</TL>
+                </span>
+            </div>
+        </div>
+    }
+</LazyLoader>
+
+@code
+{
+    [CascadingParameter]
+    public User User { get; set; }
+    
+    private Website[] Websites;
+
+    private Task Load(LazyLoader lazyLoader)
+    {
+        Websites = WebsiteRepository
+            .Get()
+            .Include(x => x.Owner)
+            .Include(x => x.PleskServer)
+            .Where(x => x.Owner.Id == User.Id)
+            .ToArray();
+        
+        return Task.CompletedTask;
+    }
+}

+ 6 - 0
Moonlight/resources/lang/de_de.lang

@@ -557,3 +557,9 @@ Saving...;Saving...
 Deleting...;Deleting...
 Delete post;Delete post
 Do you really want to delete the post ";Do you really want to delete the post "
+You have no domains;You have no domains
+We were not able to find any domains associated with your account;We were not able to find any domains associated with your account
+You have no websites;You have no websites
+We were not able to find any websites associated with your account;We were not able to find any websites associated with your account
+Guest;Guest
+You need a domain;You need a domain