diff --git a/.gitignore b/.gitignore index 587b4d29..ee66b814 100644 --- a/.gitignore +++ b/.gitignore @@ -273,7 +273,7 @@ deps/*.dll zero.Commerce/ zero.Stories/ zero.Forms/ -zero.Web.UI/package.json -zero.Web.UI/package-lock.json -zero.Web.UI/app/core/plugins.js -zero.Web.UI/dist +zero.Backoffice.UI/package.json +zero.Backoffice.UI/package-lock.json +zero.Backoffice.UI/app/core/plugins.js +zero.Backoffice.UI/dist diff --git a/zero.Backoffice.UI/app/env.d.ts b/zero.Backoffice.UI/app/env.d.ts index 659d7139..3bda204a 100644 --- a/zero.Backoffice.UI/app/env.d.ts +++ b/zero.Backoffice.UI/app/env.d.ts @@ -1,15 +1,15 @@ /// -declare module '*.vue' { - import { DefineComponent } from 'vue' - // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types - const component: DefineComponent<{}, {}, any> - export default component -} - declare module 'vue' { import { CompatVue } from '@vue/runtime-dom' const Vue: CompatVue export default Vue export * from '@vue/runtime-dom' +} + +declare module '*.vue' { + import { DefineComponent } from 'vue' + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types + const component: DefineComponent<{}, {}, any> + export default component } \ No newline at end of file diff --git a/zero.Backoffice.UI/app/modules/mails/picker/ui-mailtemplatepicker.vue b/zero.Backoffice.UI/app/modules/mails/picker/ui-mailtemplatepicker.vue index 1264f578..9b7236af 100644 --- a/zero.Backoffice.UI/app/modules/mails/picker/ui-mailtemplatepicker.vue +++ b/zero.Backoffice.UI/app/modules/mails/picker/ui-mailtemplatepicker.vue @@ -6,8 +6,8 @@ + + + "; + } + string content = TokenReplacement.Apply(await LoadTemplate("zero.Backoffice.Resources.backoffice.tpl.html"), model); return Content(content, "text/html"); } @@ -94,11 +67,4 @@ public class ZeroIndexController : Controller using StreamReader reader = new(stream); return await reader.ReadToEndAsync(); } -} - -public class ZeroBackofficeModel -{ - public int Port { get; set; } - - public IZeroVue Vue { get; set; } -} +} \ No newline at end of file diff --git a/zero.Backoffice/Plugin.cs b/zero.Backoffice/Plugin.cs index 70d2a79b..a51b7c9a 100644 --- a/zero.Backoffice/Plugin.cs +++ b/zero.Backoffice/Plugin.cs @@ -28,7 +28,6 @@ public class ZeroBackofficePlugin : ZeroPlugin services.AddOptions().Bind(configuration.GetSection("Zero:Backoffice")).Configure(ConfigureOptions); services.TryAddEnumerable(ServiceDescriptor.Transient, ZeroBackofficeMvcOptions>()); services.AddHostedService(); - services.AddTransient(); services.AddSingleton(); services.AddScoped(); @@ -70,7 +69,7 @@ public class ZeroBackofficePlugin : ZeroPlugin Prefix = "fth" }); - options.SupportedLanguages = new string[2] { "en-US", "de-DE" }; + options.SupportedLanguages = new string[1] { "en-US" }; //, "de-DE" }; options.DefaultLanguage = options.SupportedLanguages[0]; } } \ No newline at end of file diff --git a/zero.Backoffice/Resources/auth.tpl.html b/zero.Backoffice/Resources/auth.tpl.html deleted file mode 100644 index db2c16ae..00000000 --- a/zero.Backoffice/Resources/auth.tpl.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - {css} - zero says hi - - - -
- {svg} - {js} - - - \ No newline at end of file diff --git a/zero.Backoffice/Resources/backoffice.tpl.html b/zero.Backoffice/Resources/backoffice.tpl.html index 4c008e68..12eb4d88 100644 --- a/zero.Backoffice/Resources/backoffice.tpl.html +++ b/zero.Backoffice/Resources/backoffice.tpl.html @@ -11,15 +11,15 @@ - - {css} + + {top} zero
{svg} - {js} + {bottom} \ No newline at end of file diff --git a/zero.Backoffice/ZeroBackofficeModel.cs b/zero.Backoffice/ZeroBackofficeModel.cs deleted file mode 100644 index 7da23af6..00000000 --- a/zero.Backoffice/ZeroBackofficeModel.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace zero.Backoffice; - -public class ZeroBackofficeModel -{ - public int Port { get; set; } - - public IZeroVue Vue { get; set; } -} \ No newline at end of file diff --git a/zero.Backoffice/ZeroVue.cs b/zero.Backoffice/ZeroVue.cs deleted file mode 100644 index c754039a..00000000 --- a/zero.Backoffice/ZeroVue.cs +++ /dev/null @@ -1,266 +0,0 @@ -using Microsoft.Extensions.Logging; -using System.Text.Json; - -namespace zero.Backoffice; - -public class ZeroVue : IZeroVue -{ - protected IZeroOptions Options { get; private set; } - - protected IPaths Paths { get; private set; } - - protected IApplicationStore ApplicationStore { get; private set; } - - protected IAuthenticationService AuthenticationApi { get; private set; } - - protected IEnumerable Plugins { get; private set; } - - protected IEnumerable Sections { get; private set; } - - protected IEnumerable SettingsGroups { get; private set; } - - protected IZeroContext Context { get; private set; } - - protected ILogger Logger { get; private set; } - - protected IZeroStore Store { get; private set; } - - - public ZeroVue(IZeroOptions options, IPaths paths, IApplicationStore applicationStore, IAuthenticationService authenticationApi, - IEnumerable plugins, IZeroContext context, ILogger logger, IZeroStore store, - IEnumerable sections, IEnumerable settingsGroups) - { - Paths = paths; - Options = options; - ApplicationStore = applicationStore; - AuthenticationApi = authenticationApi; - Plugins = plugins; - Context = context; - Logger = logger; - Store = store; - Sections = sections; - SettingsGroups = settingsGroups; - } - - - /// - public async Task Config() - { - ZeroVueConfig config = new(); - - config.Path = Options.ZeroPath.EnsureEndsWith('/'); - config.ApiPath = config.Path + "api/"; - config.PluginPath = "@/Plugins"; - config.Version = Options.Version; - config.PluginCount = Plugins.Count(); - config.ErrorFieldNone = Constants.ErrorFieldNone; - config.Alias = CreateAliases(); - config.AppId = Context.AppId; - //config.SharedAppId = Constants.Database.SharedAppId; // TODO appx - config.MultiApps = Options.Applications.Count > 1; - - ZeroUser user = await AuthenticationApi.GetUser(); - - if (user != null) - { - config.User = new - { - Id = user.Id, - AvatarId = user.AvatarId, - Email = user.Email, - IsSuper = user.IsSuper, - Name = user.Name, - Roles = user.RoleIds - }; - - config.Applications = await CreateApplications(); - - config.Plugins = Plugins.Select(x => new ZeroVuePlugin() - { - Name = x.Options.Name, - Description = x.Options.Description, - PluginPath = x.Options.PluginPath - }).ToList(); - - config.Services = new() - { - YouTubeApiKey = Options.For().YouTubeApiKey - }; - - config.Blueprints = CreateBlueprints(); - } - - return config; - } - - - /// - public async Task ConfigAsJson() - { - return JsonSerializer.Serialize(await Config(), new JsonSerializerOptions() - { - PropertyNamingPolicy = JsonNamingPolicy.CamelCase - }); - } - - - /// - /// Create aliases - /// - Dictionary> CreateAliases() - { - Dictionary> aliases = new Dictionary>(); - - Dictionary sections = new Dictionary(); - sections.Add("dashboard", Constants.Sections.Dashboard); - sections.Add("pages", Constants.Sections.Pages); - sections.Add("spaces", Constants.Sections.Spaces); - sections.Add("media", Constants.Sections.Media); - sections.Add("settings", Constants.Sections.Settings); - - Dictionary settings = new Dictionary(); - settings.Add("applications", Constants.Settings.Applications); - settings.Add("countries", Constants.Settings.Countries); - settings.Add("logging", Constants.Settings.Logging); - settings.Add("languages", Constants.Settings.Languages); - settings.Add("translations", Constants.Settings.Translations); - settings.Add("mails", Constants.Settings.Mails); - settings.Add("updates", Constants.Settings.Updates); - settings.Add("users", Constants.Settings.Users); - settings.Add("integrations", Constants.Settings.Integrations); - - aliases.Add("sections", sections); - aliases.Add("settings", settings); - aliases.Add("pages", new Dictionary() - { - { "folder", Constants.Pages.FolderAlias } - }); - - return aliases; - } - - - /// - /// Get all visible applications - /// - async Task> CreateApplications() - { - IEnumerable applications = await ApplicationStore.LoadAll(); - - string[] mediaIds = applications.Select(x => x.IconId).Where(x => x != null).ToArray(); - Dictionary media = await Store.Session().LoadAsync(mediaIds); - - return applications.OrderBy(app => app.Sort).Select(app => new ZeroVueApplication() - { - Id = app.Id, - Name = app.Name, - Image = app.IconId.IsNullOrEmpty() ? null : media.GetValueOrDefault(app.IconId)?.ImageMeta?.Thumbnails.GetValueOrDefault("thumb") - }).ToList(); - } - - - List CreateBlueprints() - { - List items = new(); - - if (!Options.For().Enabled) - { - return items; - } - - foreach (Blueprint blueprint in Options.For()) - { - string[] unlocked = blueprint.GetUnlockedFieldNames().ToArray(); - - items.Add(new() - { - Alias = blueprint.Alias, - Enabled = true, - Unlocked = unlocked - }); - } - - return items; - } -} - - -public interface IZeroVue -{ - /// - /// Creates the zero configuration for vue - /// - Task Config(); - - /// - /// Creates the zero configuration for vue - /// - Task ConfigAsJson(); -} - - -public class ZeroVueConfig -{ - public string Path { get; set; } - - public string ApiPath { get; set; } - - public string PluginPath { get; set; } - - public IList Plugins { get; set; } = new List(); - - public string Version { get; set; } - - public int PluginCount { get; set; } - - public string ErrorFieldNone { get; set; } - - public string AppId { get; set; } - - public bool MultiApps { get; set; } - - public dynamic User { get; set; } - - public IList Applications { get; set; } = new List(); - - public Dictionary> Alias { get; set; } = new Dictionary>(); - - public Dictionary Overrides { get; set; } = new Dictionary(); - - public ZeroVueServices Services { get; set; } = new(); - - public IList Blueprints { get; set; } = new List(); -} - - -public class ZeroVuePlugin -{ - public string Name { get; set; } - - public string Description { get; set; } - - public string PluginPath { get; set; } -} - -public class ZeroVueApplication -{ - public string Id { get; set; } - - public string Name { get; set; } - - public string Image { get; set; } -} - -public class ZeroVueServices -{ - public string YouTubeApiKey { get; set; } -} - -public class ZeroVueBlueprint -{ - public string Alias { get; set; } - - public bool Enabled { get; set; } - - public string[] Unlocked { get; set; } = Array.Empty(); -} \ No newline at end of file diff --git a/zero.Backoffice/zero.Backoffice.csproj b/zero.Backoffice/zero.Backoffice.csproj index 2fc1e3ac..03485234 100644 --- a/zero.Backoffice/zero.Backoffice.csproj +++ b/zero.Backoffice/zero.Backoffice.csproj @@ -18,7 +18,6 @@ -