Merge pull request #1637 from sbwalker/dev
fix #1628 - make DBContext Transient, modify Control Panel to use standard Bootstrap 5 offcanvas classes, add auto trimming to file logger, fix issue in File Repository related to populating Url on Add/Update.
This commit is contained in:
commit
01c7a8fcdb
|
@ -14,182 +14,177 @@
|
||||||
|
|
||||||
@if (_moduleDefinitions != null && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.Permissions))
|
@if (_moduleDefinitions != null && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.Permissions))
|
||||||
{
|
{
|
||||||
<div class="offcanvas offcanvas-end" tabindex="-1" data-bs-scroll="true" data-bs-backdrop="true" id="offcanvasControlPanel" aria-labelledby="offcanvasControlPanelLabel">
|
<div class="offcanvas offcanvas-end" tabindex="-1" data-bs-scroll="true" data-bs-backdrop="true" id="offcanvasControlPanel" aria-labelledby="offcanvasScrollingLabel">
|
||||||
<div class="@CardClass">
|
<div class="@HeaderClass">
|
||||||
<div class="@HeaderClass d-flex">
|
<h5 id="offcanvasScrollingLabel">@Localizer["ControlPanel"]</h5>
|
||||||
<span class="font-weight-bold">@Localizer["ControlPanel"]</span>
|
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
||||||
<div class="ms-auto">
|
</div>
|
||||||
<button type="button" class="btn-close" aria-label="Close" data-bs-dismiss="offcanvas"></button>
|
<div class="@BodyClass">
|
||||||
|
@if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
|
||||||
|
{
|
||||||
|
<div class="row d-flex">
|
||||||
|
<div class="col">
|
||||||
|
<button data-bs-dismiss="offcanvas" type="button" class="btn btn-primary col-12" @onclick=@(async () => Navigate("Admin"))>@Localizer["AdminDash"]</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="@BodyClass">
|
|
||||||
|
|
||||||
@if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
|
<hr class="app-rule" />
|
||||||
{
|
|
||||||
<div class="row d-flex">
|
|
||||||
<div class="col">
|
|
||||||
<button data-bs-dismiss="offcanvas" type="button" class="btn btn-primary col-12" @onclick=@(async () => Navigate("Admin"))>@Localizer["AdminDash"]</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr class="app-rule" />
|
<div class="row">
|
||||||
|
<div class="col text-center">
|
||||||
|
<label class="control-label">@Localizer["Page.Manage"] </label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row d-flex">
|
||||||
|
<div class="col d-flex justify-content-between">
|
||||||
|
<button type="button" class="btn btn-secondary col-3" data-bs-dismiss="offcanvas" @onclick=@(async () => Navigate("Add"))>@SharedLocalizer["Add"]</button>
|
||||||
|
<button type="button" class="btn btn-secondary col-3" data-bs-dismiss="offcanvas" @onclick=@(async () => Navigate("Edit"))>@SharedLocalizer["Edit"]</button>
|
||||||
|
<button type="button" class="btn btn-danger col-3" @onclick="ConfirmDelete">@SharedLocalizer["Delete"]</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<div class="row d-flex">
|
||||||
|
<div class="col">
|
||||||
|
@if (UserSecurity.GetPermissionStrings(PageState.Page.Permissions).FirstOrDefault(item => item.PermissionName == PermissionNames.View).Permissions.Split(';').Contains(RoleNames.Everyone))
|
||||||
|
{
|
||||||
|
<button type="button" class="btn btn-secondary col-12" @onclick=@(async () => Publish("unpublish"))>@Localizer["Page.Unpublish"]</button>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<button type="button" class="btn btn-secondary col-12" @onclick=@(async () => Publish("publish"))>@Localizer["Page.Publish"]</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
<div class="row">
|
@if (_deleteConfirmation)
|
||||||
<div class="col text-center">
|
{
|
||||||
<label class="control-label">@Localizer["Page.Manage"] </label>
|
<div class="app-admin-modal">
|
||||||
</div>
|
<div class="modal" tabindex="-1" role="dialog">
|
||||||
</div>
|
<div class="modal-dialog">
|
||||||
<div class="row d-flex">
|
<div class="modal-content">
|
||||||
<div class="col d-flex justify-content-between">
|
<div class="modal-header">
|
||||||
<button type="button" class="btn btn-secondary col-3" data-bs-dismiss="offcanvas" @onclick=@(async () => Navigate("Add"))>@SharedLocalizer["Add"]</button>
|
<h5 class="modal-title">@Localizer["Page.Delete"]</h5>
|
||||||
<button type="button" class="btn btn-secondary col-3" data-bs-dismiss="offcanvas" @onclick=@(async () => Navigate("Edit"))>@SharedLocalizer["Edit"]</button>
|
<button type="button" class="btn-close" aria-label="Close" @onclick="ConfirmDelete"></button>
|
||||||
<button type="button" class="btn btn-danger col-3" @onclick="ConfirmDelete">@SharedLocalizer["Delete"]</button>
|
</div>
|
||||||
</div>
|
<div class="modal-body">
|
||||||
</div>
|
<p>Are You Sure You Want To Delete This Page?</p>
|
||||||
<br />
|
</div>
|
||||||
<div class="row d-flex">
|
<div class="modal-footer">
|
||||||
<div class="col">
|
<button type="button" class="btn btn-danger" @onclick="DeletePage">@SharedLocalizer["Delete"]</button>
|
||||||
@if (UserSecurity.GetPermissionStrings(PageState.Page.Permissions).FirstOrDefault(item => item.PermissionName == PermissionNames.View).Permissions.Split(';').Contains(RoleNames.Everyone))
|
<button type="button" class="btn btn-secondary" @onclick="ConfirmDelete">@SharedLocalizer["Cancel"]</button>
|
||||||
{
|
|
||||||
<button type="button" class="btn btn-secondary col-12" @onclick=@(async () => Publish("unpublish"))>@Localizer["Page.Unpublish"]</button>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<button type="button" class="btn btn-secondary col-12" @onclick=@(async () => Publish("publish"))>@Localizer["Page.Publish"]</button>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
@if (_deleteConfirmation)
|
|
||||||
{
|
|
||||||
<div class="app-admin-modal">
|
|
||||||
<div class="modal" tabindex="-1" role="dialog">
|
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title">@Localizer["Page.Delete"]</h5>
|
|
||||||
<button type="button" class="btn-close" aria-label="Close" @onclick="ConfirmDelete"></button>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<p>Are You Sure You Want To Delete This Page?</p>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-danger" @onclick="DeletePage">@SharedLocalizer["Delete"]</button>
|
|
||||||
<button type="button" class="btn btn-secondary" @onclick="ConfirmDelete">@SharedLocalizer["Cancel"]</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
</div>
|
||||||
<hr class="app-rule" />
|
}
|
||||||
<div class="row">
|
<hr class="app-rule" />
|
||||||
<div class="col text-center">
|
<div class="row">
|
||||||
<label for="Module" class="control-label">@Localizer["Module.Manage"] </label>
|
<div class="col text-center">
|
||||||
<select class="form-select" @bind="@ModuleType">
|
<label for="Module" class="control-label">@Localizer["Module.Manage"] </label>
|
||||||
<option value="new">@Localizer["Module.AddNew"]</option>
|
<select class="form-select" @bind="@ModuleType">
|
||||||
<option value="existing">@Localizer["Module.AddExisting"]</option>
|
<option value="new">@Localizer["Module.AddNew"]</option>
|
||||||
</select>
|
<option value="existing">@Localizer["Module.AddExisting"]</option>
|
||||||
@if (ModuleType == "new")
|
</select>
|
||||||
|
@if (ModuleType == "new")
|
||||||
|
{
|
||||||
|
@if (_moduleDefinitions != null)
|
||||||
{
|
{
|
||||||
@if (_moduleDefinitions != null)
|
<select class="form-select" @onchange="(e => CategoryChanged(e))">
|
||||||
{
|
@foreach (var category in _categories)
|
||||||
<select class="form-select" @onchange="(e => CategoryChanged(e))">
|
{
|
||||||
@foreach (var category in _categories)
|
if (category == Category)
|
||||||
{
|
{
|
||||||
if (category == Category)
|
<option value="@category" selected>@category @Localizer["Modules"]</option>
|
||||||
{
|
|
||||||
<option value="@category" selected>@category @Localizer["Modules"]</option>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<option value="@category">@category @Localizer["Modules"]</option>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
<select class="form-select" @onchange="(e => ModuleChanged(e))">
|
|
||||||
@if (ModuleDefinitionName == "-")
|
|
||||||
{
|
|
||||||
<option value="-" selected><@Localizer["Module.Select"]></option>
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<option value="-"><@Localizer["Module.Select"]></option>
|
<option value="@category">@category @Localizer["Modules"]</option>
|
||||||
}
|
}
|
||||||
@foreach (var moduledefinition in _moduleDefinitions)
|
}
|
||||||
|
</select>
|
||||||
|
<select class="form-select" @onchange="(e => ModuleChanged(e))">
|
||||||
|
@if (ModuleDefinitionName == "-")
|
||||||
|
{
|
||||||
|
<option value="-" selected><@Localizer["Module.Select"]></option>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<option value="-"><@Localizer["Module.Select"]></option>
|
||||||
|
}
|
||||||
|
@foreach (var moduledefinition in _moduleDefinitions)
|
||||||
|
{
|
||||||
|
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Utilize, moduledefinition.Permissions))
|
||||||
{
|
{
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Utilize, moduledefinition.Permissions))
|
if (moduledefinition.Runtimes == "" || moduledefinition.Runtimes.Contains(PageState.Runtime.ToString()))
|
||||||
{
|
{
|
||||||
if (moduledefinition.Runtimes == "" || moduledefinition.Runtimes.Contains(PageState.Runtime.ToString()))
|
<option value="@moduledefinition.ModuleDefinitionName">@moduledefinition.Name</option>
|
||||||
{
|
|
||||||
<option value="@moduledefinition.ModuleDefinitionName">@moduledefinition.Name</option>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</select>
|
}
|
||||||
@((MarkupString) Description)
|
</select>
|
||||||
}
|
@((MarkupString) Description)
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
<select class="form-select" @onchange="(e => PageChanged(e))">
|
{
|
||||||
<option value="-"><@Localizer["Page.Select"]></option>
|
<select class="form-select" @onchange="(e => PageChanged(e))">
|
||||||
@foreach (Page p in _pages)
|
<option value="-"><@Localizer["Page.Select"]></option>
|
||||||
{
|
@foreach (Page p in _pages)
|
||||||
<option value="@p.PageId">@p.Name</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
<select class="form-select" @bind="@ModuleId">
|
|
||||||
<option value="-"><@Localizer["Module.Select"]></option>
|
|
||||||
@foreach (Module module in _modules)
|
|
||||||
{
|
|
||||||
<option value="@module.ModuleId">@module.Title</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col text-center">
|
|
||||||
<label for="Title" class="control-label">@Localizer["Title"] </label>
|
|
||||||
<input type="text" name="Title" class="form-control" @bind="@Title" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@if (_pane.Length > 1)
|
|
||||||
{
|
|
||||||
<div class="row">
|
|
||||||
<div class="col text-center">
|
|
||||||
<label for="Pane" class="control-label">@Localizer["Pane"] </label>
|
|
||||||
<select class="form-select" @bind="@Pane">
|
|
||||||
@foreach (string pane in PageState.Page.Panes)
|
|
||||||
{
|
|
||||||
<option value="@pane">@pane Pane</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col text-center">
|
|
||||||
<label for="Container" class="control-label">@Localizer["Container"] </label>
|
|
||||||
<select class="form-select" @bind="@ContainerType">
|
|
||||||
@foreach (var container in _containers)
|
|
||||||
{
|
{
|
||||||
<option value="@container.TypeName">@container.Name</option>
|
<option value="@p.PageId">@p.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
<select class="form-select" @bind="@ModuleId">
|
||||||
|
<option value="-"><@Localizer["Module.Select"]></option>
|
||||||
|
@foreach (Module module in _modules)
|
||||||
|
{
|
||||||
|
<option value="@module.ModuleId">@module.Title</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col text-center">
|
||||||
|
<label for="Title" class="control-label">@Localizer["Title"] </label>
|
||||||
|
<input type="text" name="Title" class="form-control" @bind="@Title" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (_pane.Length > 1)
|
||||||
|
{
|
||||||
|
<div class="row">
|
||||||
|
<div class="col text-center">
|
||||||
|
<label for="Pane" class="control-label">@Localizer["Pane"] </label>
|
||||||
|
<select class="form-select" @bind="@Pane">
|
||||||
|
@foreach (string pane in PageState.Page.Panes)
|
||||||
|
{
|
||||||
|
<option value="@pane">@pane Pane</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
}
|
||||||
<button type="button" class="btn btn-primary col-12" @onclick="@AddModule">@Localizer["Page.Module.Add"]</button>
|
<div class="row">
|
||||||
@((MarkupString) Message)
|
<div class="col text-center">
|
||||||
@if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
<label for="Container" class="control-label">@Localizer["Container"] </label>
|
||||||
{
|
<select class="form-select" @bind="@ContainerType">
|
||||||
<hr class="app-rule" />
|
@foreach (var container in _containers)
|
||||||
<NavLink class="btn btn-info col-12" href="@NavigateUrl("admin/update")">@Localizer["System.Update"]</NavLink>
|
{
|
||||||
}
|
<option value="@container.TypeName">@container.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<br />
|
||||||
|
<button type="button" class="btn btn-primary col-12" @onclick="@AddModule">@Localizer["Page.Module.Add"]</button>
|
||||||
|
@((MarkupString) Message)
|
||||||
|
@if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||||
|
{
|
||||||
|
<hr class="app-rule" />
|
||||||
|
<NavLink class="btn btn-info col-12" data-bs-dismiss="offcanvas" href="@NavigateUrl("admin/update")">@Localizer["System.Update"]</NavLink>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
@ -280,13 +275,10 @@
|
||||||
public string ButtonClass { get; set; } = "btn-outline-secondary";
|
public string ButtonClass { get; set; } = "btn-outline-secondary";
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string CardClass { get; set; } = "card border-secondary mb-3";
|
public string HeaderClass { get; set; } = "offcanvas-header";
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string HeaderClass { get; set; } = "card-header";
|
public string BodyClass { get; set; } = "offcanvas-body overflow-auto";
|
||||||
|
|
||||||
[Parameter]
|
|
||||||
public string BodyClass { get; set; } = "card-body";
|
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public bool ShowLanguageSwitcher { get; set; } = true;
|
public bool ShowLanguageSwitcher { get; set; } = true;
|
||||||
|
|
|
@ -35,8 +35,8 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
|
|
||||||
public static IServiceCollection AddOqtaneDbContext(this IServiceCollection services)
|
public static IServiceCollection AddOqtaneDbContext(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddDbContext<MasterDBContext>(options => { });
|
services.AddDbContext<MasterDBContext>(options => { }, ServiceLifetime.Transient);
|
||||||
services.AddDbContext<TenantDBContext>(options => { });
|
services.AddDbContext<TenantDBContext>(options => { }, ServiceLifetime.Transient);
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,12 @@ namespace Oqtane.Infrastructure
|
||||||
|
|
||||||
var filepath = Path.Combine(folder, "error.log");
|
var filepath = Path.Combine(folder, "error.log");
|
||||||
|
|
||||||
|
// only retain an error log for the current day as it is intended for development purposes
|
||||||
|
if (File.GetCreationTime(filepath).ToUniversalTime().Date < DateTime.UtcNow.Date && File.Exists(filepath))
|
||||||
|
{
|
||||||
|
File.Delete(filepath);
|
||||||
|
}
|
||||||
|
|
||||||
var logentry = string.Format("{0} [{1}] {2} {3}", "[" + DateTimeOffset.UtcNow.ToString("yyyy-MM-dd HH:mm:ss+00:00") + "]", logLevel.ToString(), formatter(state, exception), exception != null ? exception.StackTrace : "");
|
var logentry = string.Format("{0} [{1}] {2} {3}", "[" + DateTimeOffset.UtcNow.ToString("yyyy-MM-dd HH:mm:ss+00:00") + "]", logLevel.ToString(), formatter(state, exception), exception != null ? exception.StackTrace : "");
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -42,6 +42,7 @@ namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
_db.File.Add(file);
|
_db.File.Add(file);
|
||||||
_db.SaveChanges();
|
_db.SaveChanges();
|
||||||
|
file.Folder = _folderRepository.GetFolder(file.FolderId);
|
||||||
file.Url = GetFileUrl(file, _tenants.GetAlias());
|
file.Url = GetFileUrl(file, _tenants.GetAlias());
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +51,7 @@ namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
_db.Entry(file).State = EntityState.Modified;
|
_db.Entry(file).State = EntityState.Modified;
|
||||||
_db.SaveChanges();
|
_db.SaveChanges();
|
||||||
|
file.Folder = _folderRepository.GetFolder(file.FolderId);
|
||||||
file.Url = GetFileUrl(file, _tenants.GetAlias());
|
file.Url = GetFileUrl(file, _tenants.GetAlias());
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user