mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Move media image formats chart to ChartJS.
This commit is contained in:
@@ -577,5 +577,23 @@ namespace DiscImageChef.Server.Controllers
|
||||
|
||||
return Json(result);
|
||||
}
|
||||
|
||||
public IActionResult GetFormatsData()
|
||||
{
|
||||
string[][] result =
|
||||
{
|
||||
ctx.MediaFormats.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(),
|
||||
ctx.MediaFormats.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.MediaFormats.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString();
|
||||
|
||||
return Json(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,7 +225,8 @@
|
||||
@if (ViewBag.repMediaImages != null)
|
||||
{
|
||||
<div class="container mt-3" id="divMediaImages">
|
||||
<div class="container" id="formatsChart">
|
||||
<div class="container">
|
||||
<canvas id="formatsChart"></canvas>
|
||||
</div>
|
||||
<div class="accordion mt-3" id="formatsAccordion">
|
||||
<div class="card">
|
||||
@@ -577,6 +578,11 @@ function DrawFiltersPie(filtersData)
|
||||
DrawPie("filtersChart", `Top ${filtersData[0].length} filters found`, filtersData[0], filtersData[1])
|
||||
}
|
||||
|
||||
function DrawFormatsPie(formats)
|
||||
{
|
||||
DrawPie("formatsChart", `Top ${formats[0].length} media image formats found`, formats[0], formats[1])
|
||||
}
|
||||
|
||||
window.onload = () => {
|
||||
$.ajax({dataType: "json", url: "/Stats/GetOsData", success: DrawOsPie, cache:false});
|
||||
$.ajax({dataType: "json", url: "/Stats/GetLinuxData", success: DrawLinuxPie, cache:false});
|
||||
@@ -585,6 +591,7 @@ window.onload = () => {
|
||||
$.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/GetFiltersData", success: DrawFiltersPie, cache:false});
|
||||
$.ajax({dataType: "json", url: "/Stats/GetFormatsData", success: DrawFormatsPie, cache:false});
|
||||
}
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user