mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Make deep links for tabs.
This commit is contained in:
parent
c530851bc6
commit
347d92eed5
@ -1,4 +1,6 @@
|
||||
<li class="nav-item">
|
||||
@inject NavigationManager NavManager
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @ActiveClass" data-toggle="tab" @onclick="SetActiveTab" style="cursor: pointer; user-select: none;">
|
||||
@ChildContent
|
||||
</a>
|
||||
@ -14,24 +16,39 @@
|
||||
[Parameter]
|
||||
public Action OnActivated { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string NavigationUri { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Name { get; set; }
|
||||
|
||||
private string ActiveClass => Parent.ActiveTab == Name ? "active" : "";
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
if (Parent is null)
|
||||
{
|
||||
throw new Exception("TabHeader must be contained in a TabControl.");
|
||||
}
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(NavigationUri))
|
||||
{
|
||||
OnActivated?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetActiveTab()
|
||||
{
|
||||
Parent.SetActiveTab(this);
|
||||
StateHasChanged();
|
||||
OnActivated?.Invoke();
|
||||
if (!string.IsNullOrWhiteSpace(NavigationUri))
|
||||
{
|
||||
NavManager.NavigateTo(NavigationUri);
|
||||
}
|
||||
else
|
||||
{
|
||||
Parent.SetActiveTab(this);
|
||||
StateHasChanged();
|
||||
OnActivated?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
@page "/device-details/{deviceId?}"
|
||||
@page "/device-details/{deviceId?}/{activeTab?}"
|
||||
|
||||
@attribute [Authorize]
|
||||
@inherits AuthComponentBase
|
||||
@ -39,15 +39,15 @@ else if (!DataService.DoesUserHaveAccessToDevice(Device.ID, User))
|
||||
}
|
||||
else
|
||||
{
|
||||
<TabControl InitialActiveTab="device">
|
||||
<TabControl InitialActiveTab="@(ActiveTab ?? "device")">
|
||||
<TabHeaders>
|
||||
<TabHeader Name="device">
|
||||
<TabHeader Name="device" NavigationUri="@($"/device-details/{DeviceId}/device")">
|
||||
Details
|
||||
</TabHeader>
|
||||
<TabHeader Name="remote-logs" OnActivated="GetRemoteLogs">
|
||||
<TabHeader Name="remote-logs" OnActivated="GetRemoteLogs" NavigationUri="@($"/device-details/{DeviceId}/remote-logs")">
|
||||
Remote Logs
|
||||
</TabHeader>
|
||||
<TabHeader Name="script-history" OnActivated="GetScriptHistory">
|
||||
<TabHeader Name="script-history" OnActivated="GetScriptHistory" NavigationUri="@($"/device-details/{DeviceId}/script-history")">
|
||||
Script History
|
||||
</TabHeader>
|
||||
</TabHeaders>
|
||||
|
||||
@ -25,6 +25,9 @@ namespace Remotely.Server.Pages
|
||||
[Parameter]
|
||||
public string DeviceId { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string ActiveTab { get; set; }
|
||||
|
||||
[Inject]
|
||||
private ICircuitConnection CircuitConnection { get; set; }
|
||||
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
@page "/scripts"
|
||||
@page "/scripts/{activeTab?}"
|
||||
@inherits AuthComponentBase
|
||||
@using System.Collections
|
||||
@inject IDataService DataService
|
||||
|
||||
<CascadingValue Value="this">
|
||||
<TabControl InitialActiveTab="saved-scripts">
|
||||
<TabControl InitialActiveTab="@(ActiveTab ?? "saved-scripts")">
|
||||
<TabHeaders>
|
||||
<TabHeader Name="saved-scripts">
|
||||
<TabHeader Name="saved-scripts" NavigationUri="/scripts/saved-scripts">
|
||||
Saved Scripts
|
||||
</TabHeader>
|
||||
<TabHeader Name="run-script">
|
||||
<TabHeader Name="run-script" NavigationUri="/scripts/run-script">
|
||||
Run Script
|
||||
</TabHeader>
|
||||
<TabHeader Name="script-schedules">
|
||||
<TabHeader Name="script-schedules" NavigationUri="/scripts/script-schedules">
|
||||
Script Schedules
|
||||
</TabHeader>
|
||||
</TabHeaders>
|
||||
@ -33,6 +33,9 @@
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public string ActiveTab { get; set; }
|
||||
|
||||
public bool ShowOnlyMyScripts { get; set; } = true;
|
||||
|
||||
public readonly List<ScriptTreeNode> TreeNodes = new();
|
||||
|
||||
@ -926,6 +926,11 @@ namespace Remotely.Server.Services
|
||||
|
||||
public bool DoesUserHaveAccessToDevice(string deviceID, RemotelyUser remotelyUser)
|
||||
{
|
||||
if (remotelyUser is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
using var dbContext = _dbFactory.CreateDbContext();
|
||||
|
||||
return dbContext.Devices
|
||||
|
||||
Loading…
Reference in New Issue
Block a user