From e8efc5e508af361a3ac4af507dd66ac44571f534 Mon Sep 17 00:00:00 2001 From: Shaun Walker Date: Thu, 2 Apr 2020 12:07:35 -0400 Subject: [PATCH] upgrade to .NET Core 3.2 Preview 3 and fixes for issues created by #314 (#323) --- .../Modules/Admin/Dashboard/Index.razor | 2 +- Oqtane.Client/Modules/Admin/Pages/Add.razor | 2 + Oqtane.Client/Modules/Admin/Pages/Edit.razor | 16 +- .../Modules/Admin/Register/Index.razor | 10 +- Oqtane.Client/Modules/Admin/Site/Index.razor | 32 ++-- Oqtane.Client/Modules/Admin/Tenants/Add.razor | 2 +- .../Modules/Admin/Tenants/Edit.razor | 1 - .../Modules/Controls/AuditInfo.razor | 6 +- .../Modules/Controls/FileManager.razor | 14 +- Oqtane.Client/Modules/Controls/Label.razor | 4 +- Oqtane.Client/Oqtane.Client.csproj | 19 +- Oqtane.Client/Program.cs | 84 +++++++-- Oqtane.Client/Startup.cs | 92 --------- .../Themes/Controls/Breadcrumbs.razor | 2 +- Oqtane.Client/Themes/Controls/Menu.razor | 5 +- .../Themes/Controls/ModuleTitle.razor | 2 +- Oqtane.Client/wwwroot/index.html | 36 ---- Oqtane.Server/Oqtane.Server.csproj | 25 +-- Oqtane.Server/Pages/_Host.cshtml | 16 +- Oqtane.Server/Program.cs | 22 +-- Oqtane.Server/Properties/launchSettings.json | 2 + Oqtane.Server/Startup.cs | 175 +----------------- Oqtane.Shared/Oqtane.Shared.csproj | 10 +- Oqtane.Test/Oqtane.Test.csproj | 6 +- Oqtane.sln | 11 -- 25 files changed, 164 insertions(+), 432 deletions(-) delete mode 100644 Oqtane.Client/Startup.cs delete mode 100644 Oqtane.Client/wwwroot/index.html diff --git a/Oqtane.Client/Modules/Admin/Dashboard/Index.razor b/Oqtane.Client/Modules/Admin/Dashboard/Index.razor index 38202300..7e3004fb 100644 --- a/Oqtane.Client/Modules/Admin/Dashboard/Index.razor +++ b/Oqtane.Client/Modules/Admin/Dashboard/Index.razor @@ -19,7 +19,7 @@ @code { - var List _pages; + private List _pages; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; diff --git a/Oqtane.Client/Modules/Admin/Pages/Add.razor b/Oqtane.Client/Modules/Admin/Pages/Add.razor index 671ce22e..f8be514c 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Add.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Add.razor @@ -165,12 +165,14 @@ private List _themeList; private List _pageList; private string _name; + private string _title; private string _path = string.Empty; private string _parentid; private string _insert = ">>"; private List _children; private int _childid = -1; private string _isnavigation = "True"; + private string _url; private string _ispersonalizable = "False"; private string _mode = "view"; private string _themetype = string.Empty; diff --git a/Oqtane.Client/Modules/Admin/Pages/Edit.razor b/Oqtane.Client/Modules/Admin/Pages/Edit.razor index 0422056c..a1c964f8 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Edit.razor @@ -187,6 +187,7 @@ private List _pageList; private int _pageId; private string _name; + private string _title; private string _path; private string _currentparentid; private string _parentid; @@ -194,6 +195,7 @@ private List _children; private int _childid = -1; private string _isnavigation; + private string _url; private string _ispersonalizable; private string _mode; private string _themetype; @@ -230,12 +232,12 @@ _name = page.Name; _title = page.Title; _path = page.Path; - + if (_path.Contains("/")) { _path = _path.Substring(_path.LastIndexOf("/") + 1); } - + if (page.ParentId == null) { _parentid = string.Empty; @@ -244,7 +246,7 @@ { _parentid = page.ParentId.ToString(); } - + _currentparentid = _parentid; _isnavigation = page.IsNavigation.ToString(); _url = page.Url; @@ -335,10 +337,10 @@ page.Name = _name; page.Title = _title; if (_path == "" && _name.ToLower() != "home") - if (_path == string.Empty && _name.ToLower() != "home") - { - _path = _name; - } + if (_path == string.Empty && _name.ToLower() != "home") + { + _path = _name; + } if (_path.Contains("/")) { _path = _path.Substring(_path.LastIndexOf("/") + 1); diff --git a/Oqtane.Client/Modules/Admin/Register/Index.razor b/Oqtane.Client/Modules/Admin/Register/Index.razor index 0bc613ff..f358d905 100644 --- a/Oqtane.Client/Modules/Admin/Register/Index.razor +++ b/Oqtane.Client/Modules/Admin/Register/Index.razor @@ -3,7 +3,7 @@ @inject NavigationManager NavigationManager @inject IUserService UserService -@if (_message != string.Empty) +@if (_message != string.Empty) { } @@ -40,17 +40,16 @@ private string _confirm = string.Empty; private string _email = string.Empty; private string _displayName = string.Empty; - - public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous; + public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous; private async Task Register() { try { _message = string.Empty; - _isEmailValid = Utilities.IsValidEmail(_email); - + bool _isEmailValid = Utilities.IsValidEmail(_email); + if (_username != "" && _password != "" && _confirm != "" && _isEmailValid) { if (_password == _confirm) @@ -97,3 +96,4 @@ { NavigationManager.NavigateTo(NavigateUrl(string.Empty)); } +} \ No newline at end of file diff --git a/Oqtane.Client/Modules/Admin/Site/Index.razor b/Oqtane.Client/Modules/Admin/Site/Index.razor index 6e61f3bf..afcf50ab 100644 --- a/Oqtane.Client/Modules/Admin/Site/Index.razor +++ b/Oqtane.Client/Modules/Admin/Site/Index.razor @@ -226,15 +226,23 @@ private List _aliasList; private string _urls = string.Empty; private int _logofileid = -1; - private FileManager _filemanager; + private FileManager _logofilemanager; + private int _faviconfileid = -1; + private FileManager _faviconfilemanager; private string _themetype; private string _layouttype; - private string _containertype + private string _containertype; + private string _allowregistration; private string _smtphost = string.Empty; private string _smtpport = string.Empty; private string _smtpssl = string.Empty; private string _smtpusername = string.Empty; private string _smtppassword = string.Empty; + private string _pwaisenabled; + private int _pwaappiconfileid = -1; + private FileManager _pwaappiconfilemanager; + private int _pwasplashiconfileid = -1; + private FileManager _pwasplashiconfilemanager; private string _createdby; private DateTime _createdon; private string _modifiedby; @@ -265,12 +273,12 @@ { _logofileid = site.LogoFileId.Value; } - + if (site.FaviconFileId != null) { _faviconfileid = site.FaviconFileId.Value; } - + _themetype = site.DefaultThemeType; _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _layouttype = site.DefaultLayoutType; @@ -285,12 +293,12 @@ _smtppassword = SettingService.GetSetting(settings, "SMTPPassword", string.Empty); _pwaisenabled = site.PwaIsEnabled.ToString(); - + if (site.PwaAppIconFileId != null) { _pwaappiconfileid = site.PwaAppIconFileId.Value; } - + if (site.PwaSplashIconFileId != null) { _pwasplashiconfileid = site.PwaSplashIconFileId.Value; @@ -361,7 +369,7 @@ unique = false; } } - + if (unique) { var site = await SiteService.GetSiteAsync(PageState.Site.SiteId, PageState.Alias); @@ -369,12 +377,12 @@ { site.Name = _name; site.LogoFileId = null; - var logofileid = _filemanager.GetFileId(); + var logofileid = _logofilemanager.GetFileId(); if (logofileid != -1) { site.LogoFileId = logofileid; } - + site.DefaultThemeType = _themetype; site.DefaultLayoutType = (_layouttype == null ? string.Empty : _layouttype); site.DefaultContainerType = _containertype; @@ -382,13 +390,13 @@ site.IsDeleted = (_isdeleted == null ? true : Boolean.Parse(_isdeleted)); site.PwaIsEnabled = (_pwaisenabled == null ? true : Boolean.Parse(_pwaisenabled)); - + var pwaappiconfileid = _pwaappiconfilemanager.GetFileId(); if (pwaappiconfileid != -1) { site.PwaAppIconFileId = pwaappiconfileid; } - + var pwasplashiconfileid = _pwasplashiconfilemanager.GetFileId(); if (pwasplashiconfileid != -1) { @@ -406,7 +414,7 @@ await AliasService.DeleteAliasAsync(alias.AliasId); } } - + foreach (string name in names) { if (!_aliasList.Exists(item => item.Name == name)) diff --git a/Oqtane.Client/Modules/Admin/Tenants/Add.razor b/Oqtane.Client/Modules/Admin/Tenants/Add.razor index 5b6492bd..962b9e4c 100644 --- a/Oqtane.Client/Modules/Admin/Tenants/Add.razor +++ b/Oqtane.Client/Modules/Admin/Tenants/Add.razor @@ -101,7 +101,7 @@ { ShowProgressIndicator(); - var connectionstring = string.Empty; + var connectionString = string.Empty; if (type == "LocalDB") { connectionString = "Data Source=" + server + ";AttachDbFilename=|DataDirectory|\\" + database + ".mdf;Initial Catalog=" + database + ";Integrated Security=SSPI;"; diff --git a/Oqtane.Client/Modules/Admin/Tenants/Edit.razor b/Oqtane.Client/Modules/Admin/Tenants/Edit.razor index 3becfbe7..56f3fe20 100644 --- a/Oqtane.Client/Modules/Admin/Tenants/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Tenants/Edit.razor @@ -69,7 +69,6 @@ { tenant.Name = name; tenant.DBConnectionString = connectionstring; - tenant.DBSchema = schema; await TenantService.UpdateTenantAsync(tenant); await logger.LogInformation("Tenant Saved {TenantId}", tenantid); diff --git a/Oqtane.Client/Modules/Controls/AuditInfo.razor b/Oqtane.Client/Modules/Controls/AuditInfo.razor index 6aa6f470..75079c6c 100644 --- a/Oqtane.Client/Modules/Controls/AuditInfo.razor +++ b/Oqtane.Client/Modules/Controls/AuditInfo.razor @@ -39,7 +39,7 @@ _text = string.Empty; if (!String.IsNullOrEmpty(CreatedBy) || CreatedOn != null) { - _text += "

Created "; + _text += "

Created "; if (!String.IsNullOrEmpty(CreatedBy)) { @@ -56,7 +56,7 @@ if (!String.IsNullOrEmpty(ModifiedBy) || ModifiedOn != null) { - _text += "

Last modified "; + _text += "

Last modified "; if (!String.IsNullOrEmpty(ModifiedBy)) { @@ -73,7 +73,7 @@ if (!String.IsNullOrEmpty(DeletedBy) || DeletedOn.HasValue) { - _text += "

Deleted "; + _text += "

Deleted "; if (!String.IsNullOrEmpty(DeletedBy)) { diff --git a/Oqtane.Client/Modules/Controls/FileManager.razor b/Oqtane.Client/Modules/Controls/FileManager.razor index 474bfb49..6dd696b3 100644 --- a/Oqtane.Client/Modules/Controls/FileManager.razor +++ b/Oqtane.Client/Modules/Controls/FileManager.razor @@ -225,7 +225,7 @@ { _message = string.Empty; _fileid = int.Parse((string)e.Value); - + await SetImage(); StateHasChanged(); } @@ -245,9 +245,9 @@ var ratioY = (double)maxheight / (double)file.ImageHeight; var ratio = ratioX < ratioY ? ratioX : ratioY; - _image = "\string.Empty"; + _image = "\"""; } } } @@ -269,13 +269,13 @@ { result = await FileService.UploadFilesAsync(_folderid, upload, _id); } - + if (result == string.Empty) { await logger.LogInformation("File Upload Succeeded {Files}", upload); _message = "

File Upload Succeeded
"; await GetFiles(); - + if (upload.Length == 1) { var file = _files.Where(item => item.Name == upload[0]).FirstOrDefault(); @@ -308,7 +308,7 @@ private async Task DeleteFile() { _message = string.Empty; - + try { await FileService.DeleteFileAsync(_fileid); diff --git a/Oqtane.Client/Modules/Controls/Label.razor b/Oqtane.Client/Modules/Controls/Label.razor index af13ea16..a643e118 100644 --- a/Oqtane.Client/Modules/Controls/Label.razor +++ b/Oqtane.Client/Modules/Controls/Label.razor @@ -31,12 +31,12 @@ else _openLabel = " netstandard2.1 Exe - false - - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; - https://dotnet.myget.org/F/blazor-dev/api/v3/index.json; - 7.3 3.0 - Debug;Release;WebAssembly + Debug;Release 0.0.9 Oqtane Shaun Walker @@ -24,10 +19,6 @@ Oqtane - - TRACE;WASM - - @@ -36,10 +27,10 @@ - - - - + + + + diff --git a/Oqtane.Client/Program.cs b/Oqtane.Client/Program.cs index b256ca9b..4172834b 100644 --- a/Oqtane.Client/Program.cs +++ b/Oqtane.Client/Program.cs @@ -1,25 +1,79 @@ -// DO NOT REMOVE - needed for client-side Blazor -using Microsoft.AspNetCore.Blazor.Hosting; +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; +using Microsoft.Extensions.DependencyInjection; +using System.Threading.Tasks; +using Oqtane.Services; +using System.Reflection; +using System; +using System.Linq; +using Oqtane.Modules; +using Oqtane.Shared; +using Oqtane.Providers; +using Microsoft.AspNetCore.Components.Authorization; namespace Oqtane.Client { public class Program { -#if DEBUG || RELEASE - public static void Main(string[] args) + public static async Task Main(string[] args) { - } -#endif + var builder = WebAssemblyHostBuilder.CreateDefault(args); + builder.RootComponents.Add("app"); -#if WASM - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } + builder.Services.AddBaseAddressHttpClient(); - public static IWebAssemblyHostBuilder CreateHostBuilder(string[] args) => - BlazorWebAssemblyHost.CreateDefaultBuilder() - .UseBlazorStartup(); -#endif + // register auth services + builder.Services.AddAuthorizationCore(); + builder.Services.AddScoped(); + builder.Services.AddScoped(s => s.GetRequiredService()); + + // register scoped core services + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + + // dynamically register module contexts and repository services + Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); + foreach (Assembly assembly in assemblies) + { + Type[] implementationtypes = assembly.GetTypes() + .Where(item => item.GetInterfaces().Contains(typeof(IService))) + .ToArray(); + foreach (Type implementationtype in implementationtypes) + { + Type servicetype = Type.GetType(implementationtype.AssemblyQualifiedName.Replace(implementationtype.Name, "I" + implementationtype.Name)); + if (servicetype != null) + { + builder.Services.AddScoped(servicetype, implementationtype); // traditional service interface + } + else + { + builder.Services.AddScoped(implementationtype, implementationtype); // no interface defined for service + } + } + } + + await builder.Build().RunAsync(); + } } } diff --git a/Oqtane.Client/Startup.cs b/Oqtane.Client/Startup.cs deleted file mode 100644 index 8d4dfdeb..00000000 --- a/Oqtane.Client/Startup.cs +++ /dev/null @@ -1,92 +0,0 @@ -using Microsoft.AspNetCore.Components.Builder; -using Microsoft.Extensions.DependencyInjection; -using System; -using Oqtane.Services; -using System.Linq; -using System.Net.Http; -using Microsoft.AspNetCore.Components; -using System.Reflection; -using Oqtane.Modules; -using Oqtane.Shared; -using Oqtane.Providers; -using Microsoft.AspNetCore.Blazor.Http; -using Microsoft.AspNetCore.Components.Authorization; - -namespace Oqtane.Client -{ - public class Startup - { -#if DEBUG || RELEASE - public void ConfigureServices(IServiceCollection services) - { - - } - - public void Configure(IComponentsApplicationBuilder app) - { - - } -#endif -#if WASM - public void ConfigureServices(IServiceCollection services) - { - // register auth services - services.AddAuthorizationCore(); - services.AddScoped(); - services.AddScoped(s => s.GetRequiredService()); - - // register scoped core services - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - - // dynamically register module contexts and repository services - Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); - foreach (Assembly assembly in assemblies) - { - Type[] implementationtypes = assembly.GetTypes() - .Where(item => item.GetInterfaces().Contains(typeof(IService))) - .ToArray(); - foreach (Type implementationtype in implementationtypes) - { - Type servicetype = Type.GetType(implementationtype.AssemblyQualifiedName.Replace(implementationtype.Name, "I" + implementationtype.Name)); - if (servicetype != null) - { - services.AddScoped(servicetype, implementationtype); // traditional service interface - } - else - { - services.AddScoped(implementationtype, implementationtype); // no interface defined for service - } - } - } - } - - public void Configure(IComponentsApplicationBuilder app) - { - app.AddComponent("app"); - } -#endif - } -} diff --git a/Oqtane.Client/Themes/Controls/Breadcrumbs.razor b/Oqtane.Client/Themes/Controls/Breadcrumbs.razor index 77d95f77..c0107601 100644 --- a/Oqtane.Client/Themes/Controls/Breadcrumbs.razor +++ b/Oqtane.Client/Themes/Controls/Breadcrumbs.razor @@ -12,7 +12,7 @@ protected override void OnParametersSet() { breadcrumbs = string.Empty; - var pageid = PageState.Page.PageId; + int? pageid = PageState.Page.PageId; for (int i = PageState.Pages.Count - 1; i >= 0; i--) { var p = PageState.Pages[i]; diff --git a/Oqtane.Client/Themes/Controls/Menu.razor b/Oqtane.Client/Themes/Controls/Menu.razor index 3b70830e..442729d6 100644 --- a/Oqtane.Client/Themes/Controls/Menu.razor +++ b/Oqtane.Client/Themes/Controls/Menu.razor @@ -54,7 +54,6 @@ } menu += ""; } - menu += ""; if (p.HasChildren) { @@ -114,14 +113,14 @@ if (p.PageId == PageState.Page.PageId) { menu += "
  • " + - "" + + "" + ((p.Icon != string.Empty) ? " " : string.Empty) + p.Name + " (current)
  • "; } else { menu += "
  • " + - "" + + "" + ((p.Icon != string.Empty) ? " " : string.Empty) + p.Name + "
  • "; } diff --git a/Oqtane.Client/Themes/Controls/ModuleTitle.razor b/Oqtane.Client/Themes/Controls/ModuleTitle.razor index 785d9217..bb8d6f62 100644 --- a/Oqtane.Client/Themes/Controls/ModuleTitle.razor +++ b/Oqtane.Client/Themes/Controls/ModuleTitle.razor @@ -4,7 +4,7 @@ @((MarkupString)title) @code { - private title = ""; + private string title = ""; protected override Task OnParametersSetAsync() { diff --git a/Oqtane.Client/wwwroot/index.html b/Oqtane.Client/wwwroot/index.html deleted file mode 100644 index 4244d8d4..00000000 --- a/Oqtane.Client/wwwroot/index.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - Oqtane - - - - - - - - - - - -
    - -
    -
    - - - - - - - - - - - - - - - diff --git a/Oqtane.Server/Oqtane.Server.csproj b/Oqtane.Server/Oqtane.Server.csproj index 7471c460..bbf00ff7 100644 --- a/Oqtane.Server/Oqtane.Server.csproj +++ b/Oqtane.Server/Oqtane.Server.csproj @@ -3,12 +3,7 @@ netcoreapp3.1 7.3 - - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; - https://dotnet.myget.org/F/blazor-dev/api/v3/index.json; - - true - Debug;Release;WebAssembly + Debug;Release 0.0.9 Oqtane Shaun Walker @@ -22,10 +17,6 @@ Oqtane - - TRACE;WASM - - @@ -34,13 +25,13 @@ - - - - - - - + + + + + + + diff --git a/Oqtane.Server/Pages/_Host.cshtml b/Oqtane.Server/Pages/_Host.cshtml index ac372241..c6758960 100644 --- a/Oqtane.Server/Pages/_Host.cshtml +++ b/Oqtane.Server/Pages/_Host.cshtml @@ -1,6 +1,8 @@ @page "/" @namespace Oqtane.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@using Microsoft.Extensions.Configuration +@inject IConfiguration Configuration @@ -19,7 +21,9 @@ @(Html.AntiForgeryToken()) - @(await Html.RenderComponentAsync(RenderMode.Server)) + + + @@ -28,6 +32,14 @@ - + + @if (Configuration.GetSection("Runtime").Value == "WebAssembly") + { + + } + else + { + + } diff --git a/Oqtane.Server/Program.cs b/Oqtane.Server/Program.cs index 6402cf5e..e46805e6 100644 --- a/Oqtane.Server/Program.cs +++ b/Oqtane.Server/Program.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; // DO NOT REMOVE - needed for client-side Blazor -using Microsoft.AspNetCore.Blazor.Hosting; +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.AspNetCore; using Microsoft.Extensions.DependencyInjection; @@ -11,33 +11,17 @@ namespace Oqtane.Server { public class Program { -#if DEBUG || RELEASE public static void Main(string[] args) { - var host = CreateHostBuilder(args).Build(); + var host = BuildWebHost(args); using (var serviceScope = host.Services.GetRequiredService().CreateScope()) { var manager = serviceScope.ServiceProvider.GetService(); manager.StartupMigration(); } - //DatabaseManager.StartupMigration(); host.Run(); } - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); -#endif - -#if WASM - public static void Main(string[] args) - { - BuildWebHost(args).Run(); - } - public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseConfiguration(new ConfigurationBuilder() @@ -45,7 +29,5 @@ namespace Oqtane.Server .Build()) .UseStartup() .Build(); -#endif - } } diff --git a/Oqtane.Server/Properties/launchSettings.json b/Oqtane.Server/Properties/launchSettings.json index 55612d8c..fcddfc65 100644 --- a/Oqtane.Server/Properties/launchSettings.json +++ b/Oqtane.Server/Properties/launchSettings.json @@ -11,6 +11,7 @@ "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -18,6 +19,7 @@ "Oqtane.Server": { "commandName": "Project", "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, diff --git a/Oqtane.Server/Startup.cs b/Oqtane.Server/Startup.cs index 190e4adb..46b5e697 100644 --- a/Oqtane.Server/Startup.cs +++ b/Oqtane.Server/Startup.cs @@ -21,11 +21,6 @@ using Oqtane.Security; using Oqtane.Services; using Oqtane.Shared; -#if WASM -// DO NOT REMOVE - needed for client-side Blazor -using Microsoft.AspNetCore.ResponseCompression; -#endif - namespace Oqtane { public class Startup @@ -42,18 +37,13 @@ namespace Oqtane AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(env.ContentRootPath, "Data")); } -#if DEBUG || RELEASE // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { - services.AddRazorPages(); -#if DEBUG - services.AddServerSideBlazor().AddCircuitOptions(options => { options.DetailedErrors = true; }); -#endif -#if RELEASE + services.AddMvc().AddNewtonsoftJson(); services.AddServerSideBlazor(); -#endif + // setup HttpClient for server side in a client side compatible fashion ( with auth cookie ) if (!services.Any(x => x.ServiceType == typeof(HttpClient))) { @@ -217,6 +207,7 @@ namespace Oqtane if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); + app.UseWebAssemblyDebugging(); } else { @@ -243,168 +234,10 @@ namespace Oqtane app.UseEndpoints(endpoints => { - endpoints.MapRazorPages(); - endpoints.MapControllers(); endpoints.MapBlazorHub(); + endpoints.MapControllers(); endpoints.MapFallbackToPage("/_Host"); }); } -#endif - -#if WASM - // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 - public void ConfigureServices(IServiceCollection services) - { - // register authorization services - services.AddAuthorizationCore(options => - { - options.AddPolicy("ViewPage", policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Page, PermissionNames.View))); - options.AddPolicy("EditPage", policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Page, PermissionNames.Edit))); - options.AddPolicy("ViewModule", policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Module, PermissionNames.View))); - options.AddPolicy("EditModule", policy => policy.Requirements.Add(new PermissionRequirement(EntityNames.Module, PermissionNames.Edit))); - }); - - // register scoped core services - services.AddScoped(); - services.AddScoped(); - - services.AddSingleton(); - - services.AddDbContext(options => - options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection") - .Replace("|DataDirectory|", AppDomain.CurrentDomain.GetData("DataDirectory").ToString()) - )); - services.AddDbContext(options => { }); - - services.AddIdentityCore(options => { }) - .AddEntityFrameworkStores() - .AddSignInManager() - .AddDefaultTokenProviders(); - - services.Configure(options => - { - // Password settings - options.Password.RequireDigit = false; - options.Password.RequiredLength = 6; - options.Password.RequireNonAlphanumeric = false; - options.Password.RequireUppercase = false; - options.Password.RequireLowercase = false; - - // Lockout settings - options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(30); - options.Lockout.MaxFailedAccessAttempts = 10; - options.Lockout.AllowedForNewUsers = true; - - // User settings - options.User.RequireUniqueEmail = false; - }); - - services.AddAuthentication(IdentityConstants.ApplicationScheme) - .AddCookie(IdentityConstants.ApplicationScheme); - - services.ConfigureApplicationCookie(options => - { - options.Cookie.HttpOnly = false; - options.Events.OnRedirectToLogin = context => - { - context.Response.StatusCode = 401; - return Task.CompletedTask; - }; - }); - - // register custom claims principal factory for role claims - services.AddTransient, ClaimsPrincipalFactory>(); - - // register singleton scoped core services - services.AddSingleton(Configuration); - services.AddSingleton(); - services.AddSingleton(); - - // register transient scoped core services - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - - services.AddOqtaneModules(); - services.AddOqtaneThemes(); - services.AddOqtaneSiteTemplates(); - - services.AddMvc() - .AddOqtaneApplicationParts() - .AddNewtonsoftJson(); - - services.AddOqtaneServices(); - services.AddOqtaneHostedServices(); - - services.AddSwaggerGen(c => - { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "Oqtane", Version = "v1" }); - }); - - services.AddResponseCompression(opts => - { - opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat( - new[] { "application/octet-stream" }); - }); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IInstallationManager InstallationManager) - { - app.UseResponseCompression(); - - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - app.UseBlazorDebugging(); - } - - // install any modules or themes - InstallationManager.InstallPackages("Modules,Themes", false); - - app.UseClientSideBlazorFiles(); - app.UseStaticFiles(); - - app.UseRouting(); - app.UseAuthentication(); - app.UseAuthorization(); - - app.UseSwagger(); - app.UseSwaggerUI(c => - { - c.SwaggerEndpoint("/swagger/v1/swagger.json", "Oqtane V1"); - }); - - app.UseEndpoints(endpoints => - { - endpoints.MapDefaultControllerRoute(); - endpoints.MapFallbackToClientSideBlazor("index.html"); - }); - } -#endif - } } diff --git a/Oqtane.Shared/Oqtane.Shared.csproj b/Oqtane.Shared/Oqtane.Shared.csproj index 830bda51..6a0c0d87 100644 --- a/Oqtane.Shared/Oqtane.Shared.csproj +++ b/Oqtane.Shared/Oqtane.Shared.csproj @@ -3,7 +3,7 @@ netstandard2.1 7.3 - Debug;Release;WebAssembly + Debug;Release 0.0.9 Oqtane Shaun Walker @@ -17,13 +17,9 @@ Oqtane - - TRACE;WASM - - - - + + diff --git a/Oqtane.Test/Oqtane.Test.csproj b/Oqtane.Test/Oqtane.Test.csproj index b8e24038..022b6616 100644 --- a/Oqtane.Test/Oqtane.Test.csproj +++ b/Oqtane.Test/Oqtane.Test.csproj @@ -6,9 +6,9 @@ - - - + + + diff --git a/Oqtane.sln b/Oqtane.sln index 3832d333..0caeb4f6 100644 --- a/Oqtane.sln +++ b/Oqtane.sln @@ -17,39 +17,28 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU - WebAssembly|Any CPU = WebAssembly|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {083BB22D-DF24-43A2-95E5-8F385CCB3318}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {083BB22D-DF24-43A2-95E5-8F385CCB3318}.Debug|Any CPU.Build.0 = Debug|Any CPU {083BB22D-DF24-43A2-95E5-8F385CCB3318}.Release|Any CPU.ActiveCfg = Release|Any CPU {083BB22D-DF24-43A2-95E5-8F385CCB3318}.Release|Any CPU.Build.0 = Release|Any CPU - {083BB22D-DF24-43A2-95E5-8F385CCB3318}.WebAssembly|Any CPU.ActiveCfg = WebAssembly|Any CPU - {083BB22D-DF24-43A2-95E5-8F385CCB3318}.WebAssembly|Any CPU.Build.0 = WebAssembly|Any CPU {FD15B24A-7F6A-4830-9CA2-9C621771C330}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FD15B24A-7F6A-4830-9CA2-9C621771C330}.Debug|Any CPU.Build.0 = Debug|Any CPU {FD15B24A-7F6A-4830-9CA2-9C621771C330}.Release|Any CPU.ActiveCfg = Release|Any CPU {FD15B24A-7F6A-4830-9CA2-9C621771C330}.Release|Any CPU.Build.0 = Release|Any CPU - {FD15B24A-7F6A-4830-9CA2-9C621771C330}.WebAssembly|Any CPU.ActiveCfg = WebAssembly|Any CPU - {FD15B24A-7F6A-4830-9CA2-9C621771C330}.WebAssembly|Any CPU.Build.0 = WebAssembly|Any CPU {19D67A9D-3F2E-41BD-80E6-0B50CA83C3AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {19D67A9D-3F2E-41BD-80E6-0B50CA83C3AE}.Debug|Any CPU.Build.0 = Debug|Any CPU {19D67A9D-3F2E-41BD-80E6-0B50CA83C3AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {19D67A9D-3F2E-41BD-80E6-0B50CA83C3AE}.Release|Any CPU.Build.0 = Release|Any CPU - {19D67A9D-3F2E-41BD-80E6-0B50CA83C3AE}.WebAssembly|Any CPU.ActiveCfg = WebAssembly|Any CPU - {19D67A9D-3F2E-41BD-80E6-0B50CA83C3AE}.WebAssembly|Any CPU.Build.0 = WebAssembly|Any CPU {2E8C6889-37CF-4C8D-88B1-505547F25098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E8C6889-37CF-4C8D-88B1-505547F25098}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E8C6889-37CF-4C8D-88B1-505547F25098}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E8C6889-37CF-4C8D-88B1-505547F25098}.Release|Any CPU.Build.0 = Release|Any CPU - {2E8C6889-37CF-4C8D-88B1-505547F25098}.WebAssembly|Any CPU.ActiveCfg = Debug|Any CPU - {2E8C6889-37CF-4C8D-88B1-505547F25098}.WebAssembly|Any CPU.Build.0 = Debug|Any CPU {823B556D-8D4E-4BB8-A65A-C4EB5E7E7424}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {823B556D-8D4E-4BB8-A65A-C4EB5E7E7424}.Debug|Any CPU.Build.0 = Debug|Any CPU {823B556D-8D4E-4BB8-A65A-C4EB5E7E7424}.Release|Any CPU.ActiveCfg = Release|Any CPU {823B556D-8D4E-4BB8-A65A-C4EB5E7E7424}.Release|Any CPU.Build.0 = Release|Any CPU - {823B556D-8D4E-4BB8-A65A-C4EB5E7E7424}.WebAssembly|Any CPU.ActiveCfg = Debug|Any CPU - {823B556D-8D4E-4BB8-A65A-C4EB5E7E7424}.WebAssembly|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE