From b9fa8c681f04ee2b8db347aaeedc6fe63c3470b6 Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Thu, 26 Mar 2020 13:33:21 -0700 Subject: [PATCH] Add API token help modal. Improve handling in RemoteControl API endpoint. --- Server/API/RemoteControlController.cs | 8 ++--- .../Pages/Account/Manage/ApiTokens.cshtml | 34 ++++++++++++++++--- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Server/API/RemoteControlController.cs b/Server/API/RemoteControlController.cs index 5f2aa6ed..4c84cfba 100644 --- a/Server/API/RemoteControlController.cs +++ b/Server/API/RemoteControlController.cs @@ -13,6 +13,7 @@ using Remotely.Server.Data; using Remotely.Server.Models; using Remotely.Server.Services; using Remotely.Server.Auth; +using Remotely.Shared.Helpers; // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 @@ -100,12 +101,9 @@ namespace Remotely.Server.API var stopWatch = Stopwatch.StartNew(); - while (!RCDeviceSocketHub.SessionInfoList.Values.Any(x => x.DeviceID == targetDevice.Value.ID && !existingSessions.Any(y => y.Key != x.RCDeviceSocketID)) && stopWatch.Elapsed.TotalSeconds < 5) - { - await Task.Delay(10); - } + Func remoteControlStarted = () => RCDeviceSocketHub.SessionInfoList.Values.Any(x => x.DeviceID == targetDevice.Value.ID && !existingSessions.Any(y => y.Key != x.RCDeviceSocketID)); - if (!RCDeviceSocketHub.SessionInfoList.Values.Any(x => x.DeviceID == targetDevice.Value.ID && !existingSessions.Any(y => y.Key != x.RCDeviceSocketID))) + if (!await TaskHelper.DelayUntil(remoteControlStarted, TimeSpan.FromSeconds(15))) { return StatusCode(408, "The remote control process failed to start in time on the remote device."); } diff --git a/Server/Areas/Identity/Pages/Account/Manage/ApiTokens.cshtml b/Server/Areas/Identity/Pages/Account/Manage/ApiTokens.cshtml index 151b4f0c..bc572f92 100644 --- a/Server/Areas/Identity/Pages/Account/Manage/ApiTokens.cshtml +++ b/Server/Areas/Identity/Pages/Account/Manage/ApiTokens.cshtml @@ -4,6 +4,7 @@ @{ ViewData["Title"] = "API Access Tokens"; } +

@ViewData["Title"]

@if (!string.IsNullOrWhiteSpace(Model.Message)) @@ -27,11 +28,12 @@ @if (Model.IsAdmin) { -
- - - -
+
+ + + + +
@@ -68,6 +70,28 @@
+ +