#region ========================================================================= USING ===================================================================================== using Lumina.Presentation.Web.Common.Enums.FileSystem; using Lumina.Presentation.Web.Common.Models.Configuration; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using System.Runtime.InteropServices; #endregion namespace Lumina.Presentation.Web.ViewComponents; /// /// View component for the file system browser. /// public class FileSystemBrowserViewComponent : ViewComponent { private readonly ServerConfigurationModel _serverConfigurationModel; /// /// Initializes a new instance of the class. /// /// Injected service for retrieving . public FileSystemBrowserViewComponent(IOptions serverConfigurationModelOptions) { _serverConfigurationModel = serverConfigurationModelOptions.Value; } /// /// Invokes the view component. /// /// /// An that renders the view with file system browsing configuration. /// public IViewComponentResult Invoke() { return View(new { Path = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? @"/" : @"C:\Users\", ServerBasePath = $"{_serverConfigurationModel.BaseAddress}:{_serverConfigurationModel.Port}/api/v{_serverConfigurationModel.ApiVersion}/", ClientBasePath = "http://localhost:5012/", // TODO: take from appsettings or environment ViewMode = FileSystemViewMode.List, IconSize = FileSystemIconSize.Large }); } }