From d00e087b3547ddbbb37fa2d403e1f3a29af9b984 Mon Sep 17 00:00:00 2001 From: ivanszabo Date: Mon, 14 Sep 2026 11:14:22 +0200 Subject: [PATCH] =?UTF-8?q?Dashboard=20is=20=C3=A9l=C5=91,=20bek=C3=B6tve!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/CheckListController.cs | 30 ++- .../Services/CheckListService.cs | 182 +++++++++++++++++- .../Services/Interfaces/ICheckListService.cs | 7 +- src/WorkFlowCheck.Common/DTO/DashboardDTO.cs | 63 ++++++ src/WorkFlowCheck.Web/Pages/Index.cshtml | 35 ++-- src/WorkFlowCheck.Web/Pages/Index.cshtml.cs | 97 ++++------ .../Services/CheckListService.cs | 25 ++- .../Services/Interfaces/ICheckListService.cs | 7 +- 8 files changed, 347 insertions(+), 99 deletions(-) create mode 100644 src/WorkFlowCheck.Common/DTO/DashboardDTO.cs diff --git a/src/WorkFlowCheck.API/Controllers/CheckListController.cs b/src/WorkFlowCheck.API/Controllers/CheckListController.cs index a2ebee6..7d581bf 100644 --- a/src/WorkFlowCheck.API/Controllers/CheckListController.cs +++ b/src/WorkFlowCheck.API/Controllers/CheckListController.cs @@ -12,12 +12,30 @@ namespace WorkFlowCheck.API.Controllers public class CheckListController : ControllerBase { private ICheckListService _checkListService; - public CheckListController(ICheckListService checkListService) - { - _checkListService = checkListService; - } - - [HttpGet("GetCheckListHeader/{id}")] + public CheckListController(ICheckListService checkListService) + { + _checkListService = checkListService; + } + + [HttpGet("GetDashboardInfo")] + public async Task> GetDashboardInfo() + { + var retVal = new ApiResponseDTO(); + try + { + retVal.Data = await _checkListService.GetDashboardInfoAsync(); + retVal.IsSuccess = true; + } + catch (Exception ex) + { + retVal.IsSuccess = false; + retVal.Errors.Add("A műszerfal adatainak lekérése sikertelen."); + Log.Error(ex, "GetDashboardInfo failed"); + } + return retVal; + } + + [HttpGet("GetCheckListHeader/{id}")] public async Task> GetCheckListHeader(int id) { var retVal = new ApiResponseDTO() diff --git a/src/WorkFlowCheck.BL/Services/CheckListService.cs b/src/WorkFlowCheck.BL/Services/CheckListService.cs index 6b1fa98..c57023f 100644 --- a/src/WorkFlowCheck.BL/Services/CheckListService.cs +++ b/src/WorkFlowCheck.BL/Services/CheckListService.cs @@ -16,8 +16,9 @@ using System.Threading.Tasks; using WorkFlowCheck.BL.DocumentGenerator; using WorkFlowCheck.BL.Services.Interfaces; using WorkFlowCheck.Common.DataTables; -using WorkFlowCheck.Common.DTO; -using WorkFlowCheck.Common.Enums; +using WorkFlowCheck.Common.DTO; +using WorkFlowCheck.Common.Enums; +using WorkFlowCheck.Common.Helper; using WorkFlowCheck.DL; using WorkFlowCheck.DL.Entities; @@ -34,12 +35,177 @@ namespace WorkFlowCheck.BL.Services INumberGeneratorService numberGeneratorService, IMessageService messageService, IUserService userService) : base(dbContext, mapper) - { - _numberGeneratorService = numberGeneratorService; - _messageService = messageService; - } - - public async Task GetCheckListHeaderAsync(int Id) + { + _numberGeneratorService = numberGeneratorService; + _messageService = messageService; + } + + public async Task GetDashboardInfoAsync() + { + var now = DateTime.UtcNow; + var currentMonthStart = new DateTime(now.Year, now.Month, 1, 0, 0, 0, DateTimeKind.Utc); + var nextMonthStart = currentMonthStart.AddMonths(1); + var previousMonthStart = currentMonthStart.AddMonths(-1); + var sixMonthStart = currentMonthStart.AddMonths(-5); + var fortyEightHoursAgo = now.AddHours(-48); + + var headers = _dbContext.CheckListHeaders.AsNoTracking(); + + var statusCounts = await headers + .GroupBy(x => x.CheckStatus) + .Select(x => new { Status = x.Key, Count = x.Count() }) + .ToListAsync(); + + var monthlyRaw = await headers + .Where(x => x.CreatedAt >= sixMonthStart && x.CreatedAt < nextMonthStart) + .GroupBy(x => new { x.CreatedAt.Year, x.CreatedAt.Month }) + .Select(x => new + { + x.Key.Year, + x.Key.Month, + Total = x.Count(), + Approved = x.Count(y => y.CheckStatus == CheckStatus.Signed || y.CheckStatus == CheckStatus.Closed) + }) + .ToListAsync(); + + var topUsers = await headers + .Where(x => x.CreatedAt >= currentMonthStart && x.CreatedAt < nextMonthStart) + .GroupBy(x => new { x.UserId, x.User.LastName, x.User.FirstName }) + .Select(x => new DashboardUserItemDTO + { + Name = (x.Key.LastName + " " + x.Key.FirstName).Trim(), + Count = x.Count() + }) + .OrderByDescending(x => x.Count) + .ThenBy(x => x.Name) + .Take(5) + .ToListAsync(); + + var recentItems = await headers + .OrderByDescending(x => x.LastModAt) + .Select(x => new + { + x.Id, + x.DocumentNumber, + x.ShortName, + x.User.LastName, + x.User.FirstName, + x.LastModAt, + x.CheckStatus + }) + .Take(8) + .ToListAsync(); + + var delayedApprovalCount = await headers.CountAsync(x => + x.CheckStatus == CheckStatus.Sent && x.LastModAt < fortyEightHoursAgo); + + var blockedCount = statusCounts.FirstOrDefault(x => x.Status == CheckStatus.Blocked)?.Count ?? 0; + var currentMonthCount = monthlyRaw + .FirstOrDefault(x => x.Year == currentMonthStart.Year && x.Month == currentMonthStart.Month)?.Total ?? 0; + var previousMonthCount = monthlyRaw + .FirstOrDefault(x => x.Year == previousMonthStart.Year && x.Month == previousMonthStart.Month)?.Total ?? 0; + var approvedThisMonth = monthlyRaw + .FirstOrDefault(x => x.Year == currentMonthStart.Year && x.Month == currentMonthStart.Month)?.Approved ?? 0; + + var culture = System.Globalization.CultureInfo.GetCultureInfo("hu-HU"); + var result = new DashboardDTO + { + GeneratedAt = now, + TotalCheckLists = statusCounts.Sum(x => x.Count), + CheckListsThisMonth = currentMonthCount, + MonthlyChangePercent = previousMonthCount == 0 + ? (currentMonthCount > 0 ? 100 : 0) + : Math.Round((currentMonthCount - previousMonthCount) * 100m / previousMonthCount, 1), + OpenAndInProgressCount = statusCounts + .Where(x => x.Status == CheckStatus.Open || x.Status == CheckStatus.InProgress) + .Sum(x => x.Count), + AwaitingApprovalCount = statusCounts.FirstOrDefault(x => x.Status == CheckStatus.Sent)?.Count ?? 0, + BlockedCount = blockedCount, + ApprovedThisMonthCount = approvedThisMonth, + ApprovalRate = currentMonthCount == 0 ? 0 : Math.Round(approvedThisMonth * 100m / currentMonthCount, 1), + ActiveUserCount = await _dbContext.Users.AsNoTracking().CountAsync(x => x.Active), + TemplateCount = await _dbContext.CheckListTemplateHeaders.AsNoTracking().CountAsync(), + TopUsers = topUsers, + AttentionItems = new List(), + RecentCheckLists = recentItems.Select(x => new DashboardRecentCheckListDTO + { + Id = x.Id, + DocumentNumber = x.DocumentNumber, + ShortName = x.ShortName, + Responsible = (x.LastName + " " + x.FirstName).Trim(), + ModifiedAt = x.LastModAt, + Status = x.CheckStatus, + StatusName = DisplayNameHelper.GetEnumDisplayName(x.CheckStatus) + }).ToList() + }; + + for (var i = 0; i < 6; i++) + { + var month = sixMonthStart.AddMonths(i); + var value = monthlyRaw.FirstOrDefault(x => x.Year == month.Year && x.Month == month.Month); + result.MonthlyItems.Add(new DashboardMonthlyItemDTO + { + Month = month.ToString("MMM", culture).TrimEnd('.'), + Total = value?.Total ?? 0, + Approved = value?.Approved ?? 0 + }); + } + + foreach (var status in Enum.GetValues()) + { + result.StatusItems.Add(new DashboardStatusItemDTO + { + Status = status, + Name = DisplayNameHelper.GetEnumDisplayName(status), + Count = statusCounts.FirstOrDefault(x => x.Status == status)?.Count ?? 0, + Color = GetDashboardStatusColor(status) + }); + } + + if (delayedApprovalCount > 0) + { + result.AttentionItems.Add(new DashboardAttentionItemDTO + { + Title = $"{delayedApprovalCount} munkalap több mint 48 órája jóváhagyásra vár", + Description = "Érdemes ellenőrizni a beküldött munkalapokat.", + IsCritical = true + }); + } + if (blockedCount > 0) + { + result.AttentionItems.Add(new DashboardAttentionItemDTO + { + Title = $"{blockedCount} blokkolt munkalap", + Description = "A folytatásuk felhasználói beavatkozást igényel.", + IsCritical = true + }); + } + if (result.AwaitingApprovalCount > delayedApprovalCount) + { + result.AttentionItems.Add(new DashboardAttentionItemDTO + { + Title = $"{result.AwaitingApprovalCount - delayedApprovalCount} friss beküldött munkalap", + Description = "Jóváhagyásra váró, 48 óránál frissebb tételek.", + IsCritical = false + }); + } + + return result; + } + + private static string GetDashboardStatusColor(CheckStatus status) => status switch + { + CheckStatus.Open => "#64748b", + CheckStatus.InProgress => "#e28a17", + CheckStatus.Blocked => "#dc2626", + CheckStatus.Storno => "#7c3aed", + CheckStatus.Sent => "#38bdf8", + CheckStatus.Signed => "#16875b", + CheckStatus.Closed => "#123c69", + _ => "#94a3b8" + }; + + public async Task GetCheckListHeaderAsync(int Id) { var retVal = new CheckListHeaderDTO() { diff --git a/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs b/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs index b708fb0..7f7b5d4 100644 --- a/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs +++ b/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs @@ -4,9 +4,10 @@ using WorkFlowCheck.Common.DTO; namespace WorkFlowCheck.BL.Services.Interfaces { - public interface ICheckListService - { - Task GetCheckListHeaderAsync(int Id); + public interface ICheckListService + { + Task GetDashboardInfoAsync(); + Task GetCheckListHeaderAsync(int Id); Task>> GetFilteredCheckListHeaderAsync(DataTablesRequest dataTablesRequest); Task> GetAllCheckListHeaderAsync(int mode = 0); Task UpdateCheckListHeaderAsync(CheckListHeaderDTO checkListHeaderDTO); diff --git a/src/WorkFlowCheck.Common/DTO/DashboardDTO.cs b/src/WorkFlowCheck.Common/DTO/DashboardDTO.cs new file mode 100644 index 0000000..bb276fd --- /dev/null +++ b/src/WorkFlowCheck.Common/DTO/DashboardDTO.cs @@ -0,0 +1,63 @@ +using WorkFlowCheck.Common.Enums; + +namespace WorkFlowCheck.Common.DTO +{ + public class DashboardDTO + { + public DateTime GeneratedAt { get; set; } + public int TotalCheckLists { get; set; } + public int CheckListsThisMonth { get; set; } + public decimal MonthlyChangePercent { get; set; } + public int OpenAndInProgressCount { get; set; } + public int AwaitingApprovalCount { get; set; } + public int BlockedCount { get; set; } + public int ApprovedThisMonthCount { get; set; } + public decimal ApprovalRate { get; set; } + public int ActiveUserCount { get; set; } + public int TemplateCount { get; set; } + public List MonthlyItems { get; set; } = new(); + public List StatusItems { get; set; } = new(); + public List TopUsers { get; set; } = new(); + public List AttentionItems { get; set; } = new(); + public List RecentCheckLists { get; set; } = new(); + } + + public class DashboardMonthlyItemDTO + { + public string Month { get; set; } = string.Empty; + public int Total { get; set; } + public int Approved { get; set; } + } + + public class DashboardStatusItemDTO + { + public CheckStatus Status { get; set; } + public string Name { get; set; } = string.Empty; + public int Count { get; set; } + public string Color { get; set; } = string.Empty; + } + + public class DashboardUserItemDTO + { + public string Name { get; set; } = string.Empty; + public int Count { get; set; } + } + + public class DashboardAttentionItemDTO + { + public string Title { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public bool IsCritical { get; set; } + } + + public class DashboardRecentCheckListDTO + { + public int Id { get; set; } + public string DocumentNumber { get; set; } = string.Empty; + public string ShortName { get; set; } = string.Empty; + public string Responsible { get; set; } = string.Empty; + public DateTime ModifiedAt { get; set; } + public CheckStatus Status { get; set; } + public string StatusName { get; set; } = string.Empty; + } +} diff --git a/src/WorkFlowCheck.Web/Pages/Index.cshtml b/src/WorkFlowCheck.Web/Pages/Index.cshtml index c4e0c01..63e1a7a 100644 --- a/src/WorkFlowCheck.Web/Pages/Index.cshtml +++ b/src/WorkFlowCheck.Web/Pages/Index.cshtml @@ -46,6 +46,7 @@ .status-badge { display:inline-flex; align-items:center; gap:.3rem; padding:.3rem .52rem; border-radius:999px; font-size:.7rem; font-weight:720; white-space:nowrap; } .status-approved { color:#0d6b47; background:#dcf5e9; } .status-submitted { color:#075985; background:#e0f2fe; } .status-progress { color:#945500; background:#fff1d2; } .status-closed { color:#475569; background:#e9eef4; } + .status-blocked { color:#991b1b; background:#fee2e2; } .status-storno { color:#6d28d9; background:#ede9fe; } @@media(max-width:1199.98px){.kpi-grid{grid-template-columns:repeat(2,minmax(0,1fr));}} @@media(max-width:991.98px){.dashboard-grid,.dashboard-grid.equal{grid-template-columns:1fr;}} @@media(max-width:575.98px){.dashboard-heading{align-items:stretch;flex-direction:column}.demo-badge{align-self:flex-start}.kpi-grid{grid-template-columns:1fr}.chart-container{height:245px}.dashboard-card-header{align-items:flex-start;flex-direction:column}.dashboard-table{min-width:720px}} @@ -54,15 +55,15 @@
-

Gyártási ellenőrzések áttekintése

@Model.PeriodLabel · Frissítve: @Model.GeneratedAt.ToString("yyyy. MM. dd. HH:mm")

- Mintaadatokkal +

Ellenőrzések áttekintése

@Model.PeriodLabel · Frissítve: @Model.Dashboard.GeneratedAt.ToLocalTime().ToString("yyyy. MM. dd. HH:mm")

+ Élő adatok
-
@Model.MonthlyChangePercent.ToString("0.0")%
@Model.InspectionsThisMonth
Ellenőrzés ebben a hónapban
-
@Model.AwaitingApproval jóváhagyásra vár
@Model.InProgress
Folyamatban lévő ellenőrzés
-
@Model.ApprovalRate.ToString("0.0")% arány
@Model.ApprovedThisMonth
Jóváhagyás ebben a hónapban
-
átlagos idő
@Model.AverageDurationMinutes.ToString("0.0") perc
Egy ellenőrzés végrehajtása
+
@Model.Dashboard.MonthlyChangePercent.ToString("0.0")%
@Model.Dashboard.CheckListsThisMonth.ToString("N0")
Ellenőrzés ebben a hónapban
+
@Model.Dashboard.AwaitingApprovalCount jóváhagyásra vár
@Model.Dashboard.OpenAndInProgressCount.ToString("N0")
Nyitott vagy folyamatban
+
@Model.Dashboard.ApprovalRate.ToString("0.0")% arány
@Model.Dashboard.ApprovedThisMonthCount.ToString("N0")
Jóváhagyás ebben a hónapban
+
összesen @Model.Dashboard.TotalCheckLists.ToString("N0")
@Model.Dashboard.BlockedCount.ToString("N0")
Blokkolt munkalap
@@ -71,26 +72,26 @@
-

Aktuális állapotok

Az e havi ellenőrzések megoszlása

-
@foreach(var status in Model.Statuses){
@status.Name@status.Count
}
+

Aktuális állapotok

Az összes ellenőrzés jelenlegi megoszlása

+
@foreach(var status in Model.Dashboard.StatusItems){
@status.Name@status.Count
}
-

Jóváhagyások személyenként

Aktuális hónap · jóváhagyott ellenőrzések száma

+

Ellenőrzések személyenként

Aktuális hónap · elindított ellenőrzések száma

-

Figyelmet igényel

Elakadt vagy határidős tételek

@Model.AttentionItems.Count
-
@foreach(var item in Model.AttentionItems){
@item.Title
@item.Description
}
+

Figyelmet igényel

Elakadt vagy jóváhagyásra váró tételek

@Model.Dashboard.AttentionItems.Count
+
@if(Model.Dashboard.AttentionItems.Count == 0){
Nincs figyelmet igénylő tétel
Minden munkalap rendben halad.
}else{@foreach(var item in Model.Dashboard.AttentionItems){
@item.Title
@item.Description
}}

Legutóbbi ellenőrzések

A rendszerben legutóbb módosított tételek

Összes megtekintése
-
- @foreach(var item in Model.RecentInspections){} +
AzonosítóEllenőrzésLokációFelelősMódosítvaÁllapot
@item.Code@item.Name@item.Location@item.Responsible@item.ModifiedAt.ToString("yyyy. MM. dd. HH:mm")@item.Status
+ @if(Model.Dashboard.RecentCheckLists.Count == 0){}else{@foreach(var item in Model.Dashboard.RecentCheckLists){}}
AzonosítóEllenőrzésFelelősMódosítvaÁllapot
Még nincs megjeleníthető ellenőrzés.
@item.DocumentNumber@item.ShortName@item.Responsible@item.ModifiedAt.ToLocalTime().ToString("yyyy. MM. dd. HH:mm")@item.StatusName
@@ -99,14 +100,14 @@ } diff --git a/src/WorkFlowCheck.Web/Pages/Index.cshtml.cs b/src/WorkFlowCheck.Web/Pages/Index.cshtml.cs index 98d353a..f7125ee 100644 --- a/src/WorkFlowCheck.Web/Pages/Index.cshtml.cs +++ b/src/WorkFlowCheck.Web/Pages/Index.cshtml.cs @@ -1,76 +1,57 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using System.Globalization; +using WorkFlowCheck.Common.DTO; +using WorkFlowCheck.Common.Enums; +using WorkFlowCheck.Web.Services.Interfaces; namespace WorkFlowCheck.Web.Pages { public class IndexModel : PageModel { + private readonly ICheckListService _checkListService; private readonly ILogger _logger; - public DateTime GeneratedAt { get; private set; } - public string PeriodLabel { get; private set; } = string.Empty; - public int InspectionsThisMonth { get; private set; } - public decimal MonthlyChangePercent { get; private set; } - public int InProgress { get; private set; } - public int AwaitingApproval { get; private set; } - public int ApprovedThisMonth { get; private set; } - public decimal ApprovalRate { get; private set; } - public decimal AverageDurationMinutes { get; private set; } - public List MonthlyInspections { get; private set; } = []; - public List Statuses { get; private set; } = []; - public List Approvers { get; private set; } = []; - public List AttentionItems { get; private set; } = []; - public List RecentInspections { get; private set; } = []; + public DashboardDTO Dashboard { get; private set; } = new(); + public string PeriodLabel => Dashboard.GeneratedAt.ToLocalTime() + .ToString("yyyy. MMMM", CultureInfo.GetCultureInfo("hu-HU")); - public IndexModel(ILogger logger) => _logger = logger; - - public void OnGet() + public IndexModel(ICheckListService checkListService, ILogger logger) { - // TODO: A következő körben ezt az egy blokkot cseréljük IDashboardService hívásra. - LoadDemoData(); + _checkListService = checkListService; + _logger = logger; } - private void LoadDemoData() + public async Task OnGetAsync() { - GeneratedAt = DateTime.Now; - PeriodLabel = GeneratedAt.ToString("yyyy. MMMM", CultureInfo.GetCultureInfo("hu-HU")); - InspectionsThisMonth = 128; - MonthlyChangePercent = 18.5m; - InProgress = 17; - AwaitingApproval = 9; - ApprovedThisMonth = 96; - ApprovalRate = 75.0m; - AverageDurationMinutes = 14.2m; - - var totals = new[] { 76, 89, 84, 105, 112, 128 }; - var approved = new[] { 55, 63, 61, 79, 86, 96 }; - var firstMonth = new DateTime(GeneratedAt.Year, GeneratedAt.Month, 1).AddMonths(-5); - var culture = CultureInfo.GetCultureInfo("hu-HU"); - MonthlyInspections = Enumerable.Range(0, 6).Select(i => new MonthlyInspectionPoint(firstMonth.AddMonths(i).ToString("MMM", culture).TrimEnd('.'), totals[i], approved[i])).ToList(); - - Statuses = [new("Jóváhagyott",96,"#16875b"),new("Beküldött",9,"#38bdf8"),new("Folyamatban",17,"#e28a17"),new("Lezárt",6,"#94a3b8")]; - Approvers = [new("Kovács Péter",28),new("Nagy Anna",24),new("Tóth Gábor",19),new("Szabó Éva",15),new("Varga Tamás",10)]; - AttentionItems = - [ - new("3 ellenőrzés több mint 48 órája beküldve", "Jóváhagyásra várnak a C2 gyártócsarnokban.", true), - new("Kalibrálás hamarosan lejár", "A CNC–04 berendezés következő határideje 3 nap.", false), - new("Hiányzó fényképes dokumentáció", "2 folyamatban lévő ellenőrzésnél nincs csatolmány.", true), - new("Heti ellenőrzési terv", "A tervezett 34 ellenőrzésből még 7 nem kezdődött el.", false) - ]; - RecentInspections = - [ - new("WFC-260912-018","Műszakindító gépellenőrzés","C2 gyártócsarnok","Kiss Dániel",GeneratedAt.AddMinutes(-18),"Jóváhagyott","status-approved","bi-check-circle"), - new("WFC-260912-017","Hegesztőcella biztonsági ellenőrzés","A1 csarnok","Farkas András",GeneratedAt.AddMinutes(-42),"Beküldött","status-submitted","bi-send-check"), - new("WFC-260912-016","Csomagolósor minőségellenőrzés","B3 csomagoló","Molnár Rita",GeneratedAt.AddHours(-1.4),"Folyamatban","status-progress","bi-hourglass-split"), - new("WFC-260912-015","Napi karbantartási ellenőrzés","CNC terület","Kiss Dániel",GeneratedAt.AddHours(-2.1),"Lezárt","status-closed","bi-lock"), - new("WFC-260912-014","Beérkező alapanyag vizsgálata","Központi raktár","Nagy Júlia",GeneratedAt.AddHours(-3.3),"Jóváhagyott","status-approved","bi-check-circle") - ]; + try + { + Dashboard = await _checkListService.GetDashboardInfoAsync(); + } + catch (Exception ex) + { + _logger.LogError(ex, "A műszerfal betöltése sikertelen."); + Dashboard = new DashboardDTO { GeneratedAt = DateTime.UtcNow }; + } } - public sealed record MonthlyInspectionPoint(string Month, int Total, int Approved); - public sealed record DashboardStatus(string Name, int Count, string Color); - public sealed record ApproverStatistic(string Name, int Count); - public sealed record AttentionItem(string Title, string Description, bool IsCritical); - public sealed record RecentInspection(string Code, string Name, string Location, string Responsible, DateTime ModifiedAt, string Status, string StatusCss, string StatusIcon); + public static string GetStatusCss(CheckStatus status) => status switch + { + CheckStatus.Signed => "status-approved", + CheckStatus.Sent => "status-submitted", + CheckStatus.Open or CheckStatus.InProgress => "status-progress", + CheckStatus.Blocked => "status-blocked", + CheckStatus.Storno => "status-storno", + _ => "status-closed" + }; + + public static string GetStatusIcon(CheckStatus status) => status switch + { + CheckStatus.Signed => "bi-check-circle", + CheckStatus.Sent => "bi-send-check", + CheckStatus.Blocked => "bi-slash-circle", + CheckStatus.Storno => "bi-x-circle", + CheckStatus.Closed => "bi-lock", + _ => "bi-hourglass-split" + }; } } diff --git a/src/WorkFlowCheck.Web/Services/CheckListService.cs b/src/WorkFlowCheck.Web/Services/CheckListService.cs index 383da4c..697bdb0 100644 --- a/src/WorkFlowCheck.Web/Services/CheckListService.cs +++ b/src/WorkFlowCheck.Web/Services/CheckListService.cs @@ -13,10 +13,27 @@ namespace WorkFlowCheck.Web.Services { public class CheckListService : BaseService, ICheckListService { - public CheckListService(HttpClient httpClient, IConfiguration configuration, IHttpContextAccessor httpContextAccessor) : base(httpClient, configuration, httpContextAccessor) - { - } - public async Task>> GetFilteredCheckListHeaderAsync(DataTablesRequest dataTablesRequest) + public CheckListService(HttpClient httpClient, IConfiguration configuration, IHttpContextAccessor httpContextAccessor) : base(httpClient, configuration, httpContextAccessor) + { + } + public async Task GetDashboardInfoAsync() + { + var endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetDashboardInfo"; + try + { + var response = await _httpClient.GetFromJsonAsync>(endpoint); + if (response?.IsSuccess == true && response.Data != null) + { + return response.Data; + } + } + catch (Exception ex) + { + Log.Error(ex, "GetDashboardInfoAsync failed"); + } + return new DashboardDTO { GeneratedAt = DateTime.Now }; + } + public async Task>> GetFilteredCheckListHeaderAsync(DataTablesRequest dataTablesRequest) { try { diff --git a/src/WorkFlowCheck.Web/Services/Interfaces/ICheckListService.cs b/src/WorkFlowCheck.Web/Services/Interfaces/ICheckListService.cs index 2a596f5..03864ed 100644 --- a/src/WorkFlowCheck.Web/Services/Interfaces/ICheckListService.cs +++ b/src/WorkFlowCheck.Web/Services/Interfaces/ICheckListService.cs @@ -4,9 +4,10 @@ using WorkFlowCheck.Common.DTO; namespace WorkFlowCheck.Web.Services.Interfaces { - public interface ICheckListService - { - Task GetCheckListHeader(int id); + public interface ICheckListService + { + Task GetDashboardInfoAsync(); + Task GetCheckListHeader(int id); Task>> GetFilteredCheckListHeaderAsync(DataTablesRequest dataTablesRequest); Task> GetAllCheckListHeaderAsync(int mode = 0); Task> UpdateCheckListHeader(CheckListHeaderDTO checkListHeaderDTO);