From 994c6835640b8afd79836642c018fdc26cee112a Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 3 Nov 2019 03:46:19 +0000 Subject: [PATCH] Move Windows versions chart to ChartJS. --- DiscImageChef.Server/Controllers/StatsController.cs | 11 +++++++++++ DiscImageChef.Server/Views/Stats/Index.cshtml | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/DiscImageChef.Server/Controllers/StatsController.cs b/DiscImageChef.Server/Controllers/StatsController.cs index 0a668e6d..904c5458 100644 --- a/DiscImageChef.Server/Controllers/StatsController.cs +++ b/DiscImageChef.Server/Controllers/StatsController.cs @@ -521,5 +521,16 @@ namespace DiscImageChef.Server.Controllers ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()).OrderByDescending(o => o.Count). Take(10).Select(x => x.Count.ToString()).ToArray() }); + + public IActionResult GetWindowsData() => Json(new[] + { + ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()).OrderByDescending(o => o.Count). + Take(10). + Select(x => + $"{DetectOS.GetPlatformName(PlatformID.Win32NT, x.Version)}{(string.IsNullOrEmpty(x.Version) ? "" : " ")}{x.Version}"). + ToArray(), + ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()).OrderByDescending(o => o.Count). + Take(10).Select(x => x.Count.ToString()).ToArray() + }); } } \ No newline at end of file diff --git a/DiscImageChef.Server/Views/Stats/Index.cshtml b/DiscImageChef.Server/Views/Stats/Index.cshtml index aa6b8ae8..2cd10ff0 100644 --- a/DiscImageChef.Server/Views/Stats/Index.cshtml +++ b/DiscImageChef.Server/Views/Stats/Index.cshtml @@ -69,7 +69,8 @@ - @@ -553,10 +554,16 @@ function DrawMacOsPie(macosData) DrawPie("macosChart", `Top ${macosData[0].length} macOS versions`, macosData[0], macosData[1]) } +function DrawWindowsPie(windowsData) +{ + DrawPie("windowsChart", `Top ${windowsData[0].length} Windows versions`, windowsData[0], windowsData[1]) +} + window.onload = () => { $.ajax({dataType: "json", url: "/Stats/GetOsData", success: DrawOsPie, cache:false}); $.ajax({dataType: "json", url: "/Stats/GetLinuxData", success: DrawLinuxPie, cache:false}); $.ajax({dataType: "json", url: "/Stats/GetMacOsData", success: DrawMacOsPie, cache:false}); + $.ajax({dataType: "json", url: "/Stats/GetWindowsData", success: DrawWindowsPie, cache:false}); } \ No newline at end of file