Remotely/Server/Services/RcImplementations/ViewerPageDataProvider.cs
Jared Goodwin 3ef4cdf81a
Extract remote control functionality into separate library. (#539)
* Convert server to new single-file startup model.

* Add remote control implementations.

* Implement IViewerAuthorizer.

* Update hub endpoints.

* Implement HubEventHandler.

* Implement ViewerHubDataProvider.

* Implement page data provider.

* Implement RCL and refactor.

* Update submodule.

* Replace submodule with NuGet.

* Update copy URL.

* Update NuGet.

* Remove deprecated WebRTC.

* Remove deprecated WebRTC.

* Update Immense.RemoteControl

* Building out desktop projects.

* Bring more services into submodule.

* Update submodule.

* Update submodule.

* Refactoring for module.

* Update submodule.

* Update submodule

* Got Windows desktop app running.

* Refactor for submodule changes.

* FIx unattended session start.

* Switch desktop app out of console mode.

* Fix tests.

* Update publishing.

* Remove ClickOnce middleware.

* Remove ClickOnce remnants.

* Update submodule

* Add some logging.

* Update Linux path.

* Update submodule.

* Add cleanup service for unattended sessions that failed to start.

* Update submodule.

* Fix chat.

* Add ValidateExecutableReferencesMatchSelfContained property.

* Add other submodule projects.  Align checkbox.

* Update submodule.  Reduce deserialization in the browser, resulting in faster renders.

* Update submodule.

* Update submodule.

* Update submodule.

* Update submodule.

* Add orgId back for branding.

* Get branding loading in desktop apps.

* Update submodule.

* Create log dir.

* Refactor version check on config page.

* Update submodule.

* Update submodule.

* Change submodule URL.

* Correct namespace.

* Update submodule.

* Checkout submodules recursively.
2022-12-23 06:39:12 -08:00

51 lines
1.6 KiB
C#

using Immense.RemoteControl.Server.Abstractions;
using Immense.RemoteControl.Server.Models;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Org.BouncyCastle.Ocsp;
using Remotely.Shared.Enums;
using Remotely.Shared.Models;
using System;
namespace Remotely.Server.Services.RcImplementations
{
public class ViewerPageDataProvider : IViewerPageDataProvider
{
private readonly IDataService _dataService;
private readonly IApplicationConfig _appConfig;
public ViewerPageDataProvider(IDataService dataService, IApplicationConfig appConfig)
{
_dataService = dataService;
_appConfig = appConfig;
}
public string GetUserDisplayName(PageModel pageModel)
{
var user = _dataService.GetUserByNameWithOrg(pageModel.User.Identity.Name);
return user.UserOptions?.DisplayName ?? user.UserName;
}
public ViewerPageTheme GetTheme(PageModel pageModel)
{
if (pageModel.User.Identity.IsAuthenticated)
{
var user = _dataService.GetUserByNameWithOrg(pageModel.User.Identity.Name);
return user.UserOptions.Theme switch
{
Theme.Light => ViewerPageTheme.Light,
Theme.Dark => ViewerPageTheme.Dark,
_ => ViewerPageTheme.Dark
};
}
return _appConfig.Theme switch
{
Theme.Light => ViewerPageTheme.Light,
Theme.Dark => ViewerPageTheme.Dark,
_ => ViewerPageTheme.Dark
};
}
}
}