mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Make device ID optional on device details. Add it to the nav menu.
This commit is contained in:
parent
97d8eaf8ff
commit
63d511c083
@ -2,8 +2,11 @@
|
||||
@inherits AuthComponentBase
|
||||
|
||||
<div @ref="_card" class="card border-secondary my-3 mr-3 device-card @Theme @GetCardStateClass(Device)"
|
||||
@onclick="() => ExpandCard()"
|
||||
@onclick:stopPropagation="true">
|
||||
@onclick="ExpandCard"
|
||||
@onclick:stopPropagation="true"
|
||||
@oncontextmenu="ContextMenuOpening"
|
||||
@oncontextmenu:preventDefault="GetCardState() == DeviceCardState.Normal"
|
||||
@oncontextmenu:stopPropagation="GetCardState() == DeviceCardState.Normal">
|
||||
|
||||
<div class="card-header">
|
||||
<div>
|
||||
|
||||
@ -89,7 +89,7 @@ namespace Remotely.Server.Components.Devices
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private void ExpandCard()
|
||||
private void ExpandCard(MouseEventArgs args)
|
||||
{
|
||||
if (AppState.DevicesFrameFocusedDevice == Device.ID)
|
||||
{
|
||||
@ -105,6 +105,14 @@ namespace Remotely.Server.Components.Devices
|
||||
JsInterop.ScrollToElement(_card);
|
||||
}
|
||||
|
||||
private void ContextMenuOpening(MouseEventArgs args)
|
||||
{
|
||||
if (GetCardState() == DeviceCardState.Normal)
|
||||
{
|
||||
JsInterop.OpenWindow($"/device-details/{Device.ID}", "_blank");
|
||||
}
|
||||
}
|
||||
|
||||
private DeviceCardState GetCardState()
|
||||
{
|
||||
if (AppState.DevicesFrameFocusedDevice == Device.ID)
|
||||
@ -173,7 +181,7 @@ namespace Remotely.Server.Components.Devices
|
||||
|
||||
private void OpenDeviceDetails()
|
||||
{
|
||||
JsInterop.OpenWindow($"/DeviceDetails/{Device.ID}", "_blank");
|
||||
JsInterop.OpenWindow($"/device-details/{Device.ID}", "_blank");
|
||||
}
|
||||
|
||||
private void SetCardStateNormal()
|
||||
|
||||
@ -75,7 +75,7 @@ namespace Remotely.Server.Components.Scripts
|
||||
{
|
||||
if (User.Id != _selectedSchedule.CreatorId)
|
||||
{
|
||||
ToastService.ShowToast("You can't delete other people's scripts.", classString: "bg-warning");
|
||||
ToastService.ShowToast("You can't delete other people's script schedules.", classString: "bg-warning");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -1,10 +1,35 @@
|
||||
@page "/DeviceDetails/{deviceId}"
|
||||
@page "/device-details/{deviceId?}"
|
||||
|
||||
@attribute [Authorize]
|
||||
@inherits AuthComponentBase
|
||||
|
||||
|
||||
@if (Device is null)
|
||||
@if (string.IsNullOrWhiteSpace(DeviceId))
|
||||
{
|
||||
<div class="row mt-5">
|
||||
<div class="col-sm-6 offset-2">
|
||||
|
||||
<h3>Device ID:</h3>
|
||||
<div class="input-group mb-2">
|
||||
<input type="text" class="form-control" placeholder="Enter a device ID to see its details"
|
||||
@bind="_inputDeviceId"
|
||||
@bind:event="oninput"
|
||||
@onkeydown="EvaluateDeviceIdInputKeyDown">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" @onclick="NavigateToDeviceId">Go</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-muted">
|
||||
You can also go directly to a device's details by:
|
||||
<ul>
|
||||
<li>Right-clicking a device card on the main page while it's collapsed</li>
|
||||
<li>Clicking the "Open in New Tab" button in a device card's header while it's expanded</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else if (Device is null)
|
||||
{
|
||||
<h3>Device not found.</h3>
|
||||
}
|
||||
@ -121,9 +146,9 @@ else
|
||||
<div class="col-sm-10">
|
||||
<InputSelect @bind-Value="Device.WebRtcSetting" class="form-control">
|
||||
@foreach (var setting in Enum.GetValues(typeof(WebRtcSetting)))
|
||||
{
|
||||
{
|
||||
<option @key="setting" value="@setting">@setting</option>
|
||||
}
|
||||
}
|
||||
</InputSelect>
|
||||
<ValidationMessage For="() => Device.WebRtcSetting" />
|
||||
</div>
|
||||
@ -136,9 +161,9 @@ else
|
||||
<option value="">None</option>
|
||||
|
||||
@foreach (var group in DataService.GetDeviceGroups(Username))
|
||||
{
|
||||
{
|
||||
<option @key="group.ID" value="@group.ID">@group.Name</option>
|
||||
}
|
||||
}
|
||||
</InputSelect>
|
||||
<ValidationMessage For="() => Device.DeviceGroupID" />
|
||||
</div>
|
||||
@ -163,7 +188,7 @@ else
|
||||
</EditForm>
|
||||
</div>
|
||||
</TabContent>
|
||||
|
||||
|
||||
<TabContent Name="remote-logs">
|
||||
<div class="py-3">
|
||||
@if (!Device.IsOnline)
|
||||
@ -190,7 +215,7 @@ else
|
||||
</div>
|
||||
|
||||
</TabContent>
|
||||
|
||||
|
||||
<TabContent Name="script-history">
|
||||
|
||||
<h3 class="mb-3 mt-3">
|
||||
@ -212,19 +237,19 @@ else
|
||||
<tbody>
|
||||
@foreach (var scriptResult in _scriptResults)
|
||||
{
|
||||
<tr>
|
||||
<td>@scriptResult.Shell</td>
|
||||
<td>@scriptResult.TimeStamp</td>
|
||||
<td>@scriptResult.SenderUserName</td>
|
||||
<td>@scriptResult.RunTime</td>
|
||||
<td>@GetTrimmedText(scriptResult.ScriptInput, 25)</td>
|
||||
<td>@GetTrimmedText(scriptResult.StandardOutput, 25)</td>
|
||||
<td>@GetTrimmedText(scriptResult.ErrorOutput, 25)</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-primary" @onclick="() => ShowFullScriptOutput(scriptResult)">Show Full</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
<tr>
|
||||
<td>@scriptResult.Shell</td>
|
||||
<td>@scriptResult.TimeStamp</td>
|
||||
<td>@scriptResult.SenderUserName</td>
|
||||
<td>@scriptResult.RunTime</td>
|
||||
<td>@GetTrimmedText(scriptResult.ScriptInput, 25)</td>
|
||||
<td>@GetTrimmedText(scriptResult.StandardOutput, 25)</td>
|
||||
<td>@GetTrimmedText(scriptResult.ErrorOutput, 25)</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-primary" @onclick="() => ShowFullScriptOutput(scriptResult)">Show Full</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Rendering;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Remotely.Server.Components;
|
||||
using Remotely.Server.Hubs;
|
||||
using Remotely.Server.Services;
|
||||
@ -7,9 +8,7 @@ using Remotely.Shared.Models;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -21,6 +20,7 @@ namespace Remotely.Server.Pages
|
||||
private readonly ConcurrentQueue<ScriptResult> _scriptResults = new();
|
||||
|
||||
private string _alertMessage;
|
||||
private string _inputDeviceId;
|
||||
|
||||
[Parameter]
|
||||
public string DeviceId { get; set; }
|
||||
@ -36,8 +36,12 @@ namespace Remotely.Server.Pages
|
||||
[Inject]
|
||||
private IModalService ModalService { get; set; }
|
||||
|
||||
[Inject]
|
||||
private NavigationManager NavManager { get; set; }
|
||||
|
||||
[Inject]
|
||||
private IToastService ToastService { get; set; }
|
||||
|
||||
protected override Task OnInitializedAsync()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(DeviceId))
|
||||
@ -65,6 +69,14 @@ namespace Remotely.Server.Pages
|
||||
_alertMessage = string.Empty;
|
||||
}
|
||||
|
||||
private void EvaluateDeviceIdInputKeyDown(KeyboardEventArgs args)
|
||||
{
|
||||
if (args.Key.Equals("Enter", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
NavManager.NavigateTo($"/device-details/{_inputDeviceId}");
|
||||
}
|
||||
}
|
||||
|
||||
private void GetRemoteLogs()
|
||||
{
|
||||
_logLines.Clear();
|
||||
@ -84,7 +96,7 @@ namespace Remotely.Server.Pages
|
||||
var results = DataService
|
||||
.GetAllScriptResults(User.OrganizationID, Device.ID)
|
||||
.OrderByDescending(x => x.TimeStamp);
|
||||
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
_scriptResults.Enqueue(result);
|
||||
@ -117,6 +129,7 @@ namespace Remotely.Server.Pages
|
||||
|
||||
return source[0..25] + "...";
|
||||
}
|
||||
|
||||
private string GetTrimmedText(string[] source, int stringLength)
|
||||
{
|
||||
return GetTrimmedText(string.Join("", source), stringLength);
|
||||
@ -137,6 +150,11 @@ namespace Remotely.Server.Pages
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void NavigateToDeviceId()
|
||||
{
|
||||
NavManager.NavigateTo($"/device-details/{_inputDeviceId}");
|
||||
}
|
||||
|
||||
private void ShowAllDisks()
|
||||
{
|
||||
var disksString = JsonSerializer.Serialize(Device.Drives, JsonSerializerHelper.IndentedOptions);
|
||||
@ -166,4 +184,4 @@ namespace Remotely.Server.Pages
|
||||
ModalService.ShowModal("Script Input/Output", outputModal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,11 @@
|
||||
<span class="oi oi-script" aria-hidden="true"></span> Scripts
|
||||
</NavLink>
|
||||
</li>
|
||||
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="device-details">
|
||||
<span class="oi oi-info" aria-hidden="true"></span> Device Details
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="user-options">
|
||||
<span class="oi oi-pencil" aria-hidden="true"></span> User Options
|
||||
|
||||
Loading…
Reference in New Issue
Block a user