mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Move filters chart to ChartJS.
This commit is contained in:
@@ -131,36 +131,11 @@ namespace DiscImageChef.Server.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(ctx.Commands.Any())
|
if(ctx.Commands.Any())
|
||||||
{
|
|
||||||
ViewBag.repCommands = ctx.Commands.OrderBy(c => c.Name).ToList();
|
ViewBag.repCommands = ctx.Commands.OrderBy(c => c.Name).ToList();
|
||||||
|
|
||||||
decimal totalCommandCount = ctx.Commands.Sum(o => o.Count);
|
|
||||||
|
|
||||||
ViewData["commandsPieData"] = ctx.Commands.Select(command => new PieSeriesData
|
|
||||||
{
|
|
||||||
Name = command.Name, Y = (double?)(command.Count / totalCommandCount),
|
|
||||||
Sliced = command.Name == "analyze", Selected = command.Name == "analyze"
|
|
||||||
}).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ctx.Filters.Any())
|
if(ctx.Filters.Any())
|
||||||
{
|
|
||||||
ViewBag.repFilters = ctx.Filters.OrderBy(filter => filter.Name).ToList();
|
ViewBag.repFilters = ctx.Filters.OrderBy(filter => filter.Name).ToList();
|
||||||
|
|
||||||
List<PieSeriesData> filtersPieData = new List<PieSeriesData>();
|
|
||||||
|
|
||||||
decimal totalFiltersCount = ctx.Filters.Sum(o => o.Count);
|
|
||||||
|
|
||||||
foreach(Filter filter in ctx.Filters.ToList())
|
|
||||||
filtersPieData.Add(new PieSeriesData
|
|
||||||
{
|
|
||||||
Name = filter.Name, Y = (double?)(filter.Count / totalFiltersCount),
|
|
||||||
Sliced = filter.Name == "No filter", Selected = filter.Name == "No filter"
|
|
||||||
});
|
|
||||||
|
|
||||||
ViewData["filtersPieData"] = filtersPieData;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ctx.MediaFormats.Any())
|
if(ctx.MediaFormats.Any())
|
||||||
{
|
{
|
||||||
ViewBag.repMediaImages = ctx.MediaFormats.OrderBy(filter => filter.Name).ToList();
|
ViewBag.repMediaImages = ctx.MediaFormats.OrderBy(filter => filter.Name).ToList();
|
||||||
@@ -584,5 +559,23 @@ namespace DiscImageChef.Server.Controllers
|
|||||||
|
|
||||||
return Json(result);
|
return Json(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IActionResult GetFiltersData()
|
||||||
|
{
|
||||||
|
string[][] result =
|
||||||
|
{
|
||||||
|
ctx.Filters.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(),
|
||||||
|
ctx.Filters.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.Filters.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString();
|
||||||
|
|
||||||
|
return Json(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,7 +185,8 @@
|
|||||||
@if (ViewBag.repFilters != null)
|
@if (ViewBag.repFilters != null)
|
||||||
{
|
{
|
||||||
<div class="container mt-3" id="divFilters">
|
<div class="container mt-3" id="divFilters">
|
||||||
<div class="container" id="filtersChart">
|
<div class="container">
|
||||||
|
<canvas id="filtersChart"></canvas>
|
||||||
</div>
|
</div>
|
||||||
<div class="accordion mt-3" id="filtersAccordion">
|
<div class="accordion mt-3" id="filtersAccordion">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@@ -571,6 +572,11 @@ function DrawCommandsPie(commandsData)
|
|||||||
DrawPie("commandsChart", `Top ${commandsData[0].length} used commands`, commandsData[0], commandsData[1])
|
DrawPie("commandsChart", `Top ${commandsData[0].length} used commands`, commandsData[0], commandsData[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function DrawFiltersPie(filtersData)
|
||||||
|
{
|
||||||
|
DrawPie("filtersChart", `Top ${filtersData[0].length} filters found`, filtersData[0], filtersData[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});
|
||||||
@@ -578,6 +584,7 @@ window.onload = () => {
|
|||||||
$.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});
|
$.ajax({dataType: "json", url: "/Stats/GetVersionsData", success: DrawVersionsPie, cache:false});
|
||||||
$.ajax({dataType: "json", url: "/Stats/GetCommandsData", success: DrawCommandsPie, cache:false});
|
$.ajax({dataType: "json", url: "/Stats/GetCommandsData", success: DrawCommandsPie, cache:false});
|
||||||
|
$.ajax({dataType: "json", url: "/Stats/GetFiltersData", success: DrawFiltersPie, cache:false});
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
Reference in New Issue
Block a user