Merge pull request #1451 from sbwalker/dev
allow host to change runtime and rendermode settings in System Info
This commit is contained in:
commit
aa30caa1a7
|
@ -18,15 +18,21 @@
|
||||||
<Label For="runtime" HelpText="Blazor Runtime (Server or WebAssembly)" ResourceKey="BlazorRuntime">Blazor Runtime: </Label>
|
<Label For="runtime" HelpText="Blazor Runtime (Server or WebAssembly)" ResourceKey="BlazorRuntime">Blazor Runtime: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input id="runtime" class="form-control" @bind="@_runtime" readonly />
|
<select id="runtime" class="form-control" @bind="@_runtime">
|
||||||
|
<option value="Server">@Localizer["Server"]</option>
|
||||||
|
<option value="WebAssembly">@Localizer["WebAssembly"]</option>
|
||||||
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="rendermode" HelpText="Blazor Render Mode" ResourceKey="RenderMode">Render Mode: </Label>
|
<Label For="rendermode" HelpText="Blazor Server Render Mode" ResourceKey="RenderMode">Render Mode: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input id="rendermode" class="form-control" @bind="@_rendermode" readonly />
|
<select id="rendermode" class="form-control" @bind="@_rendermode">
|
||||||
|
<option value="Server">@Localizer["Server"]</option>
|
||||||
|
<option value="ServerPrerendered">@Localizer["ServerPrerendered"]</option>
|
||||||
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -62,6 +68,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
<button type="button" class="btn btn-success" @onclick="SaveConfig">@Localizer["Save"]</button>
|
||||||
<a class="btn btn-primary" href="swagger/index.html" target="_new">@Localizer["Access Framework API"]</a>
|
<a class="btn btn-primary" href="swagger/index.html" target="_new">@Localizer["Access Framework API"]</a>
|
||||||
<ActionDialog Header="Restart Application" Message="Are You Sure You Wish To Restart The Application?" Action="Restart Application" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await RestartApplication())" ResourceKey="RestartApplication" />
|
<ActionDialog Header="Restart Application" Message="Are You Sure You Wish To Restart The Application?" Action="Restart Application" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await RestartApplication())" ResourceKey="RestartApplication" />
|
||||||
|
|
||||||
|
@ -92,6 +99,23 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task SaveConfig()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var settings = new Dictionary<string, string>();
|
||||||
|
settings.Add("runtime", _runtime);
|
||||||
|
settings.Add("rendermode", _rendermode);
|
||||||
|
await SystemService.UpdateSystemInfoAsync(settings);
|
||||||
|
AddModuleMessage(Localizer["Configuration Updated. Please Select Restart Application For These Changes To Be Activated."], MessageType.Success);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Saving Configuration");
|
||||||
|
AddModuleMessage(Localizer["An Error Occurred Updating The Configuration"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task RestartApplication()
|
private async Task RestartApplication()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Oqtane.Services
|
namespace Oqtane.Services
|
||||||
|
@ -6,5 +6,7 @@ namespace Oqtane.Services
|
||||||
public interface ISystemService
|
public interface ISystemService
|
||||||
{
|
{
|
||||||
Task<Dictionary<string, string>> GetSystemInfoAsync();
|
Task<Dictionary<string, string>> GetSystemInfoAsync();
|
||||||
|
|
||||||
|
Task UpdateSystemInfoAsync(Dictionary<string, string> settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,5 +22,10 @@ namespace Oqtane.Services
|
||||||
{
|
{
|
||||||
return await GetJsonAsync<Dictionary<string, string>>(Apiurl);
|
return await GetJsonAsync<Dictionary<string, string>>(Apiurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task UpdateSystemInfoAsync(Dictionary<string, string> settings)
|
||||||
|
{
|
||||||
|
await PostJsonAsync(Apiurl, settings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,5 +37,23 @@ namespace Oqtane.Controllers
|
||||||
return systeminfo;
|
return systeminfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
|
public void Post([FromBody] Dictionary<string, string> settings)
|
||||||
|
{
|
||||||
|
foreach(KeyValuePair<string, string> kvp in settings)
|
||||||
|
{
|
||||||
|
switch (kvp.Key)
|
||||||
|
{
|
||||||
|
case "runtime":
|
||||||
|
_configManager.AddOrUpdateSetting("Runtime", kvp.Value, false);
|
||||||
|
break;
|
||||||
|
case "rendermode":
|
||||||
|
_configManager.AddOrUpdateSetting("RenderMode", kvp.Value, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user