https://dev.azure.com/umbraco/D-Team%20Tracker/_workitems/edit/6586 - Migrated DashboardController and BackOfficeAssetsController

This commit is contained in:
Bjarke Berg
2020-05-19 09:52:58 +02:00
parent 4ca6868553
commit 35680bba46
11 changed files with 241 additions and 124 deletions

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Web.Common.Attributes;
namespace Umbraco.Web.Editors
{
[PluginController("UmbracoApi")]
public class BackOfficeAssetsController : UmbracoAuthorizedJsonController
{
private readonly IFileSystem _jsLibFileSystem;
public BackOfficeAssetsController(IIOHelper ioHelper, ILogger logger, IGlobalSettings globalSettings)
{
_jsLibFileSystem = new PhysicalFileSystem(ioHelper, logger, globalSettings.UmbracoPath + Path.DirectorySeparatorChar + "lib");
}
[HttpGet]
public object GetSupportedLocales()
{
const string momentLocaleFolder = "moment";
const string flatpickrLocaleFolder = "flatpickr/l10n";
return new
{
moment = GetLocales(momentLocaleFolder),
flatpickr = GetLocales(flatpickrLocaleFolder)
};
}
private IEnumerable<string> GetLocales(string path)
{
var cultures = _jsLibFileSystem.GetFiles(path, "*.js").ToList();
for (var i = 0; i < cultures.Count; i++)
{
cultures[i] = cultures[i]
.Substring(cultures[i].IndexOf(path, StringComparison.Ordinal) + path.Length + 1);
}
return cultures;
}
}
}