Files
mixtape/zero.Backoffice/Plugin.cs
T

73 lines
2.4 KiB
C#
Raw Normal View History

2021-11-23 22:56:22 +01:00
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
2021-11-22 16:03:02 +01:00
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
2021-11-23 22:56:22 +01:00
using System.IO;
2021-11-22 16:03:02 +01:00
namespace zero.Backoffice;
2021-11-23 22:56:22 +01:00
public class ZeroBackofficePlugin : ZeroPlugin
2021-11-22 16:03:02 +01:00
{
2021-11-23 22:56:22 +01:00
internal Action<IServiceCollection, IConfiguration> PostConfigureServices = null;
2021-11-22 16:03:02 +01:00
public ZeroBackofficePlugin()
{
2021-11-23 22:56:22 +01:00
Options.Name = "zero.Backoffice";
2021-11-22 16:03:02 +01:00
Options.LocalizationPaths.Add("~/Resources/Localization/zero.{lang}.json");
}
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
2021-11-23 22:56:22 +01:00
services.AddOptions<BackofficeOptions>().Bind(configuration.GetSection("Zero:Backoffice")).Configure<IWebHostEnvironment>(ConfigureOptions);
2021-11-22 16:03:02 +01:00
services.TryAddEnumerable(ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, ZeroBackofficeMvcOptions>());
2021-11-23 22:56:22 +01:00
services.AddHostedService<ZeroDevService>();
services.AddTransient<IZeroVue, ZeroVue>();
2021-11-22 16:03:02 +01:00
2021-11-24 14:37:32 +01:00
services.AddZeroBackofficeUIComposition();
//services.AddTransient<ISectionsApi, SectionsApi>();
//services.AddTransient<ISettingsApi, SettingsApi>();
//services.AddTransient<ISpacesApi, SpacesApi>();
//services.AddTransient<IModulesApi, ModulesApi>();
//services.AddTransient<IIntegrationService, IntegrationService>();
//services.AddTransient<IIntegrationsCollection, IntegrationsCollection>();
//services.AddScoped<IBackofficeSearchService, BackofficeSearchService>();
2021-11-23 22:56:22 +01:00
PostConfigureServices?.Invoke(services, configuration);
2021-11-22 16:03:02 +01:00
}
2021-11-23 22:56:22 +01:00
protected void ConfigureOptions(BackofficeOptions options, IWebHostEnvironment env)
2021-11-22 16:03:02 +01:00
{
2021-11-23 22:56:22 +01:00
options.Search.Enabled = true;
options.DevServer.WorkingDirectory = Path.Combine(env.ContentRootPath, "..", "Zero.Web.UI", "App");
2021-11-22 16:03:02 +01:00
options.IconSets.Add(new BackofficeIconSet()
{
Alias = "feather",
Name = "Feather",
SpritePath = "/assets/icons/feather.svg",
Prefix = "fth"
});
2021-11-24 15:49:25 +01:00
options.SupportedLanguages = new string[2] { "en-US", "de-DE" };
options.DefaultLanguage = options.SupportedLanguages[0];
2021-11-22 16:03:02 +01:00
//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");
}
}