Skip to content

Commit 583371f

Browse files
committed
Show validation status icons on project cards
1 parent 54c077c commit 583371f

6 files changed

Lines changed: 96 additions & 4 deletions

File tree

cloud/src/LrmCloud.Api/Services/ProjectService.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
using System.Text.Json;
12
using LrmCloud.Api.Data;
23
using LrmCloud.Shared.Configuration;
34
using LrmCloud.Shared.Constants;
45
using LrmCloud.Shared.DTOs;
56
using LrmCloud.Shared.DTOs.Projects;
7+
using LrmCloud.Shared.DTOs.Resources;
68
using LrmCloud.Shared.Entities;
79
using Microsoft.EntityFrameworkCore;
810

@@ -703,6 +705,25 @@ private ProjectDto MapToProjectDto(Project project, int userId)
703705
: 0;
704706
}
705707

708+
// Parse validation cache if available
709+
int validationErrors = 0, validationWarnings = 0;
710+
if (!string.IsNullOrEmpty(project.ValidationCacheJson))
711+
{
712+
try
713+
{
714+
var validationCache = JsonSerializer.Deserialize<ValidationResultDto>(project.ValidationCacheJson);
715+
if (validationCache?.Summary != null)
716+
{
717+
validationErrors = validationCache.Summary.Errors;
718+
validationWarnings = validationCache.Summary.Warnings;
719+
}
720+
}
721+
catch
722+
{
723+
// Ignore parse errors - cache may be corrupted
724+
}
725+
}
726+
706727
return new ProjectDto
707728
{
708729
Id = project.Id,
@@ -727,7 +748,9 @@ private ProjectDto MapToProjectDto(Project project, int userId)
727748
TranslationCount = translationCount,
728749
CompletionPercentage = completionPercentage,
729750
CreatedAt = project.CreatedAt,
730-
UpdatedAt = project.UpdatedAt
751+
UpdatedAt = project.UpdatedAt,
752+
ValidationErrors = validationErrors,
753+
ValidationWarnings = validationWarnings
731754
};
732755
}
733756

cloud/src/LrmCloud.Shared/DTOs/Projects/ProjectDto.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,14 @@ public class ProjectDto
4949

5050
public DateTime CreatedAt { get; set; }
5151
public DateTime UpdatedAt { get; set; }
52+
53+
/// <summary>
54+
/// Number of validation errors (from cached validation).
55+
/// </summary>
56+
public int ValidationErrors { get; set; }
57+
58+
/// <summary>
59+
/// Number of validation warnings (from cached validation).
60+
/// </summary>
61+
public int ValidationWarnings { get; set; }
5262
}

cloud/src/LrmCloud.Web/Helpers/UiHelpers.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using LrmCloud.Shared.DTOs.Projects;
12
using Radzen;
23

34
namespace LrmCloud.Web.Helpers;
@@ -201,4 +202,17 @@ public static string GetRelativeTime(DateTime dateTime)
201202
"viewer" or "Viewer" => BadgeStyle.Light,
202203
_ => BadgeStyle.Light
203204
};
205+
206+
/// <summary>
207+
/// Gets a tooltip string describing validation issues for a project.
208+
/// </summary>
209+
public static string GetValidationTooltip(ProjectDto project)
210+
{
211+
var parts = new List<string>();
212+
if (project.ValidationErrors > 0)
213+
parts.Add($"{project.ValidationErrors} error{(project.ValidationErrors != 1 ? "s" : "")}");
214+
if (project.ValidationWarnings > 0)
215+
parts.Add($"{project.ValidationWarnings} warning{(project.ValidationWarnings != 1 ? "s" : "")}");
216+
return string.Join(", ", parts);
217+
}
204218
}

cloud/src/LrmCloud.Web/Pages/Home.razor

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,22 @@ else
135135
@(project.OrganizationName ?? "Personal")
136136
</RadzenText>
137137
</div>
138-
<RadzenBadge BadgeStyle="@UiHelpers.GetFormatBadgeStyle(project.Format)" Text="@project.Format" />
138+
<RadzenStack Orientation="Radzen.Orientation.Horizontal" Gap="0.25rem" AlignItems="Radzen.AlignItems.Center">
139+
<RadzenBadge BadgeStyle="@UiHelpers.GetFormatBadgeStyle(project.Format)" Text="@project.Format" />
140+
@if (project.ValidationErrors > 0 || project.ValidationWarnings > 0)
141+
{
142+
<span title="@UiHelpers.GetValidationTooltip(project)" style="display: flex; gap: 0.125rem;">
143+
@if (project.ValidationErrors > 0)
144+
{
145+
<RadzenIcon Icon="error" Style="color: var(--rz-danger); font-size: 1rem;" />
146+
}
147+
@if (project.ValidationWarnings > 0)
148+
{
149+
<RadzenIcon Icon="warning" Style="color: var(--rz-warning); font-size: 1rem;" />
150+
}
151+
</span>
152+
}
153+
</RadzenStack>
139154
</RadzenStack>
140155
@if (!string.IsNullOrEmpty(project.Description))
141156
{

cloud/src/LrmCloud.Web/Pages/Organizations/Detail.razor

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,22 @@ else
156156
<RadzenCard Style="cursor: pointer;" @onclick="@(() => Navigation.NavigateTo($"projects/{project.Id}"))">
157157
<RadzenStack Orientation="Radzen.Orientation.Horizontal" JustifyContent="JustifyContent.SpaceBetween" AlignItems="Radzen.AlignItems.Start">
158158
<RadzenText TextStyle="TextStyle.Subtitle1">@project.Name</RadzenText>
159-
<RadzenBadge BadgeStyle="@UiHelpers.GetFormatBadgeStyle(project.Format)" Text="@project.Format" />
159+
<RadzenStack Orientation="Radzen.Orientation.Horizontal" Gap="0.25rem" AlignItems="Radzen.AlignItems.Center">
160+
<RadzenBadge BadgeStyle="@UiHelpers.GetFormatBadgeStyle(project.Format)" Text="@project.Format" />
161+
@if (project.ValidationErrors > 0 || project.ValidationWarnings > 0)
162+
{
163+
<span title="@UiHelpers.GetValidationTooltip(project)" style="display: flex; gap: 0.125rem;">
164+
@if (project.ValidationErrors > 0)
165+
{
166+
<RadzenIcon Icon="error" Style="color: var(--rz-danger); font-size: 1rem;" />
167+
}
168+
@if (project.ValidationWarnings > 0)
169+
{
170+
<RadzenIcon Icon="warning" Style="color: var(--rz-warning); font-size: 1rem;" />
171+
}
172+
</span>
173+
}
174+
</RadzenStack>
160175
</RadzenStack>
161176
<RadzenStack Orientation="Radzen.Orientation.Horizontal" JustifyContent="JustifyContent.SpaceBetween" class="rz-mt-3">
162177
<RadzenText TextStyle="TextStyle.Caption">@project.KeyCount keys</RadzenText>

cloud/src/LrmCloud.Web/Pages/ProjectList.razor

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,22 @@ else
6565
@(project.OrganizationName ?? "Personal")
6666
</RadzenText>
6767
</div>
68-
<RadzenBadge BadgeStyle="@UiHelpers.GetFormatBadgeStyle(project.Format)" Text="@project.Format" />
68+
<RadzenStack Orientation="Radzen.Orientation.Horizontal" Gap="0.25rem" AlignItems="Radzen.AlignItems.Center">
69+
<RadzenBadge BadgeStyle="@UiHelpers.GetFormatBadgeStyle(project.Format)" Text="@project.Format" />
70+
@if (project.ValidationErrors > 0 || project.ValidationWarnings > 0)
71+
{
72+
<span title="@UiHelpers.GetValidationTooltip(project)" style="display: flex; gap: 0.125rem;">
73+
@if (project.ValidationErrors > 0)
74+
{
75+
<RadzenIcon Icon="error" Style="color: var(--rz-danger); font-size: 1rem;" />
76+
}
77+
@if (project.ValidationWarnings > 0)
78+
{
79+
<RadzenIcon Icon="warning" Style="color: var(--rz-warning); font-size: 1rem;" />
80+
}
81+
</span>
82+
}
83+
</RadzenStack>
6984
</RadzenStack>
7085
@if (!string.IsNullOrEmpty(project.Description))
7186
{

0 commit comments

Comments
 (0)