Skip to content

Commit

Permalink
Improve option
Browse files Browse the repository at this point in the history
  • Loading branch information
franklupo committed Jun 20, 2023
1 parent 2b3aacb commit 5096df2
Show file tree
Hide file tree
Showing 31 changed files with 363 additions and 347 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@using MudBlazor

<MudSelect Margin="Margin.Dense" Dense="true" T="string" Class="" Strict="true"
Variant="Variant.Outlined" Label="Sample">
Variant="Variant.Outlined">
<MudSelectItem Value="@("Mario")" >
<div class="d-flex gap-2 align-center">
<MudIconButton Icon="@Icons.Material.Filled.Dns" Size="Size.Small"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<PackageReference Include="Hangfire.Storage.SQLite" Version="0.3.4" />

<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.7" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@foreach (var item in Options.Value.Domains.OrderBy(a => a.Name))
{
<MudSelectItem Value="@item.Domain">
<div class="d-flex gap-1">
<div class="d-flex gap-1 align-center">
<MudIcon Icon="@Icons.Material.Filled.Domain" />
@item.Name
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="7.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="7.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="7.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="7.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="7.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="7.0.7" />
<PackageReference Include="Novell.Directory.Ldap.NETStandard" Version="3.6.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Fast.Components.FluentUI" Version="2.3.5" />
<PackageReference Include="Microsoft.Fast.Components.FluentUI" Version="2.3.6" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="6.5.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="6.5.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.7" />
<PackageReference Include="MudBlazor" Version="6.4.1" />
<PackageReference Include="BlazorDownloadFile" Version="2.4.0.2" />
<PackageReference Include="MudBlazor.Extensions" Version="1.7.46" />
<PackageReference Include="MudBlazor.Extensions" Version="1.7.49" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
<PackageReference Include="Toolbelt.Blazor.LoadingBar" Version="13.2.0" />
</ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/Corsinvest.AppHero.Core.MudBlazorUI/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Corsinvest.AppHero.Core.BaseUI.Extensions;
using Corsinvest.AppHero.Core.MudBlazorUI.Services;
using Corsinvest.AppHero.Core.MudBlazorUI.Shared.Components.DataGrid;
using Corsinvest.AppHero.Core.MudBlazorUI.Style;
using Corsinvest.AppHero.Core.Notification;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
Expand Down Expand Up @@ -40,6 +41,7 @@ public override void ConfigureServices(IServiceCollection services, IConfigurati
services.AddScoped<IUIMessageBox, UIMessageBox>();
services.AddMudExtensions();
services.AddMudServicesWithExtensions();
services.AddScoped<LayoutService>();
services.AddTransient(typeof(IDataGridManager<>), typeof(DataGridManager<>));
services.AddTransient(typeof(IDataGridManagerRepository<>), typeof(DataGridManagerRepository<>));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@foreach (var item in Loggins)
{
<MudSelectItem Value="@item">
<div class="d-flex gap-1">
<div class="d-flex gap-1 align-center">
<MudIcon Icon="@MudBlazorHelper.ToMBIcon(item.Icon)" />
@item.Description
</div>
Expand Down
53 changes: 18 additions & 35 deletions src/Corsinvest.AppHero.Core.MudBlazorUI/Pages/Options/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<MudTabs Elevation="1" ApplyEffectsToContainer Border>
<Header>
<AHPermissionButton Permission="Corsinvest.AppHero.Core.Options.Module.Permissions.Save" Disabled="@(!IsValid)"
Variant="Variant.Filled" OnClick="@OnSaveAsync" Style="margin:10px" Size="Size.Small" />
Variant="Variant.Filled" OnClick="@OnSaveAsync" Style="margin:10px" Size="Size.Small" Loading="@InSaving" />
</Header>
<ChildContent>
<MudTabPanel Text="@L["Service"]" Icon="@Icons.Material.Filled.Settings">
Expand Down Expand Up @@ -40,41 +40,24 @@
{
private RenderFragment RenderOptionsModules(IEnumerable<ModuleBase> modules) => __builder =>
{
@if (ExpansionPanels)
{
<MudExpansionPanels>
@foreach (var module in modules)
{
OptionsComponents.TryAdd(module.Class, null!);
<MudExpansionPanels>
@foreach (var module in modules)
{
OptionsComponents.TryAdd(module.Class, null!);

<MudExpansionPanel>
<TitleContent>
<div class="d-flex gap-4">
<MudIcon Icon="@module.ToMBIcon()" />
<MudText>@L[@module.Description]</MudText>
</div>
</TitleContent>
<MudExpansionPanel>
<TitleContent>
<div class="d-flex gap-4">
<MudIcon Icon="@module.ToMBIcon()" />
<MudText>@L[@module.Description]</MudText>
</div>
</TitleContent>

<ChildContent>
<DynamicComponent @ref="@OptionsComponents[module.Class]" Type="@module.Options!.Render" />
</ChildContent>
</MudExpansionPanel>
}
</MudExpansionPanels>
}
else
{
<MudTabs>
@foreach (var module in modules)
{
OptionsComponents.TryAdd(module.Class, null!);

<MudTabPanel IsPreRendered Text="@L[module.Description]" Icon="@module.ToMBIcon()">
<br />
<DynamicComponent @ref="@OptionsComponents[module.Class]" Type="module.Options!.Render" />
</MudTabPanel>
}
</MudTabs>
}
<ChildContent>
<DynamicComponent @ref="@OptionsComponents[module.Class]" Type="@module.Options!.Render" />
</ChildContent>
</MudExpansionPanel>
}
</MudExpansionPanels>
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ namespace Corsinvest.AppHero.Core.MudBlazorUI.Pages.Options;

public partial class Index
{
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
[Inject] private IModularityService ModularityService { get; set; } = default!;
[Inject] private IPermissionService PermissionService { get; set; } = default!;
[Inject] private IServiceScopeFactory ServiceScopeFactory { get; set; } = default!;

private bool ExpansionPanels { get; set; } = true;
private bool IsValid { get; set; }
private string[] Errors { get; set; } = default!;
private Dictionary<string, DynamicComponent> OptionsComponents { get; } = new();
private IEnumerable<ModuleBase> Modules { get; set; } = default!;
private bool InSaving { get; set; }

protected override async Task OnInitializedAsync()
{
Expand All @@ -41,6 +40,8 @@ protected override async Task OnInitializedAsync()

private async Task OnSaveAsync()
{
InSaving = true;

await ((ISavable)this).SaveAsync();

//components
Expand All @@ -54,7 +55,10 @@ private async Task OnSaveAsync()
using var scope = ServiceScopeFactory.CreateScope();
await ModularityService.RefreshOptionsAsync(scope);

NavigationManager.NavigateTo(NavigationManager.Uri, true);
//refresh force
//NavigationManager.NavigateTo(NavigationManager.Uri, true);

InSaving = false;

UINotifier.Show(L["Options saved."], UINotifierSeverity.Success);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*@
@inherits AHComponentBase

<AHPermission Permission="Permission" Loading="@Loading">
<AHPermission Permission="Permission">
<ChildContent>
<MudButton StartIcon="@Permission.ToMBIcon()" OnClick="@OnClick" Size="@Size" Color="Permission.Color.ToMBColor()"
Variant="@Variant" Class="@Class" Style="@Style">
<MudLoadingButton StartIcon="@Permission.ToMBIcon()" OnClick="@OnClick" Size="@Size" Color="Permission.Color.ToMBColor()"
Variant="@Variant" Class="@Class" Style="@Style" Loading="@Loading">
@L[Permission.Description]
</MudButton>
</MudLoadingButton>
</ChildContent>
</AHPermission>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
*@
@inherits AHComponentBase

<AHPermission Permission="Permission" Loading="@Loading">
<AHPermission Permission="Permission">
<ChildContent>
<MudIconButton Icon="@Permission.ToMBIcon()" Color="Permission.Color.ToMBColor()"
OnClick="@OnClick" Size="@Size" Title="@L[Permission.Description]"
Disabled="@Disabled" Variant="@Variant" Class="@Class" Style="@Style" />
<MudLoadingButton Icon="@Permission.ToMBIcon()" Color="Permission.Color.ToMBColor()" ButtonVariant="ButtonVariant.IconButton"
OnClick="@OnClick" Size="@Size" Title="@L[Permission.Description]"
Class="@Class" Disabled="@Disabled" Variant="@Variant" Loading="@Loading" Style="@Style" />
</ChildContent>
</AHPermission>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,59 +162,6 @@ public async Task ExportToExcel()
? "data"
: Title;
await _blazorDownloadFileService.DownloadFile($"{fileName}.xlsx", stream, "application/vnd.ms-excel");


//using var workbook = new XLWorkbook();
//var worksheet = workbook.Worksheets.Add();

//var fields = new List<string>();
//var col = 'A';
//var row = 1;

//for (int i = 0; i < DataGrid!.RenderedColumns.Count; i++)
//{
// var column = DataGrid!.RenderedColumns[i];
// if (!string.IsNullOrWhiteSpace(column.PropertyName))
// {
// worksheet.Cell($"{col}1").Value = column.Title;
// fields.Add(column.PropertyName);
// col++;
// }
//}

//col--;
//worksheet.Range($"A1:{col}1").SetAutoFilter();
//row++;
//foreach (var item in (await DataGrid!.ServerData(_state)).Items)
//{
// col = 'A';
// foreach (var field in fields)
// {
// var pi = item!.GetType().GetPropertyFromPath(field);
// if (pi != null)
// {
// var value = (pi.GetValue(item) + "").ToString();
// worksheet.Cell($"{col}{row}").Value = value;
// col++;
// }
// }
// row++;
//}

//var header = worksheet.Range($"A1:{--col}1");
//header.Style.Fill.SetBackgroundColor(XLColor.LightBlue);
//header.Style.Font.Bold = true;
//header.SetAutoFilter();

//worksheet.Columns().AdjustToContents();
//workbook.SaveAs(stream);
//stream.Seek(0, SeekOrigin.Begin);

//var fileName = string.IsNullOrEmpty(Title)
// ? "data"
// : Title;

//await _blazorDownloadFileService.DownloadFile($"{fileName}.xlsx", stream, "application/vnd.ms-excel");
}

public async Task<GridData<T>> LoadServerData(GridState<T> state)
Expand Down
Loading

0 comments on commit 5096df2

Please sign in to comment.