mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Move commands chart to ChartJS.
This commit is contained in:
@@ -44,6 +44,7 @@ using DiscImageChef.Server.Models;
|
|||||||
using Highsoft.Web.Mvc.Charts;
|
using Highsoft.Web.Mvc.Charts;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using OperatingSystem = DiscImageChef.Server.Models.OperatingSystem;
|
using OperatingSystem = DiscImageChef.Server.Models.OperatingSystem;
|
||||||
using PlatformID = DiscImageChef.CommonTypes.Interop.PlatformID;
|
using PlatformID = DiscImageChef.CommonTypes.Interop.PlatformID;
|
||||||
using Version = DiscImageChef.Server.Models.Version;
|
using Version = DiscImageChef.Server.Models.Version;
|
||||||
@@ -565,5 +566,23 @@ namespace DiscImageChef.Server.Controllers
|
|||||||
|
|
||||||
return Json(result);
|
return Json(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IActionResult GetCommandsData()
|
||||||
|
{
|
||||||
|
string[][] result =
|
||||||
|
{
|
||||||
|
ctx.Commands.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(),
|
||||||
|
ctx.Commands.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.Commands.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString();
|
||||||
|
|
||||||
|
return Json(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,8 @@
|
|||||||
@if (ViewBag.repCommands != null)
|
@if (ViewBag.repCommands != null)
|
||||||
{
|
{
|
||||||
<div class="container mt-3" id="divCommands">
|
<div class="container mt-3" id="divCommands">
|
||||||
<div class="container" id="commandsChart">
|
<div class="container">
|
||||||
|
<canvas id="commandsChart"></canvas>
|
||||||
</div>
|
</div>
|
||||||
<div class="accordion mt-3" id="commandsAccordion">
|
<div class="accordion mt-3" id="commandsAccordion">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@@ -565,12 +566,18 @@ function DrawVersionsPie(versionsData)
|
|||||||
DrawPie("versionsChart", `Top ${versionsData[0].length} DiscImageChef versions`, versionsData[0], versionsData[1])
|
DrawPie("versionsChart", `Top ${versionsData[0].length} DiscImageChef versions`, versionsData[0], versionsData[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function DrawCommandsPie(commandsData)
|
||||||
|
{
|
||||||
|
DrawPie("commandsChart", `Top ${commandsData[0].length} used commands`, commandsData[0], commandsData[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});
|
$.ajax({dataType: "json", url: "/Stats/GetVersionsData", success: DrawVersionsPie, cache:false});
|
||||||
|
$.ajax({dataType: "json", url: "/Stats/GetCommandsData", success: DrawCommandsPie, cache:false});
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
Reference in New Issue
Block a user