Skip to content

Commit

Permalink
Merge pull request #4468 from oqtane/dev
Browse files Browse the repository at this point in the history
5.2.0 release
  • Loading branch information
sbwalker authored Jul 25, 2024
2 parents 5fbd64d + a129dd9 commit c93e70e
Show file tree
Hide file tree
Showing 150 changed files with 5,466 additions and 1,793 deletions.
5 changes: 5 additions & 0 deletions Oqtane.Client/Extensions/OqtaneServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Components.Authorization;
using Oqtane.Interfaces;
using Oqtane.Providers;
using Oqtane.Services;
using Oqtane.Shared;
Expand Down Expand Up @@ -51,6 +52,10 @@ public static IServiceCollection AddOqtaneClientScopedServices(this IServiceColl
services.AddScoped<IVisitorService, VisitorService>();
services.AddScoped<ISyncService, SyncService>();

// providers
services.AddScoped<ITextEditor, Oqtane.Modules.Controls.QuillJSTextEditor>();
services.AddScoped<ITextEditor, Oqtane.Modules.Controls.TextAreaTextEditor>();

return services;
}
}
Expand Down
19 changes: 19 additions & 0 deletions Oqtane.Client/Modules/Admin/Files/ModuleInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Oqtane.Documentation;
using Oqtane.Models;
using Oqtane.Shared;

namespace Oqtane.Modules.Admin.Files
{
[PrivateApi("Mark this as private, since it's not very useful in the public docs")]
public class ModuleInfo : IModule
{
public ModuleDefinition ModuleDefinition => new ModuleDefinition
{
Name = "File Management",
Description = "File Management",
Version = Constants.Version,
Categories = "Admin",
ServerManagerType = "Oqtane.Modules.Admin.Files.Manager.FileManager, Oqtane.Server"
};
}
}
22 changes: 14 additions & 8 deletions Oqtane.Client/Modules/Admin/Jobs/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
}
else
{
<ActionLink Action="Log" Class="btn btn-secondary" Text="View Logs" ResourceKey="ViewJobs" />
<button type="button" class="btn btn-secondary" @onclick="(async () => await Refresh())">@Localizer["Refresh.Text"]</button>
<br />
<button type="button" class="btn btn-secondary" @onclick="Refresh">@Localizer["Refresh.Text"]</button>
<br />

<Pager Items="@_jobs" SearchProperties="Name">
Expand Down Expand Up @@ -44,21 +42,29 @@ else
</td>
</Row>
</Pager>

<br />
<ActionLink Action="Log" Class="btn btn-secondary" Text="View All Logs" ResourceKey="ViewLogs" />
}

@code {
private List<Job> _jobs;

public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }

protected override async Task OnInitializedAsync()
{
_jobs = await JobService.GetJobsAsync();
await GetJobs();
if (_jobs.Count == 0)
{
AddModuleMessage(string.Format(Localizer["Message.NoJobs"], NavigateUrl("admin/system")), MessageType.Warning);
}
}
}

private async Task GetJobs()
{
_jobs = await JobService.GetJobsAsync();
}

private string DisplayStatus(bool isEnabled, bool isExecuting)
{
Expand Down Expand Up @@ -146,7 +152,7 @@ else

private async Task Refresh()
{
_jobs = await JobService.GetJobsAsync();
await GetJobs();
StateHasChanged();
}
}
14 changes: 14 additions & 0 deletions Oqtane.Client/Modules/Admin/Jobs/Log.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
}
else
{
<button type="button" class="btn btn-secondary" @onclick="Refresh">@Localizer["Refresh"]</button>
<br /><br />

<Pager Items="@_jobLogs">
<Header>
<th>@SharedLocalizer["Name"]</th>
Expand All @@ -35,6 +38,11 @@ else
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;

protected override async Task OnParametersSetAsync()
{
await GetJobLogs();
}

private async Task GetJobLogs()
{
_jobLogs = await JobLogService.GetJobLogsAsync();

Expand Down Expand Up @@ -67,4 +75,10 @@ else

return status;
}

private async Task Refresh()
{
await GetJobLogs();
StateHasChanged();
}
}
1 change: 1 addition & 0 deletions Oqtane.Client/Modules/Admin/Login/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
private string _code = string.Empty;

public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
public override bool? Prerender => true;

public override List<Resource> Resources => new List<Resource>()
{
Expand Down
2 changes: 1 addition & 1 deletion Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<TabPanel Name="Upload" ResourceKey="Upload" Heading="Upload">
<div class="container">
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" HelpText="Upload one or more module packages. Once they are uploaded click Install to complete the installation." ResourceKey="Module">Module: </Label>
<Label Class="col-sm-3" HelpText="Upload one or more module packages." ResourceKey="Module">Module: </Label>
<div class="col-sm-9">
<FileManager Folder="@Constants.PackagesFolder" UploadMultiple="true" OnUpload="OnUpload" />
</div>
Expand Down
9 changes: 6 additions & 3 deletions Oqtane.Client/Modules/Admin/ModuleDefinitions/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@inject IStringLocalizer<SharedResources> SharedLocalizer
@inject IPageModuleService PageModuleService
@inject IModuleService ModuleService
@inject IPageService PageService

@if (_initialized)
{
Expand Down Expand Up @@ -307,13 +308,15 @@
}

// get distinct pages where module exists
var distinctPageIds = PageState.Modules
var modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId);
var distinctPageIds = modules
.Where(md => md.ModuleDefinition?.ModuleDefinitionId == _moduleDefinitionId && md.IsDeleted == false)
.Select(md => md.PageId)
.Distinct();

// Filter and retrieve the corresponding pages
_pagesWithModules = PageState.Pages
// retrieve the pages which contain the module
var pages = await PageService.GetPagesAsync(PageState.Site.SiteId);
_pagesWithModules = pages
.Where(pg => distinctPageIds.Contains(pg.PageId) && pg.IsDeleted == false)
.ToList();

Expand Down
5 changes: 4 additions & 1 deletion Oqtane.Client/Modules/Admin/ModuleDefinitions/Index.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@namespace Oqtane.Modules.Admin.ModuleDefinitions
@inherits ModuleBase
@inject NavigationManager NavigationManager
@inject IModuleService ModuleService
@inject IModuleDefinitionService ModuleDefinitionService
@inject IPackageService PackageService
@inject IStringLocalizer<Index> Localizer
Expand Down Expand Up @@ -70,7 +71,7 @@ else
}
</td>
<td>
@if (context.AssemblyName == Constants.ClientId || PageState.Modules.Where(m => m.ModuleDefinition?.ModuleDefinitionId == context.ModuleDefinitionId).FirstOrDefault() != null)
@if (context.AssemblyName == Constants.ClientId || _modules.Where(m => m.ModuleDefinition?.ModuleDefinitionId == context.ModuleDefinitionId).FirstOrDefault() != null)
{
<span>@SharedLocalizer["Yes"]</span>
}
Expand Down Expand Up @@ -99,6 +100,7 @@ else
}

@code {
private List<Module> _modules;
private List<ModuleDefinition> _allModuleDefinitions;
private List<ModuleDefinition> _moduleDefinitions;
private List<Package> _packages;
Expand All @@ -111,6 +113,7 @@ else
{
try
{
_modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId);
_allModuleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
_categories = _allModuleDefinitions.SelectMany(m => m.Categories.Split(',')).Distinct().ToList();
await LoadModuleDefinitions();
Expand Down
19 changes: 12 additions & 7 deletions Oqtane.Client/Modules/Admin/Modules/Settings.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@inherits ModuleBase
@inject NavigationManager NavigationManager
@inject IThemeService ThemeService
@inject IPageService PageService
@inject IModuleService ModuleService
@inject IPageModuleService PageModuleService
@inject IStringLocalizer<Settings> Localizer
Expand Down Expand Up @@ -79,14 +80,16 @@
}
else
{
foreach (Page p in PageState.Pages)
if (_pages != null)
{
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, p.PermissionList))
foreach (Page p in _pages)
{
<option value="@p.PageId">@(new string('-', p.Level * 2))@(p.Name)</option>
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, p.PermissionList))
{
<option value="@p.PageId">@(new string('-', p.Level * 2))@(p.Name)</option>
}
}
}

}
</select>
</div>
Expand Down Expand Up @@ -154,10 +157,12 @@
private DateTime modifiedon;
private DateTime? _effectivedate = null;
private DateTime? _expirydate = null;
private List<Page> _pages;

protected override void OnInitialized()
protected override async Task OnInitializedAsync()
{
SetModuleTitle(Localizer["ModuleSettings.Title"]);

_module = ModuleState.ModuleDefinition.Name;
_title = ModuleState.Title;
_moduleSettingsTitle = Localizer["ModuleSettings.Heading"];
Expand All @@ -173,8 +178,8 @@
modifiedon = ModuleState.ModifiedOn;
_effectivedate = Utilities.UtcAsLocalDate(ModuleState.EffectiveDate);
_expirydate = Utilities.UtcAsLocalDate(ModuleState.ExpiryDate);

_pages = await PageService.GetPagesAsync(PageState.Site.SiteId);

if (ModuleState.ModuleDefinition != null)
{
_permissionNames = ModuleState.ModuleDefinition?.PermissionNames;
Expand Down
18 changes: 10 additions & 8 deletions Oqtane.Client/Modules/Admin/Pages/Add.razor
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div class="col-sm-9">
<select id="parent" class="form-select" value="@_parentid" @onchange="(e => ParentChanged(e))" required>
<option value="-1">&lt;@Localizer["SiteRoot"]&gt;</option>
@foreach (Page page in PageState.Pages)
@foreach (Page page in _pages)
{
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, page.PermissionList))
{
Expand Down Expand Up @@ -213,6 +213,7 @@
private bool validated = false;
private List<ThemeControl> _themes = new List<ThemeControl>();
private List<ThemeControl> _containers = new List<ThemeControl>();
private List<Page> _pages;
private int _pageId;
private string _name;
private string _parentid = "-1";
Expand Down Expand Up @@ -243,6 +244,8 @@
{
try
{
_pages = await PageService.GetPagesAsync(PageState.Site.SiteId);

if (PageState.QueryString.ContainsKey("id"))
{
_pageId = Int32.Parse(PageState.QueryString["id"]);
Expand All @@ -263,7 +266,7 @@
_containers = ThemeService.GetContainerControls(PageState.Site.Themes, _themetype);
_containertype = PageState.Site.DefaultContainerType;
_children = new List<Page>();
foreach (Page p in PageState.Pages.Where(item => (_parentid == "-1" && item.ParentId == null) || (item.ParentId == int.Parse(_parentid))))
foreach (Page p in _pages.Where(item => (_parentid == "-1" && item.ParentId == null) || (item.ParentId == int.Parse(_parentid))))
{
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.PermissionList))
{
Expand Down Expand Up @@ -293,7 +296,7 @@
{
_parentid = (string)e.Value;
_children = new List<Page>();
foreach (Page p in PageState.Pages.Where(item => (_parentid == "-1" && item.ParentId == null) || (item.ParentId == int.Parse(_parentid))))
foreach (Page p in _pages.Where(item => (_parentid == "-1" && item.ParentId == null) || (item.ParentId == int.Parse(_parentid))))
{
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.PermissionList))
{
Expand Down Expand Up @@ -371,7 +374,7 @@
}
else
{
Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == page.ParentId);
Page parent = _pages.FirstOrDefault(item => item.PageId == page.ParentId);
if (parent.Path == string.Empty)
{
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path);
Expand All @@ -382,7 +385,6 @@
}
}

var _pages = await PageService.GetPagesAsync(PageState.Site.SiteId);
if (_pages.Any(item => item.Path == page.Path))
{
AddModuleMessage(string.Format(Localizer["Message.Page.Exists"], _path), MessageType.Warning);
Expand All @@ -402,11 +404,11 @@
page.Order = 0;
break;
case "<":
child = PageState.Pages.Where(item => item.PageId == _childid).FirstOrDefault();
child = _pages.Where(item => item.PageId == _childid).FirstOrDefault();
page.Order = child.Order - 1;
break;
case ">":
child = PageState.Pages.Where(item => item.PageId == _childid).FirstOrDefault();
child = _pages.Where(item => item.PageId == _childid).FirstOrDefault();
page.Order = child.Order + 1;
break;
case ">>":
Expand Down Expand Up @@ -449,7 +451,7 @@
await logger.LogInformation("Page Added {Page}", page);
if (!string.IsNullOrEmpty(PageState.ReturnUrl))
{
NavigationManager.NavigateTo(page.Path, true); // redirect to page added and reload
NavigationManager.NavigateTo(NavigateUrl(page.Path), true); // redirect to page added and reload
}
else
{
Expand Down
Loading

0 comments on commit c93e70e

Please sign in to comment.