Skip to content

Commit

Permalink
Add buttons to clear and refresh remote logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed May 11, 2021
1 parent e47b59c commit f315a48
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Server/Pages/DeviceDetails.razor
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ else
}
else
{
<div class="mb-2">
<button class="btn btn-primary mr-2" @onclick="GetRemoteLogs">Refresh</button>
<button class="btn btn-danger" @onclick="DeleteLogs">Delete Logs</button>
</div>

@if (_logLines.Any())
{
<div style="white-space: pre;">
Expand Down
21 changes: 18 additions & 3 deletions Server/Pages/DeviceDetails.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Remotely.Server.Components;
using Remotely.Server.Hubs;
using Remotely.Server.Services;
using Remotely.Shared.Enums;
using Remotely.Shared.Models;
using Remotely.Shared.Utilities;
using System;
Expand All @@ -22,12 +23,11 @@ public partial class DeviceDetails : AuthComponentBase
private string _alertMessage;
private string _inputDeviceId;

[Parameter]
public string DeviceId { get; set; }

[Parameter]
public string ActiveTab { get; set; }

[Parameter]
public string DeviceId { get; set; }
[Inject]
private ICircuitConnection CircuitConnection { get; set; }

Expand All @@ -36,6 +36,9 @@ public partial class DeviceDetails : AuthComponentBase

private Device Device { get; set; }

[Inject]
private IJsInterop JsInterop { get; set; }

[Inject]
private IModalService ModalService { get; set; }

Expand All @@ -45,6 +48,7 @@ public partial class DeviceDetails : AuthComponentBase
[Inject]
private IToastService ToastService { get; set; }


protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
Expand All @@ -67,6 +71,17 @@ private void CircuitConnection_MessageReceived(object sender, Models.CircuitEven
}
}

private async Task DeleteLogs()
{
var result = await JsInterop.Confirm("Are you sure you want to delete the remote logs?");
if (result)
{
var psCommmand = "Remove-Item -Path \"$env:TEMP/Remotely_Logs.log\" -Force";
await CircuitConnection.ExecuteCommandOnAgent(ScriptingShell.PSCore, psCommmand, new string[] { Device.ID });
ToastService.ShowToast("Delete command sent.");
}
}

private void EditFormKeyDown()
{
_alertMessage = string.Empty;
Expand Down

0 comments on commit f315a48

Please sign in to comment.