Merge pull request #1423 from sbwalker/dev
made RenderMode configurable
This commit is contained in:
commit
c402113df3
|
@ -15,12 +15,20 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="runtime" HelpText="Blazor Runtime (Server or WebAssembly)" ResourceKey="BlazorRunime">Blazor Runtime: </Label>
|
||||
<Label For="runtime" HelpText="Blazor Runtime (Server or WebAssembly)" ResourceKey="BlazorRuntime">Blazor Runtime: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="runtime" class="form-control" @bind="@_runtime" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="rendermode" HelpText="Blazor Render Mode" ResourceKey="RenderMode">Render Mode: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="rendermode" class="form-control" @bind="@_rendermode" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="clrversion" HelpText="Common Language Runtime Version" ResourceKey="ClrVerion">CLR Version: </Label>
|
||||
|
@ -62,6 +70,7 @@
|
|||
|
||||
private string _version = string.Empty;
|
||||
private string _runtime = string.Empty;
|
||||
private string _rendermode = string.Empty;
|
||||
private string _clrversion = string.Empty;
|
||||
private string _osversion = string.Empty;
|
||||
private string _serverpath = string.Empty;
|
||||
|
@ -75,6 +84,7 @@
|
|||
Dictionary<string, string> systeminfo = await SystemService.GetSystemInfoAsync();
|
||||
if (systeminfo != null)
|
||||
{
|
||||
_rendermode = systeminfo["rendermode"];
|
||||
_clrversion = systeminfo["clrversion"];
|
||||
_osversion = systeminfo["osversion"];
|
||||
_serverpath = systeminfo["serverpath"];
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using Oqtane.Shared;
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -11,10 +12,12 @@ namespace Oqtane.Controllers
|
|||
public class SystemController : Controller
|
||||
{
|
||||
private readonly IWebHostEnvironment _environment;
|
||||
private readonly IConfigManager _configManager;
|
||||
|
||||
public SystemController(IWebHostEnvironment environment)
|
||||
public SystemController(IWebHostEnvironment environment, IConfigManager configManager)
|
||||
{
|
||||
_environment = environment;
|
||||
_configManager = configManager;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
|
@ -23,11 +26,14 @@ namespace Oqtane.Controllers
|
|||
public Dictionary<string, string> Get()
|
||||
{
|
||||
Dictionary<string, string> systeminfo = new Dictionary<string, string>();
|
||||
|
||||
systeminfo.Add("rendermode", _configManager.GetSetting("RenderMode", "Server"));
|
||||
systeminfo.Add("clrversion", Environment.Version.ToString());
|
||||
systeminfo.Add("osversion", Environment.OSVersion.ToString());
|
||||
systeminfo.Add("machinename", Environment.MachineName);
|
||||
systeminfo.Add("serverpath", _environment.ContentRootPath);
|
||||
systeminfo.Add("servertime", DateTime.Now.ToString());
|
||||
|
||||
return systeminfo;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,10 +20,23 @@ namespace Oqtane.Infrastructure
|
|||
return _config.GetSection(key);
|
||||
}
|
||||
|
||||
public string GetSetting(string sectionKey, string settingKey, string defaultValue)
|
||||
public T GetSetting<T>(string sectionKey, T defaultValue)
|
||||
{
|
||||
var value = _config.GetSection(sectionKey).GetValue(settingKey, defaultValue);
|
||||
if (string.IsNullOrEmpty(value)) value = defaultValue;
|
||||
return GetSetting(sectionKey, "", defaultValue);
|
||||
}
|
||||
|
||||
public T GetSetting<T>(string sectionKey, string settingKey, T defaultValue)
|
||||
{
|
||||
T value;
|
||||
if (!string.IsNullOrEmpty(settingKey))
|
||||
{
|
||||
value = _config.GetSection(sectionKey).GetValue(settingKey, defaultValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = _config.GetValue(sectionKey, defaultValue);
|
||||
}
|
||||
if (value == null) value = defaultValue;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace Oqtane.Infrastructure
|
|||
{
|
||||
File.Delete(destinationFile);
|
||||
}
|
||||
if (Path.GetExtension(destinationFile) == ".nupkg.bak")
|
||||
if (destinationFile.ToLower().EndsWith(".nupkg.bak"))
|
||||
{
|
||||
// leave a copy in the current folder as it is distributed with the core framework
|
||||
File.Copy(file, destinationFile);
|
||||
|
|
|
@ -5,7 +5,8 @@ namespace Oqtane.Infrastructure
|
|||
public interface IConfigManager
|
||||
{
|
||||
public IConfigurationSection GetSection(string sectionKey);
|
||||
public string GetSetting(string sectionKey, string settingKey, string defaultValue);
|
||||
public T GetSetting<T>(string settingKey, T defaultValue);
|
||||
public T GetSetting<T>(string sectionKey, string settingKey, T defaultValue);
|
||||
void AddOrUpdateSetting<T>(string key, T value, bool reload);
|
||||
void AddOrUpdateSetting<T>(string file, string key, T value, bool reload);
|
||||
void RemoveSetting(string key, bool reload);
|
||||
|
|
|
@ -41,6 +41,9 @@ namespace Oqtane.Infrastructure
|
|||
case "2.0.2":
|
||||
Upgrade_2_0_2(tenant, scope);
|
||||
break;
|
||||
case "2.1.0":
|
||||
Upgrade_2_1_0(tenant, scope);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,6 +116,18 @@ namespace Oqtane.Infrastructure
|
|||
}
|
||||
}
|
||||
|
||||
private void Upgrade_2_1_0(Tenant tenant, IServiceScope scope)
|
||||
{
|
||||
if (tenant.Name == TenantNames.Master)
|
||||
{
|
||||
_configManager.RemoveSetting("Localization:SupportedCultures", true);
|
||||
if (_configManager.GetSetting("RenderMode", "") == "")
|
||||
{
|
||||
_configManager.AddOrUpdateSetting("RenderMode", "ServerPrerendered", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateSitePages(IServiceScope scope, List<PageTemplate> pageTemplates)
|
||||
{
|
||||
if (pageTemplates.Count != 0)
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
@page "/"
|
||||
@namespace Oqtane.Pages
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@using Microsoft.Extensions.Configuration
|
||||
@inject IConfiguration Configuration
|
||||
@model Oqtane.Pages.HostModel
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -22,14 +20,7 @@
|
|||
<body>
|
||||
@(Html.AntiForgeryToken())
|
||||
<app>
|
||||
@if (Configuration.GetSection("Runtime").Value == "WebAssembly")
|
||||
{
|
||||
<component type="typeof(Oqtane.App)" render-mode="Server" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<component type="typeof(Oqtane.App)" render-mode="ServerPrerendered" />
|
||||
}
|
||||
<component type="typeof(Oqtane.App)" render-mode="@Model.RenderMode" />
|
||||
</app>
|
||||
|
||||
<div id="blazor-error-ui">
|
||||
|
@ -52,7 +43,7 @@
|
|||
|
||||
<script src="js/interop.js"></script>
|
||||
|
||||
@if (Configuration.GetSection("Runtime").Value == "WebAssembly")
|
||||
@if (Model.Runtime == "WebAssembly")
|
||||
{
|
||||
<script src="_framework/blazor.webassembly.js"></script>
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ using System.Reflection;
|
|||
using Oqtane.Repository;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
namespace Oqtane.Pages
|
||||
{
|
||||
|
@ -33,12 +34,24 @@ namespace Oqtane.Pages
|
|||
_languages = languages;
|
||||
}
|
||||
|
||||
public string Runtime = "Server";
|
||||
public RenderMode RenderMode = RenderMode.Server;
|
||||
public string HeadResources = "";
|
||||
public string BodyResources = "";
|
||||
public string Message = "";
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
if (_configuration.GetSection("Runtime").Exists())
|
||||
{
|
||||
Runtime = _configuration.GetSection("Runtime").Value;
|
||||
}
|
||||
|
||||
if (Runtime != "WebAssembly" && _configuration.GetSection("RenderMode").Exists())
|
||||
{
|
||||
RenderMode = (RenderMode)Enum.Parse(typeof(RenderMode), _configuration.GetSection("RenderMode").Value, true);
|
||||
}
|
||||
|
||||
var assemblies = AppDomain.CurrentDomain.GetOqtaneAssemblies();
|
||||
foreach (Assembly assembly in assemblies)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user