Implemented extendable system settings tab. Started implementing white labeling settings
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Moonlight.Api.Constants;
|
||||
using Moonlight.Api.Services;
|
||||
using Moonlight.Shared;
|
||||
using Moonlight.Shared.Http.Requests.Admin.Settings;
|
||||
using Moonlight.Shared.Http.Responses.Admin.Settings;
|
||||
|
||||
namespace Moonlight.Api.Http.Controllers.Admin.Settings;
|
||||
|
||||
[ApiController]
|
||||
[Authorize(Policy = Permissions.System.Settings)]
|
||||
[Route("api/admin/system/settings/whiteLabeling")]
|
||||
public class WhiteLabelingController : Controller
|
||||
{
|
||||
private readonly SettingsService SettingsService;
|
||||
private readonly FrontendService FrontendService;
|
||||
|
||||
public WhiteLabelingController(SettingsService settingsService, FrontendService frontendService)
|
||||
{
|
||||
SettingsService = settingsService;
|
||||
FrontendService = frontendService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<WhiteLabelingDto>> GetAsync()
|
||||
{
|
||||
var dto = new WhiteLabelingDto
|
||||
{
|
||||
Name = await SettingsService.GetValueAsync<string>(FrontendSettingConstants.Name) ?? "Moonlight"
|
||||
};
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<WhiteLabelingDto>> PostAsync([FromBody] SetWhiteLabelingDto request)
|
||||
{
|
||||
await SettingsService.SetValueAsync(FrontendSettingConstants.Name, request.Name);
|
||||
await FrontendService.ResetCacheAsync();
|
||||
|
||||
var dto = new WhiteLabelingDto
|
||||
{
|
||||
Name = await SettingsService.GetValueAsync<string>(FrontendSettingConstants.Name) ?? "Moonlight"
|
||||
};
|
||||
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user