upgrade to .NET Core 3.2 Preview 3 and fixes for issues created by #314 (#323)

This commit is contained in:
Shaun Walker 2020-04-02 12:07:35 -04:00 committed by GitHub
parent c2a29831c4
commit e8efc5e508
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 164 additions and 432 deletions

View File

@ -19,7 +19,7 @@
</div>
@code {
var List<Page> _pages;
private List<Page> _pages;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;

View File

@ -165,12 +165,14 @@
private List<Theme> _themeList;
private List<Page> _pageList;
private string _name;
private string _title;
private string _path = string.Empty;
private string _parentid;
private string _insert = ">>";
private List<Page> _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;

View File

@ -187,6 +187,7 @@
private List<Page> _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<Page> _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);

View File

@ -3,7 +3,7 @@
@inject NavigationManager NavigationManager
@inject IUserService UserService
@if (_message != string.Empty)
@if (_message != string.Empty)
{
<ModuleMessage Message="@_message" Type="MessageType.Info" />
}
@ -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));
}
}

View File

@ -226,15 +226,23 @@
private List<Alias> _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))

View File

@ -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;";

View File

@ -69,7 +69,6 @@
{
tenant.Name = name;
tenant.DBConnectionString = connectionstring;
tenant.DBSchema = schema;
await TenantService.UpdateTenantAsync(tenant);
await logger.LogInformation("Tenant Saved {TenantId}", tenantid);

View File

@ -39,7 +39,7 @@
_text = string.Empty;
if (!String.IsNullOrEmpty(CreatedBy) || CreatedOn != null)
{
_text += "<p style=\string.Empty + Style + "\">Created ";
_text += "<p style=\"" + Style + "\">Created ";
if (!String.IsNullOrEmpty(CreatedBy))
{
@ -56,7 +56,7 @@
if (!String.IsNullOrEmpty(ModifiedBy) || ModifiedOn != null)
{
_text += "<p style=\string.Empty + Style + "\">Last modified ";
_text += "<p style=\"" + Style + "\">Last modified ";
if (!String.IsNullOrEmpty(ModifiedBy))
{
@ -73,7 +73,7 @@
if (!String.IsNullOrEmpty(DeletedBy) || DeletedOn.HasValue)
{
_text += "<p style=\string.Empty + Style + "\">Deleted ";
_text += "<p style=\"" + Style + "\">Deleted ";
if (!String.IsNullOrEmpty(DeletedBy))
{

View File

@ -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 = "<img src=\string.Empty + ContentUrl(_fileid) + "\" alt=\string.Empty + file.Name +
"\" width=\string.Empty + Convert.ToInt32(file.ImageWidth * ratio).ToString() +
"\" height=\string.Empty + Convert.ToInt32(file.ImageHeight * ratio).ToString() + "\" />";
_image = "<img src=\"" + ContentUrl(_fileid) + "\" alt=\"" + file.Name +
"\" width=\"" + Convert.ToInt32(file.ImageWidth * ratio).ToString() +
"\" height=\"" + Convert.ToInt32(file.ImageHeight * ratio).ToString() + "\" />";
}
}
}
@ -269,13 +269,13 @@
{
result = await FileService.UploadFilesAsync(_folderid, upload, _id);
}
if (result == string.Empty)
{
await logger.LogInformation("File Upload Succeeded {Files}", upload);
_message = "<br /><div class=\"alert alert-success\" role=\"alert\">File Upload Succeeded</div>";
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);

View File

@ -31,12 +31,12 @@ else
_openLabel = "<label";
if (!string.IsNullOrEmpty(For))
{
_openLabel += " for=\string.Empty + For + "\string.Empty;
_openLabel += " for=\"" + For + "\"";
}
if (!string.IsNullOrEmpty(Class))
{
_openLabel += " class=\string.Empty + Class + "\string.Empty;
_openLabel += " class=\"" + Class + "\"";
}
_openLabel += ">";

View File

@ -3,14 +3,9 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Exe</OutputType>
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
<RestoreAdditionalProjectSources>
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
</RestoreAdditionalProjectSources>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
<Configurations>Debug;Release;WebAssembly</Configurations>
<Configurations>Debug;Release</Configurations>
<Version>0.0.9</Version>
<Product>Oqtane</Product>
<Authors>Shaun Walker</Authors>
@ -24,10 +19,6 @@
<RootNamespace>Oqtane</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='WebAssembly|AnyCPU'">
<DefineConstants>TRACE;WASM</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Modules\Admin\ModuleCreator\Templates\**" />
<Content Remove="Modules\Admin\ModuleCreator\Templates\**" />
@ -36,10 +27,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.1.0-preview4.19579.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.1.0-preview4.19579.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.1.0-preview4.19579.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-preview3.20168.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-preview3.20168.3" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.2.0-preview3.20168.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="3.1.2" />
</ItemGroup>
<ItemGroup>

View File

@ -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>("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<Startup>();
#endif
// register auth services
builder.Services.AddAuthorizationCore();
builder.Services.AddScoped<IdentityAuthenticationStateProvider>();
builder.Services.AddScoped<AuthenticationStateProvider>(s => s.GetRequiredService<IdentityAuthenticationStateProvider>());
// register scoped core services
builder.Services.AddScoped<SiteState>();
builder.Services.AddScoped<IInstallationService, InstallationService>();
builder.Services.AddScoped<IModuleDefinitionService, ModuleDefinitionService>();
builder.Services.AddScoped<IThemeService, ThemeService>();
builder.Services.AddScoped<IAliasService, AliasService>();
builder.Services.AddScoped<ITenantService, TenantService>();
builder.Services.AddScoped<ISiteService, SiteService>();
builder.Services.AddScoped<IPageService, PageService>();
builder.Services.AddScoped<IModuleService, ModuleService>();
builder.Services.AddScoped<IPageModuleService, PageModuleService>();
builder.Services.AddScoped<IUserService, UserService>();
builder.Services.AddScoped<IProfileService, ProfileService>();
builder.Services.AddScoped<IRoleService, RoleService>();
builder.Services.AddScoped<IUserRoleService, UserRoleService>();
builder.Services.AddScoped<ISettingService, SettingService>();
builder.Services.AddScoped<IPackageService, PackageService>();
builder.Services.AddScoped<ILogService, LogService>();
builder.Services.AddScoped<IJobService, JobService>();
builder.Services.AddScoped<IJobLogService, JobLogService>();
builder.Services.AddScoped<INotificationService, NotificationService>();
builder.Services.AddScoped<IFolderService, FolderService>();
builder.Services.AddScoped<IFileService, FileService>();
builder.Services.AddScoped<ISiteTemplateService, SiteTemplateService>();
builder.Services.AddScoped<ISqlService, SqlService>();
// 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();
}
}
}

View File

@ -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<IdentityAuthenticationStateProvider>();
services.AddScoped<AuthenticationStateProvider>(s => s.GetRequiredService<IdentityAuthenticationStateProvider>());
// register scoped core services
services.AddScoped<SiteState>();
services.AddScoped<IInstallationService, InstallationService>();
services.AddScoped<IModuleDefinitionService, ModuleDefinitionService>();
services.AddScoped<IThemeService, ThemeService>();
services.AddScoped<IAliasService, AliasService>();
services.AddScoped<ITenantService, TenantService>();
services.AddScoped<ISiteService, SiteService>();
services.AddScoped<IPageService, PageService>();
services.AddScoped<IModuleService, ModuleService>();
services.AddScoped<IPageModuleService, PageModuleService>();
services.AddScoped<IUserService, UserService>();
services.AddScoped<IProfileService, ProfileService>();
services.AddScoped<IRoleService, RoleService>();
services.AddScoped<IUserRoleService, UserRoleService>();
services.AddScoped<ISettingService, SettingService>();
services.AddScoped<IPackageService, PackageService>();
services.AddScoped<ILogService, LogService>();
services.AddScoped<IJobService, JobService>();
services.AddScoped<IJobLogService, JobLogService>();
services.AddScoped<INotificationService, NotificationService>();
services.AddScoped<IFolderService, FolderService>();
services.AddScoped<IFileService, FileService>();
services.AddScoped<ISiteTemplateService, SiteTemplateService>();
services.AddScoped<ISqlService, SqlService>();
// 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>("app");
}
#endif
}
}

View File

@ -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];

View File

@ -54,7 +54,6 @@
}
menu += "<a href=\"" + p.Url + "\" class=\"nav-link\" style=\"padding-left: " + ((p.Level + 1) * 15).ToString() + "px !important;\"" + target + ">";
}
menu += "<a href=\string.Empty + NavigateUrl(p.Path) + "\" class=\"nav-link\" style=\"padding-left: " + ((p.Level + 1) * 15).ToString() + "px !important;\">";
if (p.HasChildren)
{
@ -114,14 +113,14 @@
if (p.PageId == PageState.Page.PageId)
{
menu += "<li class=\"nav-item active\">" +
"<a class=\"nav-link\" href=\string.Empty + NavigateUrl(p.Path) + "\">" +
"<a class=\"nav-link\" href=\"" + NavigateUrl(p.Path) + "\">" +
((p.Icon != string.Empty) ? "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span> " : string.Empty) +
p.Name + " <span class=\"sr-only\">(current)</span></a></li>";
}
else
{
menu += "<li class=\"nav-item\">" +
"<a class=\"nav-link\" href=\string.Empty + NavigateUrl(p.Path) + "\">" +
"<a class=\"nav-link\" href=\"" + NavigateUrl(p.Path) + "\">" +
((p.Icon != string.Empty) ? "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span> " : string.Empty) +
p.Name + "</a></li>";
}

View File

@ -4,7 +4,7 @@
@((MarkupString)title)
@code {
private title = "";
private string title = "";
protected override Task OnParametersSetAsync()
{

View File

@ -1,36 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width">
<title>Oqtane</title>
<base href="/" />
<link id="fav-icon" rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<!-- stub the PWA manifest but defer the assignment of href -->
<link id="pwa-manifest" rel="manifest" />
<link href="css/quill/quill1.3.6.bubble.css" rel="stylesheet" />
<link href="css/quill/quill1.3.6.snow.css" rel="stylesheet" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link href="css/app.css" rel="stylesheet" />
</head>
<body>
<app>
<div>
<img src="oqtane.png" style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);" />
</div>
</app>
<script src="js/site.js"></script>
<script src="js/interop.js"></script>
<script src="js/quill1.3.6.min.js"></script>
<script src="js/quill-blot-formatter.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="_framework/blazor.webassembly.js"></script>
</body>
</html>

View File

@ -3,12 +3,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>7.3</LangVersion>
<RestoreAdditionalProjectSources>
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
</RestoreAdditionalProjectSources>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<Configurations>Debug;Release;WebAssembly</Configurations>
<Configurations>Debug;Release</Configurations>
<Version>0.0.9</Version>
<Product>Oqtane</Product>
<Authors>Shaun Walker</Authors>
@ -22,10 +17,6 @@
<RootNamespace>Oqtane</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='WebAssembly|AnyCPU'">
<DefineConstants>TRACE;WASM</DefineConstants>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Scripts\Master.00.00.00.sql" />
<EmbeddedResource Include="Scripts\Master.00.00.01.sql" />
@ -34,13 +25,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="dbup" Version="4.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Server" Version="3.1.0-preview4.19579.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc3" />
<PackageReference Include="dbup" Version="4.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="3.2.0-preview3.20168.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.1.0" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
</ItemGroup>

View File

@ -1,6 +1,8 @@
@page "/"
@namespace Oqtane.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@using Microsoft.Extensions.Configuration
@inject IConfiguration Configuration
<!DOCTYPE html>
<html>
@ -19,7 +21,9 @@
</head>
<body>
@(Html.AntiForgeryToken())
<app>@(await Html.RenderComponentAsync<App>(RenderMode.Server))</app>
<app>
<component type="typeof(Oqtane.App)" render-mode="Server" />
</app>
<script src="js/site.js"></script>
<script src="js/interop.js"></script>
@ -28,6 +32,14 @@
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="_framework/blazor.server.js"></script>
@if (Configuration.GetSection("Runtime").Value == "WebAssembly")
{
<script src="_framework/blazor.webassembly.js"></script>
}
else
{
<script src="_framework/blazor.server.js"></script>
}
</body>
</html>

View File

@ -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<IServiceScopeFactory>().CreateScope())
{
var manager = serviceScope.ServiceProvider.GetService<DatabaseManager>();
manager.StartupMigration();
}
//DatabaseManager.StartupMigration();
host.Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
#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<Startup>()
.Build();
#endif
}
}

View File

@ -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"
},

View File

@ -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<SiteState>();
services.AddScoped<IAuthorizationHandler, PermissionHandler>();
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddDbContext<MasterDBContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")
.Replace("|DataDirectory|", AppDomain.CurrentDomain.GetData("DataDirectory").ToString())
));
services.AddDbContext<TenantDBContext>(options => { });
services.AddIdentityCore<IdentityUser>(options => { })
.AddEntityFrameworkStores<TenantDBContext>()
.AddSignInManager()
.AddDefaultTokenProviders();
services.Configure<IdentityOptions>(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<IUserClaimsPrincipalFactory<IdentityUser>, ClaimsPrincipalFactory<IdentityUser>>();
// register singleton scoped core services
services.AddSingleton<IConfigurationRoot>(Configuration);
services.AddSingleton<IInstallationManager, InstallationManager>();
services.AddSingleton<ISyncManager, SyncManager>();
// register transient scoped core services
services.AddTransient<IModuleDefinitionRepository, ModuleDefinitionRepository>();
services.AddTransient<IThemeRepository, ThemeRepository>();
services.AddTransient<IUserPermissions, UserPermissions>();
services.AddTransient<ITenantResolver, TenantResolver>();
services.AddTransient<IAliasRepository, AliasRepository>();
services.AddTransient<ITenantRepository, TenantRepository>();
services.AddTransient<ISiteRepository, SiteRepository>();
services.AddTransient<IPageRepository, PageRepository>();
services.AddTransient<IModuleRepository, ModuleRepository>();
services.AddTransient<IPageModuleRepository, PageModuleRepository>();
services.AddTransient<IUserRepository, UserRepository>();
services.AddTransient<IProfileRepository, ProfileRepository>();
services.AddTransient<IRoleRepository, RoleRepository>();
services.AddTransient<IUserRoleRepository, UserRoleRepository>();
services.AddTransient<IPermissionRepository, PermissionRepository>();
services.AddTransient<ISettingRepository, SettingRepository>();
services.AddTransient<ILogRepository, LogRepository>();
services.AddTransient<ILogManager, LogManager>();
services.AddTransient<IJobRepository, JobRepository>();
services.AddTransient<IJobLogRepository, JobLogRepository>();
services.AddTransient<INotificationRepository, NotificationRepository>();
services.AddTransient<IFolderRepository, FolderRepository>();
services.AddTransient<IFileRepository, FileRepository>();
services.AddTransient<ISiteTemplateRepository, SiteTemplateRepository>();
services.AddTransient<ISqlRepository, SqlRepository>();
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<Client.Startup>();
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<Client.Startup>("index.html");
});
}
#endif
}
}

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<LangVersion>7.3</LangVersion>
<Configurations>Debug;Release;WebAssembly</Configurations>
<Configurations>Debug;Release</Configurations>
<Version>0.0.9</Version>
<Product>Oqtane</Product>
<Authors>Shaun Walker</Authors>
@ -17,13 +17,9 @@
<RootNamespace>Oqtane</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='WebAssembly|AnyCPU'">
<DefineConstants>TRACE;WASM</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ComponentModel.Annotations" Version="4.6.0" />
<PackageReference Include="System.Text.Json" Version="4.6.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
<PackageReference Include="System.Text.Json" Version="4.7.1" />
</ItemGroup>
</Project>

View File

@ -6,9 +6,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.0-preview-20200310-03" />
<PackageReference Include="bunit" Version="1.0.0-beta-6" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="xunit.core" Version="2.4.1" />

View File

@ -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