mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Move DiscImageChef versions chart to ChartJS.
This commit is contained in:
@@ -114,22 +114,6 @@ namespace DiscImageChef.Server.Controllers
|
|||||||
});
|
});
|
||||||
|
|
||||||
ViewBag.repOperatingSystems = operatingSystems.OrderBy(os => os.name).ToList();
|
ViewBag.repOperatingSystems = operatingSystems.OrderBy(os => os.name).ToList();
|
||||||
|
|
||||||
List<PieSeriesData> windowsPieData = new List<PieSeriesData>();
|
|
||||||
|
|
||||||
decimal windowsCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()).
|
|
||||||
Sum(o => o.Count);
|
|
||||||
|
|
||||||
foreach(OperatingSystem version in
|
|
||||||
ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()))
|
|
||||||
windowsPieData.Add(new PieSeriesData
|
|
||||||
{
|
|
||||||
Name =
|
|
||||||
$"{DetectOS.GetPlatformName(PlatformID.Win32NT, version.Version)}{(string.IsNullOrEmpty(version.Version) ? "" : " ")}{version.Version}",
|
|
||||||
Y = (double?)(version.Count / windowsCount)
|
|
||||||
});
|
|
||||||
|
|
||||||
ViewData["windowsPieData"] = windowsPieData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ctx.Versions.Any())
|
if(ctx.Versions.Any())
|
||||||
@@ -143,15 +127,6 @@ namespace DiscImageChef.Server.Controllers
|
|||||||
});
|
});
|
||||||
|
|
||||||
ViewBag.repVersions = versions.OrderBy(ver => ver.name).ToList();
|
ViewBag.repVersions = versions.OrderBy(ver => ver.name).ToList();
|
||||||
|
|
||||||
decimal totalVersionCount = ctx.Versions.Sum(o => o.Count);
|
|
||||||
|
|
||||||
ViewData["versionsPieData"] = ctx.Versions.Select(version => new PieSeriesData
|
|
||||||
{
|
|
||||||
Name = version.Value == "previous" ? "Previous than 3.4.99.0" : version.Value,
|
|
||||||
Y = (double?)(version.Count / totalVersionCount), Sliced = version.Value == "previous",
|
|
||||||
Selected = version.Value == "previous"
|
|
||||||
}).ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ctx.Commands.Any())
|
if(ctx.Commands.Any())
|
||||||
@@ -571,5 +546,24 @@ namespace DiscImageChef.Server.Controllers
|
|||||||
|
|
||||||
return Json(result);
|
return Json(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IActionResult GetVersionsData()
|
||||||
|
{
|
||||||
|
string[][] result =
|
||||||
|
{
|
||||||
|
ctx.Versions.OrderByDescending(o => o.Count).Take(10).
|
||||||
|
Select(v => v.Value == "previous" ? "Previous than 3.4.99.0" : v.Value).ToArray(),
|
||||||
|
ctx.Versions.OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray()
|
||||||
|
};
|
||||||
|
|
||||||
|
if(result[0].Length < 10)
|
||||||
|
return Json(result);
|
||||||
|
|
||||||
|
result[0][9] = "Other";
|
||||||
|
|
||||||
|
result[1][9] = (ctx.Versions.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString();
|
||||||
|
|
||||||
|
return Json(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,8 @@
|
|||||||
@if (ViewBag.repVersions != null)
|
@if (ViewBag.repVersions != null)
|
||||||
{
|
{
|
||||||
<div class="container mt-3" id="divVersions">
|
<div class="container mt-3" id="divVersions">
|
||||||
<div class="container" id="versionsChart">
|
<div class="container">
|
||||||
|
<canvas id="versionsChart"></canvas>
|
||||||
</div>
|
</div>
|
||||||
<div class="accordion mt-3" id="versionsAccordion">
|
<div class="accordion mt-3" id="versionsAccordion">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@@ -559,11 +560,17 @@ function DrawWindowsPie(windowsData)
|
|||||||
DrawPie("windowsChart", `Top ${windowsData[0].length} Windows versions`, windowsData[0], windowsData[1])
|
DrawPie("windowsChart", `Top ${windowsData[0].length} Windows versions`, windowsData[0], windowsData[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function DrawVersionsPie(versionsData)
|
||||||
|
{
|
||||||
|
DrawPie("versionsChart", `Top ${versionsData[0].length} DiscImageChef versions`, versionsData[0], versionsData[1])
|
||||||
|
}
|
||||||
|
|
||||||
window.onload = () => {
|
window.onload = () => {
|
||||||
$.ajax({dataType: "json", url: "/Stats/GetOsData", success: DrawOsPie, cache:false});
|
$.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/GetLinuxData", success: DrawLinuxPie, cache:false});
|
||||||
$.ajax({dataType: "json", url: "/Stats/GetMacOsData", success: DrawMacOsPie, cache:false});
|
$.ajax({dataType: "json", url: "/Stats/GetMacOsData", success: DrawMacOsPie, cache:false});
|
||||||
$.ajax({dataType: "json", url: "/Stats/GetWindowsData", success: DrawWindowsPie, cache:false});
|
$.ajax({dataType: "json", url: "/Stats/GetWindowsData", success: DrawWindowsPie, cache:false});
|
||||||
|
$.ajax({dataType: "json", url: "/Stats/GetVersionsData", success: DrawVersionsPie, cache:false});
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
Reference in New Issue
Block a user