From 97d8eaf8ffb0cd2cd15dad40d0dca90192a98588 Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Fri, 16 Apr 2021 06:25:36 -0700 Subject: [PATCH] Auto-populate name on Remote Control page. --- Server/Pages/RemoteControl.cshtml | 8 +++----- Server/Pages/RemoteControl.cshtml.cs | 13 +++++++++++++ Server/wwwroot/src/RemoteControl/App.js | 11 ++++++++++- Server/wwwroot/src/RemoteControl/App.js.map | 2 +- Server/wwwroot/src/RemoteControl/App.ts | 13 ++++++++++++- .../src/RemoteControl/Interfaces/Settings.ts | 1 + Server/wwwroot/src/RemoteControl/SettingsService.js | 3 ++- .../src/RemoteControl/SettingsService.js.map | 2 +- Server/wwwroot/src/RemoteControl/SettingsService.ts | 3 ++- 9 files changed, 45 insertions(+), 11 deletions(-) diff --git a/Server/Pages/RemoteControl.cshtml b/Server/Pages/RemoteControl.cshtml index ee2f88c0..e9a9ab67 100644 --- a/Server/Pages/RemoteControl.cshtml +++ b/Server/Pages/RemoteControl.cshtml @@ -1,7 +1,6 @@ @page @using Remotely.Shared.Models @inject Remotely.Server.Services.IApplicationConfig AppConfig -@inject UserManager UserManager @model Remotely.Server.Pages.RemoteControlModel @{ Layout = null; @@ -30,10 +29,9 @@ } - @if (User.Identity.IsAuthenticated) + @if (Model.RemotelyUser is not null) { - var user = await UserManager.GetUserAsync(User); - switch (user.UserOptions.Theme) + switch (Model.RemotelyUser.UserOptions.Theme) { case Remotely.Shared.Enums.Theme.Light: @@ -214,7 +212,7 @@

- +
diff --git a/Server/Pages/RemoteControl.cshtml.cs b/Server/Pages/RemoteControl.cshtml.cs index e629e6a5..851c83b1 100644 --- a/Server/Pages/RemoteControl.cshtml.cs +++ b/Server/Pages/RemoteControl.cshtml.cs @@ -1,14 +1,27 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Remotely.Server.Auth; +using Remotely.Server.Services; +using Remotely.Shared.Models; namespace Remotely.Server.Pages { [ServiceFilter(typeof(RemoteControlFilterAttribute))] public class RemoteControlModel : PageModel { + private readonly IDataService _dataService; + public RemoteControlModel(IDataService dataService) + { + _dataService = dataService; + } + + public RemotelyUser RemotelyUser { get; private set; } public void OnGet() { + if (User.Identity.IsAuthenticated) + { + RemotelyUser = _dataService.GetUserByNameWithOrg(base.User.Identity.Name); + } } } } diff --git a/Server/wwwroot/src/RemoteControl/App.js b/Server/wwwroot/src/RemoteControl/App.js index 7b7c5e57..caff60bf 100644 --- a/Server/wwwroot/src/RemoteControl/App.js +++ b/Server/wwwroot/src/RemoteControl/App.js @@ -8,7 +8,7 @@ import { MessageSender } from "./MessageSender.js"; import { SessionRecorder } from "./SessionRecorder.js"; import { ApplyInputHandlers } from "./InputEventHandlers.js"; import { ViewerHubConnection } from "./ViewerHubConnection.js"; -import { GetSettings } from "./SettingsService.js"; +import { GetSettings, SetSettings } from "./SettingsService.js"; var queryString = Utilities.ParseSearchString(); export const ViewerApp = { ClipboardWatcher: new ClipboardWatcher(), @@ -31,6 +31,13 @@ export const ViewerApp = { UI.ViewOnlyButton.classList.add("toggled"); } ApplyInputHandlers(); + if (UI.RequesterNameInput.value) { + ViewerApp.RequesterName = UI.RequesterNameInput.value; + } + else if (ViewerApp.Settings.displayName) { + UI.RequesterNameInput.value = ViewerApp.Settings.displayName; + ViewerApp.RequesterName = ViewerApp.Settings.displayName; + } if (ViewerApp.CasterID) { ViewerApp.Mode = RemoteControlMode.Unattended; ViewerApp.ViewerHubConnection.Connect(); @@ -53,6 +60,8 @@ export const ViewerApp = { ViewerApp.Mode = RemoteControlMode.Normal; ViewerApp.ViewerHubConnection.Connect(); UI.StatusMessage.innerHTML = "Sending connection request..."; + ViewerApp.Settings.displayName = ViewerApp.RequesterName; + SetSettings(ViewerApp.Settings); } }; window["ViewerApp"] = ViewerApp; diff --git a/Server/wwwroot/src/RemoteControl/App.js.map b/Server/wwwroot/src/RemoteControl/App.js.map index 6228cc74..a6513661 100644 --- a/Server/wwwroot/src/RemoteControl/App.js.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EAAE,CAAC;QACxC,EAAE,CAAC,aAAa,CAAC,SAAS,GAAG,+BAA+B,CAAC;QAE7D,SAAS,CAAC,QAAQ,CAAC,WAAW,GAAG,SAAS,CAAC,aAAa,CAAC;QACzD,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;CACJ,CAAA;AAED,MAAM,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC"} \ No newline at end of file diff --git a/Server/wwwroot/src/RemoteControl/App.ts b/Server/wwwroot/src/RemoteControl/App.ts index 55bb6194..cc6b763f 100644 --- a/Server/wwwroot/src/RemoteControl/App.ts +++ b/Server/wwwroot/src/RemoteControl/App.ts @@ -8,7 +8,7 @@ import { MessageSender } from "./MessageSender.js"; import { SessionRecorder } from "./SessionRecorder.js"; import { ApplyInputHandlers } from "./InputEventHandlers.js"; import { ViewerHubConnection } from "./ViewerHubConnection.js"; -import { GetSettings } from "./SettingsService.js"; +import { GetSettings, SetSettings } from "./SettingsService.js"; var queryString = Utilities.ParseSearchString(); @@ -37,6 +37,14 @@ export const ViewerApp = { ApplyInputHandlers(); + if (UI.RequesterNameInput.value) { + ViewerApp.RequesterName = UI.RequesterNameInput.value; + } + else if (ViewerApp.Settings.displayName) { + UI.RequesterNameInput.value = ViewerApp.Settings.displayName; + ViewerApp.RequesterName = ViewerApp.Settings.displayName; + } + if (ViewerApp.CasterID) { ViewerApp.Mode = RemoteControlMode.Unattended; ViewerApp.ViewerHubConnection.Connect(); @@ -60,6 +68,9 @@ export const ViewerApp = { ViewerApp.Mode = RemoteControlMode.Normal; ViewerApp.ViewerHubConnection.Connect(); UI.StatusMessage.innerHTML = "Sending connection request..."; + + ViewerApp.Settings.displayName = ViewerApp.RequesterName; + SetSettings(ViewerApp.Settings); } } diff --git a/Server/wwwroot/src/RemoteControl/Interfaces/Settings.ts b/Server/wwwroot/src/RemoteControl/Interfaces/Settings.ts index 7156612c..885f8dda 100644 --- a/Server/wwwroot/src/RemoteControl/Interfaces/Settings.ts +++ b/Server/wwwroot/src/RemoteControl/Interfaces/Settings.ts @@ -1,3 +1,4 @@ export interface Settings { streamModeEnabled: boolean; + displayName: string; } \ No newline at end of file diff --git a/Server/wwwroot/src/RemoteControl/SettingsService.js b/Server/wwwroot/src/RemoteControl/SettingsService.js index 918315a8..fecf17ff 100644 --- a/Server/wwwroot/src/RemoteControl/SettingsService.js +++ b/Server/wwwroot/src/RemoteControl/SettingsService.js @@ -1,5 +1,6 @@ const defaultSettings = { - streamModeEnabled: false + streamModeEnabled: false, + displayName: "" }; export function GetSettings() { try { diff --git a/Server/wwwroot/src/RemoteControl/SettingsService.js.map b/Server/wwwroot/src/RemoteControl/SettingsService.js.map index 98206066..c94413ad 100644 --- a/Server/wwwroot/src/RemoteControl/SettingsService.js.map +++ b/Server/wwwroot/src/RemoteControl/SettingsService.js.map @@ -1 +1 @@ -{"version":3,"file":"SettingsService.js","sourceRoot":"","sources":["SettingsService.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAG;IACpB,iBAAiB,EAAE,KAAK;CAC3B,CAAC;AAGF,MAAM,UAAU,WAAW;IACvB,IAAI;QACA,IAAI,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACvD,IAAI,QAAQ,EAAE;YACV,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SAC/B;KACJ;IACD,OAAO,EAAE,EAAE;QACP,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;KACrB;IAED,WAAW,CAAC,eAAe,CAAC,CAAC;IAC7B,OAAO,eAAe,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAAkB;IAC1C,YAAY,CAAC,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;AACtE,CAAC"} \ No newline at end of file +{"version":3,"file":"SettingsService.js","sourceRoot":"","sources":["SettingsService.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAG;IACpB,iBAAiB,EAAE,KAAK;IACxB,WAAW,EAAE,EAAE;CAClB,CAAC;AAGF,MAAM,UAAU,WAAW;IACvB,IAAI;QACA,IAAI,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACvD,IAAI,QAAQ,EAAE;YACV,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SAC/B;KACJ;IACD,OAAO,EAAE,EAAE;QACP,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;KACrB;IAED,WAAW,CAAC,eAAe,CAAC,CAAC;IAC7B,OAAO,eAAe,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAAkB;IAC1C,YAAY,CAAC,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;AACtE,CAAC"} \ No newline at end of file diff --git a/Server/wwwroot/src/RemoteControl/SettingsService.ts b/Server/wwwroot/src/RemoteControl/SettingsService.ts index 53cf9a71..d2bcf821 100644 --- a/Server/wwwroot/src/RemoteControl/SettingsService.ts +++ b/Server/wwwroot/src/RemoteControl/SettingsService.ts @@ -1,7 +1,8 @@ import { Settings } from "./Interfaces/Settings.js"; const defaultSettings = { - streamModeEnabled: false + streamModeEnabled: false, + displayName: "" };