-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#115 chore: added first setup page and enabled settings edition
- Loading branch information
1 parent
2b8b72d
commit 9d3ef58
Showing
14 changed files
with
176 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
@page "/setup" | ||
@layout SetupLayout | ||
@using Linguard.Core.Utils | ||
@using Linguard.Core.Managers | ||
@using Linguard.Core.Configuration | ||
@using Linguard.Log | ||
@using Linguard.Web.Services | ||
|
||
<PageTitle>@($"{AssemblyInfo.Product} | {Title}")</PageTitle> | ||
|
||
<RadzenHeading Text="@Title" class="mb-3 text-center"/> | ||
|
||
<RadzenCard class="mb-3 mx-auto col-xxl-6"> | ||
<RadzenTemplateForm Data="@_configuration" Submit="@((IConfiguration args) => { Save(args); })"> | ||
<RadzenCard> | ||
<h2>Web</h2> | ||
<WebSettings Configuration="@_configuration.Web"/> | ||
</RadzenCard> | ||
<RadzenCard class="mt-2"> | ||
<h2>Wireguard</h2> | ||
<WireguardSettings Configuration="@_configuration.Wireguard"/> | ||
</RadzenCard> | ||
<RadzenCard class="mt-2"> | ||
<h2>Logging</h2> | ||
<LoggingSettings Configuration="@_configuration.Logging"/> | ||
</RadzenCard> | ||
<div class="row mt-3 d-flex"> | ||
<div class="col-md-12 align-items-end"> | ||
<RadzenButton ButtonType="ButtonType.Submit" Icon="save" Text="Save" class="me-2" | ||
ButtonStyle="ButtonStyle.Primary"/> | ||
</div> | ||
</div> | ||
</RadzenTemplateForm> | ||
</RadzenCard> | ||
|
||
@inject IConfigurationManager _configurationManager | ||
@inject NotificationService _notificationService | ||
@inject IWebService _webService | ||
@inject ILinguardLogger _logger | ||
@inject NavigationManager _navigationManager | ||
|
||
@code { | ||
const string Title = "Setup"; | ||
IConfiguration _configuration; | ||
|
||
protected override void OnInitialized() { | ||
_configuration = (IConfiguration) _configurationManager.Configuration.Clone(); | ||
} | ||
|
||
private void Save(IConfiguration configuration) { | ||
try { | ||
_logger.LogDebug("Saving configuration..."); | ||
_configurationManager.Configuration = (IConfiguration)configuration.Clone(); | ||
_configurationManager.Save(); | ||
_logger.LogInformation("Setup completed. Redirecting..."); | ||
_navigationManager.NavigateTo("/"); | ||
} | ||
catch (Exception e) { | ||
_logger.LogError(e, "Setup failed: unable to save configuration."); | ||
_notificationService.Notify(new NotificationMessage { | ||
Severity = NotificationSeverity.Error, | ||
Summary = "Failed to save configuration", | ||
Detail = e.Message | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
@using Linguard.Core.Managers | ||
@inherits LayoutComponentBase | ||
|
||
<RadzenDialog /> | ||
<RadzenNotification /> | ||
<RadzenTooltip /> | ||
<RadzenContextMenu /> | ||
|
||
<RadzenLayout> | ||
<ChildContent> | ||
<RadzenBody @ref="_body"> | ||
<ChildContent> | ||
<RadzenContentContainer Name="main"> | ||
<ErrorBoundary @ref="errorBoundary"> | ||
<ChildContent> | ||
@Body | ||
</ChildContent> | ||
<ErrorContent> | ||
<UnhandledError Exception="context"/> | ||
</ErrorContent> | ||
</ErrorBoundary> | ||
</RadzenContentContainer> | ||
</ChildContent> | ||
</RadzenBody> | ||
<RadzenFooter> | ||
<ChildContent> | ||
<Footer></Footer> | ||
</ChildContent> | ||
</RadzenFooter> | ||
</ChildContent> | ||
</RadzenLayout> | ||
|
||
@inject IConfigurationManager _configurationManager | ||
@inject NavigationManager _navigationManager | ||
|
||
@code { | ||
private RadzenBody _body; | ||
private ErrorBoundary? errorBoundary; | ||
|
||
protected override void OnParametersSet() { | ||
errorBoundary?.Recover(); | ||
} | ||
|
||
protected override void OnInitialized() { | ||
base.OnInitialized(); | ||
if (!_configurationManager.IsSetupNeeded) { | ||
_navigationManager.NavigateTo("/"); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters