mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Move filesystems chart to ChartJS.
This commit is contained in:
@@ -143,34 +143,8 @@ namespace DiscImageChef.Server.Controllers
|
||||
ViewBag.repPartitions = ctx.Partitions.OrderBy(filter => filter.Name).ToList();
|
||||
|
||||
if(ctx.Filesystems.Any())
|
||||
{
|
||||
ViewBag.repFilesystems = ctx.Filesystems.OrderBy(filter => filter.Name).ToList();
|
||||
|
||||
List<PieSeriesData> filesystemsPieData = new List<PieSeriesData>();
|
||||
|
||||
decimal totalFilesystemsCount = ctx.Filesystems.Sum(o => o.Count);
|
||||
decimal top10FilesystemCount = 0;
|
||||
|
||||
foreach(Filesystem filesystem in ctx.Filesystems.OrderByDescending(o => o.Count).Take(10))
|
||||
{
|
||||
top10FilesystemCount += filesystem.Count;
|
||||
|
||||
filesystemsPieData.Add(new PieSeriesData
|
||||
{
|
||||
Name = filesystem.Name, Y = (double?)(filesystem.Count / totalFilesystemsCount)
|
||||
});
|
||||
}
|
||||
|
||||
filesystemsPieData.Add(new PieSeriesData
|
||||
{
|
||||
Name = "Other",
|
||||
Y = (double?)((totalFilesystemsCount - top10FilesystemCount) / totalFilesystemsCount),
|
||||
Sliced = true, Selected = true
|
||||
});
|
||||
|
||||
ViewData["filesystemsPieData"] = filesystemsPieData;
|
||||
}
|
||||
|
||||
if(ctx.Medias.Any())
|
||||
{
|
||||
realMedia = new List<MediaItem>();
|
||||
@@ -562,5 +536,23 @@ namespace DiscImageChef.Server.Controllers
|
||||
|
||||
return Json(result);
|
||||
}
|
||||
|
||||
public IActionResult GetFilesystemsData()
|
||||
{
|
||||
string[][] result =
|
||||
{
|
||||
ctx.Filesystems.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(),
|
||||
ctx.Filesystems.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.Filesystems.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString();
|
||||
|
||||
return Json(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -305,7 +305,8 @@
|
||||
@if (ViewBag.repFilesystems != null)
|
||||
{
|
||||
<div class="container mt-3" id="divFilesystems">
|
||||
<div class="container" id="filesystemsChart">
|
||||
<div class="container">
|
||||
<canvas id="filesystemsChart"></canvas>
|
||||
</div>
|
||||
<div class="accordion mt-3" id="filesystemsAccordion">
|
||||
<div class="card">
|
||||
@@ -589,6 +590,11 @@ function DrawPartitionsPie(partitionsData)
|
||||
DrawPie("partitionsChart", `Top ${partitionsData[0].length} partitioning schemes found`, partitionsData[0], partitionsData[1])
|
||||
}
|
||||
|
||||
function DrawFilesystemsPie(filesystemsData)
|
||||
{
|
||||
DrawPie("filesystemsChart", `Top ${filesystemsData[0].length} filesystems found`, filesystemsData[0], filesystemsData[1])
|
||||
}
|
||||
|
||||
window.onload = () => {
|
||||
$.ajax({dataType: "json", url: "/Stats/GetOsData", success: DrawOsPie, cache:false});
|
||||
$.ajax({dataType: "json", url: "/Stats/GetLinuxData", success: DrawLinuxPie, cache:false});
|
||||
@@ -599,6 +605,7 @@ window.onload = () => {
|
||||
$.ajax({dataType: "json", url: "/Stats/GetFiltersData", success: DrawFiltersPie, cache:false});
|
||||
$.ajax({dataType: "json", url: "/Stats/GetFormatsData", success: DrawFormatsPie, cache:false});
|
||||
$.ajax({dataType: "json", url: "/Stats/GetPartitionsData", success: DrawPartitionsPie, cache:false});
|
||||
$.ajax({dataType: "json", url: "/Stats/GetFilesystemsData", success: DrawFilesystemsPie, cache:false});
|
||||
}
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user