This commit is contained in:
2021-11-22 16:03:02 +01:00
parent 8827f65f92
commit 86263bbd8d
22 changed files with 133 additions and 129 deletions
-28
View File
@@ -1,28 +0,0 @@
namespace zero.Core.Entities
{
/// <summary>
/// Define a backoffice icon set
/// </summary>
public class IconSet
{
/// <summary>
/// The alias
/// </summary>
public string Alias { get; set; }
/// <summary>
/// Name of the icon set
/// </summary>
public string Name { get; set; }
/// <summary>
/// Prefix for addressing symbols (by default the alias)
/// </summary>
public string Prefix { get; set; }
/// <summary>
/// Path to the SVG sprite
/// </summary>
public string SpritePath { get; set; }
}
}
@@ -8,13 +8,6 @@ namespace zero.Web.Defaults
{
internal class ZeroBackofficePlugin : ZeroPlugin
{
public ZeroBackofficePlugin()
{
Options.Name = "zero.Defaults";
Options.LocalizationPaths.Add("~/Resources/Localization/zero.{lang}.json");
}
public override void Configure(IZeroOptions zero)
{
zero.Sections.Add<DashboardSection>();
@@ -31,12 +24,7 @@ namespace zero.Web.Defaults
zero.Permissions.AddCollection<SettingsPermissions>();
zero.Permissions.AddCollection<SpacePermissions>();
zero.Icons.AddSet("feather", "Feather", "/assets/icons/feather.svg", "fth");
zero.Pages.Add<PageFolder>(Constants.Pages.FolderAlias, "@page.folder.name", "@page.folder.description", "fth-folder");
zero.Interceptors.Add<ZeroEntityRouteInterceptor, ZeroEntity>(gravity: 100);
zero.Interceptors.Add<BlueprintInterceptor>(gravity: -1);
zero.Interceptors.Add<BlueprintChildInterceptor>(gravity: -1);
}
@@ -0,0 +1,27 @@
namespace zero.Backoffice.Configuration;
/// <summary>
/// Define a backoffice icon set
/// </summary>
public class BackofficeIconSet
{
/// <summary>
/// The alias for reference
/// </summary>
public string Alias { get; set; }
/// <summary>
/// Name of the icon set
/// </summary>
public string Name { get; set; }
/// <summary>
/// Optional symbol identifier prefix (by default the alias is used)
/// </summary>
public string Prefix { get; set; }
/// <summary>
/// Path to the SVG sprite containing addressable symbols
/// </summary>
public string SpritePath { get; set; }
}
@@ -0,0 +1,29 @@
namespace zero.Backoffice.Configuration;
public class BackofficeOptions
{
/// <summary>
/// URL path to the backoffice (defaults to /zero)
/// </summary>
public string Path { get; set; }
/// <summary>
/// Paths in the backoffice which are not handled by zero
/// </summary>
public List<string> ExcludedPaths { get; private set; } = new();
/// <summary>
/// Define icon sets which can be used in icon pickers (and also in backoffice rendering)
/// </summary>
public List<BackofficeIconSet> IconSets { get; set; } = new();
/// <summary>
/// Authentication configuration for external services
/// </summary>
public ExternalServicesOptions ExternalServices { get; set; } = new();
/// <summary>
/// Configure search maps
/// </summary>
public SearchOptions Search { get; set; } = new();
}
@@ -1,6 +1,6 @@
namespace zero.Configuration;
namespace zero.Backoffice.Configuration;
public class ServiceOptions
public class ExternalServicesOptions
{
/// <summary>
/// Define a YouTube API Key so the zero videopicker can display previews
-15
View File
@@ -1,15 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace zero.Backoffice;
internal class BackofficeModule : ZeroModule
{
/// <inheritdoc />
public override void Register(IZeroModuleConfiguration config)
{
config.Services.TryAddEnumerable(ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, ZeroBackofficeMvcOptions>());
}
}
-1
View File
@@ -7,7 +7,6 @@ internal class SearchModule : ZeroModule
/// <inheritdoc />
public override void Register(IZeroModuleConfiguration config)
{
config.Services.AddOptions<SearchOptions>().Bind(config.Configuration.GetSection(SearchOptions.KEY));
config.Services.AddScoped<IBackofficeSearchService, BackofficeSearchService>();
}
@@ -2,27 +2,8 @@
public class SearchOptions : OptionsEnumerable<SearchIndexMap>, IOptionsEnumerable
{
public static string KEY { get; set; } = "Zero:Backoffice:Search";
public bool Enabled { get; set; }
public SearchOptions()
{
Enabled = true;
//Map<Page>().Display((x, res, opts) =>
//{
// PageType pageType = opts.Pages.GetByAlias(x.PageTypeAlias);
// if (pageType != null)
// {
// res.Icon = pageType.Icon;
// }
// res.Url = "/pages/edit/" + x.Id;
//});
//Map<MediaFolder>("fth-image");
}
public SearchIndexMap<T> Map<T>(string icon = null) where T : ZeroEntity, new()
{
SearchIndexMap<T> map = new(icon);
+55
View File
@@ -0,0 +1,55 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace zero.Backoffice;
internal class ZeroBackofficePlugin : ZeroPlugin
{
public ZeroBackofficePlugin()
{
Options.Name = "zero.Defaults";
Options.LocalizationPaths.Add("~/Resources/Localization/zero.{lang}.json");
}
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddOptions<BackofficeOptions>().Bind(configuration.GetSection("Zero:Backoffice")).Configure(ConfigureOptions);
services.TryAddEnumerable(ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, ZeroBackofficeMvcOptions>());
// register all modules
ZeroModuleConfiguration moduleConfig = new(services, configuration);
foreach (ZeroModule module in Registrations.Modules)
{
module.Register(moduleConfig);
}
}
protected void ConfigureOptions(BackofficeOptions options)
{
options.Path = "/zero";
options.IconSets.Add(new BackofficeIconSet()
{
Alias = "feather",
Name = "Feather",
SpritePath = "/assets/icons/feather.svg",
Prefix = "fth"
});
options.Search.Enabled = true;
//Map<Page>().Display((x, res, opts) =>
//{
// PageType pageType = opts.Pages.GetByAlias(x.PageTypeAlias);
// if (pageType != null)
// {
// res.Icon = pageType.Icon;
// }
// res.Url = "/pages/edit/" + x.Id;
//});
//Map<MediaFolder>("fth-image");
}
}
+10
View File
@@ -0,0 +1,10 @@
namespace zero.Backoffice;
internal class Registrations
{
public static List<ZeroModule> Modules { get; } = new()
{
new CountriesModule(),
new SearchModule()
};
}
+2 -1
View File
@@ -24,4 +24,5 @@ global using zero.Applications;
global using zero.Backoffice;
global using zero.Backoffice.Models;
global using zero.Backoffice.Modules;
global using zero.Backoffice.Modules;
global using zero.Backoffice.Configuration;
@@ -7,6 +7,7 @@ public class BlueprintChildInterceptor : Interceptor<ZeroEntity>, IBlueprintInte
public BlueprintChildInterceptor(IZeroContext context)
{
Gravity = -1;
configuredZeroDatabase = context.Options.For<RavenOptions>().Database;
}
@@ -23,6 +23,7 @@ public class BlueprintInterceptor : Interceptor<ZeroEntity>, IBlueprintIntercept
public BlueprintInterceptor(IZeroContext context, IZeroStore store, ILogger<BlueprintInterceptor> logger, IBlueprintService blueprintService, IInterceptors interceptors)
{
Gravity = -1;
Context = context;
Store = store;
Logger = logger;
+1 -1
View File
@@ -7,7 +7,7 @@ internal class ArchitectureModule : ZeroModule
/// <inheritdoc />
public override void Register(IZeroModuleConfiguration config)
{
config.Services.AddScoped<IBlueprintService, BlueprintService>();
config.Services.AddScoped<IBlueprintService, BlueprintService>();
config.Services.AddScoped<IInterceptor, BlueprintInterceptor>();
config.Services.AddScoped<IInterceptor, BlueprintChildInterceptor>();
}
@@ -9,7 +9,7 @@ public class ZeroModuleConfiguration : IZeroModuleConfiguration
public IConfiguration Configuration { get; }
internal ZeroModuleConfiguration(IServiceCollection servicse, IConfiguration configuration)
public ZeroModuleConfiguration(IServiceCollection servicse, IConfiguration configuration)
{
Services = servicse;
Configuration = configuration;
@@ -1,4 +1,4 @@
namespace zero.Architecture;
namespace zero;
public interface IZeroRouteEntity
{
@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using System.Diagnostics;
namespace zero.Architecture;
namespace zero;
[DebuggerDisplay("Id = {Id,nq}, Name = {Name}, Alias = {Alias}")]
public class ZeroEntity : ZeroIdEntity, IZeroDbConventions, IZeroRouteEntity
@@ -1,4 +1,4 @@
namespace zero.Architecture;
namespace zero;
public class ZeroIdEntity
{
+1
View File
@@ -7,6 +7,7 @@ internal class CommunicationModule : ZeroModule
/// <inheritdoc />
public override void Register(IZeroModuleConfiguration config)
{
config.Services.AddScoped<IInterceptors, Interceptors>();
config.Services.AddSingleton<IMessageAggregator, MessageAggregator>();
config.Services.AddTransient<IHandlerHolder, HandlerHolder>();
}
@@ -1,22 +0,0 @@
namespace zero.Configuration;
public class IconOptions : OptionsEnumerable<IconSet>, IOptionsEnumerable
{
/// <summary>
/// Add a new backoffice icon set
/// </summary>
/// <param name="alias">Alias for reference</param>
/// <param name="name">Name of the icon set</param>
/// <param name="spritePath">Path to the SVG sprite containing addressable symbols</param>
/// <param name="prefix">Optional symbol identifier prefix (by default the alias is used)</param>
public void AddSet(string alias, string name, string spritePath, string prefix = null)
{
Items.Add(new IconSet()
{
Alias = alias,
Name = name,
SpritePath = spritePath,
Prefix = prefix ?? alias
});
}
}
-24
View File
@@ -66,14 +66,6 @@ public class ZeroOptions : IZeroOptions
///// <inheritdoc />
//public ApplicationOptions Applications { get; set; }
///// <inheritdoc />
//public string BackofficePath { get; set; }
///// <summary>
///// Paths in the backoffice which are not handled by zero
///// </summary>
//public List<string> ExcludedPaths { get; private set; }
///// <inheritdoc />
//public SectionOptions Sections { get; private set; }
@@ -98,12 +90,6 @@ public class ZeroOptions : IZeroOptions
///// <inheritdoc />
//public IntegrationOptions Integrations { get; private set; }
///// <inheritdoc />
//public IconOptions Icons { get; private set; }
///// <inheritdoc />
//public ServiceOptions Services { get; private set; }
///// <inheritdoc />
//public BlueprintOptions Blueprints { get; private set; }
}
@@ -151,14 +137,4 @@ public interface IZeroOptions
///// Application options
///// </summary>
//ApplicationOptions Applications { get; set; }
///// <summary>
///// URL path to the backoffice (defaults to /zero)
///// </summary>
//string BackofficePath { get; set; }
///// <summary>
///// Paths in the backoffice which are not handled by zero
///// </summary>
//List<string> ExcludedPaths { get; }
}