Implemented extendable system settings tab. Started implementing white labeling settings
This commit is contained in:
@@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Moonlight.Api.Configuration;
|
||||
using Moonlight.Api.Constants;
|
||||
using Moonlight.Api.Database;
|
||||
using Moonlight.Api.Database.Entities;
|
||||
using Moonlight.Api.Models;
|
||||
@@ -13,14 +14,16 @@ public class FrontendService
|
||||
private readonly IMemoryCache Cache;
|
||||
private readonly DatabaseRepository<Theme> ThemeRepository;
|
||||
private readonly IOptions<FrontendOptions> Options;
|
||||
private readonly SettingsService SettingsService;
|
||||
|
||||
private const string CacheKey = $"Moonlight.{nameof(FrontendService)}.{nameof(GetConfigurationAsync)}";
|
||||
|
||||
public FrontendService(IMemoryCache cache, DatabaseRepository<Theme> themeRepository, IOptions<FrontendOptions> options)
|
||||
public FrontendService(IMemoryCache cache, DatabaseRepository<Theme> themeRepository, IOptions<FrontendOptions> options, SettingsService settingsService)
|
||||
{
|
||||
Cache = cache;
|
||||
ThemeRepository = themeRepository;
|
||||
Options = options;
|
||||
SettingsService = settingsService;
|
||||
}
|
||||
|
||||
public async Task<FrontendConfiguration> GetConfigurationAsync()
|
||||
@@ -35,7 +38,9 @@ public class FrontendService
|
||||
.Query()
|
||||
.FirstOrDefaultAsync(x => x.IsEnabled);
|
||||
|
||||
var config = new FrontendConfiguration("Moonlight", theme?.CssContent);
|
||||
var name = await SettingsService.GetValueAsync<string>(FrontendSettingConstants.Name);
|
||||
|
||||
var config = new FrontendConfiguration(name ?? "Moonlight", theme?.CssContent);
|
||||
|
||||
Cache.Set(CacheKey, config, TimeSpan.FromMinutes(Options.Value.CacheMinutes));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user