Trigger heartbeat when device is expanded.

This commit is contained in:
Jared Goodwin 2021-04-18 12:14:00 -07:00
parent 838a36f72a
commit 6a0cb369ac
6 changed files with 32 additions and 11 deletions

View File

@ -91,8 +91,8 @@ namespace Remotely.Server.Components.Devices
return string.Empty;
}
private void ExpandCard(MouseEventArgs args)
{
private async Task ExpandCard(MouseEventArgs args)
{
if (AppState.DevicesFrameFocusedDevice == Device.ID)
{
if (AppState.DevicesFrameFocusedCardState == DeviceCardState.Normal)
@ -105,6 +105,8 @@ namespace Remotely.Server.Components.Devices
AppState.DevicesFrameFocusedDevice = Device.ID;
AppState.DevicesFrameFocusedCardState = DeviceCardState.Expanded;
JsInterop.ScrollToElement(_card);
await CircuitConnection.TriggerHeartbeat(Device.ID);
}
private void ContextMenuOpening(MouseEventArgs args)
@ -168,7 +170,7 @@ namespace Remotely.Server.Components.Devices
InvokeAsync(StateHasChanged);
}
private Task HandleValidSubmit()
private async Task HandleValidSubmit()
{
DataService.UpdateDevice(Device.ID,
Device.Tags,
@ -178,7 +180,8 @@ namespace Remotely.Server.Components.Devices
Device.WebRtcSetting);
ToastService.ShowToast("Device settings saved.");
return Task.CompletedTask;
await CircuitConnection.TriggerHeartbeat(Device.ID);
}
private void OpenDeviceDetails()

View File

@ -48,6 +48,7 @@ namespace Remotely.Server.Hubs
Task UninstallAgents(string[] deviceIDs);
Task UpdateTags(string deviceID, string tags);
Task UploadFiles(List<string> fileIDs, string transferID, string[] deviceIDs);
Task TriggerHeartbeat(string deviceId);
}
public class CircuitConnection : CircuitHandler, ICircuitConnection
@ -311,6 +312,18 @@ namespace Remotely.Server.Hubs
return true;
}
public async Task TriggerHeartbeat(string deviceId)
{
var (canAccess, connectionId) = CanAccessDevice(deviceId);
if (!canAccess)
{
return;
}
await _agentHubContext.Clients.Client(connectionId).SendAsync("TriggerHeartbeat");
}
public Task UninstallAgents(string[] deviceIDs)
{
deviceIDs = _dataService.FilterDeviceIDsByUserPermission(deviceIDs, User);

View File

@ -1383,10 +1383,11 @@ namespace Remotely.Server.Services
var scriptRunGroups = dbContext.ScriptRuns
.Include(x => x.Devices)
.Include(x => x.DevicesCompleted)
.Where(x =>
x.Devices.Any(x => x.ID == deviceId) &&
!x.DevicesCompleted.Any(x => x.ID == deviceId) &&
x.RunAt < now)
.Where(scriptRun =>
dbContext.SavedScripts.Any(savedScript => savedScript.Id == scriptRun.SavedScriptId) &&
scriptRun.Devices.Any(device => device.ID == deviceId) &&
!scriptRun.DevicesCompleted.Any(deviceCompleted => deviceCompleted.ID == deviceId) &&
scriptRun.RunAt < now)
.AsEnumerable()
.GroupBy(x => x.SavedScriptId);

View File

@ -105,7 +105,6 @@ export function ToggleConnectUI(shown) {
else {
DisconnectedBox.style.removeProperty("display");
}
ConnectBox.style.removeProperty("display");
BlockInputButton.classList.remove("toggled");
AudioButton.classList.remove("toggled");
}

File diff suppressed because one or more lines are too long

View File

@ -117,7 +117,12 @@ export function ToggleConnectUI(shown: boolean) {
Screen2DContext.clearRect(0, 0, ScreenViewer.width, ScreenViewer.height);
ScreenViewer.setAttribute("hidden", "hidden");
VideoScreenViewer.setAttribute("hidden", "hidden");
ConnectBox.style.removeProperty("display");
if (ViewerApp.Mode == RemoteControlMode.Normal) {
ConnectBox.style.removeProperty("display");
}
else {
DisconnectedBox.style.removeProperty("display");
}
BlockInputButton.classList.remove("toggled");
AudioButton.classList.remove("toggled");
}