diff --git a/Sitko.Blockly.sln b/Sitko.Blockly.sln index 3bd6a09..cf0ce80 100644 --- a/Sitko.Blockly.sln +++ b/Sitko.Blockly.sln @@ -54,6 +54,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitko.Blockly.HtmlParser.Te EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitko.Blockly.MudBlazor", "src\Sitko.Blockly.MudBlazor\Sitko.Blockly.MudBlazor.csproj", "{4B682521-01D4-4A3E-9F15-16DBA1FB91C9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitko.Blockly.Demo.Client", "apps\Sitko.Blockly.Demo.Client\Sitko.Blockly.Demo.Client.csproj", "{4C374AF7-0748-4915-988D-0338996B6AF9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitko.Blockly.Data", "apps\Sitko.Blockly.Data\Sitko.Blockly.Data.csproj", "{88B081A7-F838-4E90-BB2E-581BAFAECEA6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -175,6 +179,30 @@ Global {4B682521-01D4-4A3E-9F15-16DBA1FB91C9}.Release|x64.Build.0 = Release|Any CPU {4B682521-01D4-4A3E-9F15-16DBA1FB91C9}.Release|x86.ActiveCfg = Release|Any CPU {4B682521-01D4-4A3E-9F15-16DBA1FB91C9}.Release|x86.Build.0 = Release|Any CPU + {4C374AF7-0748-4915-988D-0338996B6AF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4C374AF7-0748-4915-988D-0338996B6AF9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4C374AF7-0748-4915-988D-0338996B6AF9}.Debug|x64.ActiveCfg = Debug|Any CPU + {4C374AF7-0748-4915-988D-0338996B6AF9}.Debug|x64.Build.0 = Debug|Any CPU + {4C374AF7-0748-4915-988D-0338996B6AF9}.Debug|x86.ActiveCfg = Debug|Any CPU + {4C374AF7-0748-4915-988D-0338996B6AF9}.Debug|x86.Build.0 = Debug|Any CPU + {4C374AF7-0748-4915-988D-0338996B6AF9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4C374AF7-0748-4915-988D-0338996B6AF9}.Release|Any CPU.Build.0 = Release|Any CPU + {4C374AF7-0748-4915-988D-0338996B6AF9}.Release|x64.ActiveCfg = Release|Any CPU + {4C374AF7-0748-4915-988D-0338996B6AF9}.Release|x64.Build.0 = Release|Any CPU + {4C374AF7-0748-4915-988D-0338996B6AF9}.Release|x86.ActiveCfg = Release|Any CPU + {4C374AF7-0748-4915-988D-0338996B6AF9}.Release|x86.Build.0 = Release|Any CPU + {88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Debug|x64.ActiveCfg = Debug|Any CPU + {88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Debug|x64.Build.0 = Debug|Any CPU + {88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Debug|x86.ActiveCfg = Debug|Any CPU + {88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Debug|x86.Build.0 = Debug|Any CPU + {88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Release|Any CPU.Build.0 = Release|Any CPU + {88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Release|x64.ActiveCfg = Release|Any CPU + {88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Release|x64.Build.0 = Release|Any CPU + {88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Release|x86.ActiveCfg = Release|Any CPU + {88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {0367FAD9-C3FD-4E07-9CBE-103A17666A1D} = {DA312F56-FDB4-4853-A7A1-A8B2527399FC} @@ -187,5 +215,7 @@ Global {33DD2E49-9A55-4648-8D97-81FB4FDFB4CC} = {DA312F56-FDB4-4853-A7A1-A8B2527399FC} {C46F1161-7FFC-47DC-9140-463A02FD6DEC} = {BE2C5E4A-BFBD-4645-AE0A-8B57A9EC1CB2} {4B682521-01D4-4A3E-9F15-16DBA1FB91C9} = {DA312F56-FDB4-4853-A7A1-A8B2527399FC} + {4C374AF7-0748-4915-988D-0338996B6AF9} = {32D6C989-DF2C-4C06-BD48-C322E72888B9} + {88B081A7-F838-4E90-BB2E-581BAFAECEA6} = {32D6C989-DF2C-4C06-BD48-C322E72888B9} EndGlobalSection EndGlobal diff --git a/apps/Sitko.Blockly.Data/Entities/Post.cs b/apps/Sitko.Blockly.Data/Entities/Post.cs new file mode 100644 index 0000000..49158ce --- /dev/null +++ b/apps/Sitko.Blockly.Data/Entities/Post.cs @@ -0,0 +1,19 @@ +using System.ComponentModel.DataAnnotations; +using Sitko.Core.Repository; + +namespace Sitko.Blockly.Data.Entities; + +public abstract record BaseEntityRecord : EntityRecord +{ + public override Guid Id { get; set; } = Guid.NewGuid(); + public DateTimeOffset DateAdded { get; set; } = DateTimeOffset.UtcNow; + public DateTimeOffset DateUpdated { get; set; } = DateTimeOffset.UtcNow; + public object GetId() => Id; +} + +public record Post : BaseEntityRecord +{ + public string Title { get; set; } = ""; + public List Blocks { get; set; } = new(); + public List SecondaryBlocks { get; set; } = new(); +} diff --git a/apps/Sitko.Blockly.Data/Sitko.Blockly.Data.csproj b/apps/Sitko.Blockly.Data/Sitko.Blockly.Data.csproj new file mode 100644 index 0000000..6a9cb76 --- /dev/null +++ b/apps/Sitko.Blockly.Data/Sitko.Blockly.Data.csproj @@ -0,0 +1,16 @@ + + + + net8.0 + enable + enable + + + + + + + + + + diff --git a/apps/Sitko.Blockly.Data/TestMetadata.cs b/apps/Sitko.Blockly.Data/TestMetadata.cs new file mode 100644 index 0000000..11dab9c --- /dev/null +++ b/apps/Sitko.Blockly.Data/TestMetadata.cs @@ -0,0 +1,3 @@ +namespace Sitko.Blockly.Data; + +public record TestMetadata(Guid Id, string Type); diff --git a/apps/Sitko.Blockly.Demo.Client/Data/Repositories/PostRemoteRepository.cs b/apps/Sitko.Blockly.Demo.Client/Data/Repositories/PostRemoteRepository.cs new file mode 100644 index 0000000..2cd79ca --- /dev/null +++ b/apps/Sitko.Blockly.Demo.Client/Data/Repositories/PostRemoteRepository.cs @@ -0,0 +1,11 @@ +using Sitko.Blockly.Data.Entities; +using Sitko.Core.Repository.Remote; + +namespace Sitko.Blockly.Demo.Client.Data.Repositories; + +public class PostRemoteRepository : BaseRemoteRepository +{ + public PostRemoteRepository(RemoteRepositoryContext repositoryContext) : base(repositoryContext) + { + } +} diff --git a/apps/Sitko.Blockly.Demo.Client/Layout/MainAppDrawerBar.razor b/apps/Sitko.Blockly.Demo.Client/Layout/MainAppDrawerBar.razor new file mode 100644 index 0000000..8563754 --- /dev/null +++ b/apps/Sitko.Blockly.Demo.Client/Layout/MainAppDrawerBar.razor @@ -0,0 +1,34 @@ +@inject IJSRuntime JSRuntime + + + My Application + + + + + +@code { + private bool _isDrawerOpen = true; + private bool _shouldHandleDrawerToggled = false; + private IJSObjectReference? _jsModule; + + void ToggleDrawer() + { + _isDrawerOpen = !_isDrawerOpen; + _shouldHandleDrawerToggled = true; + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + _jsModule = await JSRuntime.InvokeAsync("import", "./Layout/MainAppDrawerBar.razor.js"); + } + if (_shouldHandleDrawerToggled) + { + await _jsModule!.InvokeVoidAsync("HandleDrawerToggled", _isDrawerOpen); + _shouldHandleDrawerToggled = false; + } + } + +} diff --git a/apps/Sitko.Blockly.Demo.Client/Layout/MainAppDrawerBar.razor.js b/apps/Sitko.Blockly.Demo.Client/Layout/MainAppDrawerBar.razor.js new file mode 100644 index 0000000..f73c29b --- /dev/null +++ b/apps/Sitko.Blockly.Demo.Client/Layout/MainAppDrawerBar.razor.js @@ -0,0 +1,11 @@ +//MainAppDrawerBar.razor.js +export function HandleDrawerToggled(isOpen) { + const layoutElement = document.querySelector(".mud-layout"); + if (isOpen) { + layoutElement.classList.replace("mud-drawer-close-responsive-md-left", "mud-drawer-open-responsive-md-left"); + console.log("Open"); + } else { + layoutElement.classList.replace("mud-drawer-open-responsive-md-left", "mud-drawer-close-responsive-md-left"); + console.log("Close"); + } +} diff --git a/apps/Sitko.Blockly.Demo/Shared/NavMenu.razor b/apps/Sitko.Blockly.Demo.Client/Layout/NavMenu.razor similarity index 100% rename from apps/Sitko.Blockly.Demo/Shared/NavMenu.razor rename to apps/Sitko.Blockly.Demo.Client/Layout/NavMenu.razor diff --git a/apps/Sitko.Blockly.Demo.Client/Layout/PageLayout.razor b/apps/Sitko.Blockly.Demo.Client/Layout/PageLayout.razor new file mode 100644 index 0000000..46bc98e --- /dev/null +++ b/apps/Sitko.Blockly.Demo.Client/Layout/PageLayout.razor @@ -0,0 +1,58 @@ +@using Sitko.Core.App +@PageTitle + + + @if (Extra is not null || Breadcrumbs.Count > 0) + { + + + @if (Extra is not null) + { + + @Extra + } + + } + + @if (!string.IsNullOrEmpty(Title) || !string.IsNullOrEmpty(Description)) + { + + @if (!string.IsNullOrEmpty(Title)) + { + @Title + } + @if (!string.IsNullOrEmpty(Description)) + { + @Description + } + + } + + @ChildContent + + + +@code{ + + [Parameter] public RenderFragment? Extra { get; set; } + + [Parameter] public List Breadcrumbs { get; set; } = new(); + + [Parameter] public string Title { get; set; } = ""; + + private string PageTitle + { + get + { + var prefix = $" {PageTitleSeparator} {ApplicationContext.Name}"; + return $"{Title}{prefix}"; + } + } + + [Parameter] public string Description { get; set; } = ""; + [Parameter] public string PageTitleSeparator { get; set; } = "/"; + [Inject] protected IApplicationContext ApplicationContext { get; set; } = null!; + + [EditorRequired] [Parameter] public RenderFragment ChildContent { get; set; } = null!; + +} diff --git a/apps/Sitko.Blockly.Demo.Client/Pages/Add.razor b/apps/Sitko.Blockly.Demo.Client/Pages/Add.razor new file mode 100644 index 0000000..0ebf1dc --- /dev/null +++ b/apps/Sitko.Blockly.Demo.Client/Pages/Add.razor @@ -0,0 +1,6 @@ +@page "/Posts/Add" +@inherits BaseComponent +@rendermode InteractiveAuto + + + diff --git a/apps/Sitko.Blockly.Demo/Pages/Edit.razor b/apps/Sitko.Blockly.Demo.Client/Pages/Edit.razor similarity index 76% rename from apps/Sitko.Blockly.Demo/Pages/Edit.razor rename to apps/Sitko.Blockly.Demo.Client/Pages/Edit.razor index 81a2007..fd8e488 100644 --- a/apps/Sitko.Blockly.Demo/Pages/Edit.razor +++ b/apps/Sitko.Blockly.Demo.Client/Pages/Edit.razor @@ -1,11 +1,12 @@ @page "/Posts/{PostId:guid}/Edit" +@rendermode InteractiveAuto @inherits BaseComponent @{ var title = $"Edit post {PostId}"; } - + - + @code { diff --git a/apps/Sitko.Blockly.Demo.Client/Pages/Index.razor b/apps/Sitko.Blockly.Demo.Client/Pages/Index.razor new file mode 100644 index 0000000..dc61496 --- /dev/null +++ b/apps/Sitko.Blockly.Demo.Client/Pages/Index.razor @@ -0,0 +1,42 @@ +@page "/" +@using Sitko.Blockly.Display +@using Sitko.Core.Storage +@using Sitko.Blockly.Data.Entities +@using Sitko.Core.Repository +@inherits BaseComponent + + + Add + + + @foreach (var post in Posts) + { + + + @post.Title + + + Edit + + + + + + + } + + + +@code{ + + protected override async Task InitializeAsync() + { + await base.InitializeAsync(); + var posts = await GetRequiredService>().GetAllAsync(); + Posts = posts.items; + } + + private Post[] Posts { get; set; } = Array.Empty(); + +} diff --git a/apps/Sitko.Blockly.Demo/Pages/PostForm.cs b/apps/Sitko.Blockly.Demo.Client/Pages/PostForm.cs similarity index 54% rename from apps/Sitko.Blockly.Demo/Pages/PostForm.cs rename to apps/Sitko.Blockly.Demo.Client/Pages/PostForm.cs index ff535e2..214c305 100644 --- a/apps/Sitko.Blockly.Demo/Pages/PostForm.cs +++ b/apps/Sitko.Blockly.Demo.Client/Pages/PostForm.cs @@ -1,24 +1,15 @@ -using System; -using System.Collections.Generic; -using FluentValidation; -using Sitko.Blockly.Demo.Data.Entities; +using FluentValidation; +using KellermanSoftware.CompareNetObjects; +using Sitko.Blockly.Blazor.Extensions; +using Sitko.Blockly.Data.Entities; using Sitko.Blockly.Validation; -using Sitko.Core.Blazor.Forms; using Sitko.Core.Blazor.MudBlazorComponents; +using Sitko.Core.Repository; -namespace Sitko.Blockly.Demo.Pages; - -using Blazor.Extensions; -using Data.Repositories; -using KellermanSoftware.CompareNetObjects; -using Microsoft.AspNetCore.Components; +namespace Sitko.Blockly.Demo.Client.Pages; -public class PostForm : BaseMudRepositoryForm +public class PostForm : BaseMudRepositoryForm> { - [Parameter] public RenderFragment ChildContent { get; set; } = null!; - - protected override RenderFragment ChildContentFragment => ChildContent(this); - protected override void ConfigureComparer(ComparisonConfig comparisonConfig) { base.ConfigureComparer(comparisonConfig); diff --git a/apps/Sitko.Blockly.Demo/Pages/PostFormComponent.razor b/apps/Sitko.Blockly.Demo.Client/Pages/PostFormComponent.razor similarity index 81% rename from apps/Sitko.Blockly.Demo/Pages/PostFormComponent.razor rename to apps/Sitko.Blockly.Demo.Client/Pages/PostFormComponent.razor index 0065210..1fa05c3 100644 --- a/apps/Sitko.Blockly.Demo/Pages/PostFormComponent.razor +++ b/apps/Sitko.Blockly.Demo.Client/Pages/PostFormComponent.razor @@ -1,24 +1,26 @@ -@using Sitko.Blockly.Demo.Data.Entities -@using Sitko.Blockly.Blocks +@using Sitko.Blockly.Blocks @using Sitko.Blockly.Blazor @using Sitko.Blockly.Blazor.Forms @using Sitko.Core.Storage @using Sitko.Blazor.CKEditor.Bundle +@using Sitko.Blockly.Data +@using Sitko.Blockly.Data.Entities @inherits BaseComponent - + - + - Save + Save + Reset + @code { - [Parameter] - public Guid PostId { get; set; } + [Parameter] public Guid PostId { get; set; } private Task GoToPost(Post post) { @@ -58,7 +60,7 @@ ckEditorConfig.Language = "ru"; blocksOptions = new MudBlazorBlocklyFormOptions { - Storage = GetService>(), + Storage = GetService(), ImagesOptions = imagesStorageOptions, FilesOptions = filesStorageOptions, CKEditorConfig = ckEditorConfig }; @@ -67,7 +69,7 @@ secondaryBlocksOptions = new MudBlazorBlocklyFormOptions { - MaxBlocks = 5, Storage = GetService>(), + MaxBlocks = 5, Storage = GetService(), ImagesOptions = imagesStorageOptions, FilesOptions = filesStorageOptions }; diff --git a/apps/Sitko.Blockly.Demo/Pages/Show.razor b/apps/Sitko.Blockly.Demo.Client/Pages/Show.razor similarity index 79% rename from apps/Sitko.Blockly.Demo/Pages/Show.razor rename to apps/Sitko.Blockly.Demo.Client/Pages/Show.razor index a215844..3e084bf 100644 --- a/apps/Sitko.Blockly.Demo/Pages/Show.razor +++ b/apps/Sitko.Blockly.Demo.Client/Pages/Show.razor @@ -2,11 +2,12 @@ @using Sitko.Core.Storage @using Sitko.Blockly.Display @inherits BaseComponent - +@Post.Title + Edit - + - + diff --git a/apps/Sitko.Blockly.Demo/Pages/Show.razor.cs b/apps/Sitko.Blockly.Demo.Client/Pages/Show.razor.cs similarity index 55% rename from apps/Sitko.Blockly.Demo/Pages/Show.razor.cs rename to apps/Sitko.Blockly.Demo.Client/Pages/Show.razor.cs index f858b9a..24f92c2 100644 --- a/apps/Sitko.Blockly.Demo/Pages/Show.razor.cs +++ b/apps/Sitko.Blockly.Demo.Client/Pages/Show.razor.cs @@ -1,10 +1,8 @@ -using System; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Components; -using Sitko.Blockly.Demo.Data.Entities; -using Sitko.Blockly.Demo.Data.Repositories; +using Microsoft.AspNetCore.Components; +using Sitko.Blockly.Data.Entities; +using Sitko.Core.Repository; -namespace Sitko.Blockly.Demo.Pages; +namespace Sitko.Blockly.Demo.Client.Pages; public partial class Show { @@ -13,7 +11,7 @@ public partial class Show protected override async Task InitializeAsync() { await base.InitializeAsync(); - var post = await GetRequiredService().GetByIdAsync(PostId); + var post = await GetRequiredService>().GetByIdAsync(PostId); if (post is null) { NavigationManager.NavigateTo("/404"); diff --git a/apps/Sitko.Blockly.Demo.Client/Program.cs b/apps/Sitko.Blockly.Demo.Client/Program.cs new file mode 100644 index 0000000..80c78d8 --- /dev/null +++ b/apps/Sitko.Blockly.Demo.Client/Program.cs @@ -0,0 +1,38 @@ +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; +using Sitko.Blockly.Demo.Client; +using Sitko.Blockly.Demo.Client.Data.Repositories; +using Sitko.Blockly.MudBlazorComponents; +using Sitko.Core.App.Localization; +using Sitko.Core.Blazor.MudBlazorComponents; +using Sitko.Core.Blazor.Wasm; +using Sitko.Core.Repository.Remote; +using Sitko.Core.Repository.Remote.Wasm; +using Sitko.Core.Storage.Remote; + +var builder = WebAssemblyHostBuilder.CreateDefault(args); + +builder + .AddSitkoCoreBlazorWasm() + .AddMudBlazor() + .AddMudBlazorBlockly(options => + { + options.AddBlocks(); + }) + .AddJsonLocalization(options => options.AddDefaultResource()) + .AddRemoteStorage((context, options) => + { + context.Configuration.Bind("Storage:Remote:DigitClubRemoteStorageOptions"); + }) + .AddRemoteRepositories(options => + { + options.AddRepository(); + }) + .AddWasmHttpRepositoryTransport((context, options) => + { + context.Configuration.Bind(context.IsDevelopment() ? "HttpRoutes:Development" : "HttpRoutes:Production"); + }); + + +builder.ConfigureLocalization("ru-RU"); + +await builder.RunApplicationAsync(); diff --git a/apps/Sitko.Blockly.Demo.Client/RemoteStorageOptions.cs b/apps/Sitko.Blockly.Demo.Client/RemoteStorageOptions.cs new file mode 100644 index 0000000..15902cb --- /dev/null +++ b/apps/Sitko.Blockly.Demo.Client/RemoteStorageOptions.cs @@ -0,0 +1,10 @@ +using Sitko.Core.Storage; +using Sitko.Core.Storage.Remote; + +namespace Sitko.Blockly.Demo.Client; + +public class RemoteStorageOptions : StorageOptions, IRemoteStorageOptions +{ + public Uri RemoteUrl { get; set; } + public Func? HttpClientFactory { get; set; } +} diff --git a/apps/Sitko.Blockly.Demo.Client/Sitko.Blockly.Demo.Client.csproj b/apps/Sitko.Blockly.Demo.Client/Sitko.Blockly.Demo.Client.csproj new file mode 100644 index 0000000..bfa248f --- /dev/null +++ b/apps/Sitko.Blockly.Demo.Client/Sitko.Blockly.Demo.Client.csproj @@ -0,0 +1,27 @@ + + + + net8.0 + enable + enable + true + Default + true + + + + + + + + + + + + + + + + + + diff --git a/apps/Sitko.Blockly.Demo/_Imports.razor b/apps/Sitko.Blockly.Demo.Client/_Imports.razor similarity index 73% rename from apps/Sitko.Blockly.Demo/_Imports.razor rename to apps/Sitko.Blockly.Demo.Client/_Imports.razor index 4d9ba3d..feae714 100644 --- a/apps/Sitko.Blockly.Demo/_Imports.razor +++ b/apps/Sitko.Blockly.Demo.Client/_Imports.razor @@ -1,16 +1,16 @@ @using System.Net.Http -@using Microsoft.AspNetCore.Authorization -@using Microsoft.AspNetCore.Components.Authorization +@using System.Net.Http.Json @using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode @using Microsoft.AspNetCore.Components.Web.Virtualization @using Microsoft.JSInterop -@using Sitko.Blockly.Demo.Shared -@using Sitko.Blockly.Demo +@using Sitko.Blockly.Demo.Client +@using Sitko.Blockly.Demo.Client.Layout +@using MudBlazor @using Sitko.Blockly.MudBlazorComponents.Forms @using Sitko.Blockly.MudBlazorComponents.Display @using Sitko.Core.Blazor.Components @using Sitko.Core.Blazor.MudBlazorComponents -@using MudBlazor diff --git a/apps/Sitko.Blockly.Demo.Client/wwwroot/appsettings.Development.json b/apps/Sitko.Blockly.Demo.Client/wwwroot/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/apps/Sitko.Blockly.Demo.Client/wwwroot/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/apps/Sitko.Blockly.Demo.Client/wwwroot/appsettings.json b/apps/Sitko.Blockly.Demo.Client/wwwroot/appsettings.json new file mode 100644 index 0000000..1f0cc33 --- /dev/null +++ b/apps/Sitko.Blockly.Demo.Client/wwwroot/appsettings.json @@ -0,0 +1,26 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "Storage": { + "Remote": { + "RemoteStorageOptions": { + "PublicUri": "https://localhost:7196/Static/", + "Name": "Remote", + "RemoteUrl": "https://localhost:7196/Upload/" + } + } + }, + "Repositories": { + "Remote": { + "Transports": { + "Http": { + "RepositoryControllerApiRoute": "https://localhost:7196/api" + } + } + } + } +} diff --git a/apps/Sitko.Blockly.Demo/App.razor b/apps/Sitko.Blockly.Demo/App.razor deleted file mode 100644 index 1c360b7..0000000 --- a/apps/Sitko.Blockly.Demo/App.razor +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - -

Sorry, there's nothing at this address.

-
-
-
diff --git a/apps/Sitko.Blockly.Demo/BlocklyApplication.cs b/apps/Sitko.Blockly.Demo/BlocklyApplication.cs deleted file mode 100644 index 82efecb..0000000 --- a/apps/Sitko.Blockly.Demo/BlocklyApplication.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using Serilog.Events; -using Sitko.Blockly.Demo.Data; -using Sitko.Blockly.MudBlazorComponents; -using Sitko.Core.App.Localization; -using Sitko.Core.Blazor.MudBlazor.Server; -using Sitko.Core.Db.Postgres; -using Sitko.Core.Repository.EntityFrameworkCore; -using Sitko.Core.Storage; -using Sitko.Core.Storage.FileSystem; -using Sitko.Core.Storage.Metadata.Postgres; - -namespace Sitko.Blockly.Demo; - -public class BlocklyApplication : MudBlazorApplication -{ - public BlocklyApplication(string[] args) : base(args) - { - this.AddPostgresDatabase() - .AddEFRepositories() - .AddFileSystemStorage() - .AddPostgresStorageMetadata() - .AddJsonLocalization() - .AddMudBlazorBlockly(moduleOptions => - { - moduleOptions.AddBlocks(); - }); - ConfigureLogLevel("System.Net.Http.HttpClient.health-checks", LogEventLevel.Error) - .ConfigureLogLevel("Microsoft.AspNetCore", LogEventLevel.Warning) - .ConfigureLogLevel("Microsoft.EntityFrameworkCore", LogEventLevel.Warning); - } -} - -public class BlocklyStorageOptions : StorageOptions, IFileSystemStorageOptions -{ - public string StoragePath { get; set; } = ""; -} - -public record TestMetadata(Guid Id, string Type); diff --git a/apps/Sitko.Blockly.Demo/BlocklyStorageOptions.cs b/apps/Sitko.Blockly.Demo/BlocklyStorageOptions.cs new file mode 100644 index 0000000..6b210eb --- /dev/null +++ b/apps/Sitko.Blockly.Demo/BlocklyStorageOptions.cs @@ -0,0 +1,9 @@ +using Sitko.Core.Storage; +using Sitko.Core.Storage.FileSystem; + +namespace Sitko.Blockly.Demo; + +public class BlocklyStorageOptions : StorageOptions, IFileSystemStorageOptions +{ + public string StoragePath { get; set; } = ""; +} diff --git a/apps/Sitko.Blockly.Demo/Components/App.razor b/apps/Sitko.Blockly.Demo/Components/App.razor new file mode 100644 index 0000000..bd352c3 --- /dev/null +++ b/apps/Sitko.Blockly.Demo/Components/App.razor @@ -0,0 +1,26 @@ +@using Sitko.Core.App +@inject IApplicationContext applicationContext + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/Sitko.Blockly.Demo/Components/Layout/MainLayout.razor b/apps/Sitko.Blockly.Demo/Components/Layout/MainLayout.razor new file mode 100644 index 0000000..ac3e4b3 --- /dev/null +++ b/apps/Sitko.Blockly.Demo/Components/Layout/MainLayout.razor @@ -0,0 +1,8 @@ +@inherits LayoutComponentBase + + + + + + @Body + diff --git a/apps/Sitko.Blockly.Demo/Components/Routes.razor b/apps/Sitko.Blockly.Demo/Components/Routes.razor new file mode 100644 index 0000000..3771030 --- /dev/null +++ b/apps/Sitko.Blockly.Demo/Components/Routes.razor @@ -0,0 +1,6 @@ + + + + + + diff --git a/apps/Sitko.Blockly.Demo/Components/_Imports.razor b/apps/Sitko.Blockly.Demo/Components/_Imports.razor new file mode 100644 index 0000000..f7298aa --- /dev/null +++ b/apps/Sitko.Blockly.Demo/Components/_Imports.razor @@ -0,0 +1,17 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using Sitko.Blockly.Demo +@using Sitko.Blockly.Demo.Client +@using Sitko.Blockly.Demo.Client.Layout +@using Sitko.Blockly.Demo.Components +@using MudBlazor +@using Sitko.Blockly.MudBlazorComponents.Forms +@using Sitko.Blockly.MudBlazorComponents.Display +@using Sitko.Core.Blazor.Components +@using Sitko.Core.Blazor.MudBlazorComponents diff --git a/apps/Sitko.Blockly.Demo/Controllers/FileStorageController.cs b/apps/Sitko.Blockly.Demo/Controllers/FileStorageController.cs new file mode 100644 index 0000000..4a1c5c8 --- /dev/null +++ b/apps/Sitko.Blockly.Demo/Controllers/FileStorageController.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; +using Sitko.Blockly.Data; +using Sitko.Core.Storage; +using Sitko.Core.Storage.Remote.Server; + +namespace Sitko.Blockly.Demo.Controllers; + +[Route("/Upload")] +public class FileStorageController( + IStorage storage, + ILogger logger) + : BaseRemoteStorageController(storage, logger); diff --git a/apps/Sitko.Blockly.Demo/Controllers/PostsController.cs b/apps/Sitko.Blockly.Demo/Controllers/PostsController.cs new file mode 100644 index 0000000..6302101 --- /dev/null +++ b/apps/Sitko.Blockly.Demo/Controllers/PostsController.cs @@ -0,0 +1,11 @@ +using Microsoft.AspNetCore.Mvc; +using Sitko.Blockly.Data.Entities; +using Sitko.Core.Repository; +using Sitko.Core.Repository.Remote.Server; + +namespace Sitko.Blockly.Demo.Controllers; + +[Route("/api/Post")] +public class PostsController(IRepository repository, ILogger logger) + : BaseRemoteRepositoryController(repository, + logger); diff --git a/apps/Sitko.Blockly.Demo/Data/BlocklyContext.cs b/apps/Sitko.Blockly.Demo/Data/BlocklyContext.cs index acf0f81..37ab9f9 100644 --- a/apps/Sitko.Blockly.Demo/Data/BlocklyContext.cs +++ b/apps/Sitko.Blockly.Demo/Data/BlocklyContext.cs @@ -1,5 +1,5 @@ using Microsoft.EntityFrameworkCore; -using Sitko.Blockly.Demo.Data.Entities; +using Sitko.Blockly.Data.Entities; using Sitko.Blockly.EntityFrameworkCore; namespace Sitko.Blockly.Demo.Data; diff --git a/apps/Sitko.Blockly.Demo/Data/Entities/Post.cs b/apps/Sitko.Blockly.Demo/Data/Entities/Post.cs deleted file mode 100644 index ab36b14..0000000 --- a/apps/Sitko.Blockly.Demo/Data/Entities/Post.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using Sitko.Core.Repository; - -namespace Sitko.Blockly.Demo.Data.Entities; - -public abstract class BaseEntity : Entity -{ - public override Guid Id { get; set; } = Guid.NewGuid(); - - [Required] public DateTimeOffset DateAdded { get; set; } = DateTimeOffset.UtcNow; - [Required] public DateTimeOffset DateUpdated { get; set; } = DateTimeOffset.UtcNow; - - public object GetId() => Id; -} - -public class Post : BaseEntity -{ - public string Title { get; set; } = ""; - public List Blocks { get; set; } = new(); - public List SecondaryBlocks { get; set; } = new(); -} diff --git a/apps/Sitko.Blockly.Demo/Migrations/20210622053022_Init.Designer.cs b/apps/Sitko.Blockly.Demo/Data/Migrations/20210622053022_Init.Designer.cs similarity index 100% rename from apps/Sitko.Blockly.Demo/Migrations/20210622053022_Init.Designer.cs rename to apps/Sitko.Blockly.Demo/Data/Migrations/20210622053022_Init.Designer.cs diff --git a/apps/Sitko.Blockly.Demo/Migrations/20210622053022_Init.cs b/apps/Sitko.Blockly.Demo/Data/Migrations/20210622053022_Init.cs similarity index 100% rename from apps/Sitko.Blockly.Demo/Migrations/20210622053022_Init.cs rename to apps/Sitko.Blockly.Demo/Data/Migrations/20210622053022_Init.cs diff --git a/apps/Sitko.Blockly.Demo/Migrations/20210630100829_AddSecondaryBlocksToPost.Designer.cs b/apps/Sitko.Blockly.Demo/Data/Migrations/20210630100829_AddSecondaryBlocksToPost.Designer.cs similarity index 100% rename from apps/Sitko.Blockly.Demo/Migrations/20210630100829_AddSecondaryBlocksToPost.Designer.cs rename to apps/Sitko.Blockly.Demo/Data/Migrations/20210630100829_AddSecondaryBlocksToPost.Designer.cs diff --git a/apps/Sitko.Blockly.Demo/Migrations/20210630100829_AddSecondaryBlocksToPost.cs b/apps/Sitko.Blockly.Demo/Data/Migrations/20210630100829_AddSecondaryBlocksToPost.cs similarity index 100% rename from apps/Sitko.Blockly.Demo/Migrations/20210630100829_AddSecondaryBlocksToPost.cs rename to apps/Sitko.Blockly.Demo/Data/Migrations/20210630100829_AddSecondaryBlocksToPost.cs diff --git a/apps/Sitko.Blockly.Demo/Migrations/20210630123143_AddTitleToPost.Designer.cs b/apps/Sitko.Blockly.Demo/Data/Migrations/20210630123143_AddTitleToPost.Designer.cs similarity index 100% rename from apps/Sitko.Blockly.Demo/Migrations/20210630123143_AddTitleToPost.Designer.cs rename to apps/Sitko.Blockly.Demo/Data/Migrations/20210630123143_AddTitleToPost.Designer.cs diff --git a/apps/Sitko.Blockly.Demo/Migrations/20210630123143_AddTitleToPost.cs b/apps/Sitko.Blockly.Demo/Data/Migrations/20210630123143_AddTitleToPost.cs similarity index 100% rename from apps/Sitko.Blockly.Demo/Migrations/20210630123143_AddTitleToPost.cs rename to apps/Sitko.Blockly.Demo/Data/Migrations/20210630123143_AddTitleToPost.cs diff --git a/apps/Sitko.Blockly.Demo/Migrations/BlocklyContextModelSnapshot.cs b/apps/Sitko.Blockly.Demo/Data/Migrations/BlocklyContextModelSnapshot.cs similarity index 100% rename from apps/Sitko.Blockly.Demo/Migrations/BlocklyContextModelSnapshot.cs rename to apps/Sitko.Blockly.Demo/Data/Migrations/BlocklyContextModelSnapshot.cs diff --git a/apps/Sitko.Blockly.Demo/Data/Repositories/PostsRepository.cs b/apps/Sitko.Blockly.Demo/Data/Repositories/PostsRepository.cs index f89d26e..534eed4 100644 --- a/apps/Sitko.Blockly.Demo/Data/Repositories/PostsRepository.cs +++ b/apps/Sitko.Blockly.Demo/Data/Repositories/PostsRepository.cs @@ -1,5 +1,4 @@ -using System; -using Sitko.Blockly.Demo.Data.Entities; +using Sitko.Blockly.Data.Entities; using Sitko.Core.Repository.EntityFrameworkCore; namespace Sitko.Blockly.Demo.Data.Repositories; diff --git a/apps/Sitko.Blockly.Demo/Dockerfile b/apps/Sitko.Blockly.Demo/Dockerfile index 7c2a695..864d292 100644 --- a/apps/Sitko.Blockly.Demo/Dockerfile +++ b/apps/Sitko.Blockly.Demo/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/aspnet:6.0 +FROM mcr.microsoft.com/dotnet/aspnet:8.0 WORKDIR /app COPY . . diff --git a/apps/Sitko.Blockly.Demo/Pages/Add.razor b/apps/Sitko.Blockly.Demo/Pages/Add.razor deleted file mode 100644 index 7aca9ef..0000000 --- a/apps/Sitko.Blockly.Demo/Pages/Add.razor +++ /dev/null @@ -1,5 +0,0 @@ -@page "/Posts/Add" -@inherits BaseComponent - - - diff --git a/apps/Sitko.Blockly.Demo/Pages/Index.razor b/apps/Sitko.Blockly.Demo/Pages/Index.razor deleted file mode 100644 index 64146d9..0000000 --- a/apps/Sitko.Blockly.Demo/Pages/Index.razor +++ /dev/null @@ -1,42 +0,0 @@ -@page "/" -@using Sitko.Blockly.Demo.Data.Entities -@using Sitko.Blockly.Demo.Data.Repositories -@using Sitko.Blockly.Display -@using Sitko.Core.Storage -@inherits BaseComponent - - - Add - - - @foreach (var post in Posts) - { - - - @post.Title - - - Edit - - - - - - - } - - - -@code{ - - protected override async Task InitializeAsync() - { - await base.InitializeAsync(); - var posts = await GetRequiredService().GetAllAsync(); - Posts = posts.items; - } - - private Post[] Posts { get; set; } = Array.Empty(); - -} diff --git a/apps/Sitko.Blockly.Demo/Pages/_Host.cshtml b/apps/Sitko.Blockly.Demo/Pages/_Host.cshtml deleted file mode 100644 index 99e00c1..0000000 --- a/apps/Sitko.Blockly.Demo/Pages/_Host.cshtml +++ /dev/null @@ -1,40 +0,0 @@ -@page "/" -@using Microsoft.Extensions.Options -@using Sitko.Blockly.MudBlazorComponents -@using Sitko.Core.App -@namespace Sitko.Blockly.Demo.Pages -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers -@inject IOptionsMonitor options -@inject IApplicationContext applicationContext -@{ - Layout = null; -} - - - - - - - Sitko.Blockly.Demo - - - - - - - - -
- - An error has occurred. This application may no longer respond until reloaded. - - - An unhandled exception has occurred. See browser dev tools for details. - - Reload - 🗙 -
- - - - diff --git a/apps/Sitko.Blockly.Demo/Program.cs b/apps/Sitko.Blockly.Demo/Program.cs index 832c925..bedcffc 100644 --- a/apps/Sitko.Blockly.Demo/Program.cs +++ b/apps/Sitko.Blockly.Demo/Program.cs @@ -1,14 +1,47 @@ -using System.Threading.Tasks; -using Microsoft.Extensions.Hosting; +using Sitko.Blockly.Demo; +using Sitko.Blockly.Demo.Components; +using Sitko.Blockly.Demo.Data; +using Sitko.Blockly.MudBlazorComponents; +using Sitko.Core.App.Localization; +using Sitko.Core.App.Web; +using Sitko.Core.Blazor.MudBlazor.Server; +using Sitko.Core.Blazor.Server; +using Sitko.Core.Db.Postgres; +using Sitko.Core.Repository.EntityFrameworkCore; +using Sitko.Core.Storage.FileSystem; +using Sitko.Core.Storage.Metadata.Postgres; +using Index = Sitko.Blockly.Demo.Client.Pages.Index; -namespace Sitko.Blockly.Demo; +var builder = WebApplication.CreateBuilder(args); +builder + .AddSitkoCoreBlazorServer() + .AddMudBlazorServer() + .AddMudBlazorBlockly(options => + { + options.AddBlocks(); + }) + .AddInteractiveWebAssembly() + .AddJsonLocalization() + .AddPostgresDatabase() + .AddEFRepositories(); -public class Program -{ - public static async Task Main(string[] args) => await CreateApplication(args).RunAsync().ConfigureAwait(false); +builder + .AddSitkoCoreBlazorServer() + .AddFileSystemStorage() + .AddPostgresStorageMetadata(); + +var app = builder.Build(); - public static IHostBuilder CreateHostBuilder(string[] args) => - CreateApplication(args).GetHostBuilder(); +// Configure the HTTP request pipeline. +app.ConfigureLocalization("ru-RU"); - private static BlocklyApplication CreateApplication(string[] args) => new(args); +if (app.Environment.IsDevelopment()) +{ + app.UseWebAssemblyDebugging(); } + +app.MapSitkoCoreBlazor() + .AddInteractiveWebAssemblyRenderMode() + .AddAdditionalAssemblies(typeof(Index).Assembly); + +app.Run(); diff --git a/apps/Sitko.Blockly.Demo/Properties/launchSettings.json b/apps/Sitko.Blockly.Demo/Properties/launchSettings.json index d81dbbc..f9cd5fd 100644 --- a/apps/Sitko.Blockly.Demo/Properties/launchSettings.json +++ b/apps/Sitko.Blockly.Demo/Properties/launchSettings.json @@ -1,13 +1,14 @@ -{ - "profiles": { - "Sitko.Blockly.Demo": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": false, - "applicationUrl": "https://localhost:5001;http://localhost:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } +{ + "profiles": { + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "https://localhost:7196;http://localhost:5132", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } } + } } diff --git a/apps/Sitko.Blockly.Demo/Shared/MainLayout.razor b/apps/Sitko.Blockly.Demo/Shared/MainLayout.razor deleted file mode 100644 index 9e5e8fa..0000000 --- a/apps/Sitko.Blockly.Demo/Shared/MainLayout.razor +++ /dev/null @@ -1,9 +0,0 @@ -@inherits LayoutComponentBase - - - - - - @Body - - diff --git a/apps/Sitko.Blockly.Demo/Sitko.Blockly.Demo.csproj b/apps/Sitko.Blockly.Demo/Sitko.Blockly.Demo.csproj index be59dd8..c1c9f32 100644 --- a/apps/Sitko.Blockly.Demo/Sitko.Blockly.Demo.csproj +++ b/apps/Sitko.Blockly.Demo/Sitko.Blockly.Demo.csproj @@ -1,26 +1,33 @@ - net6.0 - blockly + net8.0 enable + enable - - + + - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + + + + + + + diff --git a/apps/Sitko.Blockly.Demo/Startup.cs b/apps/Sitko.Blockly.Demo/Startup.cs deleted file mode 100644 index 3f20c9c..0000000 --- a/apps/Sitko.Blockly.Demo/Startup.cs +++ /dev/null @@ -1,33 +0,0 @@ -using FluentValidation; -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using MudBlazor.Services; -using Sitko.Core.Blazor.MudBlazor.Server; - -namespace Sitko.Blockly.Demo; - -public class Startup : MudBlazorStartup -{ - public Startup(IConfiguration configuration, IHostEnvironment environment) : base(configuration, environment) - { - } - - protected override void ConfigureAppServices(IServiceCollection services) - { - base.ConfigureAppServices(services); - services.AddValidatorsFromAssemblyContaining(); - services.AddMudServices(); - services.AddServerSideBlazor().AddCircuitOptions(options => { options.DetailedErrors = true; }); - - } - - protected override void ConfigureAfterRoutingMiddleware(IApplicationBuilder app) - { - base.ConfigureAfterRoutingMiddleware(app); - app.UseRequestLocalization(new RequestLocalizationOptions() - .AddSupportedCultures("en-US", "ru") - .AddSupportedUICultures("en-US", "ru")); - } -} diff --git a/apps/Sitko.Blockly.Demo/appsettings.Development.json b/apps/Sitko.Blockly.Demo/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/apps/Sitko.Blockly.Demo/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/apps/Sitko.Blockly.Demo/appsettings.json b/apps/Sitko.Blockly.Demo/appsettings.json index 9243db0..482bd92 100644 --- a/apps/Sitko.Blockly.Demo/appsettings.json +++ b/apps/Sitko.Blockly.Demo/appsettings.json @@ -33,15 +33,16 @@ "Db": { "Postgres": { "BlocklyContext": { - "Database": "Blockly" + "Database": "Blockly", + "Port": 25432 } } }, "Storage": { "FileSystem": { "BlocklyStorageOptions": { - "StoragePath": "wwwroot/static", - "PublicUri": "https://localhost:5001/static/", + "StoragePath": "wwwroot/Static", + "PublicUri": "https://localhost:7196/Static/", "Name": "Blockly" } }, @@ -49,7 +50,8 @@ "Postgres": { "BlocklyStorageOptions": { "Database": "Blockly", - "schema": "storage" + "schema": "storage", + "Port": 25432 } } } diff --git a/apps/Sitko.Blockly.Demo/wwwroot/css/site.css b/apps/Sitko.Blockly.Demo/wwwroot/css/site.css deleted file mode 100644 index f29788b..0000000 --- a/apps/Sitko.Blockly.Demo/wwwroot/css/site.css +++ /dev/null @@ -1,22 +0,0 @@ -/* blazor */ -#blazor-error-ui { - bottom: 0; - left: 0; - padding: 0.6rem 1.25rem 0.7rem 1.25rem; - position: fixed; - width: 100%; - z-index: 1000; - background: #e91e63; - text-decoration: underline; - text-align: center; - display: none; -} - -#blazor-error-ui a.reload { - position: absolute; - left: 0; - top: 0; - height: 100%; - width: 100%; - font-size: 0; -} diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 7ca825a..3f1624e 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,6 +1,6 @@ - net6.0 + net8.0 latest enable true @@ -22,7 +22,7 @@ true - + diff --git a/src/Sitko.Blockly.AntDesign/ApplicationExtensions.cs b/src/Sitko.Blockly.AntDesign/ApplicationExtensions.cs index 5c041bc..b57eaf9 100644 --- a/src/Sitko.Blockly.AntDesign/ApplicationExtensions.cs +++ b/src/Sitko.Blockly.AntDesign/ApplicationExtensions.cs @@ -1,17 +1,45 @@ using JetBrains.Annotations; +using Microsoft.Extensions.Hosting; using Sitko.Core.App; +using Sitko.Core.Blazor; namespace Sitko.Blockly.AntDesignComponents; [PublicAPI] public static class ApplicationExtensions { - public static Application AddAntDesignBlockly(this Application application, + public static IHostApplicationBuilder AddAntDesignBlockly(this IHostApplicationBuilder hostApplicationBuilder, + Action configure, string? optionsKey = null) + { + hostApplicationBuilder.GetSitkoCore() + .AddAntDesignBlockly(configure, optionsKey); + return hostApplicationBuilder; + } + + public static IHostApplicationBuilder AddAntDesignBlockly(this IHostApplicationBuilder hostApplicationBuilder, + Action? configure = null, string? optionsKey = null) + { + hostApplicationBuilder.GetSitkoCore() + .AddAntDesignBlockly(configure, optionsKey); + return hostApplicationBuilder; + } + + public static ISitkoCoreBlazorApplicationBuilder AddAntDesignBlockly( + this ISitkoCoreBlazorApplicationBuilder applicationBuilder, Action configure, - string? configKey = null) => - application.AddModule(configure, configKey); + string? configKey = null) + { + applicationBuilder + .AddModule(configure, configKey); + return applicationBuilder; + } - public static Application AddAntDesignBlockly(this Application application, - Action? configure = null, string? configKey = null) => - application.AddModule(configure, configKey); + public static ISitkoCoreBlazorApplicationBuilder AddAntDesignBlockly( + this ISitkoCoreBlazorApplicationBuilder applicationBuilder, + Action? configure = null, string? configKey = null) + { + applicationBuilder + .AddModule(configure, configKey); + return applicationBuilder; + } } diff --git a/src/Sitko.Blockly.AntDesign/Sitko.Blockly.AntDesign.csproj b/src/Sitko.Blockly.AntDesign/Sitko.Blockly.AntDesign.csproj index be4c3fa..e6db21e 100644 --- a/src/Sitko.Blockly.AntDesign/Sitko.Blockly.AntDesign.csproj +++ b/src/Sitko.Blockly.AntDesign/Sitko.Blockly.AntDesign.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/src/Sitko.Blockly.Blazor/Sitko.Blockly.Blazor.csproj b/src/Sitko.Blockly.Blazor/Sitko.Blockly.Blazor.csproj index 0030c0d..ec4da5c 100644 --- a/src/Sitko.Blockly.Blazor/Sitko.Blockly.Blazor.csproj +++ b/src/Sitko.Blockly.Blazor/Sitko.Blockly.Blazor.csproj @@ -5,8 +5,9 @@ - - + + + diff --git a/src/Sitko.Blockly.EntityFrameworkCore/Sitko.Blockly.EntityFrameworkCore.csproj b/src/Sitko.Blockly.EntityFrameworkCore/Sitko.Blockly.EntityFrameworkCore.csproj index 6000397..e100894 100644 --- a/src/Sitko.Blockly.EntityFrameworkCore/Sitko.Blockly.EntityFrameworkCore.csproj +++ b/src/Sitko.Blockly.EntityFrameworkCore/Sitko.Blockly.EntityFrameworkCore.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/Sitko.Blockly.MudBlazor/ApplicationExtensions.cs b/src/Sitko.Blockly.MudBlazor/ApplicationExtensions.cs index 1a2e1de..f4e4320 100644 --- a/src/Sitko.Blockly.MudBlazor/ApplicationExtensions.cs +++ b/src/Sitko.Blockly.MudBlazor/ApplicationExtensions.cs @@ -1,17 +1,45 @@ using JetBrains.Annotations; +using Microsoft.Extensions.Hosting; using Sitko.Core.App; +using Sitko.Core.Blazor; namespace Sitko.Blockly.MudBlazorComponents; [PublicAPI] public static class ApplicationExtensions { - public static Application AddMudBlazorBlockly(this Application application, + public static IHostApplicationBuilder AddMudBlazorBlockly(this IHostApplicationBuilder hostApplicationBuilder, + Action configure, string? optionsKey = null) + { + hostApplicationBuilder.GetSitkoCore() + .AddMudBlazorBlockly(configure, optionsKey); + return hostApplicationBuilder; + } + + public static IHostApplicationBuilder AddMudBlazorBlockly(this IHostApplicationBuilder hostApplicationBuilder, + Action? configure = null, string? optionsKey = null) + { + hostApplicationBuilder.GetSitkoCore() + .AddMudBlazorBlockly(configure, optionsKey); + return hostApplicationBuilder; + } + + public static ISitkoCoreBlazorApplicationBuilder AddMudBlazorBlockly( + this ISitkoCoreBlazorApplicationBuilder applicationBuilder, Action configure, - string? configKey = null) => - application.AddModule(configure, configKey); + string? configKey = null) + { + applicationBuilder + .AddModule(configure, configKey); + return applicationBuilder; + } - public static Application AddMudBlazorBlockly(this Application application, - Action? configure = null, string? configKey = null) => - application.AddModule(configure, configKey); + public static ISitkoCoreBlazorApplicationBuilder AddMudBlazorBlockly( + this ISitkoCoreBlazorApplicationBuilder applicationBuilder, + Action? configure = null, string? configKey = null) + { + applicationBuilder + .AddModule(configure, configKey); + return applicationBuilder; + } } diff --git a/src/Sitko.Blockly.MudBlazor/Forms/Blocks/MudQuoteBlockForm.razor b/src/Sitko.Blockly.MudBlazor/Forms/Blocks/MudQuoteBlockForm.razor index 28149c0..fe445db 100644 --- a/src/Sitko.Blockly.MudBlazor/Forms/Blocks/MudQuoteBlockForm.razor +++ b/src/Sitko.Blockly.MudBlazor/Forms/Blocks/MudQuoteBlockForm.razor @@ -17,7 +17,7 @@ @if (FormOptions.Storage is not null) { - - - + + diff --git a/src/Sitko.Blockly/ApplicationExtensions.cs b/src/Sitko.Blockly/ApplicationExtensions.cs index 38a5893..b0852f9 100644 --- a/src/Sitko.Blockly/ApplicationExtensions.cs +++ b/src/Sitko.Blockly/ApplicationExtensions.cs @@ -1,4 +1,5 @@ using JetBrains.Annotations; +using Microsoft.Extensions.Hosting; using Sitko.Core.App; namespace Sitko.Blockly; @@ -6,11 +7,25 @@ namespace Sitko.Blockly; [PublicAPI] public static class ApplicationExtensions { - public static Application AddBlockly(this Application application, + public static IHostApplicationBuilder AddBlockly(this IHostApplicationBuilder hostApplicationBuilder, + Action configure, string? optionsKey = null) + { + hostApplicationBuilder.GetSitkoCore().AddBlockly(configure, optionsKey); + return hostApplicationBuilder; + } + + public static IHostApplicationBuilder AddBlockly(this IHostApplicationBuilder hostApplicationBuilder, + Action? configure = null, string? optionsKey = null) + { + hostApplicationBuilder.GetSitkoCore().AddBlockly(configure, optionsKey); + return hostApplicationBuilder; + } + + public static ISitkoCoreApplicationBuilder AddBlockly(this ISitkoCoreApplicationBuilder applicationBuilder, Action configure, string? configKey = null) => - application.AddModule(configure, configKey); + applicationBuilder.AddModule(configure, configKey); - public static Application AddBlockly(this Application application, + public static ISitkoCoreApplicationBuilder AddBlockly(this ISitkoCoreApplicationBuilder applicationBuilder, Action? configure = null, string? configKey = null) => - application.AddModule(configure, configKey); + applicationBuilder.AddModule(configure, configKey); } diff --git a/src/Sitko.Blockly/Sitko.Blockly.csproj b/src/Sitko.Blockly/Sitko.Blockly.csproj index 5d6ee77..d2ebef4 100644 --- a/src/Sitko.Blockly/Sitko.Blockly.csproj +++ b/src/Sitko.Blockly/Sitko.Blockly.csproj @@ -1,7 +1,7 @@ - - + + diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 0975de9..9fc2575 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -5,6 +5,6 @@ false - + diff --git a/tests/Sitko.Blockly.HtmlParser.Tests/HtmlParserTests.cs b/tests/Sitko.Blockly.HtmlParser.Tests/HtmlParserTests.cs index 2c64a55..4d9d1e8 100644 --- a/tests/Sitko.Blockly.HtmlParser.Tests/HtmlParserTests.cs +++ b/tests/Sitko.Blockly.HtmlParser.Tests/HtmlParserTests.cs @@ -1,5 +1,6 @@ using HtmlAgilityPack; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Sitko.Blockly.Blocks; using Sitko.Blockly.Tests; @@ -105,23 +106,17 @@ private static void CheckGalleryBlock(ContentBlock block, string[] fileNames) => public class BlocklyHtmlParserTestScope : BlocklyTestScope { - protected override TestApplication ConfigureApplication(TestApplication application, string name) + protected override IHostApplicationBuilder ConfigureServices(IHostApplicationBuilder builder, string name) { - base.ConfigureApplication(application, name); - application + base.ConfigureServices(builder, name); + builder .AddFileSystemStorage(moduleOptions => { moduleOptions.StoragePath = Path.Combine(Path.GetTempPath(), nameof(BlocklyHtmlParserTestScope)); }) .AddFileSystemStorageMetadata(); - return application; - } - - protected override IServiceCollection ConfigureServices(IApplicationContext applicationContext, - IServiceCollection services, string name) - { - services.AddHttpClient(); - return base.ConfigureServices(applicationContext, services, name); + builder.Services.AddHttpClient(); + return builder; } } diff --git a/tests/Sitko.Blockly.HtmlParser.Tests/Sitko.Blockly.HtmlParser.Tests.csproj b/tests/Sitko.Blockly.HtmlParser.Tests/Sitko.Blockly.HtmlParser.Tests.csproj index 6ea93da..b265117 100644 --- a/tests/Sitko.Blockly.HtmlParser.Tests/Sitko.Blockly.HtmlParser.Tests.csproj +++ b/tests/Sitko.Blockly.HtmlParser.Tests/Sitko.Blockly.HtmlParser.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 false latest enable @@ -14,9 +14,9 @@ - - - + + + diff --git a/tests/Sitko.Blockly.Tests/ChangesTest.cs b/tests/Sitko.Blockly.Tests/ChangesTest.cs index fda6d2b..3edcd3a 100644 --- a/tests/Sitko.Blockly.Tests/ChangesTest.cs +++ b/tests/Sitko.Blockly.Tests/ChangesTest.cs @@ -1,6 +1,8 @@ using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Hosting; using Sitko.Blockly.Blocks; using Sitko.Blockly.EntityFrameworkCore; +using Sitko.Core.App; using Sitko.Core.App.Collections; using Sitko.Core.Repository; using Sitko.Core.Repository.EntityFrameworkCore; @@ -66,7 +68,7 @@ public async Task FormPositionChanges() } } -public class BlocklyTestScope : DbBaseTestScope +public class BlocklyTestScope : DbBaseTestScope { protected override async Task InitDbContextAsync(TestBlocklyDbContext dbContext) { @@ -76,20 +78,30 @@ protected override async Task InitDbContextAsync(TestBlocklyDbContext dbContext) model.Blocks.Add(new CutBlock { ButtonText = "Cut", Position = 1 }); model.Blocks.Add(new TextBlock { Text = "Bar", Position = 2 }); await dbContext.AddAsync(model); - await dbContext.SaveChangesAsync(); + var res = await dbContext.SaveChangesAsync(); + } - protected override TestApplication ConfigureApplication(TestApplication application, string name) + protected override IHostApplicationBuilder ConfigureServices(IHostApplicationBuilder builder, string name) { - base.ConfigureApplication(application, name); - application.AddEFRepositories(); - application.AddBlockly(moduleOptions => + base.ConfigureServices(builder, name); + builder.AddEFRepositories(); + builder.AddBlockly(moduleOptions => { moduleOptions.AddBlock(); moduleOptions.AddBlock(); }); - return application; + return builder; } + + protected override HostApplicationBuilder CreateHostBuilder() + { + var builder = Host.CreateApplicationBuilder(); + builder.AddSitkoCore(); + return builder; + } + + protected override IHost BuildApplication(HostApplicationBuilder builder) => builder.Build(); } public class BlocklyTestScopeConfig : BaseDbTestConfig diff --git a/tests/Sitko.Blockly.Tests/Sitko.Blockly.Tests.csproj b/tests/Sitko.Blockly.Tests/Sitko.Blockly.Tests.csproj index b9c26a1..41f855a 100644 --- a/tests/Sitko.Blockly.Tests/Sitko.Blockly.Tests.csproj +++ b/tests/Sitko.Blockly.Tests/Sitko.Blockly.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 false latest enable @@ -15,7 +15,7 @@ - - + +