mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Put stats charts in carousels.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
@using Aaru.CommonTypes.Metadata
|
||||
@using Aaru.Server.Database
|
||||
@using Aaru.Server.Database.Models
|
||||
@using Blazorise
|
||||
@using Blazorise.Charts
|
||||
@using Blazorise.DataGrid
|
||||
@rendermode InteractiveServer
|
||||
@@ -19,10 +20,20 @@
|
||||
<h1>
|
||||
<p class="text-center" style="color: deeppink;">All operating systems Aaru has run on...</p>
|
||||
</h1>
|
||||
<PieChart @ref="_operatingSystemsChart" style="padding: 40px" TItem="long"/>
|
||||
<PieChart @ref="_linuxChart" style="padding: 40px" TItem="long"/>
|
||||
<PieChart @ref="_macosChart" style="padding: 40px" TItem="long"/>
|
||||
<PieChart @ref="_windowsChart" style="padding: 40px" TItem="long"/>
|
||||
<Carousel @ref="_operatingSystemsCarousel">
|
||||
<CarouselSlide Name="1">
|
||||
<PieChart @ref="_operatingSystemsChart" style="padding: 40px" TItem="long"/>
|
||||
</CarouselSlide>
|
||||
<CarouselSlide Name="2">
|
||||
<PieChart @ref="_linuxChart" style="padding: 40px" TItem="long"/>
|
||||
</CarouselSlide>
|
||||
<CarouselSlide Name="3">
|
||||
<PieChart @ref="_macosChart" style="padding: 40px" TItem="long"/>
|
||||
</CarouselSlide>
|
||||
<CarouselSlide Name="4">
|
||||
<PieChart @ref="_windowsChart" style="padding: 40px" TItem="long"/>
|
||||
</CarouselSlide>
|
||||
</Carousel>
|
||||
<DataGrid Data="@OperatingSystems" FixedHeader FixedHeaderDataGridMaxHeight="300px" PageSize="int.MaxValue" TItem="NameValueStats">
|
||||
<DataGridColumn Caption="Name" Field="@nameof(NameValueStats.name)"/>
|
||||
<DataGridNumericColumn Caption="Times" Field="@nameof(NameValueStats.Value)"/>
|
||||
@@ -123,8 +134,14 @@
|
||||
<h1>
|
||||
<p class="text-center" style="color: deeppink;">All devices found...</p>
|
||||
</h1>
|
||||
<PieChart @ref="_devicesByBusChart" style="padding: 40px" TItem="long"/>
|
||||
<PieChart @ref="_devicesByManufacturerChart" style="padding: 40px" TItem="long"/>
|
||||
<Carousel @ref="_devicesCarousel">
|
||||
<CarouselSlide Name="1">
|
||||
<PieChart @ref="_devicesByBusChart" style="padding: 40px" TItem="long"/>
|
||||
</CarouselSlide>
|
||||
<CarouselSlide Name="2">
|
||||
<PieChart @ref="_devicesByManufacturerChart" style="padding: 40px" TItem="long"/>
|
||||
</CarouselSlide>
|
||||
</Carousel>
|
||||
<DataGrid Data="@Devices" FixedHeader FixedHeaderDataGridMaxHeight="300px" PageSize="int.MaxValue" TItem="DeviceItem">
|
||||
<DataGridColumn Caption="Manufacturer" Field="@nameof(DeviceItem.Manufacturer)"/>
|
||||
<DataGridColumn Caption="Model" Field="@nameof(DeviceItem.Model)"/>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using Aaru.CommonTypes.Interop;
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.Server.Database.Models;
|
||||
using Blazorise;
|
||||
using Blazorise.Charts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using DbContext = Aaru.Server.Database.DbContext;
|
||||
using Media = Aaru.Server.Database.Models.Media;
|
||||
using PlatformID = Aaru.CommonTypes.Interop.PlatformID;
|
||||
|
||||
namespace Aaru.Server.New.Components.Pages;
|
||||
@@ -29,6 +31,7 @@ public partial class Stats
|
||||
PieChart<long>? _devicesByManufacturerChart;
|
||||
List<long> _devicesByManufacturerCounts = [];
|
||||
string[] _devicesByManufacturerLabels = [];
|
||||
Carousel? _devicesCarousel;
|
||||
PieChart<long>? _filesystemsChart;
|
||||
List<long> _filesystemsCounts = [];
|
||||
string[] _filesystemsLabels = [];
|
||||
@@ -42,11 +45,12 @@ public partial class Stats
|
||||
List<long> _linuxCounts = [];
|
||||
string[] _linuxLabels = [];
|
||||
PieChart<long>? _macosChart;
|
||||
List<long> _macosCounts = [];
|
||||
string[] _macosLabels = [];
|
||||
List<long> _operatingSystemCounts = [];
|
||||
string[] _operatingSystemLabels = [];
|
||||
List<long> _macosCounts = [];
|
||||
string[] _macosLabels = [];
|
||||
Carousel? _operatingSystemsCarousel;
|
||||
PieChart<long>? _operatingSystemsChart;
|
||||
List<long> _operatingSystemsCounts = [];
|
||||
string[] _operatingSystemsLabels = [];
|
||||
PieChart<long>? _partitionsChart;
|
||||
List<long> _partitionsCounts = [];
|
||||
string[] _partitionsLabels = [];
|
||||
@@ -103,13 +107,13 @@ public partial class Stats
|
||||
Count = g.Sum()
|
||||
});
|
||||
|
||||
_operatingSystemLabels = await osQuery.Select(static x => x.Name).ToArrayAsync();
|
||||
_operatingSystemCounts = await osQuery.Select(static x => x.Count).ToListAsync();
|
||||
_operatingSystemsLabels = await osQuery.Select(static x => x.Name).ToArrayAsync();
|
||||
_operatingSystemsCounts = await osQuery.Select(static x => x.Count).ToListAsync();
|
||||
|
||||
for(var i = 0; i < _operatingSystemLabels.Length; i++)
|
||||
for(var i = 0; i < _operatingSystemsLabels.Length; i++)
|
||||
{
|
||||
_operatingSystemLabels[i] =
|
||||
DetectOS.GetPlatformName((PlatformID)Enum.Parse(typeof(PlatformID), _operatingSystemLabels[i]));
|
||||
_operatingSystemsLabels[i] =
|
||||
DetectOS.GetPlatformName((PlatformID)Enum.Parse(typeof(PlatformID), _operatingSystemsLabels[i]));
|
||||
}
|
||||
|
||||
_linuxLabels = await _ctx.OperatingSystems.Where(static o => o.Name == PlatformID.Linux.ToString())
|
||||
@@ -498,25 +502,29 @@ public partial class Stats
|
||||
#pragma warning disable CS8604 // Possible null reference argument.
|
||||
|
||||
await
|
||||
Task.WhenAll(HandleRedraw(_operatingSystemsChart, _operatingSystemLabels, GetOperatingSystemsChartDataset),
|
||||
HandleRedraw(_linuxChart, _linuxLabels, GetLinuxChartDataset),
|
||||
HandleRedraw(_macosChart, _macosLabels, GetMacosChartDataset),
|
||||
HandleRedraw(_windowsChart, _windowsLabels, GetWindowsChartDataset),
|
||||
HandleRedraw(_versionsChart, _versionsLabels, GetVersionsChartDataset),
|
||||
HandleRedraw(_commandsChart, _commandsLabels, GetCommandsChartDataset),
|
||||
HandleRedraw(_filtersChart, _filtersLabels, GetFiltersChartDataset),
|
||||
HandleRedraw(_formatsChart, _formatsLabels, GetFormatsChartDataset),
|
||||
HandleRedraw(_partitionsChart, _partitionsLabels, GetPartitionsChartDataset),
|
||||
HandleRedraw(_filesystemsChart, _filesystemsLabels, GetFilesystemsChartDataset),
|
||||
HandleRedraw(_virtualMediaChart, _virtualMediaLabels, GetVirtualMediaChartDataset),
|
||||
HandleRedraw(_realMediaChart, _realMediaLabels, GetRealMediaChartDataset),
|
||||
HandleRedraw(_devicesByBusChart, _devicesByBusLabels, GetDevicesByBusChartDataset),
|
||||
Task.WhenAll(HandleRedraw(_operatingSystemsChart, _operatingSystemsLabels, GetOperatingSystemsChartDataset),
|
||||
HandleRedraw(_linuxChart, _linuxLabels, GetLinuxChartDataset),
|
||||
HandleRedraw(_macosChart, _macosLabels, GetMacosChartDataset),
|
||||
HandleRedraw(_windowsChart, _windowsLabels, GetWindowsChartDataset),
|
||||
HandleRedraw(_versionsChart, _versionsLabels, GetVersionsChartDataset),
|
||||
HandleRedraw(_commandsChart, _commandsLabels, GetCommandsChartDataset),
|
||||
HandleRedraw(_filtersChart, _filtersLabels, GetFiltersChartDataset),
|
||||
HandleRedraw(_formatsChart, _formatsLabels, GetFormatsChartDataset),
|
||||
HandleRedraw(_partitionsChart, _partitionsLabels, GetPartitionsChartDataset),
|
||||
HandleRedraw(_filesystemsChart, _filesystemsLabels, GetFilesystemsChartDataset),
|
||||
HandleRedraw(_virtualMediaChart, _virtualMediaLabels, GetVirtualMediaChartDataset),
|
||||
HandleRedraw(_realMediaChart, _realMediaLabels, GetRealMediaChartDataset),
|
||||
HandleRedraw(_devicesByBusChart, _devicesByBusLabels, GetDevicesByBusChartDataset),
|
||||
HandleRedraw(_devicesByManufacturerChart,
|
||||
_devicesByManufacturerLabels,
|
||||
GetDevicesByManufacturerChartDataset));
|
||||
}
|
||||
#pragma warning restore CS8604 // Possible null reference argument.
|
||||
|
||||
// Upstream: https://github.com/Megabit/Blazorise/issues/5491
|
||||
_operatingSystemsCarousel.Interval = 5000;
|
||||
_devicesCarousel.Interval = 5000;
|
||||
}
|
||||
|
||||
static async Task HandleRedraw<TDataSet, TItem, TOptions, TModel>(
|
||||
BaseChart<TDataSet, TItem, TOptions, TModel> chart, string[] labels, Func<TDataSet> getDataSet)
|
||||
where TDataSet : ChartDataset<TItem> where TOptions : ChartOptions where TModel : ChartModel
|
||||
@@ -529,7 +537,7 @@ public partial class Stats
|
||||
PieChartDataset<long> GetOperatingSystemsChartDataset() => new()
|
||||
{
|
||||
Label = "Operating systems",
|
||||
Data = _operatingSystemCounts,
|
||||
Data = _operatingSystemsCounts,
|
||||
BackgroundColor = _backgroundColors,
|
||||
BorderColor = _borderColors,
|
||||
BorderWidth = 1
|
||||
|
||||
Reference in New Issue
Block a user