From 2482e30cb3340bc2d12f97fe84e6fa67617bce82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=97=D0=B5=D0=BB?= =?UTF-8?q?=D1=82=D1=8B=D0=BD=D1=8C?= Date: Tue, 2 Jun 2026 00:09:50 +0900 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=B4=D0=B8=D0=B0=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CartriX.Web/Layout/MainLayout.razor | 2 +- CartriX.Web/Pages/Dashboard.razor | 156 +++++++++++++++++++++++++--- 2 files changed, 143 insertions(+), 15 deletions(-) diff --git a/CartriX.Web/Layout/MainLayout.razor b/CartriX.Web/Layout/MainLayout.razor index 4716145..7b6c566 100644 --- a/CartriX.Web/Layout/MainLayout.razor +++ b/CartriX.Web/Layout/MainLayout.razor @@ -16,5 +16,5 @@ @code { - bool sideBarExpanded = true; + bool sideBarExpanded = false; } \ No newline at end of file diff --git a/CartriX.Web/Pages/Dashboard.razor b/CartriX.Web/Pages/Dashboard.razor index 25719be..4de6638 100644 --- a/CartriX.Web/Pages/Dashboard.razor +++ b/CartriX.Web/Pages/Dashboard.razor @@ -2,30 +2,158 @@ @page "/dashboard" @inject HttpClient http - - - + + + + + + + +
+ + +
+ + + + - + + + + + - + +
+ + +
+ + +
+ + + + + + + + + + + + + +
+ @code { + private List recordPrintedPagesItems = new(); + private List groupedData = new(); + private readonly List availableDays = new() { 7, 14, 21 }; + private int selectedDays = 7; - List recordPrintedPagesItems = new(); - - protected async override Task OnInitializedAsync() + protected override async Task OnInitializedAsync() { - + await LoadData(); } - - async Task GetrecordPrintedPagesItems() + private async Task OnDaysChanged(object value) { - var responce = http.GetAsync(Shared.Classes.ApiRoutes.Report.GetRecordPrintAtSeletedDays(5)); - + selectedDays = Convert.ToInt32(value); + await LoadData(); } -} + + private async Task LoadData() + { + try + { + var response = await http.GetAsync( + Shared.Classes.ApiRoutes.Report.GetRecordPrintAtSeletedDays(selectedDays)); + + var json = await response.Content.ReadAsStringAsync(); + var items = JsonConvert.DeserializeObject>(json) ?? new(); + + recordPrintedPagesItems = items; + BuildGroupedData(); + } + catch (Exception ex) + { + Console.WriteLine($"Ошибка: {ex.Message}"); + } + } + + private void BuildGroupedData() + { + var grouped = recordPrintedPagesItems + .GroupBy(x => x.Date) + .ToDictionary(g => g.Key, g => g.Sum(x => x.CounntPrinted)); + + var today = DateOnly.FromDateTime(DateTime.Now); + var startDate = today.AddDays(-(selectedDays - 1)); + + groupedData = Enumerable.Range(0, selectedDays) + .Select(i => + { + var date = startDate.AddDays(i); + return new GroupedPrintData + { + Date = date, + DateString = date.ToString("dd.MM.yyyy"), + TotalPrinted = grouped.TryGetValue(date, out var total) ? total : 0 + }; + }) + .ToList(); + } + + public class GroupedPrintData + { + public DateOnly Date { get; set; } + public string DateString { get; set; } = string.Empty; + public int TotalPrinted { get; set; } + } +} \ No newline at end of file