Skip to content

Commit

Permalink
Additional form parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Koloskov committed Sep 6, 2024
1 parent 8f7dffb commit e68b49f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latestmajor</LangVersion>
<PackageId>Core</PackageId>
<Version>2.0.7</Version>
<Version>2.0.8</Version>
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
</PropertyGroup>

Expand Down
52 changes: 38 additions & 14 deletions Elib2EbookWeb/Components/BookForm.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,45 @@
<MudToggleItem Value="@("txt")" UnselectedIcon="@Icons.Material.Filled.CheckBoxOutlineBlank" SelectedIcon="@Icons.Material.Filled.CheckBox" />
</MudToggleGroup>
</MudStack>

<MudTextField @bind-Value="@_options.Login" Label="Логин" Variant="Variant.Outlined"/>
<MudTextField @bind-Value="@_options.Password" Label="Пароль" Variant="Variant.Outlined" InputType="@_passwordInput" Adornment="Adornment.End" AdornmentIcon="@_passwordInputIcon" OnAdornmentClick="ShowPassword" AdornmentAriaLabel="Показать пароль" />

<MudTextField T="string" Label="Логин" Variant="Variant.Outlined" @bind-Value="@_options.Login"/>
<MudTextField @bind-Value="@_options.Password" Label="Пароль" Variant="Variant.Outlined" InputType="@_passwordInput" Adornment="Adornment.End" AdornmentIcon="@_passwordInputIcon" OnAdornmentClick="ShowPassword" AdornmentAriaLabel="Показать пароль" />
<div class="d-flex gap-x-4">
<MudTextField T="int?" Label="Глава от" Variant="Variant.Outlined" @bind-Value="@_options.Start"/>
<MudTextField T="int?" Label="Глава до" Variant="Variant.Outlined" @bind-Value="@_options.End"/>
</div>
</MudForm>
</MudPaper>

<MudPaper Class="pa-4 mt-4">
<MudButton Variant="Variant.Filled" Color="Color.Info" DropShadow="false" OnClick="OnCLick" Disabled="_onGenerate" FullWidth="true" Size="Size.Large">
@if (_onGenerate) {
@if (!string.IsNullOrWhiteSpace(_log)) {
<MudText Class="text-truncate">@_log</MudText>
} else {
<MudProgressCircular Class="ms-n1" Size="Size.Small" Indeterminate="true"/>
@if (_onGenerate) {
<MudButton Variant="Variant.Filled" Color="Color.Info" DropShadow="false" Disabled="true" FullWidth="true" Size="Size.Large">
@if (_onGenerate) {
@if (!string.IsNullOrWhiteSpace(_log)) {
<MudText Class="text-truncate">@_log</MudText>
} else {
<MudProgressCircular Class="ms-n1" Size="Size.Small" Indeterminate="true"/>
}
}
} else {
<MudText>Сгенерировать</MudText>
}
</MudButton>
</MudButton>
} else {
<MudButtonGroup Color="Color.Info" Variant="Variant.Filled" Size="Size.Large" FullWidth="true">
<MudButton OnClick="WithImages" Disabled="_onGenerate" FullWidth="true">
<MudText>Скачать</MudText>
</MudButton>
<MudMenu Icon="@Icons.Material.Filled.ArrowDropDown" Style="align-self: auto;">
<MudMenuItem OnClick="NoImages">Скачать без картинок</MudMenuItem>
</MudMenu>
</MudButtonGroup>
}
</MudPaper>

@code {
private readonly Options _options = new();
private ActionLogger? _logger;
private bool _onGenerate;
private string _log;
private string? _log;

private bool _isShow;
private InputType _passwordInput = InputType.Password;
Expand All @@ -60,7 +74,17 @@
}
}

private async Task OnCLick() {
private async Task WithImages() {
_options.NoImage = false;
await Download();
}

private async Task NoImages() {
_options.NoImage = true;
await Download();
}

private async Task Download() {
if (_options.Url == null || !_options.Url.Any() || string.IsNullOrWhiteSpace(_options.Url.First())) {
Snackbar.Add("Укажите ссылку на книгу", Severity.Error);
return;
Expand Down
4 changes: 2 additions & 2 deletions Elib2EbookWeb/Misc/SbWriter.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace Elib2EbookWeb.Misc;

public class ActionLogger : ILogger {
private readonly Action<string> _action;
private readonly Action<string?> _action;

public ActionLogger(Action<string> action) {
public ActionLogger(Action<string?> action) {
_action = action;
}

Expand Down

0 comments on commit e68b49f

Please sign in to comment.