Skip to content

Commit

Permalink
Add user preferences. Remove alert broadcast.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Oct 23, 2024
1 parent 980fe1d commit 85e58af
Show file tree
Hide file tree
Showing 121 changed files with 1,053 additions and 1,568 deletions.
2 changes: 1 addition & 1 deletion .build/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ if ($BuildStreamer) {
Compress-Archive -Path "$Root\ControlR.Streamer\bin\publish\*" -DestinationPath "$DownloadsFolder\win-x86\ControlR.Streamer.zip" -Force
}

dotnet publish -p:ExcludeApp_Data=true --runtime linux-x64 --configuration Release --output $OutputPath --self-contained true "$Root\ControlR.Web.Server\"
dotnet publish -p:ExcludeApp_Data=true --runtime linux-x64 --configuration Release -p:Version=$CurrentVersion -p:FileVersion=$CurrentVersion --output $OutputPath --self-contained true "$Root\ControlR.Web.Server\"


if ($BuildWebsite) {
Expand Down
1 change: 1 addition & 0 deletions ControlR.Streamer/Services/DisplayManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Drawing;
using Bitbound.SimpleMessenger;
using ControlR.Libraries.ScreenCapture.Extensions;
using ControlR.Libraries.Shared.Dtos.HubDtos;
using ControlR.Libraries.Shared.Services.Buffers;
using ControlR.Streamer.Messages;
using Microsoft.Extensions.Hosting;
Expand Down
1 change: 1 addition & 0 deletions ControlR.Streamer/Services/DtoHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bitbound.SimpleMessenger;
using ControlR.Libraries.Shared.Dtos.HubDtos;
using ControlR.Libraries.Shared.Dtos.SidecarDtos;
using Microsoft.Extensions.Hosting;

Expand Down
1 change: 1 addition & 0 deletions ControlR.Streamer/Services/StreamerStreamingClient.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Net.WebSockets;
using Bitbound.SimpleMessenger;
using ControlR.Libraries.Clients.Services;
using ControlR.Libraries.Shared.Dtos.HubDtos;
using ControlR.Libraries.Shared.Services.Buffers;
using ControlR.Streamer.Messages;
using Microsoft.Extensions.Hosting;
Expand Down
20 changes: 10 additions & 10 deletions ControlR.Web.Client/Components/Dashboard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

<div class="d-inline-block">
<MudCheckBox T="bool"
Value="Settings.HideOfflineDevices"
Value="_hideOfflineDevices"
ValueChanged="HideOfflineDevicesChanged"
Label="Hide Offline Devices"
Disabled="IsHideOfflineDevicesDisabled"/>
</div>

<MudDataGrid T="DeviceDto"
<MudDataGrid T="DeviceResponseDto"
RowsPerPage="@(25)"
Items="FilteredDevices"
SortMode="SortMode.Multiple"
Expand Down Expand Up @@ -53,7 +53,7 @@
</ToolBarContent>

<Columns>
<TemplateColumn T="DeviceDto"
<TemplateColumn T="DeviceResponseDto"
Sortable="false"
Filterable="false"
ShowColumnOptions="false"
Expand Down Expand Up @@ -118,7 +118,7 @@
</CellTemplate>
</TemplateColumn>

<TemplateColumn T="DeviceDto"
<TemplateColumn T="DeviceResponseDto"
StickyLeft="true"
Sortable="true"
Filterable="true"
Expand All @@ -135,7 +135,7 @@
</CellTemplate>
</TemplateColumn>

<TemplateColumn T="DeviceDto"
<TemplateColumn T="DeviceResponseDto"
Sortable="true"
Filterable="true"
Title="Online">
Expand Down Expand Up @@ -173,7 +173,7 @@
</CellTemplate>
</PropertyColumn>

<TemplateColumn T="DeviceDto"
<TemplateColumn T="DeviceResponseDto"
Title="CPU"
Sortable="true"
Filterable="true">
Expand All @@ -182,7 +182,7 @@
</CellTemplate>
</TemplateColumn>

<TemplateColumn T="DeviceDto"
<TemplateColumn T="DeviceResponseDto"
Title="Memory"
Sortable="true"
Filterable="true">
Expand All @@ -191,7 +191,7 @@
</CellTemplate>
</TemplateColumn>

<TemplateColumn T="DeviceDto"
<TemplateColumn T="DeviceResponseDto"
Title="Storage"
Sortable="true"
Filterable="true">
Expand All @@ -200,7 +200,7 @@
</CellTemplate>
</TemplateColumn>

<HierarchyColumn T="DeviceDto"/>
<HierarchyColumn T="DeviceResponseDto"/>
</Columns>
<ChildRowContent>
<div class="child-content-grid">
Expand Down Expand Up @@ -255,6 +255,6 @@
</div>
</ChildRowContent>
<PagerContent>
<MudDataGridPager T="DeviceDto" />
<MudDataGridPager T="DeviceResponseDto" />
</PagerContent>
</MudDataGrid>
43 changes: 24 additions & 19 deletions ControlR.Web.Client/Components/Dashboard.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace ControlR.Web.Client.Components;

public partial class Dashboard
{
private readonly Dictionary<string, SortDefinition<DeviceDto>> _sortDefinitions = new()
private readonly Dictionary<string, SortDefinition<DeviceResponseDto>> _sortDefinitions = new()
{
["IsOnline"] = new SortDefinition<DeviceDto>(nameof(DeviceDto.IsOnline), true, 0, x => x.IsOnline),
["Name"] = new SortDefinition<DeviceDto>(nameof(DeviceDto.Name), false, 1, x => x.Name)
["IsOnline"] = new SortDefinition<DeviceResponseDto>(nameof(DeviceResponseDto.IsOnline), true, 0, x => x.IsOnline),
["Name"] = new SortDefinition<DeviceResponseDto>(nameof(DeviceResponseDto.Name), false, 1, x => x.Name)
};

private readonly FunnelLock _stateChangeLock = new(2, 2, 1, 1);
Expand Down Expand Up @@ -37,9 +37,8 @@ public partial class Dashboard
[Inject]
public required ISnackbar Snackbar { get; init; }


[Inject]
public required IVersionApi VersionApi { get; init; }
public required IControlrApi ControlrApi { get; init; }

[Inject]
public required IViewerHubConnection ViewerHub { get; init; }
Expand All @@ -48,11 +47,14 @@ public partial class Dashboard
[Inject]
public required IDeviceContentWindowStore WindowStore { get; init; }

private IEnumerable<DeviceDto> FilteredDevices
private bool _hideOfflineDevices;


private IEnumerable<DeviceResponseDto> FilteredDevices
{
get
{
if (!Settings.HideOfflineDevices || IsHideOfflineDevicesDisabled)
if (!_hideOfflineDevices || IsHideOfflineDevicesDisabled)
{
return DeviceCache.Devices;
}
Expand All @@ -64,7 +66,7 @@ private IEnumerable<DeviceDto> FilteredDevices
private bool IsHideOfflineDevicesDisabled =>
!string.IsNullOrWhiteSpace(_searchText);

private Func<DeviceDto, bool> QuickFilter => x =>
private Func<DeviceResponseDto, bool> QuickFilter => x =>
{
if (string.IsNullOrWhiteSpace(_searchText))
{
Expand All @@ -90,6 +92,8 @@ protected override async Task OnInitializedAsync()
{
using var _ = BusyCounter.IncrementBusyCounter();

_hideOfflineDevices = await Settings.GetHideOfflineDevices();

await RefreshLatestAgentVersion();

Messenger.RegisterGenericMessage(this, HandleGenericMessage);
Expand All @@ -100,7 +104,7 @@ protected override async Task OnInitializedAsync()
_loading = false;
}

private async Task ConfigureDeviceSettings(DeviceDto device)
private async Task ConfigureDeviceSettings(DeviceResponseDto device)
{
try
{
Expand Down Expand Up @@ -194,11 +198,12 @@ private async Task HandleRefreshClicked()

private async Task HideOfflineDevicesChanged(bool isChecked)
{
Settings.HideOfflineDevices = isChecked;
_hideOfflineDevices = isChecked;
await Settings.SetHideOfflineDevices(isChecked);
await InvokeAsync(StateHasChanged);
}

private bool IsAgentOutdated(DeviceDto device)
private bool IsAgentOutdated(DeviceResponseDto device)
{
return _agentReleaseVersion is not null &&
Version.TryParse(device.AgentVersion, out var agentVersion) &&
Expand All @@ -207,14 +212,14 @@ private bool IsAgentOutdated(DeviceDto device)

private async Task RefreshLatestAgentVersion()
{
var agentVerResult = await VersionApi.GetCurrentAgentVersion();
var agentVerResult = await ControlrApi.GetCurrentAgentVersion();
if (agentVerResult.IsSuccess)
{
_agentReleaseVersion = agentVerResult.Value;
}
}

private async Task RemoveDevice(DeviceDto device)
private async Task RemoveDevice(DeviceResponseDto device)
{
var result = await DialogService.ShowMessageBox(
"Confirm Removal",
Expand All @@ -230,7 +235,7 @@ private async Task RemoveDevice(DeviceDto device)
Snackbar.Add("Device removed", Severity.Success);
}

private async Task RestartDevice(DeviceDto device)
private async Task RestartDevice(DeviceResponseDto device)
{
var result = await DialogService.ShowMessageBox(
"Confirm Restart",
Expand All @@ -247,7 +252,7 @@ private async Task RestartDevice(DeviceDto device)
Snackbar.Add("Restart command sent", Severity.Success);
}

private async Task ShutdownDevice(DeviceDto device)
private async Task ShutdownDevice(DeviceResponseDto device)
{
var result = await DialogService.ShowMessageBox(
"Confirm Shutdown",
Expand All @@ -264,12 +269,12 @@ private async Task ShutdownDevice(DeviceDto device)
Snackbar.Add("Shutdown command sent", Severity.Success);
}

private async Task UpdateDevice(DeviceDto device)
private async Task UpdateDevice(DeviceResponseDto device)
{
Snackbar.Add("Sending update request", Severity.Success);
await ViewerHub.SendAgentUpdateTrigger(device);
}
private async Task RemoteControlClicked(DeviceDto device)
private async Task RemoteControlClicked(DeviceResponseDto device)
{
switch (device.Platform)
{
Expand Down Expand Up @@ -310,7 +315,7 @@ private async Task RemoteControlClicked(DeviceDto device)
}


private void StartTerminal(DeviceDto device)
private void StartTerminal(DeviceResponseDto device)
{
try
{
Expand All @@ -333,7 +338,7 @@ private void StartTerminal(DeviceDto device)
}
}

private async Task WakeDevice(DeviceDto device)
private async Task WakeDevice(DeviceResponseDto device)
{
if (device.MacAddresses is null ||
device.MacAddresses.Length == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
public required AgentAppSettings AppSettings { get; set; }

[Parameter]
public required DeviceDto Device { get; set; }
public required DeviceResponseDto Device { get; set; }

[CascadingParameter]
public required MudDialogInstance DialogInstance { get; init; }
Expand Down
24 changes: 0 additions & 24 deletions ControlR.Web.Client/Components/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@
}
else
{
<div>
@if (_showAlert)
{
<MudAlert Severity="_alertSeverity.ToMudSeverity()" ShowCloseIcon="true" CloseIconClicked="CloseAlert">
@(_alertMessage)
</MudAlert>
}
</div>
@Body
}
</MudMainContent>
Expand Down Expand Up @@ -129,10 +121,7 @@
private bool _isBrowser;
private bool _isBusy;
private bool _isWaitingForWasmLoad = true;
private bool _showAlert;
private HubConnectionState _hubConnectionState = HubConnectionState.Disconnected;
private AlertSeverity _alertSeverity = AlertSeverity.Information;
private string _alertMessage = string.Empty;
private MudTheme? _customTheme;
private int _pendingOperations;

Expand Down Expand Up @@ -174,7 +163,6 @@
{
Messenger.Value.RegisterGenericMessage(this, HandleGeneric);
Messenger.Value.Register<ToastMessage>(this, HandleToastMessage);
Messenger.Value.Register<DtoReceivedMessage<AlertBroadcastDto>>(this, HandleAlertBroadcastReceived);
Messenger.Value.Register<HubConnectionStateChangedMessage>(this, HandleHubConnectionStateChanged);

AuthState.AuthenticationStateChanged += HandleAuthenticationStateChanged;
Expand Down Expand Up @@ -202,24 +190,12 @@
return base.ShouldRender();
}

private void CloseAlert()
{
_showAlert = false;
}

private void DrawerToggle()
{
_drawerOpen = !_drawerOpen;
}

private async Task HandleAlertBroadcastReceived(object subscriber, DtoReceivedMessage<AlertBroadcastDto> message)
{
_alertMessage = message.Dto.Message;
_alertSeverity = message.Dto.Severity;
_showAlert = true;
await InvokeAsync(StateHasChanged);
}

private async void HandleAuthenticationStateChanged(Task<AuthenticationState> taskState)
{
try
Expand Down
6 changes: 3 additions & 3 deletions ControlR.Web.Client/Components/Layout/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@inject NavigationManager NavMan
@inject AuthenticationStateProvider AuthState
@inject ILogger<NavMenu> Logger
@inject IServerSettingsApi ServerSettingsApi
@inject IControlrApi ServerSettingsApi

<MudNavMenu>
<MudNavLink Href="" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Home">
Expand Down Expand Up @@ -37,8 +37,8 @@
Server Admin
</MudText>
</div>
<MudNavLink Disabled="IsDisabled" Href="@(RouteNames.ServerAdmin)" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.AdminPanelSettings">
Server Admin
<MudNavLink Disabled="IsDisabled" Href="@(RouteNames.ServerStats)" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.AdminPanelSettings">
Server Stats
</MudNavLink>
</Authorized>
</AuthorizeView>
Expand Down
5 changes: 2 additions & 3 deletions ControlR.Web.Client/Components/Pages/Deploy.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
@attribute [Authorize]

@inject NavigationManager NavMan
@inject ISettings Settings
@inject ISnackbar Snackbar
@inject IClipboardManager Clipboard
@inject IBusyCounter BusyCounter
@inject IDeviceGroupsApi DeviceGroupsApi
@inject IControlrApi ControlrApi

<PageTitle>Deploy</PageTitle>

Expand Down Expand Up @@ -113,7 +112,7 @@
{
await base.OnInitializedAsync();

var result = await DeviceGroupsApi.GetAllDeviceGroups();
var result = await ControlrApi.GetAllDeviceGroups();
if (result.IsSuccess)
{
_deviceGroups = result.Value;
Expand Down
Loading

0 comments on commit 85e58af

Please sign in to comment.