diff --git a/Aaru.Server.New/Aaru.Server.New.csproj b/Aaru.Server.New/Aaru.Server.New.csproj index 7a2232df..3661c069 100644 --- a/Aaru.Server.New/Aaru.Server.New.csproj +++ b/Aaru.Server.New/Aaru.Server.New.csproj @@ -8,6 +8,9 @@ + + + diff --git a/Aaru.Server.New/Components/App.razor b/Aaru.Server.New/Components/App.razor index 8feb082b..375d3112 100644 --- a/Aaru.Server.New/Components/App.razor +++ b/Aaru.Server.New/Components/App.razor @@ -1,11 +1,15 @@ - +@using Blazorise + - + + + + @@ -14,9 +18,22 @@ - + + + - \ No newline at end of file + + +@code{ + private readonly Theme theme = new() + { + ColorOptions = new ThemeColorOptions + { + Dark = ThemeColors.Gray.Shades["100"].Value, + Light = ThemeColors.Gray.Shades["800"].Value + } + }; +} \ No newline at end of file diff --git a/Aaru.Server.New/Components/Pages/Stats.razor b/Aaru.Server.New/Components/Pages/Stats.razor index 23f9c674..46cffa79 100644 --- a/Aaru.Server.New/Components/Pages/Stats.razor +++ b/Aaru.Server.New/Components/Pages/Stats.razor @@ -1,6 +1,134 @@ @page "/Stats" +@using Aaru.CommonTypes.Metadata @using Aaru.Server.Database +@using Aaru.Server.Database.Models +@using Blazorise.DataGrid @inject Microsoft.EntityFrameworkCore.IDbContextFactory DbContextFactory -Aaru: Statistics \ No newline at end of file +Aaru: Statistics + +@* + TODO: Group by datagrid + TODO: Sortable datagrid +*@ + +
+

+

All operating systems Aaru has run on...

+

+ + + + +
+ +
+

+

All Aaru versions...

+

+ + + + +
+ +
+

+

All Aaru commands...

+

+ + + + +
+ +
+

+

All filters found...

+

+ + + + +
+ +
+

+

All media image formats found...

+

+ + + + +
+ +
+

+

All partitioning schemes found...

+

+ + + + +
+ +
+

+

All filesystems found...

+

+ + + + +
+ +
+

+

All media types found in images...

+

+ + + + + +
+ +
+

+

All media types found in devices...

+

+ + + + + +
+ +
+

+

All devices found...

+

+ + + + + + + + @{ + int? reportId = context?.ReportId; + + if(reportId > 0) + { + Yes + } + else + { + No + } + } + + + +
\ No newline at end of file diff --git a/Aaru.Server.New/Components/Pages/Stats.razor.cs b/Aaru.Server.New/Components/Pages/Stats.razor.cs index 8f6f3e0c..670a668f 100644 --- a/Aaru.Server.New/Components/Pages/Stats.razor.cs +++ b/Aaru.Server.New/Components/Pages/Stats.razor.cs @@ -9,6 +9,23 @@ namespace Aaru.Server.New.Components.Pages; public partial class Stats { + List OperatingSystems { get; set; } = []; + + List Versions { get; set; } = []; + + List Commands { get; set; } = []; + + List Filters { get; set; } = []; + + List MediaImages { get; set; } = []; + + List Partitions { get; set; } = []; + + List Filesystems { get; set; } = []; + List RealMedia { get; set; } = []; + List VirtualMedia { get; set; } = []; + List Devices { get; set; } = []; + /// protected override async Task OnInitializedAsync() { @@ -17,38 +34,37 @@ public partial class Stats // TOOD: Cache real OS name in database, lookups would be much faster await using DbContext _ctx = await DbContextFactory.CreateDbContextAsync(); - var operatingSystems = (await _ctx.OperatingSystems.OrderBy(static os => os.Name) - .ThenBy(static os => os.Version) - .Select(static nvs => new NameValueStats - { - name = - $"{GetPlatformName(nvs.Name, nvs.Version)}{(string.IsNullOrEmpty(nvs.Version) ? "" : " ")}{nvs.Version}", - Value = nvs.Count - }) - .ToListAsync()).OrderBy(static os => os.name) - .ToList(); + OperatingSystems = (await _ctx.OperatingSystems.OrderBy(static os => os.Name) + .ThenBy(static os => os.Version) + .Select(static nvs => new NameValueStats + { + name = + $"{GetPlatformName(nvs.Name, nvs.Version)}{(string.IsNullOrEmpty(nvs.Version) ? "" : " ")}{nvs.Version}", + Value = nvs.Count + }) + .ToListAsync()).OrderBy(static os => os.name) + .ToList(); - var versions = (await _ctx.Versions.Select(static nvs => new NameValueStats - { - name = nvs.Name == "previous" ? "Previous than 3.4.99.0" : nvs.Name, - Value = nvs.Count - }) - .ToListAsync()).OrderBy(static version => version.name) - .ToList(); + Versions = (await _ctx.Versions.Select(static nvs => new NameValueStats + { + name = nvs.Name == "previous" ? "Previous than 3.4.99.0" : nvs.Name, + Value = nvs.Count + }) + .ToListAsync()).OrderBy(static version => version.name) + .ToList(); - List commands = await _ctx.Commands.OrderBy(static c => c.Name).ToListAsync(); + Commands = await _ctx.Commands.OrderBy(static c => c.Name).ToListAsync(); - List filters = await _ctx.Filters.OrderBy(static filter => filter.Name).ToListAsync(); + Filters = await _ctx.Filters.OrderBy(static filter => filter.Name).ToListAsync(); - List mediaImages = await _ctx.MediaFormats.OrderBy(static format => format.Name).ToListAsync(); + MediaImages = await _ctx.MediaFormats.OrderBy(static format => format.Name).ToListAsync(); - List partitions = await _ctx.Partitions.OrderBy(static partition => partition.Name).ToListAsync(); + Partitions = await _ctx.Partitions.OrderBy(static partition => partition.Name).ToListAsync(); - List filesystems = - await _ctx.Filesystems.OrderBy(static filesystem => filesystem.Name).ToListAsync(); + Filesystems = await _ctx.Filesystems.OrderBy(static filesystem => filesystem.Name).ToListAsync(); - List realMedia = []; - List virtualMedia = []; + RealMedia = []; + VirtualMedia = []; await foreach(Media nvs in _ctx.Medias.AsAsyncEnumerable()) { @@ -60,7 +76,7 @@ public partial class Stats if(nvs.Real) { - realMedia.Add(new MediaItem + RealMedia.Add(new MediaItem { Type = mediaType.type, SubType = mediaType.subType, @@ -69,7 +85,7 @@ public partial class Stats } else { - virtualMedia.Add(new MediaItem + VirtualMedia.Add(new MediaItem { Type = mediaType.type, SubType = mediaType.subType, @@ -81,7 +97,7 @@ public partial class Stats { if(nvs.Real) { - realMedia.Add(new MediaItem + RealMedia.Add(new MediaItem { Type = nvs.Type, SubType = null, @@ -90,7 +106,7 @@ public partial class Stats } else { - virtualMedia.Add(new MediaItem + VirtualMedia.Add(new MediaItem { Type = nvs.Type, SubType = null, @@ -100,24 +116,22 @@ public partial class Stats } } - realMedia = realMedia.OrderBy(static media => media.Type).ThenBy(static media => media.SubType).ToList(); - virtualMedia = virtualMedia.OrderBy(static media => media.Type).ThenBy(static media => media.SubType).ToList(); + RealMedia = RealMedia.OrderBy(static media => media.Type).ThenBy(static media => media.SubType).ToList(); + VirtualMedia = VirtualMedia.OrderBy(static media => media.Type).ThenBy(static media => media.SubType).ToList(); - List devices = await _ctx.DeviceStats.Include(static deviceStat => deviceStat.Report) - .Select(static device => new DeviceItem - { - Manufacturer = device.Manufacturer, - Model = device.Model, - Revision = device.Revision, - Bus = device.Bus, - ReportId = device.Report != null && device.Report.Id != 0 - ? device.Report.Id - : 0 - }) - .ToListAsync(); + Devices = await _ctx.DeviceStats.Include(static deviceStat => deviceStat.Report) + .Select(static device => new DeviceItem + { + Manufacturer = device.Manufacturer, + Model = device.Model, + Revision = device.Revision, + Bus = device.Bus, + ReportId = device.Report != null && device.Report.Id != 0 ? device.Report.Id : 0 + }) + .ToListAsync(); - devices = devices.OrderBy(static device => device.Manufacturer) + Devices = Devices.OrderBy(static device => device.Manufacturer) .ThenBy(static device => device.Model) .ThenBy(static device => device.Revision) .ThenBy(static device => device.Bus) diff --git a/Aaru.Server.New/Program.cs b/Aaru.Server.New/Program.cs index ac3daace..309ce8cc 100644 --- a/Aaru.Server.New/Program.cs +++ b/Aaru.Server.New/Program.cs @@ -1,5 +1,8 @@ using Aaru.Server.New.Components; using Aaru.Server.New.Components.Account; +using Blazorise; +using Blazorise.Bootstrap; +using Blazorise.Icons.FontAwesome; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; @@ -43,6 +46,8 @@ builder.Services.AddIdentityCore(options => builder.Services.AddSingleton, IdentityNoOpEmailSender>(); +builder.Services.AddBlazorise(options => { options.Immediate = true; }).AddBootstrapProviders().AddFontAwesomeIcons(); + WebApplication app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/Aaru.Server.New/wwwroot/app.css b/Aaru.Server.New/wwwroot/app.css index bcd38fe1..4bca0265 100644 --- a/Aaru.Server.New/wwwroot/app.css +++ b/Aaru.Server.New/wwwroot/app.css @@ -697,3 +697,22 @@ kbd { padding: 3px 5px; vertical-align: middle; } + +.table { + color: #DEDEDE; +} + +.stats-section { + margin: 0 auto; + max-width: 800px; + padding: 30px 15px 40px !important; + position: relative; +} + +.table-fixed-header .table thead:not(.table-thead-theme) th { + background-color: #333333; +} + +.table-fixed-header { + scrollbar-color: #888888 #333333; +} \ No newline at end of file