feat: init new config dialog
This commit is contained in:
@@ -4,9 +4,15 @@
|
|||||||
|
|
||||||
<MudDialog>
|
<MudDialog>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
|
@if (IsNew)
|
||||||
|
{
|
||||||
|
<MudTextField @bind-Value="FileName" Label="File name" Variant="Variant.Outlined"
|
||||||
|
Style="margin-bottom: 16px;"
|
||||||
|
ShrinkLabel="true"></MudTextField>
|
||||||
|
}
|
||||||
|
<MudText Typo="Typo.caption" Style="padding-left: 8px; padding-bottom: 4px;">File content</MudText>
|
||||||
<StandaloneCodeEditor ConstructionOptions="@EditorConstructionOptions"
|
<StandaloneCodeEditor ConstructionOptions="@EditorConstructionOptions"
|
||||||
CssClass="caddy-file-editor"></StandaloneCodeEditor>
|
CssClass="caddy-file-editor"></StandaloneCodeEditor>
|
||||||
<MudDivider/>
|
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<MudButton OnClick="Cancel">Cancel</MudButton>
|
<MudButton OnClick="Cancel">Cancel</MudButton>
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ public partial class CaddyfileEditor : ComponentBase
|
|||||||
[CascadingParameter]
|
[CascadingParameter]
|
||||||
private IMudDialogInstance MudDialog { get; set; } = null!;
|
private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if the Caddy configuration file is new
|
||||||
|
/// </summary>
|
||||||
|
private bool IsNew => string.IsNullOrWhiteSpace(FileName);
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
|
||||||
@@ -27,8 +32,9 @@ public partial class CaddyfileEditor : ComponentBase
|
|||||||
return new StandaloneEditorConstructionOptions
|
return new StandaloneEditorConstructionOptions
|
||||||
{
|
{
|
||||||
AutomaticLayout = true,
|
AutomaticLayout = true,
|
||||||
Language = "plaintext",
|
Language = "graphql",
|
||||||
Value = _caddyConfigurationContent,
|
Value = _caddyConfigurationContent,
|
||||||
|
Theme = "vs-dark",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,14 @@
|
|||||||
@attribute [StreamRendering]
|
@attribute [StreamRendering]
|
||||||
@using CaddyManager.Contracts.Caddy
|
@using CaddyManager.Contracts.Caddy
|
||||||
@inject ICaddyService CaddyService
|
@inject ICaddyService CaddyService
|
||||||
|
@inject IDialogService DialogService
|
||||||
|
|
||||||
<PageTitle>Reverse proxy configurations</PageTitle>
|
<PageTitle>Reverse proxy configurations</PageTitle>
|
||||||
|
|
||||||
<MudContainer Class="d-flex flex-row flex-grow-1 gap-4">
|
<MudContainer Class="d-flex flex-row flex-grow-1 gap-4">
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Add">New...</MudButton>
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Add"
|
||||||
|
OnClick="NewReverseProxy">New...
|
||||||
|
</MudButton>
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete"
|
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete"
|
||||||
Disabled="@(_selectedCaddyConfigurations.Count <= 0)">Delete
|
Disabled="@(_selectedCaddyConfigurations.Count <= 0)">Delete
|
||||||
</MudButton>
|
</MudButton>
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using MudBlazor;
|
||||||
|
|
||||||
namespace CaddyManager.Components.Pages.ReverseProxies;
|
namespace CaddyManager.Components.Pages.ReverseProxies;
|
||||||
|
|
||||||
public partial class ReverseProxiesPage
|
public partial class ReverseProxiesPage : ComponentBase
|
||||||
{
|
{
|
||||||
private List<string> _availableCaddyConfigurations = [];
|
private List<string> _availableCaddyConfigurations = [];
|
||||||
private IReadOnlyCollection<string> _selectedCaddyConfigurations = [];
|
private IReadOnlyCollection<string> _selectedCaddyConfigurations = [];
|
||||||
@@ -10,4 +13,21 @@ public partial class ReverseProxiesPage
|
|||||||
_availableCaddyConfigurations = CaddyService.GetExistingCaddyConfigurations();
|
_availableCaddyConfigurations = CaddyService.GetExistingCaddyConfigurations();
|
||||||
return base.OnInitializedAsync();
|
return base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method to help open the dialog to create a new reverse proxy configuration
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private Task NewReverseProxy()
|
||||||
|
{
|
||||||
|
return DialogService.ShowAsync<CaddyfileEditor.CaddyfileEditor>("New configuration",
|
||||||
|
options: new DialogOptions
|
||||||
|
{
|
||||||
|
FullWidth = true,
|
||||||
|
MaxWidth = MaxWidth.Medium,
|
||||||
|
}, parameters: new DialogParameters
|
||||||
|
{
|
||||||
|
{ "FileName", string.Empty }
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user