using Microsoft.AspNetCore.Mvc; using System.Collections; using System.Reflection; using zero.Backoffice.Services; namespace zero.Backoffice.Endpoints.UI; public class UIController : ZeroBackofficeController { readonly IIconService IconService; readonly IResourceService ResourceService; readonly ISectionService SectionService; readonly IZeroOptions Options; public UIController(IIconService iconService, IResourceService resourceService, ISectionService sectionService, IZeroOptions options) { IconService = iconService; ResourceService = resourceService; SectionService = sectionService; Options = options; } [HttpGet("sections")] //[ZeroAuthorize(CountryPermissions.Create)] public async Task> GetSections() => Ok(await SectionService.GetSections()); [HttpGet("settingareas")] public async Task> GetSettingGroups() => Ok(await SectionService.GetSettingsAreas()); [HttpGet("iconsets")] public async Task> GetIconSets() { return Ok(await IconService.GetSets()); } [HttpGet("translations")] public async Task>> GetTranslations() { return Ok(await ResourceService.GetTranslations("en-us")); } [HttpGet("flavors")] public ActionResult> GetFlavors() { Dictionary result = new(); foreach ((Type type, FlavorProvider provider) in Options.For().Providers) { string key = type.GetCustomAttribute(true)?.Name ?? type.Name; result[Safenames.Alias(key)] = provider; } return result; } [HttpGet("blueprints")] public ActionResult> GetBlueprints() { HashSet result = new(); foreach (Blueprint blueprint in Options.For()) { string key = blueprint.ContentType.GetCustomAttribute(true)?.Name ?? blueprint.Alias; result.Add(Safenames.Alias(key)); } return result; } }