diff --git a/Moonlight/Shared/Views/Admin/Domains/Shared.razor b/Moonlight/Shared/Views/Admin/Domains/Shared.razor deleted file mode 100644 index 95b270c..0000000 --- a/Moonlight/Shared/Views/Admin/Domains/Shared.razor +++ /dev/null @@ -1,126 +0,0 @@ -@page "/admin/domains/shared" -@using Moonlight.App.Repositories.Domains -@using Moonlight.App.Services -@using CloudFlare.Client.Api.Zones -@using Moonlight.App.Database.Entities -@using Moonlight.App.Services.Interop - -@inject SharedDomainRepository SharedDomainRepository -@inject SmartTranslateService SmartTranslateService -@inject DomainService DomainService -@inject AlertService AlertService -@inject ToastService ToastService - - - - - - - - Domain - - - @if (Zones.Any()) - { - foreach (var zone in Zones) - { - @(zone.Name) - } - } - else - { - - No domains available - - } - - - - - - - @foreach (var sharedDomain in SharedDomains) - { - - - - - - - - @(sharedDomain.Name) - - - @(sharedDomain.Id) - - - - - - - - - } - - - -@code -{ - private string DomainId = ""; - private Zone[] Zones; - private SharedDomain[] SharedDomains; - - private LazyLoader LazyLoader; - - private async Task Load(LazyLoader lazyLoader) - { - Zones = await DomainService.GetAvailableDomains(); - - SharedDomains = SharedDomainRepository.Get().ToArray(); - } - - private async Task Add() - { - if(string.IsNullOrEmpty(DomainId)) - return; - - var domain = Zones.First(x => x.Id == DomainId); - - var sd = new SharedDomain() - { - CloudflareId = domain.Id, - Name = domain.Name - }; - - SharedDomainRepository.Add(sd); - await ToastService.Success(SmartTranslateService.Translate("Shared domain successfully added")); - - await LazyLoader.Reload(); - } - - private async Task Delete(SharedDomain sharedDomain) - { - try - { - SharedDomainRepository.Delete(sharedDomain); - await ToastService.Success(SmartTranslateService.Translate("Shared domain successfully deleted")); - - await LazyLoader.Reload(); - } - catch (Exception e) - { - //TODO: Add check if any domains are left - - await AlertService.Error( - SmartTranslateService.Translate("Error"), - SmartTranslateService.Translate("Something went wrong. Are any domains associated with this shared domain still there?") - ); - } - } -} \ No newline at end of file diff --git a/Moonlight/Shared/Views/Admin/Domains/Shared/Index.razor b/Moonlight/Shared/Views/Admin/Domains/Shared/Index.razor new file mode 100644 index 0000000..86a1d1c --- /dev/null +++ b/Moonlight/Shared/Views/Admin/Domains/Shared/Index.razor @@ -0,0 +1,83 @@ +@page "/admin/domains/shared" +@using Moonlight.App.Repositories.Domains +@using Moonlight.App.Services +@using CloudFlare.Client.Api.Zones +@using Moonlight.App.Database.Entities +@using Moonlight.App.Services.Interop +@using BlazorTable + +@inject SharedDomainRepository SharedDomainRepository +@inject SmartTranslateService SmartTranslateService +@inject DomainService DomainService +@inject AlertService AlertService +@inject ToastService ToastService + + + + + + + + Shared domains + + + + + + Add shared domain + + + + + + + + + + + + + + + + + + + +@code +{ + private string DomainId = ""; + private Zone[] Zones; + private SharedDomain[] SharedDomains; + + private LazyLoader LazyLoader; + + private async Task Load(LazyLoader lazyLoader) + { + Zones = await DomainService.GetAvailableDomains(); + + SharedDomains = SharedDomainRepository.Get().ToArray(); + } + + private async Task Delete(SharedDomain sharedDomain) + { + try + { + SharedDomainRepository.Delete(sharedDomain); + await ToastService.Success(SmartTranslateService.Translate("Shared domain successfully deleted")); + + await LazyLoader.Reload(); + } + catch (Exception e) + { + //TODO: Add check if any domains are left + + await AlertService.Error( + SmartTranslateService.Translate("Error"), + SmartTranslateService.Translate("Something went wrong. Are any domains associated with this shared domain still there?") + ); + } + } +} \ No newline at end of file diff --git a/Moonlight/Shared/Views/Admin/Domains/Shared/New.razor b/Moonlight/Shared/Views/Admin/Domains/Shared/New.razor new file mode 100644 index 0000000..6d48f93 --- /dev/null +++ b/Moonlight/Shared/Views/Admin/Domains/Shared/New.razor @@ -0,0 +1,83 @@ +@page "/admin/domains/shared/new" + +@using Moonlight.App.Services +@using Moonlight.App.Services.Interop +@using Moonlight.App.Repositories.Domains +@using CloudFlare.Client.Api.Zones +@using Moonlight.App.Database.Entities + +@inject SharedDomainRepository SharedDomainRepository +@inject SmartTranslateService SmartTranslateService +@inject DomainService DomainService +@inject ToastService ToastService +@inject NavigationManager NavigationManager + + + + + + + + Domain + + + @if (Zones.Any()) + { + foreach (var zone in Zones) + { + @(zone.Name) + } + } + else + { + + No domains available + + } + + + + + + + + + + + +@code { + private string DomainId = ""; + private Zone[] Zones; + private SharedDomain[] SharedDomains; + + private LazyLoader LazyLoader; + + private async Task Load(LazyLoader lazyLoader) + { + Zones = await DomainService.GetAvailableDomains(); + + SharedDomains = SharedDomainRepository.Get().ToArray(); + } + + private async Task Add() + { + if(string.IsNullOrEmpty(DomainId)) + return; + + var domain = Zones.First(x => x.Id == DomainId); + + var sd = new SharedDomain() + { + CloudflareId = domain.Id, + Name = domain.Name + }; + + SharedDomainRepository.Add(sd); + await ToastService.Success(SmartTranslateService.Translate("Shared domain successfully added")); + + NavigationManager.NavigateTo("/admin/domains/shared"); + } +} \ No newline at end of file